form and menu for p_spec
This commit is contained in:
parent
c1d3c255ee
commit
bc96c5bc23
@ -33,6 +33,8 @@ class Admin::PProductRefSpecsController < ApplicationController
|
||||
|
||||
def new
|
||||
@p_product_ref_spec = PProductRefSpec.new
|
||||
@p_product_ref_spec.build_p_spec_type
|
||||
@p_product_ref_spec.build_p_spec_value
|
||||
|
||||
end
|
||||
|
||||
|
@ -99,6 +99,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_ref_specs, "Specs"
|
||||
set_sub_menu :stocks, :p_product_powers, "Types de chargeurs"
|
||||
set_sub_menu :stocks, :p_product_zones, "Zones produits"
|
||||
|
||||
|
@ -9,10 +9,14 @@ 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
|
||||
|
||||
has_many :p_product_ref_specs
|
||||
accepts_nested_attributes_for :p_product_ref_specs, allow_destroy: true
|
||||
|
||||
#validates :ct_price_ht, :presence => true
|
||||
|
||||
|
||||
@ -67,7 +71,9 @@ class PProductRef < ApplicationRecord
|
||||
|
||||
|
||||
def ca_name
|
||||
self.p_product.name if self.p_product
|
||||
if self.p_product
|
||||
self.p_product.name + " - " + self.ct_sub_name
|
||||
end
|
||||
end
|
||||
|
||||
def ca_code
|
||||
|
@ -2,4 +2,17 @@ class PProductRefSpec < ApplicationRecord
|
||||
belongs_to :p_product_ref
|
||||
belongs_to :p_spec_type
|
||||
belongs_to :p_spec_value
|
||||
|
||||
accepts_nested_attributes_for :p_spec_type, :p_spec_value
|
||||
|
||||
acts_as_sorting :fields => {
|
||||
:id => {:name => "ID"},
|
||||
:p_product_ref => {:name => "Référence produit", :reorder => true},
|
||||
:p_product_ref_id => {:name => "ID Ref produit", :reorder => true},
|
||||
:p_spec_type => {:name => "Type", :reorder => true},
|
||||
:p_spec_value => {:name => "Valeur", :reorder => true},
|
||||
|
||||
:actions => {:name => "Actions", :reorder => true}
|
||||
|
||||
}
|
||||
end
|
||||
|
@ -1,2 +1,5 @@
|
||||
class PSpecType < ApplicationRecord
|
||||
has_many :p_product_ref_specs
|
||||
|
||||
TYPES = ["Ram", "Stockage"]
|
||||
end
|
||||
|
@ -1,2 +1,5 @@
|
||||
class PSpecValue < ApplicationRecord
|
||||
has_many :p_product_ref_specs
|
||||
|
||||
UNITS = ["Go", "Mo"]
|
||||
end
|
||||
|
@ -2,9 +2,12 @@
|
||||
|
||||
.content
|
||||
=f.inputs do
|
||||
= f.input :p_product_ref, :label => f.object.label_for(:p_product_ref)
|
||||
= f.input :p_spec_type, :label => f.object.label_for(:p_spec_type)
|
||||
= f.input :p_spec_value, :label => f.object.label_for(:p_spec_value)
|
||||
= f.input :p_product_ref, as: :select, collection: PProductRef.pluck(:cc_name, :id) ,:label => f.object.label_for(:p_product_ref)
|
||||
= f.semantic_fields_for :p_spec_type do | form |
|
||||
=render :partial => "admin/p_spec_types/form", :locals => {:f => form}
|
||||
= f.semantic_fields_for :p_spec_value do | form |
|
||||
=render :partial => "admin/p_spec_values/form", :locals => {:f => form}
|
||||
/ = f.input :p_spec_value, :label => f.object.label_for(:p_spec_value)
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,20 @@
|
||||
%tr#p_product_ref_spec_row{:id => p_product_ref_spec.id}
|
||||
-tr = {}
|
||||
-tr[:p_product_ref] = capture do
|
||||
%td
|
||||
= p_product_ref_spec.p_product_ref.cc_name
|
||||
|
||||
-tr[:p_product_ref_id] = capture do
|
||||
%td
|
||||
= p_product_ref_spec.p_product_ref.id
|
||||
|
||||
-tr[:p_spec_type] = capture do
|
||||
%td
|
||||
= p_product_ref_spec.p_spec_type.name
|
||||
-tr[:p_spec_value] = capture do
|
||||
%td
|
||||
= p_product_ref_spec.p_spec_value.value
|
||||
= p_product_ref_spec.p_spec_value.unit
|
||||
|
||||
-tr[:actions] = capture do
|
||||
%td.actions
|
||||
|
@ -1,12 +1,2 @@
|
||||
=semantic_form_for [:admin, @p_spec_type], :remote => true do |f|
|
||||
|
||||
.content
|
||||
=f.inputs do
|
||||
= f.input :type, :label => f.object.label_for(:type)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.actions=f.submit "sauvegarder", :class => "btn btn-primary"
|
||||
|
||||
= f.input :name, :label => "Type", as: :select, collection: PSpecType::TYPES
|
||||
|
@ -1,13 +1,3 @@
|
||||
=semantic_form_for [:admin, @p_spec_value], :remote => true do |f|
|
||||
|
||||
.content
|
||||
=f.inputs do
|
||||
= f.input :value, :label => f.object.label_for(:value)
|
||||
= f.input :unit, :label => f.object.label_for(:unit)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.actions=f.submit "sauvegarder", :class => "btn btn-primary"
|
||||
|
||||
= f.input :value, :label => "Valeur"
|
||||
= f.input :unit, :label => "Unité", as: :select, collection: PSpecValue::UNITS
|
||||
|
Reference in New Issue
Block a user