diff --git a/js/backend.js b/js/backend.js index 30db1ce..42b8039 100644 --- a/js/backend.js +++ b/js/backend.js @@ -1,10 +1,6 @@ /*global $, dotclear */ 'use strict'; -Object.assign(dotclear.msg, dotclear.getData('uninstaller')); - $(() => { - $('#uninstall-form').on('submit', function () { - return window.confirm(dotclear.msg.confirm_uninstall); - }); + $('a.uninstall_module_button').parent().find('input.delete').hide(); }); \ No newline at end of file diff --git a/js/manage.js b/js/manage.js new file mode 100644 index 0000000..30db1ce --- /dev/null +++ b/js/manage.js @@ -0,0 +1,10 @@ +/*global $, dotclear */ +'use strict'; + +Object.assign(dotclear.msg, dotclear.getData('uninstaller')); + +$(() => { + $('#uninstall-form').on('submit', function () { + return window.confirm(dotclear.msg.confirm_uninstall); + }); +}); \ No newline at end of file diff --git a/src/Backend.php b/src/Backend.php index d3502c3..0552d56 100644 --- a/src/Backend.php +++ b/src/Backend.php @@ -19,6 +19,7 @@ use dcCore; use dcModuleDefine; use dcNsProcess; use dcPage; +use dcUtils; use Exception; class Backend extends dcNsProcess @@ -47,7 +48,7 @@ class Backend extends dcNsProcess return empty(Uninstaller::instance()->loadModules([$define])->getUserActions($define->getId())) ? '' : sprintf( - ' ' . __('Uninstall') . '', + ' ' . __('Uninstall') . '', dcCore::app()->adminurl?->get('admin.plugin.' . My::id(), ['type' => $define->get('type'), 'id' => $define->getId()]) ); }, @@ -59,6 +60,14 @@ class Backend extends dcNsProcess 'pluginBeforeDeleteV2' => function (dcModuleDefine $define): void { self::moduleBeforeDelete($define); }, + // add js to hide delete button when uninstaller exists + 'pluginsToolsHeadersV2' => function (): string { + return self::modulesToolsHeader(); + }, + // add js to hide delete button when uninstaller exists + 'themesToolsHeadersV2' => function (): string { + return self::modulesToolsHeader(); + }, ]); return true; @@ -98,4 +107,9 @@ class Backend extends dcNsProcess dcCore::app()->error->add($e->getMessage()); } } + + protected static function modulesToolsHeader() + { + return dcUtils::jsModuleLoad(My::id() . '/js/backend.js'); + } } diff --git a/src/Manage.php b/src/Manage.php index fef8819..67ff92f 100644 --- a/src/Manage.php +++ b/src/Manage.php @@ -127,7 +127,7 @@ class Manage extends dcNsProcess dcPage::openModule( My::name(), dcPage::jsJson('uninstaller', ['confirm_uninstall' => __('Are you sure you perform these ations?')]) . - dcPage::jsModuleLoad(My::id() . '/js/backend.js') . + dcPage::jsModuleLoad(My::id() . '/js/manage.js') . # --BEHAVIOR-- UninstallerHeader dcCore::app()->callBehavior('UninstallerHeader')