Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: Admin login page opens in recommendations popup #859

Merged
merged 3 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion admin/themes/default/sass/partials/_icons.sass
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 9 additions & 3 deletions admin/themes/default/template/page_header_toolbar.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
//]]>
</script>
Expand Down
2 changes: 2 additions & 0 deletions classes/controller/AdminController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'])) {
Expand Down
11 changes: 11 additions & 0 deletions controllers/admin/AdminLoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,17 @@ public function __construct()
}
}

public function init()
{
parent::init();

if ($this->ajax && Tools::getValue('action') == 'checkLoginStatus') {
$this->ajaxDie(json_encode(array(
'is_logged_in' => $this->context->employee->isLoggedBack(),
)));
}
}

public function setMedia()
{
$this->addJquery();
Expand Down
2 changes: 1 addition & 1 deletion controllers/admin/AdminModulesCatalogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
Expand Down
18 changes: 18 additions & 0 deletions js/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,24 @@ 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) {
resolve(response.is_logged_in);
}
});
});
}

function openModulesList()
{
if (!modules_list_loaded)
Expand Down