Skip to content

Commit fd80f57

Browse files
authored
Fix Twig templates
* Twig fixes * Fix constants notation * Fix call on null
1 parent f117b4d commit fd80f57

File tree

11 files changed

+24
-16
lines changed

11 files changed

+24
-16
lines changed

src/Glpi/Form/Condition/ConditionData.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function getLogicOperator(): LogicOperator
7979

8080
public function getValueOperator(): ?ValueOperator
8181
{
82-
// No follback here as an empty value is valid if the condition is not
82+
// No fallback here as an empty value is valid if the condition is not
8383
// fully specified yet.
8484
return ValueOperator::tryFrom($this->value_operator ?? "");
8585
}

templates/components/checkbox_matrix.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
</td>
7979

8080
{% for col_name, column in columns %}
81-
{% set content = row['columns'][col_name] %}
81+
{% set content = row['columns'][col_name] ?? false %}
8282
<td>
8383
{% if content is iterable and content['checked'] is defined %}
8484
{% if content['readonly'] is not defined %}

templates/components/illustration/icon.svg.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#}
3232

3333
<svg role="img" width="{{ width }}" height="{{ height }}">
34-
{% if title is not empty %}
34+
{% if (title ?? '') is not empty %}
3535
<title>{{ title }}</title>
3636
{% endif %}
3737
<use xlink:href="{{ path(file_path) }}#{{ icon_id }}"/>

templates/components/itilobject/actors/field.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
{% set unique_id = "user_opt_" ~ actortype ~ actor.itemtype ~ actor.items_id %}
5757
<option selected="true" value="{{ actor['itemtype'] ~ '_' ~ actor['items_id'] }}"
5858
data-itemtype="{{ actor['itemtype'] }}" data-items-id="{{ actor['items_id'] }}"
59-
data-use-notification="{{ actor['use_notification'] }}"
59+
data-use-notification="{{ actor['use_notification'] ?? false }}"
6060
data-default-email="{{ actor['default_email'] ?? '' }}"
6161
data-alternative-email="{{ actor['alternative_email'] ?? '' }}"
6262
{% if (actor['itemtype'] == 'User' and itiltemplate.isHiddenField('_users_id_' ~ actortype)) or (actor['itemtype'] == 'Group' and itiltemplate.isHiddenField('_groups_id_' ~ actortype)) %}

templates/components/itilobject/actors/main.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@
228228
{
229229
itemtype: "{{ actor['itemtype'] }}",
230230
items_id: "{{ actor['items_id'] }}",
231-
use_notification: {{ actor['use_notification'] ? "1" : "0" }},
231+
use_notification: {{ (actor['use_notification'] ?? false) ? "1" : "0" }},
232232
alternative_email: "{{ actor['alternative_email'] ?? '' }}",
233233
default_email: "{{ actor['default_email'] ?? '' }}",
234234
},

templates/layout/parts/head.html.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
#}
3232

3333
<!DOCTYPE html>
34-
<html lang="{{ lang }}"
34+
<html lang="{{ lang ?? 'en' }}"
3535
{% if session('glpihighcontrast_css') %}
3636
data-high-contrast="1"
3737
{% endif %}
@@ -44,7 +44,7 @@
4444
{% endif %}
4545
>
4646
<head>
47-
<title>{{ title }} - {{ config('app_name') }}</title>
47+
<title>{% if title is defined %}{{ title }} - {% endif %}{{ config('app_name') }}</title>
4848

4949
<meta charset="utf-8" />
5050

templates/pages/admin/customobjects/profiles.html.twig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
{% set params = params|merge({'candel': false}) %}
3636
{# do not display footer with dates #}
3737
{% set params = params|merge({'formfooter': false}) %}
38+
{% set target = target|default('') %} {# not sure empty target should happen. #}
39+
{% set formoptions = formoptions|default('') %}
3840

3941
<div class="p-2">
4042
<form id="main-form" name="asset_form" method="post" action="{{ target }}" {{ formoptions|raw }} enctype="multipart/form-data" data-submit-once>
@@ -44,6 +46,7 @@
4446
'rand': random(),
4547
'col_check_all': 'top',
4648
'row_check_all': true,
49+
'first_cell': '',
4750
},
4851
'columns': matrix_columns,
4952
'rows': matrix_rows,

templates/pages/admin/form/condition_handler_templates/input.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
placeholder="{{ __("Enter a value...") }}"
3838
data-glpi-conditions-editor-value
3939
aria-label="{{ input_label }}"
40-
{% for attribute, value in attributes %}
40+
{% for attribute, value in (attributes ?? []) %}
4141
{{ attribute }}="{{ value }}"
4242
{% endfor %}
4343
/>

templates/pages/admin/form/conditional_visibility_editor.html.twig

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,17 @@
8989
/>
9090

9191
<span class="me-2 value-operator-selector">
92+
{% set value_op = '' %}
93+
{% if condition.getValueOperator() is not null %}
94+
{% set value_op = condition.getValueOperator().value %}
95+
{% endif %}
9296
{% do call('Dropdown::showFromArray', [
9397
'_conditions[' ~ loop.index0 ~ '][value_operator]',
9498
manager.getValueOperatorDropdownValues(
9599
condition.getItemUuid()
96100
),
97101
{
98-
'value': condition.getValueOperator().value,
102+
'value': value_op,
99103
'aria_label' : __('Value operator'),
100104
'add_data_attributes': {
101105
'glpi-conditions-editor-value-operator': '',

templates/pages/admin/helpdesk_home_config_tiles.html.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
# ---------------------------------------------------------------------
3131
#}
3232

33+
{% set editable = editable|default(false) %}
3334
{% for tile in tiles %}
3435
<section
3536
class="col-12 col-lg-6 col-xl-4 d-flex-soft"

0 commit comments

Comments
 (0)