From 0bb954dd9e5110da8f70a3a3ffceb8b1947ce95d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Cailly?= Date: Wed, 6 Nov 2024 11:16:44 +0100 Subject: [PATCH] ui(forms): Rework and refactor editor page, render page and question type components --- .../components/form/_form-editor.scss | 31 ++++- .../components/form/_form-renderer.scss | 18 +++ .../AbstractQuestionTypeActors.php | 27 ++-- .../AbstractQuestionTypeSelectable.php | 3 +- .../AbstractQuestionTypeShortAnswer.php | 2 +- .../QuestionType/QuestionTypeDateTime.php | 6 +- .../QuestionType/QuestionTypeDropdown.php | 3 +- .../Form/QuestionType/QuestionTypeFile.php | 2 + .../Form/QuestionType/QuestionTypeItem.php | 14 +- .../QuestionType/QuestionTypeLongText.php | 18 +-- .../QuestionType/QuestionTypeRequestType.php | 6 +- .../Form/QuestionType/QuestionTypeUrgency.php | 6 +- .../QuestionType/QuestionTypeUserDevice.php | 9 +- .../pages/admin/form/form_question.html.twig | 2 +- templates/pages/form_renderer.html.twig | 124 +++++++++--------- 15 files changed, 174 insertions(+), 97 deletions(-) diff --git a/css/includes/components/form/_form-editor.scss b/css/includes/components/form/_form-editor.scss index e0f6fba81d1..50a09cc2202 100644 --- a/css/includes/components/form/_form-editor.scss +++ b/css/includes/components/form/_form-editor.scss @@ -74,6 +74,24 @@ display: flex !important; } } + + .fileupload { + margin: 0; + } + + .only-uploaded-files { + .fileupload_info { + margin-bottom: 0; + + p:first-child { + margin-top: 10px; + } + + p:last-child { + margin-bottom: 0; + } + } + } } .editor-footer { @@ -250,7 +268,6 @@ border-bottom-right-radius: var(--tblr-border-radius); padding: 0.5rem; padding-bottom: 0; - margin-bottom: 0.5rem; } .single-preview-dropdown, .multiple-preview-dropdown { @@ -259,5 +276,17 @@ border-bottom-right-radius: unset; } } + + div:not([data-glpi-form-editor-selectable-question-options])>[data-glpi-form-selectable-question-option]:last-child { + margin-bottom: 0 !important; + } + } + + &:not([data-glpi-form-editor-active-question]) { + [data-glpi-form-editor-selectable-question-options] { + [data-glpi-form-selectable-question-option]:last-child { + margin-bottom: 0 !important; + } + } } } diff --git a/css/includes/components/form/_form-renderer.scss b/css/includes/components/form/_form-renderer.scss index cf354277564..ad7030ed6a9 100644 --- a/css/includes/components/form/_form-renderer.scss +++ b/css/includes/components/form/_form-renderer.scss @@ -41,4 +41,22 @@ margin-bottom: 0 !important; } } + + .fileupload { + margin: 0; + } + + .only-uploaded-files { + .fileupload_info { + margin-bottom: 0; + + p:first-child { + margin-top: 10px; + } + + p:last-child { + margin-bottom: 0; + } + } + } } diff --git a/src/Glpi/Form/QuestionType/AbstractQuestionTypeActors.php b/src/Glpi/Form/QuestionType/AbstractQuestionTypeActors.php index 43f4dd91910..2797e66e745 100644 --- a/src/Glpi/Form/QuestionType/AbstractQuestionTypeActors.php +++ b/src/Glpi/Form/QuestionType/AbstractQuestionTypeActors.php @@ -213,15 +213,16 @@ public function renderAdministrationTemplate(?Question $question): string actors_dropdown, '', { - 'disabled': is_multiple_actors, - 'no_label': true, + 'disabled' : is_multiple_actors, + 'no_label' : true, + 'mb' : '', + 'wrapper_class': '', 'field_class': [ 'actors-dropdown', 'col-12', 'col-sm-6', not is_multiple_actors ? '' : 'd-none' ]|join(' '), - wrapper_class: '' } ) }} {{ fields.htmlField( @@ -229,14 +230,15 @@ public function renderAdministrationTemplate(?Question $question): string actors_dropdown_multiple, '', { - 'no_label': true, - 'field_class': [ + 'no_label' : true, + 'wrapper_class': '', + 'mb' : '', + 'field_class' : [ 'actors-dropdown', 'col-12', 'col-sm-6', is_multiple_actors ? '' : 'd-none' ]|join(' '), - wrapper_class: '' } ) }} TWIG; @@ -338,9 +340,10 @@ public function renderEndUserTemplate(Question $question): string question.getEndUserInputName(), value, { - 'multiple': is_multiple_actors, + 'multiple' : is_multiple_actors, 'allowed_types': allowed_types, - 'aria_label': aria_label + 'aria_label' : aria_label, + 'mb' : '' } ]) %} @@ -349,11 +352,13 @@ public function renderEndUserTemplate(Question $question): string actors_dropdown, '', { - 'no_label': true, - 'field_class': [ + 'no_label' : true, + 'wrapper_class': '', + 'mb' : '', + 'field_class' : [ 'col-12', 'col-sm-6', - ]|join(' ') + ]|join(' '), } ) }} TWIG; diff --git a/src/Glpi/Form/QuestionType/AbstractQuestionTypeSelectable.php b/src/Glpi/Form/QuestionType/AbstractQuestionTypeSelectable.php index 4e9668481a3..21168820234 100644 --- a/src/Glpi/Form/QuestionType/AbstractQuestionTypeSelectable.php +++ b/src/Glpi/Form/QuestionType/AbstractQuestionTypeSelectable.php @@ -211,6 +211,7 @@ public function renderAdministrationTemplate(?Question $question): string
+
{% endfor %}