feat(routing): ui side: prevent tdc deletion if used for routing
This commit is contained in:
parent
213d463ff4
commit
3f55fddcef
3 changed files with 20 additions and 5 deletions
|
@ -1,10 +1,17 @@
|
|||
%li.type-de-champ.flex.column.justify-start{ html_options }
|
||||
.flex.justify-start.section.head.hr
|
||||
.flex.justify-between.section.head.hr
|
||||
.handle.small.icon-only.icon.move-handle{ title: "Déplacer le champ vers le haut ou vers le bas" }
|
||||
.flex.justify-start.delete
|
||||
= button_to type_de_champ_path, class: 'button small icon-only danger', method: :delete, form: { data: { turbo_confirm: 'Êtes vous sûr de vouloir supprimer ce champ ?' } } do
|
||||
.icon.delete
|
||||
%span.sr-only Supprimer
|
||||
|
||||
- if coordinate.used_by_routing_rules?
|
||||
.flex.align-center
|
||||
%span
|
||||
utilisé pour
|
||||
= link_to('le routage', admin_procedure_groupe_instructeurs_path(revision.procedure_id, anchor: 'routing-rules'))
|
||||
- else
|
||||
.flex.justify-start.delete
|
||||
= button_to type_de_champ_path, class: 'button small icon-only danger', method: :delete, form: { data: { turbo_confirm: 'Êtes vous sûr de vouloir supprimer ce champ ?' } } do
|
||||
.icon.delete
|
||||
%span.sr-only Supprimer
|
||||
|
||||
- if @errors.present?
|
||||
.types-de-champ-errors
|
||||
|
|
|
@ -919,4 +919,8 @@ class Procedure < ApplicationRecord
|
|||
groupe_instructeurs.create(label: GroupeInstructeur::DEFAUT_LABEL)
|
||||
end
|
||||
end
|
||||
|
||||
def stable_ids_used_by_routing_rules
|
||||
@stable_ids_used_by_routing_rules ||= groupe_instructeurs.flat_map { _1.routing_rule&.sources }.compact
|
||||
end
|
||||
end
|
||||
|
|
|
@ -69,4 +69,8 @@ class ProcedureRevisionTypeDeChamp < ApplicationRecord
|
|||
revision
|
||||
end
|
||||
end
|
||||
|
||||
def used_by_routing_rules?
|
||||
stable_id.in?(procedure.stable_ids_used_by_routing_rules)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Reference in a new issue