{% else %}
{% set text = __('No model currently available', 'datainjection') %}
{% if can_create_model %}
@@ -71,11 +73,11 @@
diff --git a/templates/info_add_form.html.twig b/templates/info_add_form.html.twig
new file mode 100644
index 00000000..592c68c2
--- /dev/null
+++ b/templates/info_add_form.html.twig
@@ -0,0 +1,44 @@
+{#
+ # -------------------------------------------------------------------------
+ # DataInjection plugin for GLPI
+ # -------------------------------------------------------------------------
+ #
+ # LICENSE
+ #
+ # This file is part of DataInjection.
+ #
+ # DataInjection 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.
+ #
+ # DataInjection 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 DataInjection. If not, see .
+ # -------------------------------------------------------------------------
+ # @copyright Copyright (C) 2007-2023 by DataInjection plugin team.
+ # @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
+ # @link https://github.com/pluginsGLPI/datainjection
+ # -------------------------------------------------------------------------
+ #}
+
+{% embed '@datainjection/components/mapping_table.html.twig' with {
+ form_action: form_action,
+ fields_url: fields_url,
+ rows: [info],
+ title: __('Add an additional information', 'datainjection'),
+ icon: 'ti ti-row-insert-bottom',
+ switch_label: __('Mandatory information', 'datainjection'),
+} %}
+ {% block footer %}
+
+
+ {% endblock %}
+{% endembed %}
diff --git a/templates/info_additional_information.html.twig b/templates/info_additional_information.html.twig
new file mode 100644
index 00000000..4f795499
--- /dev/null
+++ b/templates/info_additional_information.html.twig
@@ -0,0 +1,37 @@
+{#
+ # -------------------------------------------------------------------------
+ # DataInjection plugin for GLPI
+ # -------------------------------------------------------------------------
+ #
+ # LICENSE
+ #
+ # This file is part of DataInjection.
+ #
+ # DataInjection 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.
+ #
+ # DataInjection 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 DataInjection. If not, see .
+ # -------------------------------------------------------------------------
+ # @copyright Copyright (C) 2007-2023 by DataInjection plugin team.
+ # @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
+ # @link https://github.com/pluginsGLPI/datainjection
+ # -------------------------------------------------------------------------
+ #}
+
+{% import 'components/form/fields_macros.html.twig' as fields %}
+
+{{ fields.htmlField(name, field_html, label, {
+ 'field_class': 'col-12',
+ 'label_class': 'col-sm-4',
+ 'input_class': 'col-sm-8',
+ 'wrapper_class': 'd-block',
+ 'required': is_mandatory,
+}) }}
diff --git a/templates/info_additional_input.html.twig b/templates/info_additional_input.html.twig
new file mode 100644
index 00000000..ac21dfd8
--- /dev/null
+++ b/templates/info_additional_input.html.twig
@@ -0,0 +1,37 @@
+{#
+ # -------------------------------------------------------------------------
+ # DataInjection plugin for GLPI
+ # -------------------------------------------------------------------------
+ #
+ # LICENSE
+ #
+ # This file is part of DataInjection.
+ #
+ # DataInjection 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.
+ #
+ # DataInjection 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 DataInjection. If not, see .
+ # -------------------------------------------------------------------------
+ # @copyright Copyright (C) 2007-2023 by DataInjection plugin team.
+ # @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
+ # @link https://github.com/pluginsGLPI/datainjection
+ # -------------------------------------------------------------------------
+ #}
+
+{% import 'components/form/basic_inputs_macros.html.twig' as inputs %}
+
+{% if type == 'textarea' %}
+ {{ inputs.textarea(name, value, {'id': '%id%', 'rows': 5}) }}
+{% elseif type == 'password' %}
+ {{ inputs.password(name, '', {'id': '%id%', 'additional_attributes': {'autocomplete': 'off'}}) }}
+{% else %}
+ {{ inputs.text(name, value, {'id': '%id%'}) }}
+{% endif %}
diff --git a/templates/infoadditionnalinfo.html.twig b/templates/infoadditionnalinfo.html.twig
index 50ff3c63..442548cb 100644
--- a/templates/infoadditionnalinfo.html.twig
+++ b/templates/infoadditionnalinfo.html.twig
@@ -48,16 +48,10 @@
{% endif %}
{% if rendered_infos|length > 0 %}
-
-
-
- {% for rendered_info in rendered_infos %}
-
- {{ rendered_info|raw }}
-
- {% endfor %}
-
-
+
+ {% for rendered_info in rendered_infos %}
+ {{ rendered_info|raw }}
+ {% endfor %}
{% endif %}
{% endif %}
\ No newline at end of file
diff --git a/templates/infos_form.html.twig b/templates/infos_form.html.twig
new file mode 100644
index 00000000..b8f7938e
--- /dev/null
+++ b/templates/infos_form.html.twig
@@ -0,0 +1,69 @@
+{#
+ # -------------------------------------------------------------------------
+ # DataInjection plugin for GLPI
+ # -------------------------------------------------------------------------
+ #
+ # LICENSE
+ #
+ # This file is part of DataInjection.
+ #
+ # DataInjection 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.
+ #
+ # DataInjection 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 DataInjection. If not, see .
+ # -------------------------------------------------------------------------
+ # @copyright Copyright (C) 2007-2023 by DataInjection plugin team.
+ # @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
+ # @link https://github.com/pluginsGLPI/datainjection
+ # -------------------------------------------------------------------------
+ #}
+
+{% embed '@datainjection/components/mapping_table.html.twig' with {
+ form_action: form_action,
+ fields_url: fields_url,
+ rows: infos,
+ title: __('Additional information', 'datainjection'),
+ icon: 'ti ti-list-details',
+ selectable: canedit,
+ select_all: select_all,
+ switch_label: __('Mandatory information', 'datainjection'),
+ badges: [
+ {
+ class: 'bg-secondary-lt',
+ labels: [_n('%d additional information', '%d additional information', 1, 'datainjection'), _n('%d additional information', '%d additional information', 2, 'datainjection')],
+ count: infos|length,
+ },
+ {
+ class: 'bg-blue-lt',
+ labels: [_n('%d mandatory information', '%d mandatory information', 1, 'datainjection'), _n('%d mandatory information', '%d mandatory information', 2, 'datainjection')],
+ count: nb_mandatory,
+ counter: 'link',
+ },
+ ],
+} %}
+ {% block selection_actions %}
+ {% if canedit %}
+
+ {% endif %}
+ {% endblock %}
+ {% block footer %}
+ {% if canedit %}
+
+
+ {% endif %}
+ {% endblock %}
+{% endembed %}
diff --git a/templates/log_results.html.twig b/templates/log_results.html.twig
index 0a8fd8f2..b5ee7947 100644
--- a/templates/log_results.html.twig
+++ b/templates/log_results.html.twig
@@ -26,121 +26,153 @@
# -------------------------------------------------------------------------
#}
-
+{% set nb_success = (logresults[SUCCESS] ?? [])|length %}
+{% set nb_failed = (logresults[FAILED] ?? [])|length %}
- {% if logresults[SUCCESS] is defined %}
-
-
-
- {{ __('Array of successful injections', 'datainjection') }}
-
diff --git a/templates/mappings_form.html.twig b/templates/mappings_form.html.twig
index 598065a1..e2e8f638 100644
--- a/templates/mappings_form.html.twig
+++ b/templates/mappings_form.html.twig
@@ -26,45 +26,51 @@
# -------------------------------------------------------------------------
#}
-
-
+ {% endblock %}
+{% endembed %}
diff --git a/templates/preview_mappings.html.twig b/templates/preview_mappings.html.twig
new file mode 100644
index 00000000..857572f1
--- /dev/null
+++ b/templates/preview_mappings.html.twig
@@ -0,0 +1,87 @@
+{#
+ # -------------------------------------------------------------------------
+ # DataInjection plugin for GLPI
+ # -------------------------------------------------------------------------
+ #
+ # LICENSE
+ #
+ # This file is part of DataInjection.
+ #
+ # DataInjection 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.
+ #
+ # DataInjection 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 DataInjection. If not, see .
+ # -------------------------------------------------------------------------
+ # @copyright Copyright (C) 2007-2023 by DataInjection plugin team.
+ # @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
+ # @link https://github.com/pluginsGLPI/datainjection
+ # -------------------------------------------------------------------------
+ #}
+
+{% set nb_columns = headers|length > 0 ? headers|length : (rows|first ?: [])|length %}
+{% set nb_rows = rows|length %}
+
+
+ {% if value is same as('') or value is null %}
+ -
+ {% else %}
+ {{ value }}
+ {% endif %}
+
+ {% endfor %}
+
+ {% endfor %}
+
+
+
+
+ {% else %}
+
{{ __('No data to display', 'datainjection') }}
+ {% endif %}
+
diff --git a/templates/profile_form.html.twig b/templates/profile_form.html.twig
new file mode 100644
index 00000000..d61f4630
--- /dev/null
+++ b/templates/profile_form.html.twig
@@ -0,0 +1,51 @@
+{#
+ # -------------------------------------------------------------------------
+ # DataInjection plugin for GLPI
+ # -------------------------------------------------------------------------
+ #
+ # LICENSE
+ #
+ # This file is part of DataInjection.
+ #
+ # DataInjection 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.
+ #
+ # DataInjection 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 DataInjection. If not, see .
+ # -------------------------------------------------------------------------
+ # @copyright Copyright (C) 2007-2023 by DataInjection plugin team.
+ # @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html
+ # @link https://github.com/pluginsGLPI/datainjection
+ # -------------------------------------------------------------------------
+ #}
+
+
+ {% if canedit %}
+
+ {% endif %}
+
diff --git a/tests/unit/AdditionalInformationTest.php b/tests/unit/AdditionalInformationTest.php
index f366d82f..12f689ce 100644
--- a/tests/unit/AdditionalInformationTest.php
+++ b/tests/unit/AdditionalInformationTest.php
@@ -42,6 +42,7 @@
use PluginDatainjectionMapping;
use PluginDatainjectionModel;
use Session;
+use Symfony\Component\DomCrawler\Crawler;
final class AdditionalInformationTest extends DbTestCase
{
@@ -128,7 +129,13 @@ public function testFormInputIsNamedAfterItemtypeAndField(): void
PluginDatainjectionInfo::displayAdditionalInformation($info);
$html = ob_get_clean();
- self::assertStringContainsString("name='info[DeviceProcessor][designation]'", $html);
+ $crawler = new Crawler($html);
+ $input = $crawler->filter('input[name="info[DeviceProcessor][designation]"]');
+ self::assertCount(1, $input);
self::assertStringContainsString(DeviceProcessor::getTypeName(1) . ' - ', $html);
+
+ // The label targets the input
+ self::assertNotEmpty($input->attr('id'));
+ self::assertSame($input->attr('id'), $crawler->filter('label')->attr('for'));
}
}
diff --git a/tests/unit/InjectionTypeFieldsHtmlTest.php b/tests/unit/InjectionTypeFieldsHtmlTest.php
index 2cb817b7..ed41fb19 100644
--- a/tests/unit/InjectionTypeFieldsHtmlTest.php
+++ b/tests/unit/InjectionTypeFieldsHtmlTest.php
@@ -36,6 +36,7 @@
use PluginDatainjectionModel;
use Session;
use Glpi\Tests\DbTestCase;
+use Symfony\Component\DomCrawler\Crawler;
final class InjectionTypeFieldsHtmlTest extends DbTestCase
{
@@ -68,15 +69,15 @@ public function testEachRowKeepsItsFieldAndHidesTheOtherRowsOne(): void
}
//Rendered in the same request, as the Mappings tab does: the static caches are shared by the rows
- $options = ['primary_type' => Computer::class];
- $html = [];
+ $selects = [];
foreach ($mappings as $field => $mapping) {
- $html[$field] = PluginDatainjectionInjectionType::getFieldsHtml($mapping, $options)['field'];
+ $row = PluginDatainjectionInjectionType::getRow($mapping, Computer::class);
+ $selects[$field] = (new Crawler($row['field_html']))->filter('select');
}
foreach (['name' => 'serial', 'serial' => 'name'] as $field => $other) {
- $this->assertStringContainsString(sprintf("