Skip to content

Commit 99f6331

Browse files
committed
ui : ola fields hidden depending on template hidden field configuration
end forced display + clean template
1 parent 3a5484a commit 99f6331

1 file changed

Lines changed: 28 additions & 49 deletions

File tree

templates/components/itilobject/service_levels.html.twig

Lines changed: 28 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,6 @@ Handle only linked ola, not ola ttr and tto defined using datetime fields
146146
{% endif %}
147147
{% set _rand = random() %}
148148

149-
{# @todo cleanup supprimer forcage de debug #}
150-
{% set display_datetime_field = true %}
151-
{% set display_associatedsla_field = true %}
152-
153149
<td class="right pe-2 align-middle border-0">{{ _label }}</td>
154150
<td class="d-flex ms-n2 border-0 py-0">
155151
{# state flag #}
@@ -220,7 +216,8 @@ Handle only linked ola, not ola ttr and tto defined using datetime fields
220216
</tbody>
221217

222218
{# --------- OLA display ---------- #}
223-
<thead>
219+
{% set display_associatedsla_field = field_options.fields_template is not defined or not field_options.fields_template.isHiddenField('_olas_id') %}
220+
<thead class="{% if not display_associatedsla_field %}d-none{% endif %}">
224221
<tr class="">
225222
<th class="visually-hidden"></th>
226223
<th class="border-0 fs-4">
@@ -231,47 +228,33 @@ Handle only linked ola, not ola ttr and tto defined using datetime fields
231228
</th>
232229
</tr>
233230
</thead>
234-
<tbody>
235-
{% for ola in item.getOlasDataFromField() %}
236-
{% set _rand = random() %}
231+
<tbody class="{% if not display_associatedsla_field %}d-none{% endif %}">
232+
{% for ola in item.getOlasDataFromField() %}
233+
{% set _rand = random() %}
237234

235+
<tr id="ola_row_{{ _rand }}">
236+
{% set can_assign_sla_ola = canupdate and has_profile_right('slm', constant('SLM::RIGHT_ASSIGN')) and not field_options.fields_template.isReadonlyField('_olas_id') %}
238237

239-
<tr id="ola_row_{{ _rand }}">
240-
{% if ola.type == constant('SLM::TTO') %}
241-
{# {% set display_datetime_field = field_options.fields_template is not defined or not field_options.fields_template.isHiddenField('time_to_own') %}#}
242-
{# @todo voir comment gérer ce choix d'afficher ou pas selon une config #}
243-
{# {% set display_associatedsla_field = field_options.fields_template is not defined or not field_options.fields_template.isHiddenField('slas_id_tto') %}#}
244-
{# {% set _fieldname = 'time_to_own' %}#}
245-
{% set can_assign_sla_ola = canupdate and has_profile_right('slm', constant('SLM::RIGHT_ASSIGN')) and not field_options.fields_template.isReadonlyField('_olas_id') %}
246-
{% set _label = __('TTO') %}
247-
{% elseif ola.type == constant('SLM::TTR') %}
248-
{# {% set display_datetime_field = field_options.fields_template is not defined or not field_options.fields_template.isHiddenField('time_to_resolve') %}#}
249-
{# {% set display_associatedsla_field = field_options.fields_template is not defined or not field_options.fields_template.isHiddenField('slas_id_ttr') %}#}
250-
{# {% set _fieldname = 'time_to_resolve' %}#}
251-
{% set can_assign_sla_ola = canupdate and has_profile_right('slm', constant('SLM::RIGHT_ASSIGN')) and not field_options.fields_template.isReadonlyField('_olas_id') %}
252-
{% set _label = __('TTR') %}
253-
{% endif %}
254-
{# {% set _value = item.fields[_fieldname] %}#}
255-
256-
{# @todo supprimer forcage de debug #}
257-
{% set display_datetime_field = true %}
258-
{% set display_associatedsla_field = true %}
259-
260-
<td class="right pe-2 align-middle border-0">{{ _label }}</td>
261-
<td class="d-flex ms-n2 border-0 py-0">
262-
{{ _self.linkedOlaField(
263-
ola,
264-
field_options|merge({
265-
'can_assign': can_assign_sla_ola,
266-
'rand': _rand,
267-
'new_item': item.isNewItem(),
268-
'display_datetime_field': display_datetime_field,
269-
'display_associatedsla_field': display_associatedsla_field
270-
})
271-
) }}
272-
</td>
273-
</tr>
274-
{% endfor %}
238+
{% if ola.type == constant('SLM::TTO') %}
239+
{% set _label = __('TTO') %}
240+
{% elseif ola.type == constant('SLM::TTR') %}
241+
{% set _label = __('TTR') %}
242+
{% endif %}
243+
244+
<td class="right pe-2 align-middle border-0">{{ _label }}</td>
245+
<td class="d-flex ms-n2 border-0 py-0">
246+
{{ _self.linkedOlaField(
247+
ola,
248+
field_options|merge({
249+
'can_assign': can_assign_sla_ola and display_associatedsla_field,
250+
'rand': _rand,
251+
'new_item': item.isNewItem(),
252+
})
253+
) }}
254+
</td>
255+
</tr>
256+
{% endfor %}
257+
{# table row to display dropdown to choose OLA to associate with #}
275258
<tr>
276259
<td>&nbsp;</td>
277260
{# id used by OlaAddButton() - display ajax fetched dropdown #}
@@ -291,21 +274,18 @@ Handle only linked ola, not ola ttr and tto defined using datetime fields
291274
'can_assign': false,
292275
'is_expanded': false,
293276
'new_item': false,
294-
'display_datetime_field': false,
295-
'display_associatedsla_field': false,
296277
'rand': 'please_pass_a_rand'
297278
}|merge(options) %}
298279

299280
{% set assign_la_id = 'assign_la_' ~ options.rand %}
300281

301282
<div class="{{ options.new_item ? '' : 'collapsed' }} w-100 mt-1" id="dropdown_{{ assign_la_id }}">
302-
{% if options.display_datetime_field %}
283+
{% if la.due_time is defined %}
303284
<span class="text-muted">
304285
{{ la.due_time|formatted_datetime }}
305286
</span>
306287
{% endif %}
307288

308-
{% if options.display_associatedsla_field %}
309289
<span class="level_name badge itil-badge bg-body border-info ms-1 flex-column flex-sm-row">
310290
<span class="d-flex align-items-center">
311291
<i class="ti ti-stopwatch slt me-1"></i>
@@ -348,7 +328,6 @@ Handle only linked ola, not ola ttr and tto defined using datetime fields
348328
$('#delete_button_{{ assign_la_id }}').tooltip('hide')
349329
}
350330
</script>
351-
{% endif %}
352331

353332
{# hidden input field to preserve olas on update #}
354333
<input type="hidden" name="_olas_id[]" value="{{ la.olas_id }}" />

0 commit comments

Comments
 (0)