diff --git a/apps/Core/Components/Apps/AppsComponent.php b/apps/Core/Components/Apps/AppsComponent.php index 70378c4dc..dd728c7d8 100644 --- a/apps/Core/Components/Apps/AppsComponent.php +++ b/apps/Core/Components/Apps/AppsComponent.php @@ -112,10 +112,15 @@ public function viewAction() } } - $this->view->modulesMenus = $this->basepackages->menus->getMenusForApp($app['id']); + $this->view->modulesMenus = $this->basepackages->menus->getMenusForAppType($app['app_type'], false); //Components - $componentsArr = $this->modules->components->getComponentsForAppType($app['app_type']); + $componentsArr = $this->modules->components->getComponentsForAppType($app['app_type'], true); + + if (count($componentsArr) === 0) { + $this->view->menuBaseStructure = $this->view->modulesMenus = []; + } + foreach ($componentsArr as $key => &$componentValue) { if ($componentValue['apps']) { if (is_string($componentValue['apps'])) { @@ -163,7 +168,7 @@ public function viewAction() } //Middlewares - $middlewaresArr = $this->modules->middlewares->getMiddlewaresForAppType($app['app_type'], $app['id']); + $middlewaresArr = $this->modules->middlewares->getMiddlewaresForAppType($app['app_type'], $app['id'], true); foreach ($middlewaresArr as $key => &$middlewareValue) { if ($middlewareValue['apps']) { if (is_string($middlewareValue['apps'])) { @@ -189,7 +194,7 @@ public function viewAction() } //Views - $viewsArr = $this->modules->views->getViewsForAppType($app['app_type'], false); + $viewsArr = $this->modules->views->getViewsForAppType($app['app_type'], false, true); if (count($viewsArr) === 1) { array_push($mandatoryViews, $this->helper->first($viewsArr)['name']); diff --git a/apps/Core/Components/Devtools/Modules/ModulesComponent.php b/apps/Core/Components/Devtools/Modules/ModulesComponent.php index 338779a8f..eb3ffc483 100644 --- a/apps/Core/Components/Devtools/Modules/ModulesComponent.php +++ b/apps/Core/Components/Devtools/Modules/ModulesComponent.php @@ -28,6 +28,8 @@ public function initialize() */ public function viewAction() { + $this->view->bundles = false; + $this->view->bundlesjson = false; if (isset($this->getData()['bundles'])) { $this->view->bundles = true; @@ -99,20 +101,79 @@ public function viewAction() $modulesArr = $this->processModulesArr(msort($this->modules->{$modulesType}->{$modulesType}, 'name')); ${$modulesType . 'CategoryArr'} = $modulesArr['categoryArr']; } + if ($modulesArr['modules'] && count($modulesArr['modules']) > 0) { - $modules[$modulesType]['value'] = ucfirst($modulesType); - $modules[$modulesType]['childs'] = $modulesArr['modules']; + if ($modulesType === 'views') { + if (isset($this->view->subview)) { + foreach ($modulesArr['modules'] as $moduleArrKey => $moduleArr) { + if (array_key_exists('is_subview', $moduleArr) && + $moduleArr['is_subview'] == true + ) { + continue; + } + $modules[$modulesType]['value'] = ucfirst($modulesType); + $modules[$modulesType]['childs'][$moduleArrKey] = $moduleArr; + } + } else if (!isset($this->view->subview)) { + $modules[$modulesType]['value'] = ucfirst($modulesType); + $modules[$modulesType]['childs'] = $modulesArr['modules']; + } + } else { + $modules[$modulesType]['value'] = ucfirst($modulesType); + $modules[$modulesType]['childs'] = $modulesArr['modules']; + } } else { $modules[$modulesType]['childs'] = []; } } + if (isset($this->getData()['type'])) { + // For all - core, apptype + // For components - packages, middlewares, views (only subview), externals + // For packages - middlewares, externals + // For middlewares - packages, externals + // For views (baseview) - packages (for any tag packages like adminltetags) + // For views (sub) - views (only baseview) + // For bundles - components, packages, middlewares, views, bundles, externals + if ($this->getData()['type'] === 'components') { + unset($modules['components']); + unset($modules['bundles']); + if (count($modules['views']['childs']) > 0) { + foreach ($modules['views']['childs'] as $childKey => $child) { + if ($child['is_subview'] != true) { + unset($modules['views']['childs'][$childKey]); + } + } + } + } else if ($this->getData()['type'] === 'packages') { + unset($modules['packages']); + unset($modules['views']); + unset($modules['bundles']); + $this->view->packageSettingsModules = $modules; + unset($modules['components']); + } else if ($this->getData()['type'] === 'middlewares') { + unset($modules['components']); + unset($modules['middlewares']); + unset($modules['views']); + unset($modules['bundles']); + } else if ($this->getData()['type'] === 'views') { + unset($modules['components']); + unset($modules['middlewares']); + unset($modules['bundles']); + if (!isset($this->view->subview)) { + unset($modules['views']); + } + } + } + $this->view->modules = $modules; $modulesJson = []; foreach ($modules as $moduleKey => $moduleJson) { - if ($moduleKey === 'bundles') { + if ($moduleKey === 'bundles' && + !$this->view->bundles + ) { continue; } @@ -149,6 +210,11 @@ public function viewAction() if ($type !== 'apptypes') { if ($type !== 'core' && $type !== 'bundles') { + if (isset($modules['bundles'])) { + unset($modules['bundles']); + } + $this->view->modules = $modules; + $this->view->categoryArr = ${$type . 'CategoryArr'}; if ($type === 'components') { @@ -165,7 +231,11 @@ public function viewAction() $this->view->apis = $apis; $this->view->moduleTypes = $this->modulesPackage->getModuleTypes(); $this->view->moduleSettings = $this->modulesPackage->getDefaultSettings(); - $this->view->moduleDependencies = $this->modulesPackage->getDefaultDependencies($type); + if (isset($this->view->subview)) { + $this->view->moduleDependencies = $this->modulesPackage->getDefaultDependencies($type, true); + } else { + $this->view->moduleDependencies = $this->modulesPackage->getDefaultDependencies($type); + } $this->view->moduleMenu = $this->helper->encode([]); $this->view->moduleWidgets = $this->helper->encode([]); @@ -388,7 +458,7 @@ public function viewAction() $this->view->apis = $apis; unset($appTypes['core']);//Remove core $this->view->appTypes = $appTypes; - $this->view->bundleModules = $this->modulesPackage->getDefaultDependencies(); + $this->view->bundleModules = $this->modulesPackage->getDefaultDependencies('bundles'); if ($this->getData()['id'] != 0) { $bundle = $this->modules->bundles->getById($this->getData()['id']); @@ -402,10 +472,18 @@ public function viewAction() } $this->view->bundle = $bundle; $this->view->bundleModules = $bundle['bundle_modules']; - } - if (isset($modules['bundles'])) { - unset($modules['bundles']); + if (isset($modules['bundles']['childs'])) { + foreach ($modules['bundles']['childs'] as $childBundleKey => $childBundle) { + if ($bundle['id'] === $childBundle['id']) { + unset($modules['bundles']['childs'][$childBundleKey]); + } + } + + if (count($modules['bundles']['childs']) === 0) { + unset($modules['bundles']); + } + } } $this->view->modules = $modules; @@ -696,6 +774,22 @@ public function generateModuleRepoUrlAction() } } + public function getDefaultDependenciesAction() + { + $this->requestIsPost(); + + $this->modulesPackage->getDefaultDependencies($this->postData()['type'], $this->postData()['is_subview']); + + $this->addResponse( + $this->modulesPackage->packagesData->responseMessage, + $this->modulesPackage->packagesData->responseCode + ); + + if ($this->modulesPackage->packagesData->responseData) { + $this->view->responseData = $this->modulesPackage->packagesData->responseData; + } + } + public function checkVersionAction() { $this->requestIsPost(); diff --git a/apps/Core/Components/Errors/ErrorsComponent.php b/apps/Core/Components/Errors/ErrorsComponent.php index d040582f4..343c68b8e 100644 --- a/apps/Core/Components/Errors/ErrorsComponent.php +++ b/apps/Core/Components/Errors/ErrorsComponent.php @@ -20,6 +20,13 @@ public function controllerNotFoundAction() $this->addResponse('Component Not Found', 1); } + public function controllerDependencyErrorAction() + { + $this->view->pick('common/errors/controllerdependencyerror'); + + $this->addResponse('Component Dependency Error', 1); + } + public function actionNotFoundAction() { $this->view->pick('common/errors/actionnotfound'); @@ -27,6 +34,13 @@ public function actionNotFoundAction() $this->addResponse('Component Action Not Found', 1); } + public function templateErrorAction() + { + $this->view->pick('common/errors/templateerror'); + + $this->addResponse('Template For Component Not Found', 1); + } + public function routeNotFoundAction() { $this->view->pick('common/errors/routenotfound'); diff --git a/apps/Core/Components/Home/HomeComponent.php b/apps/Core/Components/Home/HomeComponent.php index 3d28243eb..c03bd4496 100644 --- a/apps/Core/Components/Home/HomeComponent.php +++ b/apps/Core/Components/Home/HomeComponent.php @@ -12,15 +12,16 @@ class HomeComponent extends BaseComponent public function viewAction() { try { - $defaultComponentId = $this->app['default_component']; - if ($this->app['default_component'] == 0) { - $dashboardComponent = $this->modules->components->getComponentByRouteForAppId('dashboards'); + return; + } + + $defaultComponent = $this->modules->components->getById($this->app['default_component']); - $defaultComponentId = $dashboardComponent['id']; + if ($defaultComponent['class'] === get_class($this)) { + return; } - $defaultComponent = $this->modules->components->getById($defaultComponentId); $controller = $this->helper->last(explode('/', $defaultComponent['route'])); $routeArr = explode('/', $defaultComponent['route']); unset($routeArr[$this->helper->lastKey($routeArr)]); diff --git a/apps/Core/Components/Viewssettings/ViewssettingsComponent.php b/apps/Core/Components/Viewssettings/ViewssettingsComponent.php index 6b8ae1954..cf639040b 100644 --- a/apps/Core/Components/Viewssettings/ViewssettingsComponent.php +++ b/apps/Core/Components/Viewssettings/ViewssettingsComponent.php @@ -47,7 +47,10 @@ public function viewAction() if (is_string($view['settings'])) { $view['settings'] = $this->helper->decode($view['settings'], true); } - if (is_array($view['settings']['branding'])) { + + if (isset($view['settings']['branding']) && + is_array($view['settings']['branding']) + ) { foreach ($view['settings']['branding'] as $brandKey => $brand) { if (is_array($brand) && !isset($brand['brand'])) { diff --git a/apps/Core/Packages/Devtools/Modules/DevtoolsModules.php b/apps/Core/Packages/Devtools/Modules/DevtoolsModules.php index d466964e6..808506111 100644 --- a/apps/Core/Packages/Devtools/Modules/DevtoolsModules.php +++ b/apps/Core/Packages/Devtools/Modules/DevtoolsModules.php @@ -671,32 +671,64 @@ public function getDefaultSettings() return $this->helper->encode($defaultSettings); } - public function getDefaultDependencies($type = null) + public function getDefaultDependencies($type, $isSubView = false) { + // For all - core, apptype + // For components - packages, middlewares, views (only subview), externals + // For packages - middlewares, externals + // For middlewares - packages, externals + // For views (baseview) - packages (for any tag packages like adminltetags) + // For views (sub) - views (only baseview) + // For bundles - components, packages, middlewares, views, bundles, externals + $defaultDependencies = [ 'core' => [], - 'apptype' => [], - 'components' => [], - 'packages' => [], - 'middlewares' => [], - 'views' => [], - 'external' => [ - 'composer' => [ - 'require' => [] - ], - 'config' => [ - 'allow-plugins' => [] - ], - 'extra' => [ - 'patches' => [] - ] + 'apptype' => [] + ]; + + $externalDependencies = + [ + 'composer' => + [ + 'require' => [] + ], + 'config' => + [ + 'allow-plugins' => [] + ], + 'extra' => + [ + 'patches' => [] ] ]; - if ($type && $type === 'views') { - unset($defaultDependencies['external']); - } + if ($type === 'components') { + $defaultDependencies['packages'] = []; + $defaultDependencies['middlewares'] = []; + $defaultDependencies['views'] = []; + $defaultDependencies['externals'] = $externalDependencies; + } else if ($type === 'packages') { + $defaultDependencies['middlewares'] = []; + $defaultDependencies['externals'] = $externalDependencies; + } else if ($type === 'middlewares') { + $defaultDependencies['packages'] = []; + $defaultDependencies['externals'] = $externalDependencies; + } else if ($type === 'views') { + $defaultDependencies['packages'] = []; + if ($isSubView == 'true') { + $defaultDependencies['views'] = []; + } + } else if ($type === 'bundles') { + $defaultDependencies['components'] = []; + $defaultDependencies['packages'] = []; + $defaultDependencies['middlewares'] = []; + $defaultDependencies['views'] = []; + $defaultDependencies['bundles'] = []; + $defaultDependencies['externals'] = $externalDependencies; + } + + $this->addResponse('Generated default dependencies', 0, ['defaultDependencies' => $defaultDependencies]); return $this->helper->encode($defaultDependencies); } @@ -945,7 +977,11 @@ protected function getModuleJsonFileLocation(&$data) $routePath = implode('/', $pathArr) . '/Install/'; } else if ($data['module_type'] === 'views') { - if ($data['base_view_module_id'] == 0) { + if ($data['is_subview'] == true && + $data['base_view_module_id'] == 0 + ) { + throw new \Exception('View dependency for this subview not set.'); + } else if ($data['base_view_module_id'] == 0) { $routePath = $data['name'] . '/'; } else { $baseView = $this->modules->views->getViewById($data['base_view_module_id']); @@ -3044,6 +3080,12 @@ public function generateModuleRepoUrl($data) if ($data['module_type'] === 'views' && isset($data['is_subview']) && $data['is_subview'] == 'true') { $baseView = $this->modules->views->getViewById($data['base_view_module_id']); + + if (!$baseView) { + $this->addResponse('View dependency for this subview not set.', 1); + + return false; + } } if ($data['module_type'] === 'components' || $data['module_type'] === 'apps_types') { diff --git a/apps/Core/Views/Default/html/apps/tables/modules.html b/apps/Core/Views/Default/html/apps/tables/modules.html index 477527b9c..c35693f56 100644 --- a/apps/Core/Views/Default/html/apps/tables/modules.html +++ b/apps/Core/Views/Default/html/apps/tables/modules.html @@ -124,8 +124,8 @@ {% if moduleType === 'component' %} - {% if module['menu_id'] %} - {% if modulesMenus[module['menu_id']]['apps'][app['id']]['enabled'] is defined and modulesMenus[module['menu_id']]['apps'][app['id']]['enabled'] === true %} + {% if module['menu_id'] and module['menu'] != 'false' %} + {% if modulesMenus[module['menu_id']]['apps'][app['id']]['enabled'] is defined and modulesMenus[module['menu_id']]['apps'][app['id']]['enabled'] == true %} {% set menuChecked = true %} {% else %} {% set menuChecked = false %} @@ -163,7 +163,11 @@ {% if module['apps'][app['id']]['needAuth'] is defined and module['apps'][app['id']]['needAuth'] !== 'disabled' %} {% if module['apps'][app['id']]['needAuth'] is defined and module['apps'][app['id']]['needAuth'] === true %} - {% set needAuthChecked = true %} + {% if module['apps'][app['id']]['enabled'] is defined and module['apps'][app['id']]['enabled'] === true %} + {% set needAuthChecked = true %} + {% else %} + {% set needAuthChecked = false %} + {% endif %} {% else %} {% set needAuthChecked = false %} {% endif %} @@ -173,7 +177,9 @@ {% set needAuthDisabled = true %} {% endif %} {% if module['apps'][app['id']]['needAuth'] is defined and module['apps'][app['id']]['needAuth'] === 'mandatory' %} - {% set needAuthChecked = true %} + {% if module['apps'][app['id']]['enabled'] is defined and module['apps'][app['id']]['enabled'] === true %} + {% set needAuthChecked = true %} + {% endif %} {% set needAuthDisabled = true %} {% endif %} diff --git a/apps/Core/Views/Default/html/apps/wizard/modules/form/components.html b/apps/Core/Views/Default/html/apps/wizard/modules/form/components.html index 56e03e970..0c736fc78 100644 --- a/apps/Core/Views/Default/html/apps/wizard/modules/form/components.html +++ b/apps/Core/Views/Default/html/apps/wizard/modules/form/components.html @@ -203,7 +203,7 @@ ) { $('#{{componentId}}-{{sectionId}}-component-menu-' + componentId).attr('disabled', false); $('#{{componentId}}-{{sectionId}}-component-need_auth-' + componentId).attr('disabled', false); - $('#{{componentId}}-{{sectionId}}-component-menu-' + componentId)[0].checked = true; + // $('#{{componentId}}-{{sectionId}}-component-menu-' + componentId)[0].checked = true; window['dataCollection']['{{componentId}}']['{{componentId}}-{{sectionId}}']['data']['menus'][menuId][appId]['enabled'] = true; } else { //matched during onload extractComponentCheckboxData diff --git a/apps/Core/Views/Default/html/common/errors/controllerdependencyerror.html b/apps/Core/Views/Default/html/common/errors/controllerdependencyerror.html new file mode 100644 index 000000000..75cd06b5c --- /dev/null +++ b/apps/Core/Views/Default/html/common/errors/controllerdependencyerror.html @@ -0,0 +1,27 @@ +{% set sectionId = 'controllerDependencyError' %} +
+
+
+
+

+ Server Error! (Error:Controller Dependency Error) +

+

The component's controller is returning an internal error.

+ + Try Again + +
+
+
+
+
+

What happened?

+

A controller dependency error status implies there is a problem with the controller causing it to malfunction.

+
+
+

What can I do?

+

Nothing you can do at the moment. If you need immediate assistance, please + contact us.

+
+
+
\ No newline at end of file diff --git a/apps/Core/Views/Default/html/common/errors/controllererror.html b/apps/Core/Views/Default/html/common/errors/controllererror.html new file mode 100644 index 000000000..2da66953c --- /dev/null +++ b/apps/Core/Views/Default/html/common/errors/controllererror.html @@ -0,0 +1,27 @@ +{% set sectionId = 'controller-error' %} +
+
+
+
+

+ Server Error! (Error:Controller Error) +

+

The component's controller is returning an internal error.

+ + Try Again + +
+
+
+
+
+

What happened?

+

A controller error status implies there is a problem with the controller causing it to malfunction.

+
+
+

What can I do?

+

Nothing you can do at the moment. If you need immediate assistance, please + contact us.

+
+
+
\ No newline at end of file diff --git a/apps/Core/Views/Default/html/common/errors/routenotfound.html b/apps/Core/Views/Default/html/common/errors/routenotfound.html new file mode 100644 index 000000000..05e1a87c1 --- /dev/null +++ b/apps/Core/Views/Default/html/common/errors/routenotfound.html @@ -0,0 +1,30 @@ +{% set sectionId = '404' %} +
+
+
+
+

+ Not Found! (Error:404) +

+

We couldn't find what you're looking for.

+

+ + Goto Home + +

+
+
+
+
+
+

What happened?

+

A 404 error status implies that the component you're looking for could not be found.

+
+
+

What can I do?

+

This should not happen. Either it is a bug or site issue. Please + contact us. +

+
+
+
\ No newline at end of file diff --git a/apps/Core/Views/Default/html/devtools/modules/bundle/modules.html b/apps/Core/Views/Default/html/devtools/modules/bundle/modules.html index 0900a8add..a50faf8b8 100644 --- a/apps/Core/Views/Default/html/devtools/modules/bundle/modules.html +++ b/apps/Core/Views/Default/html/devtools/modules/bundle/modules.html @@ -224,4 +224,26 @@ ] )}} + +
+
+ {{adminltetags.useTag('buttons', + [ + 'component' : component, + 'componentName' : componentName, + 'componentId' : componentId, + 'sectionId' : sectionId, + 'buttonType' : 'button', + 'buttons' : + [ + 'modules-reset' : [ + 'title' : 'Reset Bundle Modules', + 'size' : 'xs', + 'type' : 'danger', + 'icon' : 'rotate-left' + ] + ] + ] + )}} +
\ No newline at end of file diff --git a/apps/Core/Views/Default/html/devtools/modules/module.html b/apps/Core/Views/Default/html/devtools/modules/module.html index ff4109049..ce0195edd 100644 --- a/apps/Core/Views/Default/html/devtools/modules/module.html +++ b/apps/Core/Views/Default/html/devtools/modules/module.html @@ -784,7 +784,7 @@ {% set bundleId = '0' %} {% endif %}