7use Ajax\php\ubiquity\JsUtils;
8use Ajax\semantic\html\base\constants\Color;
9use Ajax\semantic\html\base\constants\icons\Animals;
10use Ajax\semantic\widgets\datatable\Pagination;
40 foreach ($models as
$model) {
50 'actions' => $myModel[
'actions'] ??
null,
56 $data = [
'items' => $items,
'type' => $mainType];
58 $data[
'nav'] = $this->
nav($models);
63 $this->jquery->renderView($this->
_getFiles()->getViewHome(), $data);
87 protected function nav(?array $models =
null,
string $btIcon =
'chevron right',
string $btTitle =
'Navigate to...',
bool $asString =
true): ?string {
88 $this->_hasDropdown = true;
89 $models ??= $this->getIndexModels();
90 $myModels = $this->getIndexModelsDetails();
92 foreach ($models as $model) {
93 $resource = \lcfirst(ClassUtils::getClassSimpleName($model));
94 $items[] = $this->displayedItems[$resource] ?? [
'title' => $myModels[
'title'] ?? $this->getIndexDefaultTitle($resource),
'icon' => $myModels[
'icon'] ?? $this->getIndexDefaultIcon($resource),
'url' => $myModels[
'url'] ?? $this->getIndexDefaultUrl($resource)];
97 return $this->loadView($this->_getFiles()->getViewNav(), compact(
'items',
'btIcon',
'btTitle'), $asString);
101 return
DAO::getModels(
'default');
109 return
' colored ' . Animals::getRandomValue(true) .
' ' . Color::getRandomValue(true);
113 return \ucfirst($resource);
121 return
Router::path($this->getRouteNamePrefix() .
'crud.index', [$resource]);
130 if ($this->_hasDropdown) {
131 $this->jquery->execAtLast(
'$(".dropdown._nav").dropdown();');
133 $this->jquery->getOnClick(
'.item[data-href]',
'',
'.crud', [
'hasLoader' =>
false,
'preventDefault' =>
false,
'stopPropagation' =>
false,
'attr' =>
'data-href',
'listenerOn' =>
'body']);
137 $this->jquery->getHref(
'a[href]._crud, a._home',
"", [
'historize' =>
false,
'hasLoader' =>
false,
'listenerOn' =>
'body']);
142 return [
'four link cards',
'card'];
146 return
Startup::getNS(
'models') . \ucfirst($this->resource);
152 $this->detailClick(
'showModelClick',
'.crud', [
153 "attr" =>
"data-ajax",
156 parent::showDetail($ids);
161 $array = \explode(
"||", $modelAndId);
162 if (\is_array($array)) {
164 $this->model = $model = \str_replace(
'.',
'\\', $m);
165 $this->resource = \lcfirst(\substr($m, \strpos($m,
".") + 1));
167 $totalCount = DAO::count($model, $this->_getAdminData()->_getInstancesFilter($model));
168 $recordsPerPage = $this->_getModelViewer()->recordsPerPage($model, $totalCount);
169 if (\is_numeric($recordsPerPage)) {
171 $rownum = DAO::getRownum($model, $id);
172 $this->activePage = Pagination::getPageOfRow($rownum, $recordsPerPage);
175 $this->jquery->execAtLast(
"$(\"tr[data-ajax='" . $id .
"']\").click();");
Manipulates class and namespace names Ubiquity\cache$ClassUtils This class is part of Ubiquity.
Ubiquity\controllers\crud$CRUDController This class is part of Ubiquity.
loadView(string $viewName, $pData=null, bool $asString=false)
showModelClick($modelAndId)
hasNavigation()
To override Return true for adding a navigation dropdown menu.
getIndexDefaultUrl(string $resource)
initialize()
Method called before each action Can be override in derived class.
nav(?array $models=null, string $btIcon='chevron right', string $btTitle='Navigate to...', bool $asString=true)
getIndexDefaultTitle(string $resource)
getIndexDefaultDesc(string $modelClass)
getIndexDefaultMeta(string $modelClass)
showDetail($ids)
Shows associated members with foreign keys.
getIndexDefaultIcon(string $resource)
onRenderView(array &$data)
To override.
Gateway class between database and object model.
Http Request utilities, wrapper for accessing to $_GET, $_POST and php://input.