{#
 # ---------------------------------------------------------------------
 # Formcreator is a plugin which allows creation of custom forms of
 # easy access.
 # ---------------------------------------------------------------------
 # LICENSE
 #
 # This file is part of Formcreator.
 #
 # Formcreator 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.
 #
 # Formcreator 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 Formcreator. If not, see <http://www.gnu.org/licenses/>.
 # ---------------------------------------------------------------------
 # @copyright Copyright © 2011 - 2021 Teclib'
 # @license   http://www.gnu.org/licenses/gpl.txt GPLv3+
 # @link      https://github.com/pluginsGLPI/formcreator/
 # @link      https://pluginsglpi.github.io/formcreator/
 # @link      http://plugins.glpi-project.org/#/plugin/formcreator
 # ---------------------------------------------------------------------
 #}

{% extends "generic_show_form.html.twig" %}
{% import 'components/form/fields_macros.html.twig' as fields %}
{% import '@formcreator/components/form/fields_macros.html.twig' as formcreatorFields %}

{% block form_fields %}
    {% if item.isNewItem() %}
        {% set language = '' %}
        {% set iconColor = '#999999' %}
        {% set bgColor = '#E7E7E7' %}
    {% else %}
        {% set language = item.fields['language'] %}
        {% set iconColor = item.fields['icon_color'] %}
        {% set bgColor = item.fields['background_color'] %}
    {% endif %}

    {{ fields.autoNameField(
        'name',
        item,
        __('Name'),
    withtemplate,
    { required: true }
    ) }}

    {{ fields.dropdownYesNo('is_active', item.fields['is_active'], __('Active'), { required: true }) }}

    {{ fields.dropdownField(
        'PluginFormcreatorCategory',
        'plugin_formcreator_categories_id',
        item.fields['plugin_formcreator_categories_id'],
        'PluginFormcreatorCategory'|itemtype_name
    ) }}

    {{ fields.dropdownYesNo('helpdesk_home', item.fields['helpdesk_home'], __('Direct access on homepage', 'formcreator')) }}

    {{ formcreatorFields.dropdownFontAwesomeIconField('icon', item.fields['icon'], __('Icon', 'formcreator')) }}

    {{ fields.colorField('icon_color', iconColor, __('Icon color')) }}

    {{ formcreatorFields.dropdownLanguageField(
        'language',
        item.fields['icon'],
        __('Language', 'formcreator'),
        {
            'display_emptychoice': true,
            'emptylabel':  '--- ' ~ __('All languages', 'formcreator') ~ ' ---',
            'value': language,
        }
    ) }}

    {{ fields.colorField('background_color', bgColor, __('Background color', 'formcreator')) }}

    {{ fields.textField('description', item.fields['description'], __('Description')) }}

    {{ fields.textareaField('content', item.fields['content'], _n('Header', 'Headers', 1, 'formcreator'), { 'enable_richtext': true }) }}

    {{ fields.dropdownYesNo('is_default', item.fields['is_default'], __('Default form in service catalog', 'formcreator')) }}

    {% set tooltip = call('Html::showToolTip',
        [__(
            "If set to 'no', this form won't be shown for self-services users. They will still be able to access this form through its URL.",
            'formcreator'
        ),
        { display: false }
    ]) %}
    {% if item.isNewItem() %}
        {% set visible = 1 %}
    {% else %}
        {% set visible = item.fields['is_visible'] %}
    {% endif %}
    {{ fields.dropdownYesNo('is_visible', visible, __('Visible', 'formcreator'), { 'add_field_html': tooltip }) }}
{% endblock %}
