commit
29863310fc
7 changed files with 27 additions and 22 deletions
|
@ -17,7 +17,6 @@ class Champ < ApplicationRecord
|
||||||
:order_place,
|
:order_place,
|
||||||
:mandatory?,
|
:mandatory?,
|
||||||
:description,
|
:description,
|
||||||
:drop_down_list,
|
|
||||||
:drop_down_list_options,
|
:drop_down_list_options,
|
||||||
:drop_down_list_options?,
|
:drop_down_list_options?,
|
||||||
:drop_down_list_disabled_options,
|
:drop_down_list_disabled_options,
|
||||||
|
|
|
@ -132,18 +132,20 @@ class Dossier < ApplicationRecord
|
||||||
:traitements,
|
:traitements,
|
||||||
etablissement: :champ,
|
etablissement: :champ,
|
||||||
champs: {
|
champs: {
|
||||||
|
type_de_champ: [],
|
||||||
etablissement: :champ,
|
etablissement: :champ,
|
||||||
type_de_champ: :drop_down_list,
|
|
||||||
piece_justificative_file_attachment: :blob,
|
piece_justificative_file_attachment: :blob,
|
||||||
champs: [
|
champs: [
|
||||||
|
type_de_champ: [],
|
||||||
piece_justificative_file_attachment: :blob
|
piece_justificative_file_attachment: :blob
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
champs_private: {
|
champs_private: {
|
||||||
|
type_de_champ: [],
|
||||||
etablissement: :champ,
|
etablissement: :champ,
|
||||||
type_de_champ: :drop_down_list,
|
|
||||||
piece_justificative_file_attachment: :blob,
|
piece_justificative_file_attachment: :blob,
|
||||||
champs: [
|
champs: [
|
||||||
|
type_de_champ: [],
|
||||||
piece_justificative_file_attachment: :blob
|
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
|
populate_champ_stable_ids
|
||||||
include_list = {
|
include_list = {
|
||||||
attestation_template: nil,
|
attestation_template: nil,
|
||||||
types_de_champ: [:drop_down_list, types_de_champ: :drop_down_list],
|
types_de_champ: [:types_de_champ],
|
||||||
types_de_champ_private: [:drop_down_list, types_de_champ: :drop_down_list]
|
types_de_champ_private: [:types_de_champ]
|
||||||
}
|
}
|
||||||
include_list[:groupe_instructeurs] = :instructeurs if !is_different_admin
|
include_list[:groupe_instructeurs] = :instructeurs if !is_different_admin
|
||||||
procedure = self.deep_clone(include: include_list, &method(:clone_attachments))
|
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))
|
super(params.merge(proxy_association.owner.params_for_champ))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
has_one :drop_down_list
|
|
||||||
|
|
||||||
has_one_attached :piece_justificative_template
|
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
|
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
|
validates :libelle, presence: true, allow_blank: false, allow_nil: false
|
||||||
|
@ -212,7 +210,7 @@ class TypeDeChamp < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def drop_down_list_options
|
def drop_down_list_options
|
||||||
drop_down_options.presence || drop_down_list&.options || []
|
drop_down_options.presence || []
|
||||||
end
|
end
|
||||||
|
|
||||||
def drop_down_list_disabled_options
|
def drop_down_list_disabled_options
|
||||||
|
@ -269,9 +267,8 @@ class TypeDeChamp < ApplicationRecord
|
||||||
.merge(include: { types_de_champ: TYPES_DE_CHAMP_BASE })
|
.merge(include: { types_de_champ: TYPES_DE_CHAMP_BASE })
|
||||||
|
|
||||||
def self.as_json_for_editor
|
def self.as_json_for_editor
|
||||||
includes(:drop_down_list,
|
includes(piece_justificative_template_attachment: :blob,
|
||||||
piece_justificative_template_attachment: :blob,
|
types_de_champ: [piece_justificative_template_attachment: :blob])
|
||||||
types_de_champ: [:drop_down_list, piece_justificative_template_attachment: :blob])
|
|
||||||
.as_json(TYPES_DE_CHAMP)
|
.as_json(TYPES_DE_CHAMP)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -303,7 +300,6 @@ class TypeDeChamp < ApplicationRecord
|
||||||
|
|
||||||
def remove_drop_down_list
|
def remove_drop_down_list
|
||||||
if !drop_down_list?
|
if !drop_down_list?
|
||||||
self.drop_down_list = nil
|
|
||||||
self.drop_down_options = nil
|
self.drop_down_options = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -105,6 +105,22 @@
|
||||||
.card-admin-action
|
.card-admin-action
|
||||||
= button_to 'Modifier', admin_procedure_mail_templates_path(@procedure), method: :get, class: 'card-admin-action-btn'
|
= button_to 'Modifier', admin_procedure_mail_templates_path(@procedure), method: :get, class: 'card-admin-action-btn'
|
||||||
|
|
||||||
|
- if !@procedure.locked?
|
||||||
|
.card-admin
|
||||||
|
- if @procedure.types_de_champ_private.present?
|
||||||
|
%div
|
||||||
|
%span.icon.accept
|
||||||
|
%p.card-admin-status-accept Validé
|
||||||
|
- else
|
||||||
|
%div
|
||||||
|
%span.icon.clock
|
||||||
|
%p.card-admin-status-todo À configurer
|
||||||
|
%div
|
||||||
|
%p.card-admin-title Annotations privées
|
||||||
|
%p.card-admin-subtitle Champs à remplir par l’administration
|
||||||
|
.card-admin-action
|
||||||
|
= button_to 'Modifier', annotations_admin_procedure_path(@procedure), method: :get, class: 'card-admin-action-btn'
|
||||||
|
|
||||||
.card-admin
|
.card-admin
|
||||||
- if @procedure.api_entreprise_token.present?
|
- if @procedure.api_entreprise_token.present?
|
||||||
%div
|
%div
|
||||||
|
|
|
@ -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.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_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.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_list).compact.size).to eq procedure.types_de_champ_private.map(&:drop_down_list).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|
|
procedure.types_de_champ.zip(subject.types_de_champ).each do |ptc, stc|
|
||||||
expect(stc).to have_same_attributes_as(ptc)
|
expect(stc).to have_same_attributes_as(ptc)
|
||||||
|
|
Loading…
Add table
Reference in a new issue