Updated Warehouse
This commit is contained in:
+13
-9
@@ -10,6 +10,8 @@
|
||||
* @property array $additionalJSVariables
|
||||
* @property array $infoMessages
|
||||
* @property bool $onlyView
|
||||
* @property array $defaultOrder
|
||||
* @property array $autocompleteColumns
|
||||
*/
|
||||
class TTCrud extends mfBaseController {
|
||||
public User $user;
|
||||
@@ -251,18 +253,20 @@ class TTCrud extends mfBaseController {
|
||||
}
|
||||
|
||||
protected function autocompleteAction() {
|
||||
$searchedID = $this->request->searchedID;
|
||||
|
||||
$textKey = property_exists($this->model, 'name') ? 'name' : 'title';
|
||||
|
||||
if (strlen($searchedID) > 0) {
|
||||
$filter = ['id' => $searchedID];
|
||||
if (strlen($this->request->searchedID) > 0) {
|
||||
$filter = ['id' => $this->request->searchedID];
|
||||
$data = $this->model::getAll($filter, 10);
|
||||
} else {
|
||||
$filter = [$textKey => $this->request->q . '%'];
|
||||
$data = $this->model::getAll($filter, 10);
|
||||
if (isset($this->autocompleteColumns) && is_array($this->autocompleteColumns)) {
|
||||
$filterKey = join('|', $this->autocompleteColumns);
|
||||
} else {
|
||||
$filterKey = $textKey;
|
||||
}
|
||||
|
||||
$data = [];
|
||||
if (count($data) < 11) {
|
||||
$filter = [$textKey => $this->request->q];
|
||||
$filter = [$filterKey => '%' . $this->request->q . '%'];
|
||||
$lazyData = $this->model::getAll($filter, 10);
|
||||
$data = array_merge($data, $lazyData);
|
||||
$data = array_unique($data, SORT_REGULAR);
|
||||
@@ -270,7 +274,6 @@ class TTCrud extends mfBaseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
self::returnJson(array_map(function ($item) use ($textKey) {
|
||||
return ['value' => $item->id, 'text' => $item->$textKey];
|
||||
}, $data));
|
||||
@@ -285,6 +288,7 @@ class TTCrud extends mfBaseController {
|
||||
}
|
||||
|
||||
$data = (array) $this->model::get($id);
|
||||
if (method_exists($this, 'getByIdParse') && !isset($_GET['disableParse'])) $data = $this->getByIdParse($data);
|
||||
self::returnJson($data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user