From 478423a03b469b450efabc9210b902719b7c5132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Anne?= Date: Tue, 3 Dec 2024 14:43:53 +0100 Subject: [PATCH] Move front-end assets to be compatible with GLPI 11.0 --- example.css => public/css/example.css | 2 +- example.js => public/js/example.js | 2 +- public/js/modules/mymodule.js | 30 +++++++++++++++++++++++++++ public/js/modules/package.json | 3 +++ setup.php | 5 +++-- 5 files changed, 38 insertions(+), 4 deletions(-) rename example.css => public/css/example.css (98%) rename example.js => public/js/example.js (98%) create mode 100644 public/js/modules/mymodule.js create mode 100644 public/js/modules/package.json diff --git a/example.css b/public/css/example.css similarity index 98% rename from example.css rename to public/css/example.css index 187753a..d5a345a 100644 --- a/example.css +++ b/public/css/example.css @@ -26,4 +26,4 @@ * ------------------------------------------------------------------------- */ -/* empty file */ +/* empty CSS file */ diff --git a/example.js b/public/js/example.js similarity index 98% rename from example.js rename to public/js/example.js index 7aae649..a91c3f0 100644 --- a/example.js +++ b/public/js/example.js @@ -26,4 +26,4 @@ * ------------------------------------------------------------------------- */ -/* empty file */ +/* empty JS file */ diff --git a/public/js/modules/mymodule.js b/public/js/modules/mymodule.js new file mode 100644 index 0000000..93e2861 --- /dev/null +++ b/public/js/modules/mymodule.js @@ -0,0 +1,30 @@ +/** + * ------------------------------------------------------------------------- + * Example plugin for GLPI + * ------------------------------------------------------------------------- + * + * LICENSE + * + * This file is part of Example. + * + * Example is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * Example is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Example. If not, see . + * ------------------------------------------------------------------------- + * @copyright Copyright (C) 2006-2022 by Example plugin team. + * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html + * @link https://github.com/pluginsGLPI/example + * ------------------------------------------------------------------------- + */ + +/* empty JS module file */ +export {}; diff --git a/public/js/modules/package.json b/public/js/modules/package.json new file mode 100644 index 0000000..3dbc1ca --- /dev/null +++ b/public/js/modules/package.json @@ -0,0 +1,3 @@ +{ + "type": "module" +} diff --git a/setup.php b/setup.php index f80a312..fe54acc 100644 --- a/setup.php +++ b/setup.php @@ -177,8 +177,9 @@ function plugin_init_example() { $PLUGIN_HOOKS['assign_to_ticket']['example'] = 1; // Add specific files to add to the header : javascript or css - $PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT]['example'] = 'example.js'; - $PLUGIN_HOOKS[Hooks::ADD_CSS]['example'] = 'example.css'; + $PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT]['example'] = 'js/example.js'; + $PLUGIN_HOOKS[Hooks::ADD_JAVASCRIPT_MODULE]['example'] = 'js/modules/mymodule.js'; + $PLUGIN_HOOKS[Hooks::ADD_CSS]['example'] = 'css/example.css'; // Add specific tags to the header $PLUGIN_HOOKS[Hooks::ADD_HEADER_TAG]['example'] = [