diff --git a/app/models/producer_property.rb b/app/models/producer_property.rb index ac99c88013..178e7646ff 100644 --- a/app/models/producer_property.rb +++ b/app/models/producer_property.rb @@ -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 diff --git a/app/views/admin/producer_properties/_producer_property_fields.html.haml b/app/views/admin/producer_properties/_producer_property_fields.html.haml index 242172d9e0..79dc815f9d 100644 --- a/app/views/admin/producer_properties/_producer_property_fields.html.haml +++ b/app/views/admin/producer_properties/_producer_property_fields.html.haml @@ -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 diff --git a/spec/features/admin/enterprises_spec.rb b/spec/features/admin/enterprises_spec.rb index e07949aeca..8070691302 100644 --- a/spec/features/admin/enterprises_spec.rb +++ b/spec/features/admin/enterprises_spec.rb @@ -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'