Skip to content

Commit

Permalink
Fix properties population when prototype selected and order them by p…
Browse files Browse the repository at this point in the history
…osition rather then alphabetically.

Fixes spree#2389
  • Loading branch information
braincomb authored and radar committed Jan 8, 2013
1 parent 979c57c commit bbfe9b2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
2 changes: 0 additions & 2 deletions core/app/models/spree/property.rb
Expand Up @@ -9,8 +9,6 @@ class Property < ActiveRecord::Base

validates :name, :presentation, :presence => true

scope :sorted, lambda { order(:name) }

def self.find_all_by_prototype(prototype)
id = prototype
if prototype.class == Prototype
Expand Down
2 changes: 1 addition & 1 deletion core/app/views/spree/admin/prototypes/_form.html.erb
Expand Up @@ -11,7 +11,7 @@
<div id='properties' data-hook>
<%= f.field_container :property_ids do %>
<%= f.label :property_ids, t(:properties) %><br>
<%= f.select :property_ids, Spree::Property.sorted.map { |p| [p.presentation, p.id] }, {}, { :multiple => true, :class => "select2 fullwidth" } %>
<%= f.select :property_ids, Spree::Property.all.map { |p| [p.presentation, p.id] }, {}, { :multiple => true, :class => "select2 fullwidth" } %>
<% end %>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions core/app/views/spree/admin/prototypes/select.js.erb
@@ -1,4 +1,4 @@
<% @prototype_properties.each do |prop| %>
<% @prototype_properties.sort_by{ |prop| -prop[:id] }.each do |prop| %>
$("a.add_fields").click();
$(".product_property.fields:last input:first").val("<%= prop.name %>");
$(".product_property.fields:first input:first").val("<%= prop.name %>");
<% end %>

0 comments on commit bbfe9b2

Please sign in to comment.