|
38 | 38 | {% set selected_user = get_current_user() %}
|
39 | 39 | {% endif %}
|
40 | 40 |
|
41 |
| - {% set users = get_current_user().getDelegateGroupsForUser()|map( |
42 |
| - groups_id => call('Group_User::getGroupUsers', [groups_id]) |
43 |
| - )|reduce( |
44 |
| - (carry, group_users) => carry|merge(group_users), [] |
45 |
| - ) %} |
| 41 | + {% set users = get_current_user().getUsersFromDelegatedGroups() %} |
| 42 | + {% set user_dropdown_html %} |
| 43 | + {{ fields.dropdownArrayField( |
| 44 | + 'delegation_users_id', |
| 45 | + selected_user.getID(), |
| 46 | + users, |
| 47 | + '', |
| 48 | + { |
| 49 | + 'no_label' : true, |
| 50 | + 'width' : 'auto', |
| 51 | + 'field_class' : '', |
| 52 | + 'mb' : '', |
| 53 | + 'aria_label' : __('Select the user to delegate'), |
| 54 | + 'wrapper_class' : 'd-inline-block', |
| 55 | + } |
| 56 | + ) }} |
| 57 | + {% endset %} |
46 | 58 |
|
47 |
| - <div |
48 |
| - class="alert d-flex align-items-center justify-content-start" |
49 |
| - data-glpi-form-renderer-delegation-container |
50 |
| - > |
51 |
| - {% if users is not empty %} |
52 |
| - <span class="text-nowrap text-muted mx-2">This ticket is for</span> |
53 |
| - {{ fields.dropdownArrayField( |
54 |
| - 'delegation_users_id', |
55 |
| - selected_user.getID(), |
56 |
| - { |
57 |
| - (get_current_user().getID()): __('Myself'), |
58 |
| - } + users|reduce((carry, user) => carry + {(user.id): call('User::getFriendlyNameById', [user.id])}, {}), |
59 |
| - '', |
60 |
| - { |
61 |
| - 'no_label' : true, |
62 |
| - 'width' : 'auto', |
63 |
| - 'field_class': '', |
64 |
| - 'mb' : '', |
65 |
| - 'aria_label' : __('Select the user to delegate'), |
66 |
| - } |
67 |
| - ) }} |
68 |
| - <span class="text-nowrap text-muted mx-2">and</span> |
69 |
| - {% endif %} |
70 |
| - <span class="me-2 input-group d-inline-flex w-auto"> |
| 59 | + {% set notification_part_html %} |
| 60 | + <span class="input-group d-inline-flex w-auto"> |
71 | 61 | {% if selected_user.getID() == get_current_user().getID() %}
|
72 | 62 | {{ fields.dropdownArrayField(
|
73 | 63 | 'delegation_use_notification',
|
|
78 | 68 | },
|
79 | 69 | '',
|
80 | 70 | {
|
81 |
| - 'no_label' : true, |
82 |
| - 'width' : 'auto', |
83 |
| - 'field_class': '', |
84 |
| - 'mb' : '', |
85 |
| - 'aria_label' : __('Do you want to be notified of future events of this ticket'), |
| 71 | + 'no_label' : true, |
| 72 | + 'width' : 'auto', |
| 73 | + 'field_class' : '', |
| 74 | + 'mb' : '', |
| 75 | + 'aria_label' : __('Do you want to be notified of future events of this ticket'), |
| 76 | + 'wrapper_class' : 'd-inline-block', |
86 | 77 | }
|
87 | 78 | ) }}
|
88 | 79 | {% else %}
|
|
95 | 86 | },
|
96 | 87 | '',
|
97 | 88 | {
|
98 |
| - 'no_label' : true, |
99 |
| - 'width' : 'auto', |
100 |
| - 'field_class': '', |
101 |
| - 'mb' : '', |
102 |
| - 'aria_label' : __('Do you want to be notified of future events of this ticket'), |
| 89 | + 'no_label' : true, |
| 90 | + 'width' : 'auto', |
| 91 | + 'field_class' : '', |
| 92 | + 'mb' : '', |
| 93 | + 'aria_label' : __('Do you want to be notified of future events of this ticket'), |
| 94 | + 'wrapper_class' : 'd-inline-block', |
103 | 95 | }
|
104 | 96 | ) }}
|
105 | 97 | {% endif %}
|
|
126 | 118 | ) }}
|
127 | 119 | </div>
|
128 | 120 | </span>
|
129 |
| - <span class="text-nowrap text-muted ms-1">to be notified of future events of this ticket</span><span></span> |
| 121 | + {% endset %} |
| 122 | + |
| 123 | + <div class="alert d-flex align-items-center justify-content-start flex-wrap"> |
| 124 | + {% if users|length > 1 %} |
| 125 | + {{ __('This ticket is for %1$s and %2$s to be notified of future events of this ticket.')|format( |
| 126 | + '<span class="mx-2">' ~ user_dropdown_html|raw ~ '</span>', |
| 127 | + '<span class="mx-2">' ~ notification_part_html|raw ~ '</span>' |
| 128 | + )|raw }} |
| 129 | + {% else %} |
| 130 | + {{ __('%1$s to be notified of future events of this ticket.')|format( |
| 131 | + '<span class="mx-2">' ~ notification_part_html|raw ~ '</span>' |
| 132 | + )|raw }} |
| 133 | + {% endif %} |
130 | 134 | </div>
|
131 | 135 | {% endif %}
|
0 commit comments