Skip to content

Commit

Permalink
⚡ Simplify the display of the catalog page.
Browse files Browse the repository at this point in the history
Stylesheet blocks seems to reload/build again the layout.tpl, and call twice hooks...
  • Loading branch information
intraordinaire committed Nov 12, 2024
1 parent 394c219 commit 52c741f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 29 deletions.
17 changes: 1 addition & 16 deletions src/Controller/Admin/ModuleCatalogController.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,6 @@ class ModuleCatalogController extends ModuleAbstractController
*/
public function indexAction(): Response
{
$moduleUri = __PS_BASE_URI__ . 'modules/ps_mbo/';

$extraParams = [
'cdc_error_templating_url' => $moduleUri . 'views/js/cdc-error-templating.js',
'cdc_error_templating_css' => $moduleUri . 'views/css/cdc-error-templating.css',
];

$cdcJsFile = getenv('MBO_CDC_URL');
if (false === $cdcJsFile || !is_string($cdcJsFile) || empty($cdcJsFile)) {
$extraParams['cdc_script_not_found'] = true;
$extraParams['cdc_error_url'] = $moduleUri . 'views/js/cdc-error.js';
} else {
$extraParams['cdc_url'] = $cdcJsFile;
}

/*********************
* PrestaShop Account *
* *******************/
Expand Down Expand Up @@ -116,7 +101,7 @@ public function indexAction(): Response
'You do not have permission to add this.',
'Admin.Notifications.Error'
),
] + $extraParams
]
);
}

Expand Down
3 changes: 2 additions & 1 deletion src/Traits/Hooks/UseActionAdminControllerSetMedia.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ private function loadCdcMedia(): void
}
if (
!Tab::mayDisplayRecommendedModules($controllerName) &&
!in_array($controllerName, self::CONTROLLERS_WITH_CDC_SCRIPT)
!in_array($controllerName, self::CONTROLLERS_WITH_CDC_SCRIPT) &&
$controllerName !== 'AdminPsMboModule'
) {
return;
}
Expand Down
12 changes: 0 additions & 12 deletions views/templates/admin/controllers/module_catalog/catalog.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,6 @@

{% block javascripts %}
{{ parent() }}
<script type="application/javascript" src="{{ cdc_error_templating_url }}"></script>

{% if cdc_script_not_found is defined and cdc_script_not_found is same as(true) %}
<script type="application/javascript" src="{{ cdc_error_url }}"></script>
{% else %}
<script type="application/javascript" src="{{ cdc_url }}"></script>
{% endif %}

<script>
var psAccountLoaded = false;
Expand Down Expand Up @@ -63,11 +56,6 @@
</script>
{% endblock %}
{% block stylesheets %}
{{ parent() }}
<link rel="stylesheet" href="{{ cdc_error_templating_css }}" type="text/css" media="all">
{% endblock %}
{% block content %}
<prestashop-accounts style="display: none;"></prestashop-accounts>
Expand Down

0 comments on commit 52c741f

Please sign in to comment.