From ed02337d27179615cfed12837d7bf165c404045d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A9?= Date: Tue, 31 Aug 2021 08:27:31 +0200 Subject: [PATCH] Mask grade with ACTIVATED --- app/controllers/application_controller.rb | 2 +- app/models/p_article.rb | 30 ++++++++++++++-------- app/models/p_grade.rb | 1 + app/views/admin/p_articles/_form.html.haml | 3 ++- 4 files changed, 24 insertions(+), 12 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 9ab496c..63ae755 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -102,7 +102,7 @@ class ApplicationController < ActionController::Base set_sub_menu :stocks, :p_serial_num_types, "Types de Numero série" set_sub_menu :stocks, :p_product_ref_specs, "Specs" set_sub_menu :stocks, :p_spec_values, "Valeur de specs" - set_sub_menu :stocks, :p_grades, "Grades" + set_sub_menu :stocks, :p_grades, "Grades" if PGrade::ACTIVATED set_sub_menu :stocks, :p_product_powers, "Types de chargeurs" set_sub_menu :stocks, :p_product_zones, "Zones produits" diff --git a/app/models/p_article.rb b/app/models/p_article.rb index f301d09..187741f 100644 --- a/app/models/p_article.rb +++ b/app/models/p_article.rb @@ -12,16 +12,26 @@ class PArticle < ApplicationRecord # has_many :p_product_ref_specs, through: :p_product_ref # accepts_nested_attributes_for :p_product_ref_specs - acts_as_sorting :fields => { - :id => {:name => "id", :reorder => true}, - :p_product_ref_code => {:name => "Code ref", :reorder => true}, - :p_product_ref => {:name => "Désignation", :reorder => true}, - :p_grade => {:name => "Grade", :reorder => true}, - :color => {:name => "Couleur"}, - :p_article_serial_nums => {:name => "N° identifiants"}, - :actions => {:name => "Actions", :reorder => false}, - } - + if PGrade::ACTIVATED + acts_as_sorting :fields => { + :id => {:name => "id", :reorder => true}, + :p_product_ref_code => {:name => "Code ref", :reorder => true}, + :p_product_ref => {:name => "Désignation", :reorder => true}, + :p_grade => {:name => "Grade", :reorder => true}, + :color => {:name => "Couleur"}, + :p_article_serial_nums => {:name => "N° identifiants"}, + :actions => {:name => "Actions", :reorder => false}, + } + else + acts_as_sorting :fields => { + :id => {:name => "id", :reorder => true}, + :p_product_ref_code => {:name => "Code ref", :reorder => true}, + :p_product_ref => {:name => "Désignation", :reorder => true}, + :color => {:name => "Couleur"}, + :p_article_serial_nums => {:name => "N° identifiants"}, + :actions => {:name => "Actions", :reorder => false}, + } + end def member_label "#{p_product_ref.cc_name}" end diff --git a/app/models/p_grade.rb b/app/models/p_grade.rb index 949f5e1..648e10e 100644 --- a/app/models/p_grade.rb +++ b/app/models/p_grade.rb @@ -7,4 +7,5 @@ class PGrade < ApplicationRecord :actions => {:name => "Actions", :reorder => false}, } + ACTIVATED = false end diff --git a/app/views/admin/p_articles/_form.html.haml b/app/views/admin/p_articles/_form.html.haml index 3bec92b..ae711c0 100644 --- a/app/views/admin/p_articles/_form.html.haml +++ b/app/views/admin/p_articles/_form.html.haml @@ -3,7 +3,8 @@ .content =f.inputs do = f.input :p_product_ref, as: :select, collection: PProductRef.all.distinct, :label => f.object.label_for(:p_product_ref) - = f.input :p_grade, as: :select, collection: PGrade.pluck(:grade, :id), :label => "Grade" + -if PGrade::ACTIVATED + = f.input :p_grade, as: :select, collection: PGrade.pluck(:grade, :id), :label => "Grade" %h4 Numero de série : .p_article_serial_nums_form = f.semantic_fields_for :p_article_serial_nums do |form|