diff --git a/app/models/m_odr_rep.rb b/app/models/m_odr_rep.rb index cd8d3cf..23d74d1 100644 --- a/app/models/m_odr_rep.rb +++ b/app/models/m_odr_rep.rb @@ -25,7 +25,7 @@ class MOdrRep < ApplicationRecord has_many :m_odr_files, :dependent => :destroy accepts_nested_attributes_for :m_odr_files, :allow_destroy => true - + validates :m_odr_product_cat_id, :presence => true, :if => :product_cat_needed? validates :qte, :presence => true validates :m_odr_product_id, :presence => true @@ -37,6 +37,14 @@ class MOdrRep < ApplicationRecord + def product_cat_needed? + if self.m_odr.m_odr_product_cats.count > 0 + true + else + false + end + end + def rgpd_needed? if self.m_odr and self.m_odr.confirm_case_needed true diff --git a/app/views/public/m_odrs/show.html.haml b/app/views/public/m_odrs/show.html.haml index 2410fea..d83b359 100644 --- a/app/views/public/m_odrs/show.html.haml +++ b/app/views/public/m_odrs/show.html.haml @@ -102,7 +102,7 @@ -if @m_odr_rep.m_odr.tel_process =f.input :tel, :label => (!@m_odr_rep.m_odr.placeholder? ? false : "Tel :"), :placeholder => (@m_odr_rep.m_odr.placeholder? ? false : "Tel") - Nous ne vous contacterons par téléphone qu’en cas de problème avec votre dossier + Nous ne vous contacterons par téléphone qu’en cas de problème avec votre dossier -if @m_odr_rep.m_odr_rep_ribs.size > 0 .form_pannel @@ -128,7 +128,7 @@ -if f.object.m_odr.m_odr_product_cats.count > 0 =f.inputs do - =f.input :m_odr_product_cat_id, :label => (!@m_odr_rep.m_odr.placeholder ? false :(@m_odr_rep.m_odr.product_cat_label? ? @m_odr_rep.m_odr.product_cat_label : "Types :")), :as => :select, :collection => f.object.m_odr.m_odr_product_cats.order("id ASC"), :member_label => :name, :include_blank => false + =f.input :m_odr_product_cat_id, :label => (!@m_odr_rep.m_odr.placeholder ? false :(@m_odr_rep.m_odr.product_cat_label? ? @m_odr_rep.m_odr.product_cat_label : "Types :")), :as => :select, :collection => f.object.m_odr.m_odr_product_cats.order("id ASC"), :member_label => :name, :include_blank => true, :prompt => (@m_odr_rep.m_odr.product_cat_label? ? @m_odr_rep.m_odr.product_cat_label : "Nombre de pneus") =f.inputs do