diff --git a/CHANGELOG.md b/CHANGELOG.md index ab714ae3..87456f22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [UNRELEASED] +### Changed + +- Migrate config form to Twig template (Bootstrap 5 card layout) + ### Fixed - Fix tag search diff --git a/inc/config.class.php b/inc/config.class.php index 7a347fca..726b98cb 100644 --- a/inc/config.class.php +++ b/inc/config.class.php @@ -28,13 +28,14 @@ * ------------------------------------------------------------------------- */ +use Glpi\Application\View\TemplateRenderer; + class PluginTagConfig extends CommonDBTM { protected static $notable = true; public function getTabNameForItem(CommonGLPI $item, $withtemplate = 0) { - if (!$withtemplate && $item->getType() === 'Config') { return self::createTabEntry(__s('Tag Management', 'tag'), 0, $item::getType(), PluginTagTag::getIcon()); } @@ -50,35 +51,14 @@ public function showConfigForm() $config = Config::getConfigurationValues('plugin:Tag'); - echo "
"; - echo ""; - echo ""; - echo "
"; - echo ""; - echo "'; - echo ''; - echo '
" . __s('Tag Management', 'tag') . '
' . __s('Tags location', 'tag') . ''; - Dropdown::showFromArray( - 'tags_location', - [ - __s('Top'), - __s('Bottom'), - ], - [ - 'value' => $config['tags_location'] ?? 0, - ], - ); - echo '
'; + TemplateRenderer::getInstance()->display('@tag/forms/config.html.twig', [ + 'form_action' => Toolbox::getItemTypeFormURL('Config'), + 'config_class' => self::class, + 'config_context' => 'plugin:Tag', + 'tags_location' => (int) ($config['tags_location'] ?? 0), + ]); - echo ""; - echo ""; - echo "'; - echo '
"; - echo "'; - echo '
'; - echo '
'; - Html::closeForm(); - return null; + return true; } public static function displayTabContentForItem(CommonGLPI $item, $tabnum = 1, $withtemplate = 0) diff --git a/templates/forms/config.html.twig b/templates/forms/config.html.twig new file mode 100755 index 00000000..5759b937 --- /dev/null +++ b/templates/forms/config.html.twig @@ -0,0 +1,60 @@ +{# + # ------------------------------------------------------------------------- + # Tag plugin for GLPI + # ------------------------------------------------------------------------- + # + # LICENSE + # + # This file is part of Tag. + # + # Tag 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. + # + # Tag 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 Tag. If not, see . + # ------------------------------------------------------------------------- + # @copyright Copyright (C) 2014-2023 by Teclib'. + # @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html + # @link https://github.com/pluginsGLPI/tag + # ------------------------------------------------------------------------- + #} + +{% import 'components/form/fields_macros.html.twig' as fields %} + +
+
+

{{ __('Tag Management', 'tag') }}

+
+ + + + + + +
+ {{ fields.dropdownArrayField( + 'tags_location', + tags_location, + { + 0: __('Top'), + 1: __('Bottom') + }, + __('Tags location', 'tag') + ) }} +
+ + + +