fix displaying add field button with turbo

This commit is contained in:
Lisa Durand 2023-10-16 17:02:24 +02:00
parent 2c73aa64a2
commit 75c155c284
2 changed files with 9 additions and 3 deletions

View file

@ -1,6 +1,7 @@
.fr-container.fr-pb-12w
.types-de-champ-editor.editor-root{ 'data-turbo': 'true', id: dom_id(@revision, :types_de_champ_editor) }
.fr-container.fr-pb-12w{ 'data-turbo': 'true', id: dom_id(@revision, :types_de_champ_editor) }
.types-de-champ-editor.editor-root
= render TypesDeChampEditor::ErrorsSummary.new(revision: @revision)
= render TypesDeChampEditor::BlockComponent.new(block: @revision, coordinates: coordinates)
- if coordinates.empty?
= render TypesDeChampEditor::AddChampButtonComponent.new(revision: @revision, is_annotation: annotations?)
#empty-coordinates
= render TypesDeChampEditor::AddChampButtonComponent.new(revision: @revision, is_annotation: annotations?)

View file

@ -9,6 +9,9 @@
- if @destroyed.present?
= turbo_stream.remove dom_id(@destroyed, :type_de_champ_editor)
- if @destroyed.siblings.empty?
= turbo_stream.show('empty-coordinates')
- if @created.present?
- if @created.coordinate.previous_sibling.present?
= turbo_stream.after dom_id(@created.coordinate.previous_sibling, :type_de_champ_editor) do
@ -17,6 +20,8 @@
= turbo_stream.prepend dom_id(@created.coordinate.block, :types_de_champ_editor_block) do
- render @created
= turbo_stream.hide('empty-coordinates')
- @morphed&.each do |champ_component|
= turbo_stream.replace dom_id(champ_component.coordinate, :type_de_champ_editor) do
- render champ_component