From e963830fecb826328d010a898dc4ed2c21b4b6aa Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 13 Oct 2023 19:27:16 +0530 Subject: [PATCH 1/3] Fixed: Admin login page opens in recommendations popup --- .../default/template/page_header_toolbar.tpl | 12 ++++++++--- controllers/admin/AdminLoginController.php | 12 +++++++++++ js/admin.js | 20 +++++++++++++++++++ 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/admin/themes/default/template/page_header_toolbar.tpl b/admin/themes/default/template/page_header_toolbar.tpl index 8aaaa9726..bf852d48a 100644 --- a/admin/themes/default/template/page_header_toolbar.tpl +++ b/admin/themes/default/template/page_header_toolbar.tpl @@ -115,9 +115,15 @@ }); {/if} - $('.process-icon-modules-list').parent('a').unbind().bind('click', function (){ - $('#modules_list_container').modal('show'); - openModulesList(); + $('.process-icon-modules-list').parent('a').unbind().bind('click', async function (){ + let loggedIn = await checkIfEmployeeIsLoggedIn(); + + if (loggedIn) { + $('#modules_list_container').modal('show'); + openModulesList(); + } else { + window.location = window.location.pathname; + } }); //]]> diff --git a/controllers/admin/AdminLoginController.php b/controllers/admin/AdminLoginController.php index 4daeaadf0..78331bd0c 100644 --- a/controllers/admin/AdminLoginController.php +++ b/controllers/admin/AdminLoginController.php @@ -45,6 +45,18 @@ public function __construct() } } + public function init() + { + parent::init(); + + if ($this->ajax && Tools::getValue('action') == 'checkLoginStatus') { + $this->ajaxDie(json_encode(array( + 'status' => true, + 'is_logged_in' => $this->context->employee->isLoggedBack(), + ))); + } + } + public function setMedia() { $this->addJquery(); diff --git a/js/admin.js b/js/admin.js index 4d474721a..7b16f76bf 100644 --- a/js/admin.js +++ b/js/admin.js @@ -1219,6 +1219,26 @@ function sendBulkAction(form, action) $(form).submit(); } +function checkIfEmployeeIsLoggedIn() { + return new Promise(function (resolve) { + $.ajax({ + url : window.location.pathname, + type: 'POST', + dataType: 'JSON', + data : { + ajax : '1', + controller : 'AdminLogin', + action : 'checkLoginStatus', + }, + success : function(response) { + if (response.status) { + resolve(response.is_logged_in); + } + } + }); + }); +} + function openModulesList() { if (!modules_list_loaded) From 9ceee02abfc23d5de76ef11d907130600cf14824 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 23 Oct 2023 12:55:47 +0530 Subject: [PATCH 2/3] Fix click issue --- admin/themes/default/sass/partials/_icons.sass | 2 +- classes/controller/AdminController.php | 2 ++ controllers/admin/AdminModulesCatalogController.php | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/admin/themes/default/sass/partials/_icons.sass b/admin/themes/default/sass/partials/_icons.sass index 6788aad63..df946e757 100644 --- a/admin/themes/default/sass/partials/_icons.sass +++ b/admin/themes/default/sass/partials/_icons.sass @@ -362,7 +362,7 @@ @extend .icon-edit .process-icon-newAttributes, .process-icon-new, .process-icon-new-url @extend .icon-plus-sign - .process-icon-modules-list + .process-icon-modules-list, .process-icon-puzzle-piece @extend .icon-puzzle-piece .process-icon-save-date @extend .icon-download diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php index ea3a469f7..e4a79846b 100644 --- a/classes/controller/AdminController.php +++ b/classes/controller/AdminController.php @@ -2171,6 +2171,8 @@ public function initContent() */ protected function initTabModuleList() { + $this->tab_modules_list = Tab::getTabModulesList($this->id); + if (is_array($this->tab_modules_list['default_list']) && count($this->tab_modules_list['default_list'])) { $this->filter_modules_list = $this->tab_modules_list['default_list']; } elseif (is_array($this->tab_modules_list['slider_list']) && count($this->tab_modules_list['slider_list'])) { diff --git a/controllers/admin/AdminModulesCatalogController.php b/controllers/admin/AdminModulesCatalogController.php index 6b8e7f953..72888b9d8 100644 --- a/controllers/admin/AdminModulesCatalogController.php +++ b/controllers/admin/AdminModulesCatalogController.php @@ -235,7 +235,7 @@ public function initToolbar() $this->page_header_toolbar_btn['addons'] = array( 'href' => 'https://qloapps.com/addons/', 'desc' => $this->l('Explore all Addons'), - 'imgclass' => 'modules-list', + 'imgclass' => 'puzzle-piece', 'target' => true ); } From 25fb492e189f624cd05dfdc32381085b2a52cb9f Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Mon, 20 Nov 2023 13:32:24 +0530 Subject: [PATCH 3/3] Remove 'status' field --- controllers/admin/AdminLoginController.php | 1 - js/admin.js | 4 +--- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/controllers/admin/AdminLoginController.php b/controllers/admin/AdminLoginController.php index 78331bd0c..f48096f05 100644 --- a/controllers/admin/AdminLoginController.php +++ b/controllers/admin/AdminLoginController.php @@ -51,7 +51,6 @@ public function init() if ($this->ajax && Tools::getValue('action') == 'checkLoginStatus') { $this->ajaxDie(json_encode(array( - 'status' => true, 'is_logged_in' => $this->context->employee->isLoggedBack(), ))); } diff --git a/js/admin.js b/js/admin.js index 7b16f76bf..9704d959f 100644 --- a/js/admin.js +++ b/js/admin.js @@ -1231,9 +1231,7 @@ function checkIfEmployeeIsLoggedIn() { action : 'checkLoginStatus', }, success : function(response) { - if (response.status) { - resolve(response.is_logged_in); - } + resolve(response.is_logged_in); } }); });