display condition change between version

This commit is contained in:
simon lehericey 2022-07-13 12:35:11 +02:00
parent 00c4076b32
commit 2cad0e11d3
6 changed files with 125 additions and 3 deletions

View file

@ -33,7 +33,7 @@ class Logic::ChampValue < Logic::Term
end
end
def to_s = "#{type_de_champ&.libelle}#{stable_id}" # TODO: gerer le cas ou un tdc est supprimé
def to_s = type_de_champ&.libelle # TODO: gerer le cas ou un tdc est supprimé
def type
case type_de_champ&.type_champ # TODO: gerer le cas ou un tdc est supprimé

View file

@ -377,6 +377,30 @@ class ProcedureRevision < ApplicationRecord
stable_id: from_type_de_champ.stable_id
}
end
from_condition = from_type_de_champ.condition
to_condition = to_type_de_champ.condition
if from_condition != to_condition
condition_change = {
model: :type_de_champ,
op: :update,
attribute: :condition,
label: from_type_de_champ.libelle,
private: from_type_de_champ.private?,
from: from_type_de_champ.condition.to_s,
to: to_type_de_champ.condition.to_s,
stable_id: from_type_de_champ.stable_id
}
if from_condition.nil?
condition_change[:condition_op] = :add
elsif to_condition.nil?
condition_change[:condition_op] = :remove
else
condition_change[:condition_op] = :update
end
changes << condition_change
end
if to_type_de_champ.drop_down_list?
if from_type_de_champ.drop_down_list_options != to_type_de_champ.drop_down_list_options
changes << {

View file

@ -1,8 +1,8 @@
- rendered = render @condition_component
- if rendered.present?
= turbo_stream.morph dom_id(@tdc, :conditions) do
= turbo_stream.morph "conditions_type_de_champ_#{@tdc.stable_id}" do
- rendered
end
- else
= turbo_stream.remove dom_id(@tdc, :conditions)
= turbo_stream.remove "conditions_type_de_champ_#{@tdc.stable_id}"

View file

@ -54,3 +54,11 @@
%li= t(:add_option, scope: [:administrateurs, :revision_changes], items: added.map{ |term| "« #{t(term, scope: [:administrateurs, :carte_layers])} »" }.join(", "))
- if removed.present?
%li= t(:remove_option, scope: [:administrateurs, :revision_changes], items: removed.map{ |term| "« #{t(term, scope: [:administrateurs, :carte_layers])} »" }.join(", "))
- when :condition
- case change[:condition_op]
- when :add
%li= t(:add_condition, scope: [:administrateurs, :revision_changes], label: change[:label], to: change[:to])
- when :remove
%li= t(:remove_condition, scope: [:administrateurs, :revision_changes], label: change[:label], to: change[:to])
- when :update
%li= t(:update_condition, scope: [:administrateurs, :revision_changes], label: change[:label], to: change[:to])