diff --git a/RoboFile.php b/RoboFile.php
index 24802b645..364338a1b 100644
--- a/RoboFile.php
+++ b/RoboFile.php
@@ -133,9 +133,9 @@ public function archiveBuild($release = 'release') {
throw new Exception('The Official release constant must be true');
}
- if (Git::tagExists($version)) {
+ // if (Git::tagExists($version)) {
// throw new Exception("The tag $version already exists");
- }
+ // }
// if (!Git::isTagMatchesCurrentCommit($version)) {
// throw new Exception("HEAD is not pointing to the tag of the version to build");
@@ -145,13 +145,12 @@ public function archiveBuild($release = 'release') {
if (!is_array($versionTag)) {
throw new Exception("The version does not exists in the XML file");
}
+
+ // $this->updateChangelog();
}
// update version in package.json
$this->sourceUpdatePackageJson($version);
- if ($release == 'release') {
- // $this->updateChangelog();
- }
$diff = $this->gitDiff(['package.json']);
$diff = implode("\n", $diff);
diff --git a/css/print_form.css b/css/print_form.css
index a845b4cc3..ab9ae1f7f 100644
--- a/css/print_form.css
+++ b/css/print_form.css
@@ -133,3 +133,15 @@ label[for] {
height:16px;
width:16px;
}
+
+#plugin_formcreator_form.plugin_formcreator_form li.plugin_formcreator_section {
+ position: inherit;
+ top: inherit;
+ left: inherit;
+ display: inherit !important;
+}
+
+#plugin_formcreator_form.plugin_formcreator_form li.plugin_formcreator_section .next_button,
+#plugin_formcreator_form.plugin_formcreator_form li.plugin_formcreator_section .previous_button {
+ display: none;
+}
diff --git a/css/styles.scss b/css/styles.scss
index e8f43ed7c..c7c24f2e6 100644
--- a/css/styles.scss
+++ b/css/styles.scss
@@ -225,12 +225,34 @@
list-style-type: none;
text-align: left;
padding-left: 0;
+ overflow: hidden;
}
[data-itemtype = "PluginFormcreatorQuestion"]:not([hidden]), .plugin_formcreator_gap {
vertical-align: top;
display: inline-block;
}
+
+ li.plugin_formcreator_section {
+ position: relative;
+ width: 100%;
+ top: 0;
+ left: 0;
+ transition-property: left;
+ transition-duration: 0.3s;
+ }
+
+ .plugin_formcreator_section_navigate {
+ padding-bottom: 8px;
+ .previous_button {
+ margin-left: 8px;
+ float: inherit;
+ }
+
+ .next_button {
+ float: right;
+ }
+ }
}
.form_answer h1 {
diff --git a/inc/form.class.php b/inc/form.class.php
index ef4d8ffd2..27b56bf4f 100644
--- a/inc/form.class.php
+++ b/inc/form.class.php
@@ -61,6 +61,10 @@ class PluginFormcreatorForm extends CommonDBTM implements
const VALIDATION_USER = 1;
const VALIDATION_GROUP = 2;
+ const SECTION_DISPLAY_VERTICAL_STACK = 0;
+ const SECTION_DISPLAY_WIZARD = 1;
+ const SECTION_DISPLAY_ACCORDION = 2;
+
public static function getEnumAccessType() {
return [
self::ACCESS_PUBLIC => __('Public access', 'formcreator'),
@@ -69,6 +73,14 @@ public static function getEnumAccessType() {
];
}
+ public static function getEnumSectionDisplayMode() {
+ return [
+ self::SECTION_DISPLAY_VERTICAL_STACK => __('Vertical stack', 'formcreator'),
+ self::SECTION_DISPLAY_WIZARD => __('Wizard', 'formcreator'),
+ self::SECTION_DISPLAY_ACCORDION => __('Accordion', 'formcreator'),
+ ];
+ }
+
public static function getEnumShowRule() : array {
return PluginFormcreatorCondition::getEnumShowRule();
}
@@ -958,7 +970,20 @@ public function displayUserForm() : void {
}
$formanswer = new PluginFormcreatorFormAnswer();
$formanswer->loadAnswersFromSession();
- TemplateRenderer::getInstance()->display('@formcreator/pages/userform.html.twig', [
+
+ switch ($this->fields['section_display_mode']) {
+ default:
+ $template = '@formcreator/pages/userform_stack.html.twig';
+ break;
+ case self::SECTION_DISPLAY_WIZARD :
+ $template = '@formcreator/pages/userform_wizard.html.twig';
+ break;
+ case self::SECTION_DISPLAY_ACCORDION :
+ $template = '@formcreator/pages/userform_acordion.html.twig';
+ break;
+ }
+
+ TemplateRenderer::getInstance()->display($template, [
'item' => $this,
'options' => [
'columns' => PluginFormcreatorSection::COLUMNS,
@@ -2572,4 +2597,16 @@ public function getExtraHeader(): string {
return $extra_header;
}
+
+ /**
+ * Show a section display mode dropdown
+ *
+ * @param string $name
+ * @param array $options
+ * @return void
+ */
+ public static function dropdownSectionDisplayMode(string $name, array $options): void {
+ $modes = self::getEnumSectionDisplayMode();
+ Dropdown::showFromArray($name, $modes, $options);
+ }
}
diff --git a/inc/section.class.php b/inc/section.class.php
index a297e719a..a771bb911 100644
--- a/inc/section.class.php
+++ b/inc/section.class.php
@@ -449,6 +449,26 @@ public static function getSectionsFromForm($formId): \Generator {
}
}
+ /**
+ * Counts sections in a form
+ * @param int $formId ID of a form
+ * @return int
+ */
+ public static function getSectionsCountFromForm($formId): int {
+ global $DB;
+
+ $count = $DB->request([
+ 'COUNT' => 'c',
+ 'FROM' => self::getTable(),
+ 'WHERE' => [
+ 'plugin_formcreator_forms_id' => $formId
+ ],
+ 'ORDER' => 'order ASC'
+ ])->current();
+
+ return $count['c'];
+ }
+
public function showForm($ID, $options = []) {
$this->initForm($ID, $options);
$options['candel'] = false;
diff --git a/install/mysql/plugin_formcreator_empty.sql b/install/mysql/plugin_formcreator_empty.sql
index 506cc10ff..30559e0fa 100644
--- a/install/mysql/plugin_formcreator_empty.sql
+++ b/install/mysql/plugin_formcreator_empty.sql
@@ -67,6 +67,7 @@ CREATE TABLE IF NOT EXISTS `glpi_plugin_formcreator_forms` (
`show_rule` int(11) NOT NULL DEFAULT '1' COMMENT 'Conditions setting to show the submit button',
`formanswer_name` varchar(255) NOT NULL DEFAULT '',
`is_visible` tinyint NOT NULL DEFAULT 1,
+ `section_display_mode` int(11) NOT NULL DEFAULT '0',
`uuid` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`),
INDEX `entities_id` (`entities_id`),
diff --git a/install/upgrade_to_2.14.php b/install/upgrade_to_2.14.php
index 68c3c2d19..8db5b81d1 100644
--- a/install/upgrade_to_2.14.php
+++ b/install/upgrade_to_2.14.php
@@ -42,6 +42,7 @@ public function upgrade(Migration $migration) {
$this->addRights();
$this->addPropertiesToCategories();
$this->addTargetActorUnicity();
+ $this->addSectionDisplayMode();
}
public function addTtoToIssues() {
@@ -131,4 +132,9 @@ public function addTargetActorUnicity() {
// Set unicity
$this->migration->addKey($table, $unicity, 'unicity', 'UNIQUE');
}
+
+ public function addSectionDisplayMode() {
+ $table = (new DBUtils())->getTableForItemType(PluginFormcreatorForm::class);
+ $this->migration->addField($table, 'section_display_mode', 'integer', ['after' => 'is_visible']);
+ }
}
diff --git a/templates/components/form/fields_macros.html.twig b/templates/components/form/fields_macros.html.twig
index f2893c49e..7bf797359 100644
--- a/templates/components/form/fields_macros.html.twig
+++ b/templates/components/form/fields_macros.html.twig
@@ -324,3 +324,24 @@
{% endset %}
{{ fields.field(name, field, label, options) }}
{% endmacro %}
+
+{% macro dropdownSectionDisplayMode(name, value, label = '', options = {}) %}
+ {% import 'components/form/fields_macros.html.twig' as fields %}
+ {% set options = {'rand': random()}|merge(options) %}
+
+ {% if options.disabled %}
+ {% set options = options|merge({specific_tags: {'disabled': 'disabled'}}) %}
+ {% endif %}
+ {% if options.fields_template.isMandatoryField(name) %}
+ {% set options = {'specific_tags': {'required': true}}|merge(options) %}
+ {% endif %}
+
+ {% set field %}
+ {% do call('PluginFormcreatorForm::dropdownSectionDisplayMode', [name, {
+ 'value': value,
+ 'rand': rand,
+ 'width': '100%'
+ }|merge(options)]) %}
+ {% endset %}
+ {{ fields.field(name, field, label, options) }}
+{% endmacro %}
\ No newline at end of file
diff --git a/templates/pages/form.html.twig b/templates/pages/form.html.twig
index c5b149a2d..01f8a5c6f 100644
--- a/templates/pages/form.html.twig
+++ b/templates/pages/form.html.twig
@@ -98,4 +98,6 @@
{% set visible = item.fields['is_visible'] %}
{% endif %}
{{ fields.dropdownYesNo('is_visible', visible, __('Visible', 'formcreator'), { 'add_field_html': tooltip }) }}
+
+ {{ formcreatorFields.dropdownSectionDisplayMode('section_display_mode', item.fields['section_display_mode'], __('Section display mode', 'formcreator')) }}
{% endblock %}
diff --git a/templates/pages/userform.html.twig b/templates/pages/userform_stack.html.twig
similarity index 100%
rename from templates/pages/userform.html.twig
rename to templates/pages/userform_stack.html.twig
diff --git a/templates/pages/userform_wizard.html.twig b/templates/pages/userform_wizard.html.twig
new file mode 100644
index 000000000..c57d1c1c5
--- /dev/null
+++ b/templates/pages/userform_wizard.html.twig
@@ -0,0 +1,194 @@
+{#
+ # ---------------------------------------------------------------------
+ # 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