use condition_condition_component in editor

This commit is contained in:
simon lehericey 2022-07-08 11:04:58 +02:00
parent e9cf41a00d
commit 2df9d8ba98
9 changed files with 27 additions and 9 deletions

View file

@ -1,3 +1,3 @@
%ul.types-de-champ-block{ id: block_id, data: sortable_options } %ul.types-de-champ-block{ id: block_id, data: sortable_options }
- @coordinates.each do |coordinate| - @coordinates.each.with_index do |coordinate, i|
= render TypesDeChampEditor::ChampComponent.new(coordinate: coordinate) = render TypesDeChampEditor::ChampComponent.new(coordinate: coordinate, upper_coordinates: @coordinates.take(i))

View file

@ -1,7 +1,8 @@
class TypesDeChampEditor::ChampComponent < ApplicationComponent class TypesDeChampEditor::ChampComponent < ApplicationComponent
def initialize(coordinate:, focused: false) def initialize(coordinate:, upper_coordinates:, focused: false)
@coordinate = coordinate @coordinate = coordinate
@focused = focused @focused = focused
@upper_coordinates = upper_coordinates
end end
private private

View file

@ -83,3 +83,5 @@
.editor-block.flex-grow.cell .editor-block.flex-grow.cell
= render TypesDeChampEditor::BlockComponent.new(block: coordinate, coordinates: coordinate.revision_types_de_champ) = render TypesDeChampEditor::BlockComponent.new(block: coordinate, coordinates: coordinate.revision_types_de_champ)
= render TypesDeChampEditor::AddChampButtonComponent.new(revision: coordinate.revision, parent: coordinate, is_annotation: coordinate.private?) = render TypesDeChampEditor::AddChampButtonComponent.new(revision: coordinate.revision, parent: coordinate, is_annotation: coordinate.private?)
= render(TypesDeChampEditor::ConditionsComponent.new(tdc: type_de_champ, upper_tdcs: @upper_coordinates.map(&:type_de_champ), procedure_id: procedure.id))

View file

@ -2,8 +2,13 @@
- if sibling.present? - if sibling.present?
= turbo_stream.after dom_id(sibling, :type_de_champ_editor) do = turbo_stream.after dom_id(sibling, :type_de_champ_editor) do
= render TypesDeChampEditor::ChampComponent.new(coordinate: coordinate, focused: true) = render TypesDeChampEditor::ChampComponent.new(coordinate: coordinate, upper_coordinates: upper_coordinates, focused: true)
- else - else
= turbo_stream.prepend dom_id(coordinate.block, :types_de_champ_editor_block) do = turbo_stream.prepend dom_id(coordinate.block, :types_de_champ_editor_block) do
= render TypesDeChampEditor::ChampComponent.new(coordinate: coordinate, focused: true) = render TypesDeChampEditor::ChampComponent.new(coordinate: coordinate, upper_coordinates: upper_coordinates, focused: true)
= turbo_stream.dispatch 'sortable:sort' = turbo_stream.dispatch 'sortable:sort'
- if @lower_coordinates_and_dep.present?
- @lower_coordinates_and_dep.each do |other_coordinate, other_upper_coordinates|
= turbo_stream.morph dom_id(other_coordinate, :type_de_champ_editor) do
= render TypesDeChampEditor::ChampComponent.new(coordinate: other_coordinate, upper_coordinates: other_upper_coordinates)

View file

@ -1,2 +1,2 @@
- if @coordinate&.type_de_champ&.valid? - if @coordinate&.type_de_champ&.valid?
= render partial: 'insert', locals: { coordinate: @coordinate } = render partial: 'insert', locals: { coordinate: @coordinate, upper_coordinates: @upper_coordinates }

View file

@ -2,3 +2,8 @@
= turbo_stream.dispatch 'sortable:sort' = turbo_stream.dispatch 'sortable:sort'
= turbo_stream.morph dom_id(@coordinate.revision, :estimated_fill_duration) do = turbo_stream.morph dom_id(@coordinate.revision, :estimated_fill_duration) do
= render TypesDeChampEditor::EstimatedFillDurationComponent.new(revision: @coordinate.revision, is_annotation: @coordinate.private?) = render TypesDeChampEditor::EstimatedFillDurationComponent.new(revision: @coordinate.revision, is_annotation: @coordinate.private?)
- if @lower_coordinates_and_dep.present?
- @lower_coordinates_and_dep.each do |other_coordinate, other_upper_coordinates|
= turbo_stream.morph dom_id(other_coordinate, :type_de_champ_editor) do
= render TypesDeChampEditor::ChampComponent.new(coordinate: other_coordinate, upper_coordinates: other_upper_coordinates)

View file

@ -1,2 +1,2 @@
= turbo_stream.remove dom_id(@coordinate, :type_de_champ_editor) = turbo_stream.remove dom_id(@coordinate, :type_de_champ_editor)
= render partial: 'insert', locals: { coordinate: @coordinate } = render partial: 'insert', locals: { coordinate: @coordinate, upper_coordinates: @upper_coordinates }

View file

@ -1,2 +1,2 @@
= turbo_stream.remove dom_id(@coordinate, :type_de_champ_editor) = turbo_stream.remove dom_id(@coordinate, :type_de_champ_editor)
= render partial: 'insert', locals: { coordinate: @coordinate } = render partial: 'insert', locals: { coordinate: @coordinate, upper_coordinates: @upper_coordinates }

View file

@ -1,5 +1,10 @@
- if @coordinate&.type_de_champ&.valid? - if @coordinate&.type_de_champ&.valid?
= turbo_stream.morph dom_id(@coordinate, :type_de_champ_editor) do = turbo_stream.morph dom_id(@coordinate, :type_de_champ_editor) do
= render TypesDeChampEditor::ChampComponent.new(coordinate: @coordinate) = render TypesDeChampEditor::ChampComponent.new(coordinate: @coordinate, upper_coordinates: @upper_coordinates)
= turbo_stream.morph dom_id(@coordinate.revision, :estimated_fill_duration) do = turbo_stream.morph dom_id(@coordinate.revision, :estimated_fill_duration) do
= render TypesDeChampEditor::EstimatedFillDurationComponent.new(revision: @coordinate.revision, is_annotation: @coordinate.private?) = render TypesDeChampEditor::EstimatedFillDurationComponent.new(revision: @coordinate.revision, is_annotation: @coordinate.private?)
- if @lower_coordinates_and_dep.present?
- @lower_coordinates_and_dep.each do |other_coordinate, other_upper_coordinates|
= turbo_stream.morph dom_id(other_coordinate, :type_de_champ_editor) do
= render TypesDeChampEditor::ChampComponent.new(coordinate: other_coordinate, upper_coordinates: other_upper_coordinates)