Skip to content

Commit

Permalink
fix: add missing templates
Browse files Browse the repository at this point in the history
btry committed Jan 31, 2022
1 parent d870625 commit 36b8018
Showing 3 changed files with 221 additions and 0 deletions.
101 changes: 101 additions & 0 deletions templates/components/form/condition.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{#
# ---------------------------------------------------------------------
# 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
# ---------------------------------------------------------------------
#}

{% import 'components/form/fields_macros.html.twig' as fields %}
<div class="col-12 col-xxl-12 flex-column">
<div class="d-flex flex-row flex-wrap flex-xl-nowrap">
<div class="row flex-row align-items-start flex-grow-1">
<div class="row flex-row">

{# Logic operator #}
{% set elements = call('PluginFormcreatorCondition::getEnumShowLogic') %}
{% set options = {
'value': condition.fields['show_logic']|verbatim_value,
'width': '100%',
'display_emptychoice': false,
'field_class': 'col-12 col-sm-1',
'no_label': true
} %}
{% set field %}
{% do call('Dropdown::showFromArray', ['_conditions[show_logic][]', elements, options]) %}
{% endset %}
{{ fields.field(name, field, label, options|merge({'id': 'dropdown_' ~ name ~ '_' ~ options.rand})) }}

{# condition field #}
{% set options = {
'field_class': 'col-12 col-sm-5',
'no_label': true,
'rand': random(),
'width': '100%',
} %}
{% set excludeQuestions = params.excludeQuestions ?? [] %}
{% set excludeQuestions = call('PluginFormcreatorCondition::getQuestionsExclusion', [item]) %}
{% set form = call('PluginFormcreatorForm::getByItem', [item]) %}
{% set field %}
{% do call('PluginFormcreatorQuestion::dropdownForForm', [form, excludeQuestions, '_conditions[plugin_formcreator_questions_id][]', params.questionId]) %}
{% endset %}
{{ fields.field(name, field, label, options|merge({'id': 'dropdown_' ~ name ~ '_' ~ options.rand})) }}

{# operator field #}
{% set elements = call('PluginFormcreatorCondition::getEnumShowCondition') %}
{% set options = {
'value': condition.fields['show_condition']|verbatim_value,
'width': '100%',
'display_emptychoice': false,
'field_class': 'col-12 col-sm-1',
'no_label': true
} %}
{% set field %}
{% do call('Dropdown::showFromArray', ['_conditions[show_condition][]', elements, options]) %}
{% endset %}
{{ fields.field(name, field, label, options|merge({'id': 'dropdown_' ~ name ~ '_' ~ options.rand})) }}

{% set options = {
'width': '100%',
'display_emptychoice': false,
'field_class': 'col-12 col-sm-3',
'no_label': true
} %}
{{ fields.textField('_conditions[show_value][]', condition.fields['show_value'], '', options) }}

<div class="col-12 col-sm-1 mb-3">
<button class="btn btn-primary me-2" type="button" name="add" onclick="plugin_formcreator_addEmptyCondition(this, '', '')">
<i class="fas fa-plus-circle" style="cursor: pointer;"></i>
</button>
</div>
<div class="col-12 col-sm-1 mb-3">
<button class="btn btn-primary me-2" type="button" name="add" onclick="plugin_formcreator_removeNextCondition(this, '', '')">
<i class="fas fa-minus-circle" style="cursor: pointer;"></i>
</button>
</div>
</div>
</div>
</div>
</div>
29 changes: 29 additions & 0 deletions templates/components/form/question_design.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{#
# ---------------------------------------------------------------------
# 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
# ---------------------------------------------------------------------
#}
91 changes: 91 additions & 0 deletions templates/components/form/section_design.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{#
# ---------------------------------------------------------------------
# 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
# ---------------------------------------------------------------------
#}

{% set lastSectionOrder = call('PluginFormcreatorCommon::getMax', [item, { 'plugin_formcreator_forms_id': item.fields['plugin_formcreator_forms_id']}, 'order']) %}

<li class="plugin_formcreator_section" data-itemtype="PluginFormcreatorSection" data-id="{{ item.fields['id'] }}">
{% set conditionsCount = call('PluginFormcreatorCondition::countForItem', [item]) %}
<a href="#" onclick="plugin_formcreator.showSectionForm({{ item.fields['plugin_formcreator_forms_id'] }}, {{ item.fields['id'] }})">
{# TODO : Show count of conditions #}
<sup class="plugin_formcreator_conditions_count" title="{{ __('Count of conditions', 'formcreator') }}">{{ conditionsCount }}</sup>
{% if item.fields['name'] is empty %}
{% set name = '(' ~ item.fields['id'] ~ ')' %}
{% else %}
{% set name = item.fields['name'] %}
{% endif %}
{{ name }}
</a>

{# Delete a section #}
<span class='form_control pointer'>
<i class="far fa-trash-alt" onclick="plugin_formcreator.deleteSection(this)"></i>
</span>

{# Clone a section #}
<span class='form_control pointer'>
<i class="far fa-clone" onclick="plugin_formcreator.duplicateSection(this)"></i>
</span>

{# Move down a section #}
{% if item.fields['order'] < lastSectionOrder %}
{% set display = 'initial' %}
{% else %}
{% set display = 'none' %}
{% endif %}
<span class="form_control pointer moveDown" style="display: {{ display }}">
<i class="fas fa-sort-down" onclick="plugin_formcreator.moveSection(this, 'down')"></i>
</span>

{# Move up a section #}
{% if item.fields['order'] > 1 %}
{% set display = 'initial' %}
{% else %}
{% set display = 'none' %}
{% endif %}
<span class="form_control pointer moveUp" style="display: {{ display }}">
<i class="fas fa-sort-up" onclick="plugin_formcreator.moveSection(this, 'up')"></i>
</span>

{# Section content #}
{% set columns = call('constant', ['PluginFormcreatorSection::COLUMNS']) %}
<div class="grid-stack grid-stack-{{ columns }}" data-gs-animate="yes" data-gs-width="{{ columns }}" data-id="{{ item.fields['id'] }}"></div>

{# Add a question #}
<div class="plugin_formcreator_question">
<a href="#" onclick="plugin_formcreator.showQuestionForm({{ item.fields['id'] }});">
<i class="fas fa-plus"></i>&nbsp;{{ __('Add a question', 'formcreator') }}
</a>
</div>
<script type="text/javascript">
$(function () {
plugin_formcreator.initGridStack({{ item.fields['id'] }});
});
</script>
</li>

0 comments on commit 36b8018

Please sign in to comment.