Merge pull request #4449 from luisramos0/properties

Move properties and product properties from spree_backend to OFN
This commit is contained in:
Luis Ramos
2019-11-15 08:57:32 +00:00
committed by GitHub
9 changed files with 122 additions and 0 deletions

View File

@@ -0,0 +1,19 @@
module Spree
module Admin
class ProductPropertiesController < ResourceController
belongs_to 'spree/product', find_by: :permalink
before_filter :find_properties
before_filter :setup_property, only: [:index]
private
def find_properties
@properties = Spree::Property.pluck(:name)
end
def setup_property
@product.product_properties.build
end
end
end
end

View File

@@ -0,0 +1,6 @@
module Spree
module Admin
class PropertiesController < ResourceController
end
end
end

View File

@@ -0,0 +1,12 @@
module Spree
class Property < ActiveRecord::Base
has_many :product_properties, dependent: :destroy
has_many :products, through: :product_properties
attr_accessible :name, :presentation
validates :name, :presentation, presence: true
scope :sorted, -> { order(:name) }
end
end

View File

@@ -0,0 +1,15 @@
.align-center.row
.alpha.eight.columns
= f.field_container :name do
= f.label :name, t('.name')
%span.required *
%br/
= f.text_field :name, class: 'fullwidth'
= f.error_message_on :name
.eight.columns.omega
= f.field_container :presentation do
= f.label :presentation, t('.presentation')
%span.required *
%br/
= f.text_field :presentation, class: 'fullwidth'
= f.error_message_on :presentation

View File

@@ -0,0 +1,14 @@
= render partial: 'spree/admin/shared/product_sub_menu'
- content_for :page_title do
= t('.editing_property')
- content_for :page_actions do
%li= button_link_to t('.back_to_properties_list'), admin_properties_url, icon: 'icon-arrow-left'
= render partial: 'spree/shared/error_messages', locals: { target: @property }
= form_for [:admin, @property] do |f|
%fieldset.no-border-top
= render partial: 'form', locals: { f: f }
= render partial: 'spree/admin/shared/edit_resource_links'

View File

@@ -0,0 +1,30 @@
- content_for :page_title do
= t('.properties')
- content_for :page_actions do
%li#new_property_link
= button_link_to t('.new_property'), new_admin_property_url, { remote: true, icon: 'icon-plus', 'data-update' => 'new_property', id: 'new_property_link' }
= render partial: 'spree/admin/shared/product_sub_menu'
#new_property
%table#listing_properties.index
%colgroup
%col{style: "width: 45%"}/
%col{style: "width: 45%"}/
%col{style: "width: 10%"}/
%thead
%tr
%th= t('.name')
%th= t('.presentation')
%th.actions
%tbody
- @properties.each do |property|
- tr_class = cycle('odd', 'even')
- tr_id = spree_dom_id(property)
%tr{class: tr_class, id: tr_id}
%td= property.name
%td= property.presentation
%td.actions
= link_to_edit(property, no_text: true)
= link_to_delete(property, no_text: true)

View File

@@ -0,0 +1,10 @@
= render partial: 'spree/admin/shared/product_sub_menu'
= render partial: 'spree/shared/error_messages', locals: { target: @property }
= form_for [:admin, @property] do |f|
%fieldset
%legend{align: "center"}= t('.new_property')
= render partial: 'form', locals: { f: f }
.filter-actions
= render partial: 'spree/admin/shared/new_resource_links'

View File

@@ -0,0 +1,2 @@
$("#new_property").html('<%= escape_javascript(render :template => "spree/admin/properties/new", :formats => [:html], :handlers => [:erb]) %>');
$("#new_property_link").parent().hide();

View File

@@ -2992,6 +2992,20 @@ See the %{link} to find out more about %{sitename}'s features and to start using
inherits_properties_checkbox_hint: "Inherit properties from %{supplier}? (unless overridden above)"
add_product_properties: "Add Product Properties"
select_from_prototype: "Select From Prototype"
properties:
index:
properties: "Properties"
new_property: "New Property"
name: "Name"
presentation: "Presentation"
new:
new_property: "New Property"
edit:
editing_property: "Editing Property"
back_to_properties_list: "Back To Properties List"
form:
name: "Name"
presentation: "Presentation"
orders:
index:
listing_orders: "Listing Orders"