serial num sorting + form
This commit is contained in:
parent
fd0801b23d
commit
9db1d17d9a
@ -33,7 +33,7 @@ class Admin::PArticleSerialNumsController < ApplicationController
|
||||
|
||||
def new
|
||||
@p_article_serial_num = PArticleSerialNum.new
|
||||
|
||||
@p_article_serial_num.build_p_serial_num_value
|
||||
end
|
||||
|
||||
def edit
|
||||
|
@ -33,7 +33,7 @@ class Admin::PArticlesController < ApplicationController
|
||||
|
||||
def new
|
||||
@p_article = PArticle.new
|
||||
|
||||
@p_article.build_p_product_ref
|
||||
end
|
||||
|
||||
def edit
|
||||
|
@ -65,6 +65,7 @@ class ApplicationController < ActionController::Base
|
||||
if current_admin.has_permission?("products")
|
||||
set_sub_menu :stocks, :p_products, "Produits", admin_p_products_path
|
||||
set_sub_menu :stocks, :p_product_refs, "Références", admin_p_product_refs_path
|
||||
set_sub_menu :stocks, :p_articles, "Articles", admin_p_articles_path
|
||||
set_sub_menu :stocks, :promos_p_products, "Offres spots", promos_admin_p_products_path
|
||||
|
||||
end
|
||||
@ -97,6 +98,7 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
if current_admin.has_permission?("boutique")
|
||||
set_sub_menu :stocks, :p_product_colors, "Couleurs"
|
||||
set_sub_menu :stocks, :p_article_serial_nums, "Numero série"
|
||||
set_sub_menu :stocks, :p_product_powers, "Types de chargeurs"
|
||||
set_sub_menu :stocks, :p_product_zones, "Zones produits"
|
||||
|
||||
|
@ -1,3 +1,18 @@
|
||||
class PArticle < ApplicationRecord
|
||||
belongs_to :p_product_ref
|
||||
has_one :p_product, through: :p_product_ref
|
||||
belongs_to :p_product_color
|
||||
has_many :p_article_serial_nums, dependent: :destroy
|
||||
# accepts_nested_attributes_for :p_article_serial_nums
|
||||
validates_presence_of :p_product_ref
|
||||
|
||||
|
||||
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
|
||||
|
@ -1,5 +1,17 @@
|
||||
class PArticleSerialNum < ApplicationRecord
|
||||
belongs_to :p_article
|
||||
belongs_to :p_serial_num_type
|
||||
belongs_to :p_serial_num_value
|
||||
belongs_to :p_serial_num_value, inverse_of: :p_article_serial_nums
|
||||
accepts_nested_attributes_for :p_serial_num_value
|
||||
|
||||
acts_as_sorting :fields => {
|
||||
:id => {:name => "ID"},
|
||||
:p_article => {:name => "Article", :reorder => true},
|
||||
:p_article_id => {:name => "Article ID", :reorder => true},
|
||||
:p_serial_num_type => {:name => "Type", :reorder => true},
|
||||
:p_serial_num_value => {:name => "N°", :reorder => true},
|
||||
|
||||
:actions => {:name => "Actions", :reorder => true}
|
||||
|
||||
}
|
||||
end
|
||||
|
@ -5,8 +5,6 @@ class PProduct < ApplicationRecord
|
||||
has_many :p_product_refs, :dependent => :destroy
|
||||
accepts_nested_attributes_for :p_product_refs, allow_destroy: true
|
||||
|
||||
|
||||
|
||||
has_many :p_product_ingredients, :dependent => :destroy
|
||||
accepts_nested_attributes_for :p_product_ingredients, allow_destroy: true
|
||||
|
||||
@ -17,6 +15,7 @@ class PProduct < ApplicationRecord
|
||||
has_many :p_product_nutris, :dependent => :destroy
|
||||
accepts_nested_attributes_for :p_product_nutris, allow_destroy: true
|
||||
|
||||
has_many :p_articles, through: :p_product_refs
|
||||
|
||||
|
||||
has_many :p_product_images
|
||||
|
@ -9,6 +9,9 @@ class PProductRef < ApplicationRecord
|
||||
has_many :p_product_ref_price_histories
|
||||
|
||||
belongs_to :p_product_color
|
||||
has_many :p_articles
|
||||
has_many :p_article_serial_nums, through: :p_articles
|
||||
accepts_nested_attributes_for :p_article_serial_nums, allow_destroy: true
|
||||
|
||||
#validates :ct_price_ht, :presence => true
|
||||
|
||||
|
@ -1,2 +1,3 @@
|
||||
class PSerialNumType < ApplicationRecord
|
||||
has_many :p_article_serial_nums
|
||||
end
|
||||
|
@ -1,2 +1,3 @@
|
||||
class PSerialNumValue < ApplicationRecord
|
||||
has_many :p_article_serial_nums, inverse_of: :p_serial_num_value
|
||||
end
|
||||
|
@ -2,9 +2,11 @@
|
||||
|
||||
.content
|
||||
=f.inputs do
|
||||
= f.input :p_article, :label => f.object.label_for(:p_article)
|
||||
= f.input :p_article, as: :select, collection: PArticle.pluck(:id) ,:label => f.object.label_for(:p_article)
|
||||
= f.input :p_serial_num_type, :label => f.object.label_for(:p_serial_num_type)
|
||||
= f.input :p_serial_num_value, :label => f.object.label_for(:p_serial_num_value)
|
||||
= f.semantic_fields_for :p_serial_num_value do | form |
|
||||
|
||||
=render :partial => "admin/p_serial_num_values/form", :locals => {:f => form}
|
||||
|
||||
|
||||
|
||||
|
@ -1,6 +1,28 @@
|
||||
%tr#p_article_serial_num_row{:id => p_article_serial_num.id}
|
||||
-tr = {}
|
||||
|
||||
-tr[:p_article_id] = capture do
|
||||
%td
|
||||
= p_article_serial_num.p_article.id
|
||||
|
||||
-tr[:p_article] = capture do
|
||||
%td
|
||||
= p_article_serial_num.p_article.p_product.name
|
||||
\-
|
||||
= p_article_serial_num.p_article.p_product_ref.ct_sub_name
|
||||
\-
|
||||
= p_article_serial_num.p_article.p_product_ref.p_product_color.name
|
||||
|
||||
|
||||
-tr[:p_serial_num_type] = capture do
|
||||
%td
|
||||
= p_article_serial_num.p_serial_num_type.name
|
||||
|
||||
-tr[:p_serial_num_value] = capture do
|
||||
%td
|
||||
= p_article_serial_num.p_serial_num_value.value
|
||||
|
||||
|
||||
-tr[:actions] = capture do
|
||||
%td.actions
|
||||
= link_to i(:"trash-o"), [:admin, p_article_serial_num], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
.content
|
||||
=f.inputs do
|
||||
= f.input :p_product_ref, :label => f.object.label_for(:p_product_ref)
|
||||
= f.input :p_product_ref, as: :select, collection: PProductRef.all, :label => f.object.label_for(:p_product_ref)
|
||||
|
||||
|
||||
|
||||
|
@ -1,6 +1,29 @@
|
||||
%tr#p_article_row{:id => p_article.id}
|
||||
-tr = {}
|
||||
|
||||
-tr[:p_product_ref_code] = capture do
|
||||
%td
|
||||
= p_article.p_product_ref.code
|
||||
|
||||
|
||||
-tr[:color] = capture do
|
||||
%td
|
||||
= p_article.p_product_ref.p_product_color.color
|
||||
|
||||
-tr[:p_product_ref] = capture do
|
||||
%td
|
||||
= p_article.p_product_ref.p_product.name
|
||||
\-
|
||||
= p_article.p_product_ref.ct_sub_name
|
||||
\-
|
||||
= p_article.p_product_ref.p_product_color.name
|
||||
|
||||
-tr[:p_article_serial_nums] = capture do
|
||||
%td
|
||||
- p_article.p_article_serial_nums.each do |sn|
|
||||
= sn.p_serial_num_type.name + " : " + sn.p_serial_num_value.value
|
||||
|
||||
|
||||
-tr[:actions] = capture do
|
||||
%td.actions
|
||||
= link_to i(:"trash-o"), [:admin, p_article], method: :delete, data: { confirm: 'Voulez-vous vraiment supprimer cet enregistrement ? ' } , :remote => true
|
||||
|
@ -1,12 +1,12 @@
|
||||
=semantic_form_for [:admin, @p_serial_num_value], :remote => true do |f|
|
||||
/ =semantic_form_for [:admin, @p_serial_num_value], :remote => true do |f|
|
||||
|
||||
.content
|
||||
=f.inputs do
|
||||
= f.input :value, :label => f.object.label_for(:value)
|
||||
|
||||
=f.inputs do
|
||||
= f.input :value, :label => "Numéro"
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.actions=f.submit "sauvegarder", :class => "btn btn-primary"
|
||||
/ .actions=f.submit "sauvegarder", :class => "btn btn-primary"
|
||||
|
Reference in New Issue
Block a user