mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Can add an image from redesigned new product page
This commit is contained in:
@@ -4,7 +4,6 @@ Spree::Product.class_eval do
|
||||
# https://github.com/rails/rails/issues/7618
|
||||
has_many :option_types, :through => :product_option_types, :dependent => :destroy
|
||||
|
||||
|
||||
belongs_to :supplier, :class_name => 'Enterprise'
|
||||
|
||||
has_many :product_distributions, :dependent => :destroy
|
||||
@@ -12,8 +11,9 @@ Spree::Product.class_eval do
|
||||
|
||||
accepts_nested_attributes_for :product_distributions, :allow_destroy => true
|
||||
delegate_belongs_to :master, :unit_value, :unit_description
|
||||
delegate :images_attributes=, to: :master
|
||||
|
||||
attr_accessible :supplier_id, :distributor_ids, :product_distributions_attributes, :group_buy, :group_buy_unit_size, :variant_unit, :variant_unit_scale, :variant_unit_name, :unit_value, :unit_description, :notes
|
||||
attr_accessible :supplier_id, :distributor_ids, :product_distributions_attributes, :group_buy, :group_buy_unit_size, :variant_unit, :variant_unit_scale, :variant_unit_name, :unit_value, :unit_description, :notes, :images_attributes
|
||||
|
||||
validates_presence_of :supplier
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@ Spree::Variant.class_eval do
|
||||
has_many :exchange_variants, dependent: :destroy
|
||||
has_many :exchanges, through: :exchange_variants
|
||||
|
||||
attr_accessible :unit_value, :unit_description
|
||||
attr_accessible :unit_value, :unit_description, :images_attributes
|
||||
accepts_nested_attributes_for :images
|
||||
|
||||
validates_presence_of :unit_value,
|
||||
if: -> v { %w(weight volume).include? v.product.variant_unit },
|
||||
|
||||
@@ -66,7 +66,8 @@
|
||||
.row
|
||||
= image_tag "noimage/product.png", class: "four columns alpha"
|
||||
.row
|
||||
= button "Select An image"
|
||||
= f.fields_for 'images_attributes[]', f.object.images.build do |image_fields|
|
||||
= image_fields.file_field :attachment
|
||||
.sixteen.columns.alpha
|
||||
.form-buttons.filter-actions.actions{ 'data-hook' => "buttons" }
|
||||
= button t('actions.create'), 'icon-ok', :submit, value: "create"
|
||||
@@ -78,8 +79,6 @@
|
||||
= link_to_with_icon 'icon-remove', t('actions.cancel'), collection_url, :class => 'button'
|
||||
|
||||
|
||||
|
||||
|
||||
:javascript
|
||||
angular.element(document.getElementById("new_product")).ready(function() {
|
||||
angular.bootstrap(document.getElementById("new_product"), ['admin.products']);
|
||||
|
||||
Reference in New Issue
Block a user