From 7f9725f2cc3ebffaf5af5d5a90d3383ddc60074c Mon Sep 17 00:00:00 2001 From: Sebastian Castro <sebastian.castro@protonmail.com> Date: Fri, 7 May 2021 08:28:21 +0200 Subject: [PATCH] admin-category: display id & customId --- src/Admin/CategoryAdmin.php | 1 + src/Document/Category.php | 6 +++++- templates/admin/list/tree_category_item.html.twig | 1 + .../element-form/form-partials/taxonomy-field.html.twig | 2 +- translations/admin+intl-icu.fr.yaml | 1 + 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Admin/CategoryAdmin.php b/src/Admin/CategoryAdmin.php index 704c1d4e9..dffadedc5 100755 --- a/src/Admin/CategoryAdmin.php +++ b/src/Admin/CategoryAdmin.php @@ -64,6 +64,7 @@ class CategoryAdmin extends GoGoAbstractAdmin ->end() ->halfPanel('secondary') ->add('nameShort') + ->add('customId') ->add('index') ->add('showExpanded') ->add('unexpandable') diff --git a/src/Document/Category.php b/src/Document/Category.php index db8a78f4a..bdca8be71 100755 --- a/src/Document/Category.php +++ b/src/Document/Category.php @@ -16,7 +16,6 @@ class Category { /** * @var int - * @Exclude * @MongoDB\Id(strategy="INCREMENT") */ private $id; @@ -235,6 +234,11 @@ class Category return $this; } + public function getCustomStringId() + { + return $this->customId ?: strval($this->id); + } + /** * Set name. * diff --git a/templates/admin/list/tree_category_item.html.twig b/templates/admin/list/tree_category_item.html.twig index c7749c018..fbc05ca5f 100755 --- a/templates/admin/list/tree_category_item.html.twig +++ b/templates/admin/list/tree_category_item.html.twig @@ -4,6 +4,7 @@ <span class="category-item {{ category.options|length and not category.unexpandable ? 'expandable':'unexpandable' }}" {% if not category.displayInForm or not category.displayInMenu %}style="opacity: 0.5"{% endif %}> <span class="name">(Groupe) {{ category.name|capitalize }}</span> + <span style="opacity: .6;margin-right: 10px;">( {{ category.customStringId }} )</span> {% if not category.displayInForm or not category.displayInMenu %}<span class="fa fa-eye-slash"></span>{% endif %} {% if category.options|length and not category.unexpandable %}<span class="arrow-after"></span>{% endif %} {% if category.isMandatory %}<span class="label label-warning">Obligatoire</span>{% endif %} diff --git a/templates/element-form/form-partials/taxonomy-field.html.twig b/templates/element-form/form-partials/taxonomy-field.html.twig index 6a1cc4ce0..4d85ab7b9 100755 --- a/templates/element-form/form-partials/taxonomy-field.html.twig +++ b/templates/element-form/form-partials/taxonomy-field.html.twig @@ -30,7 +30,7 @@ <option value="{{option.id}}" data-custom-id="{{option.customId}}"> {{ option.name }} {% if (option.textHelper is defined and option.textHelper) %} ({{ option.textHelper }}) {% endif %} </option> - {% endif %} + {% endif %} {% endfor %} </select> </span> diff --git a/translations/admin+intl-icu.fr.yaml b/translations/admin+intl-icu.fr.yaml index a1fcb5bef..92ee1edef 100755 --- a/translations/admin+intl-icu.fr.yaml +++ b/translations/admin+intl-icu.fr.yaml @@ -701,6 +701,7 @@ categories: nameShort: "Nom (version courte)" nameShort_help: "La version courte est utilisée dans le menu, car souvent on manque de place" index: "Position" + customId: "Id personnalisé" showExpanded: "En position intiale afficher les catégories (sinon il faudra cliquer pour les afficher)" unexpandable: "Ne pas pouvoir reduire ce groupe de catégories" unexpandable_help: "Dans le menu, les catégories de ce groupe seront toujours affichées" -- GitLab