2022-12-23 13:01:18 +01:00
|
|
|
class ProcedureRevisionChange
|
2024-06-05 17:30:33 +02:00
|
|
|
class TypeDeChange
|
|
|
|
attr_reader :type_de_champ
|
|
|
|
def initialize(type_de_champ)
|
|
|
|
@type_de_champ = type_de_champ
|
|
|
|
end
|
2022-12-23 13:01:18 +01:00
|
|
|
|
2024-06-05 17:30:33 +02:00
|
|
|
def label = @type_de_champ.libelle
|
|
|
|
def stable_id = @type_de_champ.stable_id
|
|
|
|
def private? = @type_de_champ.private?
|
|
|
|
def child? = @type_de_champ.child?
|
2022-12-23 13:01:18 +01:00
|
|
|
|
2024-06-05 17:30:33 +02:00
|
|
|
def to_h = { op:, stable_id:, label:, private: private? }
|
|
|
|
end
|
2022-12-23 13:01:18 +01:00
|
|
|
|
2024-06-05 17:30:33 +02:00
|
|
|
class AddChamp < TypeDeChange
|
2022-12-23 13:01:18 +01:00
|
|
|
def initialize(type_de_champ)
|
|
|
|
super(type_de_champ)
|
|
|
|
end
|
|
|
|
|
|
|
|
def op = :add
|
|
|
|
def mandatory? = @type_de_champ.mandatory?
|
|
|
|
def can_rebase?(dossier = nil) = !mandatory?
|
|
|
|
|
|
|
|
def to_h = super.merge(mandatory: mandatory?)
|
|
|
|
end
|
|
|
|
|
2024-06-05 17:30:33 +02:00
|
|
|
class RemoveChamp < TypeDeChange
|
2022-12-23 13:01:18 +01:00
|
|
|
def initialize(type_de_champ)
|
|
|
|
super(type_de_champ)
|
|
|
|
end
|
|
|
|
|
|
|
|
def op = :remove
|
|
|
|
def can_rebase?(dossier = nil) = true
|
|
|
|
end
|
|
|
|
|
2024-06-05 17:30:33 +02:00
|
|
|
class MoveChamp < TypeDeChange
|
2022-12-23 13:01:18 +01:00
|
|
|
attr_reader :from, :to
|
|
|
|
|
|
|
|
def initialize(type_de_champ, from, to)
|
|
|
|
super(type_de_champ)
|
|
|
|
@from = from
|
|
|
|
@to = to
|
|
|
|
end
|
|
|
|
|
|
|
|
def op = :move
|
|
|
|
def can_rebase?(dossier = nil) = true
|
|
|
|
def to_h = super.merge(from:, to:)
|
|
|
|
end
|
|
|
|
|
2024-06-05 17:30:33 +02:00
|
|
|
class UpdateChamp < TypeDeChange
|
2022-12-23 13:01:18 +01:00
|
|
|
attr_reader :attribute, :from, :to
|
|
|
|
|
|
|
|
def initialize(type_de_champ, attribute, from, to)
|
|
|
|
super(type_de_champ)
|
|
|
|
@attribute = attribute
|
|
|
|
@from = from
|
|
|
|
@to = to
|
|
|
|
end
|
|
|
|
|
|
|
|
def op = :update
|
|
|
|
def to_h = super.merge(attribute:, from:, to:)
|
|
|
|
|
|
|
|
def can_rebase?(dossier = nil)
|
|
|
|
return true if private?
|
|
|
|
case attribute
|
|
|
|
when :drop_down_options
|
2023-01-06 12:57:15 +01:00
|
|
|
(from - to).empty? || dossier&.can_rebase_drop_down_options_change?(stable_id, from - to)
|
2022-12-23 13:01:18 +01:00
|
|
|
when :drop_down_other
|
|
|
|
!from && to
|
|
|
|
when :mandatory
|
|
|
|
(from && !to) || dossier&.can_rebase_mandatory_change?(stable_id)
|
2023-10-13 14:27:03 +02:00
|
|
|
when :type_champ, :condition, :expression_reguliere
|
2022-12-23 13:01:18 +01:00
|
|
|
false
|
|
|
|
else
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2024-06-05 17:30:33 +02:00
|
|
|
|
|
|
|
class EligibiliteRulesChange
|
|
|
|
attr_reader :previous_revision, :new_revision
|
|
|
|
def initialize(previous_revision, new_revision)
|
|
|
|
@previous_revision = previous_revision
|
|
|
|
@new_revision = new_revision
|
|
|
|
@previous_ineligibilite_rules = @previous_revision.ineligibilite_rules
|
|
|
|
@new_ineligibilite_rules = @new_revision.ineligibilite_rules
|
|
|
|
end
|
|
|
|
|
|
|
|
def i18n_params
|
|
|
|
{
|
|
|
|
previous_condition: @previous_ineligibilite_rules&.to_s(previous_revision.types_de_champ.filter { @previous_ineligibilite_rules.sources.include? _1.stable_id }),
|
|
|
|
new_condition: @new_ineligibilite_rules&.to_s(new_revision.types_de_champ.filter { @new_ineligibilite_rules.sources.include? _1.stable_id })
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
class AddEligibiliteRuleChange < EligibiliteRulesChange
|
|
|
|
def op = :add
|
|
|
|
end
|
|
|
|
|
|
|
|
class RemoveEligibiliteRuleChange < EligibiliteRulesChange
|
|
|
|
def op = :remove
|
|
|
|
end
|
|
|
|
|
|
|
|
class UpdateEligibiliteRuleChange < EligibiliteRulesChange
|
|
|
|
def op = :update
|
|
|
|
end
|
|
|
|
|
|
|
|
class EligibiliteEnabledChange < EligibiliteRulesChange
|
|
|
|
def op = :enabled
|
|
|
|
def i18n_params = {}
|
|
|
|
end
|
|
|
|
|
|
|
|
class EligibiliteDisabledChange < EligibiliteRulesChange
|
|
|
|
def op = :disabled
|
|
|
|
def i18n_params = {}
|
|
|
|
end
|
|
|
|
|
|
|
|
class UpdateEligibiliteMessageChange < EligibiliteRulesChange
|
|
|
|
def op = :message_updated
|
|
|
|
def i18n_params = { ineligibilite_message: @new_revision.ineligibilite_message }
|
|
|
|
end
|
2022-12-23 13:01:18 +01:00
|
|
|
end
|