Skip to content

Commit

Permalink
fix duplicata
Browse files Browse the repository at this point in the history
  • Loading branch information
E-L-T committed Dec 12, 2024
1 parent 5f380d7 commit e664cc5
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions app/controllers/administrateurs/types_de_champ_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ def create
end

def update
import_referentiel and return if referentiel_file.present?

type_de_champ = draft.find_and_ensure_exclusive_use(params[:stable_id])
@coordinate = draft.coordinate_for(type_de_champ)

import_referentiel if referentiel_file.present?

if @coordinate.used_by_routing_rules? && changing_of_type?(type_de_champ)
errors = "« #{type_de_champ.libelle} » est utilisé pour le routage, vous ne pouvez pas modifier son type."
@morphed = [champ_component_from(@coordinate, focused: false, errors:)]
Expand Down Expand Up @@ -130,11 +130,11 @@ def destroy
end

def delete_referentiel
type_de_champ = draft.find_and_ensure_exclusive_use(params[:stable_id])
type_de_champ = draft.types_de_champ.find_by(stable_id: params[:stable_id])
@coordinate = draft.coordinate_for(type_de_champ)

type_de_champ.referentiel&.destroy!
@morphed = [champ_component_from(@coordinate, focused: true)]
@morphed = [champ_component_from(@coordinate)]
end

private
Expand All @@ -150,7 +150,8 @@ def import_referentiel
file = referentiel_file.read
base_encoding = CharlockHolmes::EncodingDetector.detect(file)

type_de_champ = draft.find_and_ensure_exclusive_use(params[:stable_id])
# type_de_champ = draft.find_and_ensure_exclusive_use(params[:stable_id])
type_de_champ = draft.types_de_champ.find_by(stable_id: params[:stable_id])

ActiveRecord::Base.transaction do
# Create referentiel
Expand All @@ -167,6 +168,7 @@ def import_referentiel
end
end
@coordinate = draft.coordinate_for(type_de_champ)
@morphed = [champ_component_from(@coordinate)]
end
end

Expand Down

0 comments on commit e664cc5

Please sign in to comment.