diff --git a/app/models/champ.rb b/app/models/champ.rb index 4daf0e05d..4cbb7a48b 100644 --- a/app/models/champ.rb +++ b/app/models/champ.rb @@ -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 diff --git a/app/views/new_gestionnaire/dossiers/editable_champs/_address.html.haml b/app/views/new_gestionnaire/dossiers/editable_champs/_address.html.haml index 24ee6b39b..19a5a9e52 100644 --- a/app/views/new_gestionnaire/dossiers/editable_champs/_address.html.haml +++ b/app/views/new_gestionnaire/dossiers/editable_champs/_address.html.haml @@ -1,4 +1,4 @@ = form.text_field :value, 'data-address': 'true', placeholder: champ.libelle, - required: champ.mandatory + required: champ.mandatory? diff --git a/app/views/new_gestionnaire/dossiers/editable_champs/_champ_label.html.haml b/app/views/new_gestionnaire/dossiers/editable_champs/_champ_label.html.haml index a75334b35..38749d6da 100644 --- a/app/views/new_gestionnaire/dossiers/editable_champs/_champ_label.html.haml +++ b/app/views/new_gestionnaire/dossiers/editable_champs/_champ_label.html.haml @@ -1,6 +1,6 @@ = form.label :value do #{champ.libelle} - - if champ.mandatory + - if champ.mandatory? %span.mandatory * - if champ.updated_at.present? diff --git a/app/views/new_gestionnaire/dossiers/editable_champs/_checkbox.html.haml b/app/views/new_gestionnaire/dossiers/editable_champs/_checkbox.html.haml index 3dfe83c16..5bd197a73 100644 --- a/app/views/new_gestionnaire/dossiers/editable_champs/_checkbox.html.haml +++ b/app/views/new_gestionnaire/dossiers/editable_champs/_checkbox.html.haml @@ -1,5 +1,5 @@ = form.check_box :value, - { required: champ.mandatory }, + { required: champ.mandatory? }, 'on', 'off' diff --git a/app/views/new_gestionnaire/dossiers/editable_champs/_date.html.haml b/app/views/new_gestionnaire/dossiers/editable_champs/_date.html.haml index 40794faef..b20444520 100644 --- a/app/views/new_gestionnaire/dossiers/editable_champs/_date.html.haml +++ b/app/views/new_gestionnaire/dossiers/editable_champs/_date.html.haml @@ -1,4 +1,4 @@ = form.date_field :value, value: champ.value, placeholder: 'JJ/MM/AAAA', - required: champ.mandatory + required: champ.mandatory? diff --git a/app/views/new_gestionnaire/dossiers/editable_champs/_departements.html.haml b/app/views/new_gestionnaire/dossiers/editable_champs/_departements.html.haml index 790e22f07..90c2ca408 100644 --- a/app/views/new_gestionnaire/dossiers/editable_champs/_departements.html.haml +++ b/app/views/new_gestionnaire/dossiers/editable_champs/_departements.html.haml @@ -1,3 +1,3 @@ = form.select :value, Champ.departements, - required: champ.mandatory + required: champ.mandatory? diff --git a/app/views/new_gestionnaire/dossiers/editable_champs/_dossier_link.html.haml b/app/views/new_gestionnaire/dossiers/editable_champs/_dossier_link.html.haml index 924cdc78e..53ca52c5c 100644 --- a/app/views/new_gestionnaire/dossiers/editable_champs/_dossier_link.html.haml +++ b/app/views/new_gestionnaire/dossiers/editable_champs/_dossier_link.html.haml @@ -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;' } diff --git a/app/views/new_gestionnaire/dossiers/editable_champs/_drop_down_list.html.haml b/app/views/new_gestionnaire/dossiers/editable_champs/_drop_down_list.html.haml index fbe889285..05b938cfc 100644 --- a/app/views/new_gestionnaire/dossiers/editable_champs/_drop_down_list.html.haml +++ b/app/views/new_gestionnaire/dossiers/editable_champs/_drop_down_list.html.haml @@ -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? diff --git a/app/views/new_gestionnaire/dossiers/editable_champs/_email.html.haml b/app/views/new_gestionnaire/dossiers/editable_champs/_email.html.haml index 8cdac1a75..ce589db77 100644 --- a/app/views/new_gestionnaire/dossiers/editable_champs/_email.html.haml +++ b/app/views/new_gestionnaire/dossiers/editable_champs/_email.html.haml @@ -1,3 +1,3 @@ = form.email_field :value, placeholder: champ.libelle, - required: champ.mandatory + required: champ.mandatory? diff --git a/app/views/new_gestionnaire/dossiers/editable_champs/_engagement.html.haml b/app/views/new_gestionnaire/dossiers/editable_champs/_engagement.html.haml index 3dfe83c16..5bd197a73 100644 --- a/app/views/new_gestionnaire/dossiers/editable_champs/_engagement.html.haml +++ b/app/views/new_gestionnaire/dossiers/editable_champs/_engagement.html.haml @@ -1,5 +1,5 @@ = form.check_box :value, - { required: champ.mandatory }, + { required: champ.mandatory? }, 'on', 'off' diff --git a/app/views/new_gestionnaire/dossiers/editable_champs/_number.html.haml b/app/views/new_gestionnaire/dossiers/editable_champs/_number.html.haml index 956daca53..d5aab710a 100644 --- a/app/views/new_gestionnaire/dossiers/editable_champs/_number.html.haml +++ b/app/views/new_gestionnaire/dossiers/editable_champs/_number.html.haml @@ -1,3 +1,3 @@ = form.number_field :value, placeholder: champ.libelle, - required: champ.mandatory + required: champ.mandatory? diff --git a/app/views/new_gestionnaire/dossiers/editable_champs/_pays.html.haml b/app/views/new_gestionnaire/dossiers/editable_champs/_pays.html.haml index 678a06eff..cdc2e489d 100644 --- a/app/views/new_gestionnaire/dossiers/editable_champs/_pays.html.haml +++ b/app/views/new_gestionnaire/dossiers/editable_champs/_pays.html.haml @@ -1,3 +1,3 @@ = form.select :value, Champ.pays, - required: champ.mandatory + required: champ.mandatory? diff --git a/app/views/new_gestionnaire/dossiers/editable_champs/_phone.html.haml b/app/views/new_gestionnaire/dossiers/editable_champs/_phone.html.haml index 32f36f5f8..00ff6f5c6 100644 --- a/app/views/new_gestionnaire/dossiers/editable_champs/_phone.html.haml +++ b/app/views/new_gestionnaire/dossiers/editable_champs/_phone.html.haml @@ -1,3 +1,3 @@ = form.phone_field :value, placeholder: champ.libelle, - required: champ.mandatory + required: champ.mandatory? diff --git a/app/views/new_gestionnaire/dossiers/editable_champs/_regions.html.haml b/app/views/new_gestionnaire/dossiers/editable_champs/_regions.html.haml index 24863e110..b947a8d31 100644 --- a/app/views/new_gestionnaire/dossiers/editable_champs/_regions.html.haml +++ b/app/views/new_gestionnaire/dossiers/editable_champs/_regions.html.haml @@ -1,3 +1,3 @@ = form.select :value, Champ.regions, - required: champ.mandatory + required: champ.mandatory? diff --git a/app/views/new_gestionnaire/dossiers/editable_champs/_text.html.haml b/app/views/new_gestionnaire/dossiers/editable_champs/_text.html.haml index 6134a07b1..2b5d10584 100644 --- a/app/views/new_gestionnaire/dossiers/editable_champs/_text.html.haml +++ b/app/views/new_gestionnaire/dossiers/editable_champs/_text.html.haml @@ -1,3 +1,3 @@ = form.text_field :value, placeholder: champ.libelle, - required: champ.mandatory + required: champ.mandatory? diff --git a/app/views/new_gestionnaire/dossiers/editable_champs/_textarea.html.haml b/app/views/new_gestionnaire/dossiers/editable_champs/_textarea.html.haml index 5f67724f5..c1bac654c 100644 --- a/app/views/new_gestionnaire/dossiers/editable_champs/_textarea.html.haml +++ b/app/views/new_gestionnaire/dossiers/editable_champs/_textarea.html.haml @@ -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)