Delegate mandatory?
to type_de_champ
This commit is contained in:
parent
82e7d33e2f
commit
f80a9466b9
16 changed files with 16 additions and 20 deletions
|
@ -5,7 +5,7 @@ class Champ < ActiveRecord::Base
|
|||
belongs_to :type_de_champ, inverse_of: :champ
|
||||
has_many :commentaires
|
||||
|
||||
delegate :libelle, :type_champ, :order_place, :mandatory, :description, :drop_down_list, to: :type_de_champ
|
||||
delegate :libelle, :type_champ, :order_place, :mandatory?, :description, :drop_down_list, to: :type_de_champ
|
||||
|
||||
before_save :format_date_to_iso, if: Proc.new { type_champ == 'date' }
|
||||
before_save :format_datetime, if: Proc.new { type_champ == 'datetime' }
|
||||
|
@ -15,10 +15,6 @@ class Champ < ActiveRecord::Base
|
|||
scope :public_only, -> { where.not(type: 'ChampPrivate').or(where(private: [false, nil])) }
|
||||
scope :private_only, -> { where(type: 'ChampPrivate').or(where(private: true)) }
|
||||
|
||||
def mandatory?
|
||||
mandatory
|
||||
end
|
||||
|
||||
def public?
|
||||
!private?
|
||||
end
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
= form.text_field :value,
|
||||
'data-address': 'true',
|
||||
placeholder: champ.libelle,
|
||||
required: champ.mandatory
|
||||
required: champ.mandatory?
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
= form.label :value do
|
||||
#{champ.libelle}
|
||||
- if champ.mandatory
|
||||
- if champ.mandatory?
|
||||
%span.mandatory *
|
||||
|
||||
- if champ.updated_at.present?
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
= form.check_box :value,
|
||||
{ required: champ.mandatory },
|
||||
{ required: champ.mandatory? },
|
||||
'on',
|
||||
'off'
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
= form.date_field :value,
|
||||
value: champ.value,
|
||||
placeholder: 'JJ/MM/AAAA',
|
||||
required: champ.mandatory
|
||||
required: champ.mandatory?
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
= form.select :value,
|
||||
Champ.departements,
|
||||
required: champ.mandatory
|
||||
required: champ.mandatory?
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
placeholder: "Numéro de dossier",
|
||||
autocomplete: 'off',
|
||||
'data-type': 'dossier-link',
|
||||
required: champ.mandatory
|
||||
required: champ.mandatory?
|
||||
|
||||
.help-block
|
||||
%p.text-info{ style: show_text_summary ? nil : 'display: none;' }
|
||||
|
|
|
@ -2,4 +2,4 @@
|
|||
= form.select :value,
|
||||
champ.drop_down_list.options,
|
||||
disabled: champ.drop_down_list.disabled_options,
|
||||
required: champ.mandatory
|
||||
required: champ.mandatory?
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
= form.email_field :value,
|
||||
placeholder: champ.libelle,
|
||||
required: champ.mandatory
|
||||
required: champ.mandatory?
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
= form.check_box :value,
|
||||
{ required: champ.mandatory },
|
||||
{ required: champ.mandatory? },
|
||||
'on',
|
||||
'off'
|
||||
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
= form.number_field :value,
|
||||
placeholder: champ.libelle,
|
||||
required: champ.mandatory
|
||||
required: champ.mandatory?
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
= form.select :value,
|
||||
Champ.pays,
|
||||
required: champ.mandatory
|
||||
required: champ.mandatory?
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
= form.phone_field :value,
|
||||
placeholder: champ.libelle,
|
||||
required: champ.mandatory
|
||||
required: champ.mandatory?
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
= form.select :value,
|
||||
Champ.regions,
|
||||
required: champ.mandatory
|
||||
required: champ.mandatory?
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
= form.text_field :value,
|
||||
placeholder: champ.libelle,
|
||||
required: champ.mandatory
|
||||
required: champ.mandatory?
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
~ form.text_area :value,
|
||||
row: 6,
|
||||
placeholder: champ.description,
|
||||
required: champ.mandatory,
|
||||
required: champ.mandatory?,
|
||||
value: html_to_string(champ.value)
|
||||
|
|
Loading…
Reference in a new issue