{# # --------------------------------------------------------------------- # # GLPI - Gestionnaire Libre de Parc Informatique # # http://glpi-project.org # # @copyright 2015-2024 Teclib' and contributors. # @copyright 2003-2014 by the INDEPNET Development Team. # @licence https://www.gnu.org/licenses/gpl-3.0.html # # --------------------------------------------------------------------- # # LICENSE # # This file is part of GLPI. # # This program 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 3 of the License, or # (at your option) any later version. # # This program 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 this program. If not, see . # # --------------------------------------------------------------------- #} {# @var item Glpi\Form\Form #} {# @var params array #} {# @var question_types_manager Glpi\Form\QuestionType\QuestionTypesManager #} {# @var allow_unauthenticated_access bool #} {% import 'components/form/fields_macros.html.twig' as fields %} {% set base_field_options = { 'is_horizontal': false, 'full_width' : true, 'no_label' : true, } %}
{{ call_plugin_hook(constant('Glpi\\Plugin\\Hooks::PRE_ITEM_FORM'), {'item': item, 'options': params}) }} {# Form editor page #} {# UX and items placement are a work in progress #} {# Need more elements (questions, sections) before finalizing the design #}
{# We expect to use the right side to display some extra info later so keep some available space for now #}
{# Card containing the main form data: title, header and status #}
{# Header #}
{# Form's name #} {# Form's status #}
{# Form's hader #}
{{ fields.textareaField( 'header', item.fields.header, __('Header'), base_field_options|merge({ 'enable_richtext': true, 'add_body_classes': ['content-editable-tinymce-editor', 'text-muted'], 'editor_height': "0", 'rows' : 1, 'toolbar_location': 'bottom', 'mb': 'mb-0', 'aria_label': __("Form description"), 'placeholder': __("Add a description to your form..."), }) ) }}
{# Display all questions here #}
{% set number_of_sections = item.getSections()|length %} {% for section in item.getSections() %} {{ include('pages/admin/form/form_section.html.twig', { 'form' : item, 'section' : section, 'question_types_manager': question_types_manager, 'section_index' : loop.index, 'can_update' : item.canUpdate(), 'show_section_form' : number_of_sections > 1, 'number_of_sections' : number_of_sections, }, with_context = false) }} {% endfor %}
{{ include('pages/admin/form/form_toolbar.html.twig', { 'can_update': item.canUpdate(), 'form' : item, }, with_context = false) }}
{# Form id #} {# Special inputs to indicate that missing sections and question must be deleted #} {# Set as non draft once saved #} {% if item.fields.is_draft %} {% endif %} {# TODO: add bootstrap tooltips on each buttons #} {{ call_plugin_hook(constant('Glpi\\Plugin\\Hooks::POST_ITEM_FORM'), {'item': item, 'options': params}) }} {# Move section modal #} {{ include('pages/admin/form/move_section_modal.html.twig') }}
{% if item.canUpdate() %} {# Templates, must be outside the main form to avoid submitting their inputs #}
{# Load all possible questions types as hidden DOM content that is ready to be copied for a new question #} {% for key, question_type in question_types_manager.getQuestionTypes() %}
{# Render admin template for the given question type #} {{ include('pages/admin/form/form_question.html.twig', { 'form' : item, 'question_types_manager' : question_types_manager, 'question_type' : question_type, 'question' : null, 'section' : null, 'can_update' : true, 'allow_unauthenticated_access': allow_unauthenticated_access, }, with_context = false) }}
{% endfor %} {# Load new title and description template #}
{{ include('pages/admin/form/form_comment.html.twig', { 'form' : item, 'question_types_manager' : question_types_manager, 'question_type' : question_type, 'question' : null, 'section' : null, 'can_update' : true, }, with_context = false) }}
{# Load new section template #}
{{ include('pages/admin/form/form_section.html.twig', { 'form' : item, 'section' : null, 'can_update' : true, 'show_section_form' : true, 'number_of_sections' : 0, }, with_context = false) }}
{# Load all possible question types values #}
{% endif %}