|
1 | 1 | <% each_category do |category, tags, can_toggle_optional| %> |
2 | | - <% if category.present? %> |
3 | | - <div class="flex"> |
4 | | - <p class="fr-label fr-text--sm fr-text--bold fr-mb-1w"> |
5 | | - <%= t(category, scope: ".categories") %> |
6 | | - </p> |
7 | | - </div> |
8 | | - <% if can_toggle_optional %> |
9 | | - <div class="fr-fieldset__element fr-px-0"> |
10 | | - <div class="fr-checkbox-group fr-checkbox-group--sm"> |
11 | | - <%= check_box_tag("show_optional_#{category}", 1, false, data: { "no-autosubmit" => true, action: "change->attestation#toggleOptional"}) %> |
| 2 | + <div data-controller="tags-button-list"> |
| 3 | + <% if category.present? %> |
| 4 | + <div class="flex"> |
| 5 | + <p class="fr-label fr-text--sm fr-text--bold fr-mb-1w"> |
| 6 | + <%= t(category, scope: ".categories") %> |
| 7 | + </p> |
| 8 | + </div> |
| 9 | + <% if can_toggle_optional %> |
| 10 | + <div class="fr-fieldset__element fr-px-0"> |
| 11 | + <div class="fr-checkbox-group fr-checkbox-group--sm"> |
| 12 | + <%= check_box_tag("#{optional_toggle_id}_#{category}", 1, false, data: { "no-autosubmit" => true, action: "change->tags-button-list#toggleOptional" }) %> |
12 | 13 |
|
13 | | - <%= label_tag "show_optional_#{category}", for: "show_optional_#{category}" do %> |
14 | | - <%= category == :champ_public ? "Voir les champs facultatifs et/ou conditionnés" : "Voir les annotations facultatives et/ou conditionnées" %> |
| 14 | + <%= label_tag "#{optional_toggle_id}_#{category}", for: "#{optional_toggle_id}_#{category}" do %> |
| 15 | + <%= category == :champ_public ? "Voir les champs facultatifs et/ou conditionnés" : "Voir les annotations facultatives et/ou conditionnées" %> |
15 | 16 |
|
16 | | - <span class="hidden fr-hint-text"> |
17 | | - <%= category == :champ_public ? "Un champ non rempli par l’usager" : "Une annotation non remplie par l’instructeur" %> |
18 | | - restera vide dans l’attestation. |
19 | | - </span> |
20 | | - <% end %> |
| 17 | + <span |
| 18 | + class="hidden fr-hint-text" |
| 19 | + data-tags-button-list-target="hint" |
| 20 | + > |
| 21 | + <%= category == :champ_public ? "Un champ non rempli par l’usager" : "Une annotation non remplie par l’instructeur" %> |
| 22 | + restera vide. |
| 23 | + </span> |
| 24 | + <% end %> |
| 25 | + </div> |
21 | 26 | </div> |
22 | | - </div> |
| 27 | + <% end %> |
23 | 28 | <% end %> |
24 | | - <% end %> |
25 | 29 |
|
26 | | - <ul class="fr-tags-group" data-category="<%= category %>"> |
27 | | - <% tags.each do |tag| %> |
28 | | - <% is_optional = can_toggle_optional && optional_tag?(tag) %> |
29 | | - <% label = button_label(tag) %> |
| 30 | + <ul class="fr-tags-group" data-category="<%= category %>"> |
| 31 | + <% tags.each do |tag| %> |
| 32 | + <% is_optional = can_toggle_optional && optional_tag?(tag) %> |
| 33 | + <% label = button_label(tag) %> |
30 | 34 |
|
31 | | - <li |
32 | | - class="<%= class_names("hidden" => is_optional) %>" |
33 | | - data-optional-tag="<%= is_optional.presence %>" |
34 | | - > |
35 | | - <button |
36 | | - class="fr-tag fr-tag--sm <%= class_names("fr-tag--blue-ecume" => tag[:highlight], "fr-tag--purple-glycine" => is_optional) %>" |
37 | | - type="button" |
38 | | - title="<%= button_title(tag) %>" |
39 | | - data-action="click->tiptap#insertTag" |
40 | | - data-tiptap-target="tag" |
41 | | - data-tag-id="<%= tag[:id] %>" |
42 | | - data-tag-label="<%= label %>" |
43 | | - data-tag-mandatory="<%= tag[:mandatory].to_s %>" |
44 | | - data-tag-category="<%= category %>" |
| 35 | + <li |
| 36 | + class="<%= class_names("hidden" => is_optional) %>" |
| 37 | + data-tags-button-list-target="<%= is_optional ? "optionalItem" : nil %>" |
45 | 38 | > |
46 | | - <%= label %> |
| 39 | + <button |
| 40 | + class="fr-tag fr-tag--sm <%= class_names("fr-tag--blue-ecume" => tag[:highlight], "fr-tag--purple-glycine" => is_optional) %>" |
| 41 | + type="button" |
| 42 | + title="<%= button_title(tag) %>" |
| 43 | + data-action="click->tiptap#insertTag" |
| 44 | + data-tiptap-target="tag" |
| 45 | + data-tag-id="<%= tag[:id] %>" |
| 46 | + data-tag-label="<%= label %>" |
| 47 | + data-tag-mandatory="<%= tag[:mandatory].to_s %>" |
| 48 | + data-tag-category="<%= category %>" |
| 49 | + > |
| 50 | + <%= label %> |
47 | 51 |
|
48 | | - <% if tag[:mandatory] %> |
49 | | - * |
50 | | - <% end %> |
51 | | - </button> |
52 | | - </li> |
53 | | - <% end %> |
54 | | - </ul> |
| 52 | + <% if tag[:mandatory] %> |
| 53 | + * |
| 54 | + <% end %> |
| 55 | + </button> |
| 56 | + </li> |
| 57 | + <% end %> |
| 58 | + </ul> |
| 59 | + </div> |
55 | 60 | <% end %> |
0 commit comments