Skip to content

Commit 0c7557b

Browse files
authored
Merge branch 'main' into fix/entity-restrict-criteria-without-session
2 parents 24404ce + 1de4e34 commit 0c7557b

4 files changed

Lines changed: 42 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1414
### Fixed
1515

1616
- Fix SQL warning when no user session is active during plugin init
17+
- Fix text area fields alignment
1718
- Fix error when submitting a form with an hidden question of type `Field`
1819
- Fixed a bug where a field was deleted when at least one question in a form was linked to another field
1920

hook.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ function plugin_fields_addWhere($link, $nott, $itemtype, $ID, $val, $searchtype)
377377
$link .= ' NOT ';
378378
}
379379

380-
return $link . 'CAST(' . $DB->quoteName($table . '_' . $field) . '.' . $DB->quoteName($field) . ' AS DECIMAL(10,7))' . $operator . ' ' . $DB->quoteValue($val) ;
380+
return $link . ' CAST(' . $DB->quoteName($table . '_' . $field) . '.' . $DB->quoteName($field) . ' AS DECIMAL(10,7))' . $operator . ' ' . $DB->quoteValue($val);
381381
} else {
382382
// if 'number' field with name is found with <= or >= or < or > search
383383
// update WHERE clause with the correct operator

templates/fields.html.twig

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,46 @@
2828

2929
{% import 'components/form/fields_macros.html.twig' as macros %}
3030

31-
{% set already_wrapped = item is instanceof('CommonITILObject') and container.fields['type'] == 'dom' %}
32-
{% set dropdown_item = item is instanceof('CommonDropdown') and container.fields['type'] == 'dom' %}
33-
34-
{% if item is instanceof('Glpi\\Form\\Form') %}
35-
{% set already_wrapped = true %}
31+
{% set in_itilobject = item is instanceof('CommonITILObject') and container.fields['type'] == 'dom' %}
32+
{% set in_form_builder = item is instanceof('Glpi\\Form\\Form') %}
33+
{% set already_wrapped = in_itilobject or in_form_builder %}
34+
{% set dropdown_item = item is instanceof('CommonDropdown') and container.fields['type'] == 'dom' %}
35+
36+
{% set textarea_display_options = {
37+
'in_itilobject': {
38+
'field_class': 'col-12',
39+
'label_class': 'col-2',
40+
'input_class': 'col-10',
41+
'is_horizontal': true,
42+
'align_label_right': true,
43+
},
44+
'in_form_builder': {
45+
'field_class': 'col-12',
46+
'label_class': 'form-label',
47+
'input_class': 'w-100',
48+
'is_horizontal': false,
49+
'align_label_right': false,
50+
},
51+
'default': {
52+
'field_class': 'col-12',
53+
'label_class': 'col-xxl-2',
54+
'input_class': 'col-xxl-10',
55+
'is_horizontal': true,
56+
'align_label_right': true,
57+
},
58+
} %}
59+
60+
{% if in_itilobject %}
61+
{% set current_textarea_options = textarea_display_options.in_itilobject %}
62+
{% elseif in_form_builder %}
63+
{% set current_textarea_options = textarea_display_options.in_form_builder %}
64+
{% else %}
65+
{% set current_textarea_options = textarea_display_options.default %}
3666
{% endif %}
3767

3868
{% if not already_wrapped and not dropdown_item%}
3969

40-
{% set class = item.isNewItem() or item is instanceof('User') ? 'col-xxl-12' : 'col-xxl-9' %}
70+
{% set class = item.isNewItem() or item is instanceof('User') or container.fields['type'] == 'dom' ? 'col-xxl-12' : 'col-xxl-9' %}
4171
<div class="col-12 {{ class }} flex-column">
4272
<div class="d-flex flex-row flex-wrap flex-xl-nowrap">
4373
<div class="row flex-row align-items-start flex-grow-1">
@@ -88,15 +118,11 @@
88118
})) }}
89119

90120
{% elseif type == 'textarea' %}
91-
{{ macros.textareaField(input_name, value, label, field_options) }}
121+
{{ macros.textareaField(input_name, value, label, field_options|merge(current_textarea_options)) }}
92122

93123
{% elseif type == 'richtext' %}
94-
{{ macros.textareaField(input_name, value, label, field_options|merge({
124+
{{ macros.textareaField(input_name, value, label, field_options|merge(current_textarea_options)|merge({
95125
'enable_richtext': true,
96-
'field_class': 'col-12',
97-
'label_class': '',
98-
'input_class': '',
99-
'align_label_right': false,
100126
})) }}
101127

102128
{% elseif type == 'yesno' %}

templates/question_type_administration.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777

7878
{% if not is_ajax_reload %}
7979
<script>
80-
import(GLPI_PLUGINS_PATH.fields + "/js/modules/QuestionField.js").then((m) => {
80+
import(CFG_GLPI.root_doc + GLPI_PLUGINS_PATH.fields + "/js/modules/QuestionField.js").then((m) => {
8181
const questionField = new m.GlpiPluginFieldsQuestionTypeField();
8282
8383
{% if question is not null %}
@@ -94,7 +94,7 @@
9494
</script>
9595
{% else %}
9696
<script>
97-
import(GLPI_PLUGINS_PATH.fields + "/js/modules/QuestionField.js").then((m) => {
97+
import(CFG_GLPI.root_doc + GLPI_PLUGINS_PATH.fields + "/js/modules/QuestionField.js").then((m) => {
9898
const questionField = new m.GlpiPluginFieldsQuestionTypeField();
9999
questionField.lockMandatoryInput(
100100
$('[data-glpi-form-editor-question-type-fields-field-id-selector="{{ rand }}"]').closest('[data-glpi-form-editor-question-details]'),

0 commit comments

Comments
 (0)