Merge pull request #5381 from tchak/cleanup-drop-down-options
Remove unsused drop_down_list model
This commit is contained in:
commit
4ff8be4b46
6 changed files with 11 additions and 22 deletions
|
@ -17,7 +17,6 @@ class Champ < ApplicationRecord
|
|||
:order_place,
|
||||
:mandatory?,
|
||||
:description,
|
||||
:drop_down_list,
|
||||
:drop_down_list_options,
|
||||
:drop_down_list_options?,
|
||||
:drop_down_list_disabled_options,
|
||||
|
|
|
@ -132,18 +132,20 @@ class Dossier < ApplicationRecord
|
|||
:traitements,
|
||||
etablissement: :champ,
|
||||
champs: {
|
||||
type_de_champ: [],
|
||||
etablissement: :champ,
|
||||
type_de_champ: :drop_down_list,
|
||||
piece_justificative_file_attachment: :blob,
|
||||
champs: [
|
||||
type_de_champ: [],
|
||||
piece_justificative_file_attachment: :blob
|
||||
]
|
||||
},
|
||||
champs_private: {
|
||||
type_de_champ: [],
|
||||
etablissement: :champ,
|
||||
type_de_champ: :drop_down_list,
|
||||
piece_justificative_file_attachment: :blob,
|
||||
champs: [
|
||||
type_de_champ: [],
|
||||
piece_justificative_file_attachment: :blob
|
||||
]
|
||||
},
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
class DropDownList < ApplicationRecord
|
||||
belongs_to :type_de_champ
|
||||
|
||||
def options
|
||||
result = value.split(/[\r\n]|[\r]|[\n]|[\n\r]/).reject(&:empty?)
|
||||
result.blank? ? [] : [''] + result
|
||||
end
|
||||
end
|
|
@ -294,8 +294,8 @@ class Procedure < ApplicationRecord
|
|||
populate_champ_stable_ids
|
||||
include_list = {
|
||||
attestation_template: nil,
|
||||
types_de_champ: [:drop_down_list, types_de_champ: :drop_down_list],
|
||||
types_de_champ_private: [:drop_down_list, types_de_champ: :drop_down_list]
|
||||
types_de_champ: [:types_de_champ],
|
||||
types_de_champ_private: [:types_de_champ]
|
||||
}
|
||||
include_list[:groupe_instructeurs] = :instructeurs if !is_different_admin
|
||||
procedure = self.deep_clone(include: include_list, &method(:clone_attachments))
|
||||
|
|
|
@ -70,11 +70,9 @@ class TypeDeChamp < ApplicationRecord
|
|||
super(params.merge(proxy_association.owner.params_for_champ))
|
||||
end
|
||||
end
|
||||
has_one :drop_down_list
|
||||
|
||||
has_one_attached :piece_justificative_template
|
||||
|
||||
accepts_nested_attributes_for :drop_down_list, update_only: true
|
||||
accepts_nested_attributes_for :types_de_champ, reject_if: proc { |attributes| attributes['libelle'].blank? }, allow_destroy: true
|
||||
|
||||
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||
|
@ -212,7 +210,7 @@ class TypeDeChamp < ApplicationRecord
|
|||
end
|
||||
|
||||
def drop_down_list_options
|
||||
drop_down_options.presence || drop_down_list&.options || []
|
||||
drop_down_options.presence || []
|
||||
end
|
||||
|
||||
def drop_down_list_disabled_options
|
||||
|
@ -269,9 +267,8 @@ class TypeDeChamp < ApplicationRecord
|
|||
.merge(include: { types_de_champ: TYPES_DE_CHAMP_BASE })
|
||||
|
||||
def self.as_json_for_editor
|
||||
includes(:drop_down_list,
|
||||
piece_justificative_template_attachment: :blob,
|
||||
types_de_champ: [:drop_down_list, piece_justificative_template_attachment: :blob])
|
||||
includes(piece_justificative_template_attachment: :blob,
|
||||
types_de_champ: [piece_justificative_template_attachment: :blob])
|
||||
.as_json(TYPES_DE_CHAMP)
|
||||
end
|
||||
|
||||
|
@ -303,7 +300,6 @@ class TypeDeChamp < ApplicationRecord
|
|||
|
||||
def remove_drop_down_list
|
||||
if !drop_down_list?
|
||||
self.drop_down_list = nil
|
||||
self.drop_down_options = nil
|
||||
end
|
||||
end
|
||||
|
|
|
@ -415,8 +415,8 @@ describe Procedure do
|
|||
|
||||
expect(subject.types_de_champ.size).to eq(procedure.types_de_champ.size)
|
||||
expect(subject.types_de_champ_private.size).to eq procedure.types_de_champ_private.size
|
||||
expect(subject.types_de_champ.map(&:drop_down_list).compact.size).to eq procedure.types_de_champ.map(&:drop_down_list).compact.size
|
||||
expect(subject.types_de_champ_private.map(&:drop_down_list).compact.size).to eq procedure.types_de_champ_private.map(&:drop_down_list).compact.size
|
||||
expect(subject.types_de_champ.map(&:drop_down_options).compact.size).to eq procedure.types_de_champ.map(&:drop_down_options).compact.size
|
||||
expect(subject.types_de_champ_private.map(&:drop_down_options).compact.size).to eq procedure.types_de_champ_private.map(&:drop_down_options).compact.size
|
||||
|
||||
procedure.types_de_champ.zip(subject.types_de_champ).each do |ptc, stc|
|
||||
expect(stc).to have_same_attributes_as(ptc)
|
||||
|
|
Loading…
Reference in a new issue