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
|
class TypesDeChampEditor::BlockComponent < ApplicationComponent
|
||||||
def initialize(block:, coordinates:)
|
def initialize(block:, coordinates:, upper_coordinates: [])
|
||||||
@block = block
|
@block = block
|
||||||
@coordinates = coordinates
|
@coordinates = coordinates
|
||||||
|
@upper_coordinates = upper_coordinates
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -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.with_index do |coordinate, i|
|
- @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
|
end
|
||||||
|
|
||||||
def conditional_enabled?
|
def conditional_enabled?
|
||||||
!type_de_champ.private? && !coordinate.child?
|
!type_de_champ.private?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -87,7 +87,7 @@
|
||||||
- if type_de_champ.block?
|
- if type_de_champ.block?
|
||||||
.flex.justify-start.section.ml-1
|
.flex.justify-start.section.ml-1
|
||||||
.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, upper_coordinates: @upper_coordinates)
|
||||||
= 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?)
|
||||||
|
|
||||||
- if conditional_enabled?
|
- if conditional_enabled?
|
||||||
|
|
|
@ -55,7 +55,13 @@ module Administrateurs
|
||||||
def retrieve_coordinate_and_uppers
|
def retrieve_coordinate_and_uppers
|
||||||
@tdc = draft_revision.find_and_ensure_exclusive_use(params[:stable_id])
|
@tdc = draft_revision.find_and_ensure_exclusive_use(params[:stable_id])
|
||||||
@coordinate = draft_revision.coordinate_for(@tdc)
|
@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
|
end
|
||||||
|
|
||||||
def draft_revision
|
def draft_revision
|
||||||
|
|
|
@ -199,7 +199,7 @@ module Users
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :brouillon }
|
format.html { render :brouillon }
|
||||||
format.turbo_stream do
|
format.turbo_stream do
|
||||||
@to_shows, @to_hides = @dossier.champs_public
|
@to_shows, @to_hides = @dossier.champs_public_all
|
||||||
.filter(&:conditional?)
|
.filter(&:conditional?)
|
||||||
.partition(&:visible?)
|
.partition(&:visible?)
|
||||||
.map { |champs| champs_to_one_selector(champs) }
|
.map { |champs| champs_to_one_selector(champs) }
|
||||||
|
@ -220,7 +220,7 @@ module Users
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :modifier }
|
format.html { render :modifier }
|
||||||
format.turbo_stream do
|
format.turbo_stream do
|
||||||
@to_shows, @to_hides = @dossier.champs_public
|
@to_shows, @to_hides = @dossier.champs_public_all
|
||||||
.filter(&:conditional?)
|
.filter(&:conditional?)
|
||||||
.partition(&:visible?)
|
.partition(&:visible?)
|
||||||
.map { |champs| champs_to_one_selector(champs) }
|
.map { |champs| champs_to_one_selector(champs) }
|
||||||
|
|
Loading…
Reference in a new issue