feat(cond): enable conditional on champs in repetitions
This commit is contained in:
parent
6ce7064ffd
commit
d513c364d8
6 changed files with 14 additions and 7 deletions
|
@ -1,7 +1,8 @@
|
|||
class TypesDeChampEditor::BlockComponent < ApplicationComponent
|
||||
def initialize(block:, coordinates:)
|
||||
def initialize(block:, coordinates:, upper_coordinates: [])
|
||||
@block = block
|
||||
@coordinates = coordinates
|
||||
@upper_coordinates = upper_coordinates
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
%ul.types-de-champ-block{ id: block_id, data: sortable_options }
|
||||
- @coordinates.each.with_index do |coordinate, i|
|
||||
= render TypesDeChampEditor::ChampComponent.new(coordinate: coordinate, upper_coordinates: @coordinates.take(i))
|
||||
= render TypesDeChampEditor::ChampComponent.new(coordinate: coordinate, upper_coordinates: @upper_coordinates + @coordinates.take(i))
|
||||
|
|
|
@ -118,6 +118,6 @@ class TypesDeChampEditor::ChampComponent < ApplicationComponent
|
|||
end
|
||||
|
||||
def conditional_enabled?
|
||||
!type_de_champ.private? && !coordinate.child?
|
||||
!type_de_champ.private?
|
||||
end
|
||||
end
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
- if type_de_champ.block?
|
||||
.flex.justify-start.section.ml-1
|
||||
.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, upper_coordinates: @upper_coordinates)
|
||||
= render TypesDeChampEditor::AddChampButtonComponent.new(revision: coordinate.revision, parent: coordinate, is_annotation: coordinate.private?)
|
||||
|
||||
- if conditional_enabled?
|
||||
|
|
|
@ -55,7 +55,13 @@ module Administrateurs
|
|||
def retrieve_coordinate_and_uppers
|
||||
@tdc = draft_revision.find_and_ensure_exclusive_use(params[:stable_id])
|
||||
@coordinate = draft_revision.coordinate_for(@tdc)
|
||||
@upper_tdcs = @coordinate.upper_siblings.map(&:type_de_champ)
|
||||
|
||||
upper_coordinates = @coordinate.upper_siblings
|
||||
if @coordinate.child?
|
||||
upper_coordinates += @coordinate.parent.upper_siblings
|
||||
end
|
||||
|
||||
@upper_tdcs = upper_coordinates.map(&:type_de_champ)
|
||||
end
|
||||
|
||||
def draft_revision
|
||||
|
|
|
@ -199,7 +199,7 @@ module Users
|
|||
respond_to do |format|
|
||||
format.html { render :brouillon }
|
||||
format.turbo_stream do
|
||||
@to_shows, @to_hides = @dossier.champs_public
|
||||
@to_shows, @to_hides = @dossier.champs_public_all
|
||||
.filter(&:conditional?)
|
||||
.partition(&:visible?)
|
||||
.map { |champs| champs_to_one_selector(champs) }
|
||||
|
@ -220,7 +220,7 @@ module Users
|
|||
respond_to do |format|
|
||||
format.html { render :modifier }
|
||||
format.turbo_stream do
|
||||
@to_shows, @to_hides = @dossier.champs_public
|
||||
@to_shows, @to_hides = @dossier.champs_public_all
|
||||
.filter(&:conditional?)
|
||||
.partition(&:visible?)
|
||||
.map { |champs| champs_to_one_selector(champs) }
|
||||
|
|
Loading…
Reference in a new issue