Admin can reorder producer properties

This commit is contained in:
Rohan Mitchell
2014-06-18 15:10:46 +10:00
parent 27fa93dbb4
commit e6674d43fa
3 changed files with 6 additions and 2 deletions

View File

@@ -1,6 +1,9 @@
class ProducerProperty < ActiveRecord::Base
belongs_to :property, class_name: 'Spree::Property'
default_scope order("#{self.table_name}.position")
def property_name
property.name if property
end

View File

@@ -1,4 +1,5 @@
%tr.product_property.fields{"data-hook" => "producer_property", id: "#{dom_id(f.object)}"}
-# admin/admin.js.erb in spree requires id to start with "spree_" for sortable tables
%tr.product_property.fields{"data-hook" => "producer_property", id: "spree_#{dom_id(f.object)}"}
%td.no-border
%span.handle
= f.hidden_field :id

View File

@@ -218,7 +218,7 @@ feature %q{
# And I remove the property
page.should have_field 'enterprise_producer_properties_attributes_0_property_name', with: 'Certified Organic'
within("#producer_property_#{pp.id}") { page.find('a.remove_fields').click }
within("#spree_producer_property_#{pp.id}") { page.find('a.remove_fields').click }
# Then the property should have been removed
page.should_not have_field 'enterprise_producer_properties_attributes_0_property_name', with: 'Certified Organic'