From 61bc59109d369baf2d51d1f4f1b2d44c8a11b8ad Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Thu, 8 Jun 2023 11:16:55 +0200 Subject: [PATCH] fix(turbo): PJ deletion: turbo: true must be set on button in addition to form --- .../multiple_drop_down_list_component.html.haml | 2 +- .../repetition_component/repetition_component.html.haml | 2 +- .../repetition_row_component/repetition_row_component.html.haml | 2 +- app/components/nested_forms/owned_button_component.rb | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/components/editable_champ/multiple_drop_down_list_component/multiple_drop_down_list_component.html.haml b/app/components/editable_champ/multiple_drop_down_list_component/multiple_drop_down_list_component.html.haml index d1faf35c9..d667b87bc 100644 --- a/app/components/editable_champ/multiple_drop_down_list_component/multiple_drop_down_list_component.html.haml +++ b/app/components/editable_champ/multiple_drop_down_list_component/multiple_drop_down_list_component.html.haml @@ -7,7 +7,7 @@ - else %div{ 'data-turbo-focus-group': true } - if @champ.selected_options.present? - .fr-mb-2w{ "data-turbo": "true" } + .fr-mb-2w - @champ.selected_options.each do |option| = render NestedForms::OwnedButtonComponent.new(formaction: champs_options_path(@champ.id, option:), http_method: :delete, opt: { class: 'fr-tag fr-tag--dismiss fr-mb-1w fr-mr-1w', id: @champ.checkbox_id(option) }) do = option diff --git a/app/components/editable_champ/repetition_component/repetition_component.html.haml b/app/components/editable_champ/repetition_component/repetition_component.html.haml index 1a434b96b..d81bd8f64 100644 --- a/app/components/editable_champ/repetition_component/repetition_component.html.haml +++ b/app/components/editable_champ/repetition_component/repetition_component.html.haml @@ -8,6 +8,6 @@ - @champ.rows.each do |champs| = render EditableChamp::RepetitionRowComponent.new(form: @form, champ: @champ, row: champs, seen_at: @seen_at) - .actions{ 'data-turbo': 'true' } + .actions = render NestedForms::OwnedButtonComponent.new(formaction: champs_repetition_path(@champ.id), http_method: :create, opt: { class: "fr-btn fr-btn--secondary fr-btn--icon-left fr-icon-add-circle-line fr-mb-3w", title: t(".add_title", libelle: @champ.libelle), id: dom_id(@champ, :create_repetition)}) do = t(".add", libelle: @champ.libelle) diff --git a/app/components/editable_champ/repetition_row_component/repetition_row_component.html.haml b/app/components/editable_champ/repetition_row_component/repetition_row_component.html.haml index addb1c152..8b49d0f99 100644 --- a/app/components/editable_champ/repetition_row_component/repetition_row_component.html.haml +++ b/app/components/editable_champ/repetition_row_component/repetition_row_component.html.haml @@ -7,6 +7,6 @@ - else = render EditableChamp::SectionComponent.new(champs: @row) - .flex.row-reverse{ 'data-turbo': 'true' } + .flex.row-reverse = render NestedForms::OwnedButtonComponent.new(formaction: champs_repetition_path(@champ.id, row_id: @row.first.row_id), http_method: :delete, opt: { class: "fr-btn fr-btn--sm fr-btn--tertiary fr-text-action-high--red-marianne", title: t(".delete_title", row_number: @champ.rows.find_index(@row))}) do = t(".delete") diff --git a/app/components/nested_forms/owned_button_component.rb b/app/components/nested_forms/owned_button_component.rb index d8bfe3d19..6148ebc21 100644 --- a/app/components/nested_forms/owned_button_component.rb +++ b/app/components/nested_forms/owned_button_component.rb @@ -8,6 +8,6 @@ class NestedForms::OwnedButtonComponent < ApplicationComponent end def call - button_tag(content, @opt.merge(formaction: @formaction, form: NestedForms::FormOwnerComponent.form_id(@http_method))) + button_tag(content, @opt.merge(formaction: @formaction, form: NestedForms::FormOwnerComponent.form_id(@http_method), data: { turbo: 'true' })) end end