2024-04-29 00:17:15 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2022-12-23 14:05:39 +01:00
|
|
|
class Procedure::RevisionChangesComponent < ApplicationComponent
|
2024-06-05 17:30:33 +02:00
|
|
|
def initialize(new_revision:, previous_revision:)
|
2022-12-23 14:05:39 +01:00
|
|
|
@previous_revision = previous_revision
|
2024-06-05 17:30:33 +02:00
|
|
|
@new_revision = new_revision
|
2024-11-04 11:41:24 +01:00
|
|
|
@procedure = new_revision.procedure
|
2024-06-05 17:30:33 +02:00
|
|
|
|
|
|
|
@tdc_changes = previous_revision.compare_types_de_champ(new_revision)
|
|
|
|
@public_move_changes, @private_move_changes = @tdc_changes.filter { _1.op == :move }.partition { !_1.private? }
|
|
|
|
@delete_champ_warning = !total_dossiers.zero? && !@tdc_changes.all?(&:can_rebase?)
|
|
|
|
|
|
|
|
@ineligibilite_rules_changes = previous_revision.compare_ineligibilite_rules(new_revision)
|
2022-12-23 14:05:39 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2024-11-04 11:41:24 +01:00
|
|
|
def used_by_routing_rules?(type_de_champ)
|
|
|
|
@procedure.used_by_routing_rules?(type_de_champ)
|
|
|
|
end
|
|
|
|
|
2022-12-23 14:05:39 +01:00
|
|
|
def total_dossiers
|
|
|
|
@total_dossiers ||= @previous_revision.dossiers
|
|
|
|
.visible_by_administration
|
|
|
|
.state_en_construction_ou_instruction
|
|
|
|
.size
|
|
|
|
end
|
|
|
|
end
|