diff --git a/Gemfile b/Gemfile index 27656419..f6d953c5 100644 --- a/Gemfile +++ b/Gemfile @@ -65,4 +65,6 @@ group :development do gem 'capistrano', '2.13.5' gem 'capistrano-ext' #gem 'common_deploy', require: false, path: '../../common_deploy' # pending foodcoops/foodsoft#34, git: 'git://github.com/fsmanuel/common_deploy.git' + # Avoid having content-length warnings + gem 'thin' end diff --git a/Gemfile.lock b/Gemfile.lock index 15fcef07..79296224 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -80,7 +80,7 @@ GEM commonjs (0.2.6) daemons (1.1.9) erubis (2.7.0) - eventmachine (1.0.0) + eventmachine (1.0.3) exception_notification (2.6.1) actionmailer (>= 3.0.4) execjs (1.4.0) @@ -288,6 +288,7 @@ DEPENDENCIES sqlite3 test-unit therubyracer + thin twitter-bootstrap-rails uglifier (>= 1.0.3) whenever diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index df0ebc2f..04098d88 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -35,11 +35,14 @@ $(function() { // Check/Uncheck all checkboxes for a specific form $('input[data-check-all]').live('click', function() { - var status = $(this).is(':checked') - $($(this).data('check-all')).find('input[type="checkbox"]').each(function() { - $(this).attr('checked', status); - highlightRow($(this)); - }); + var status = $(this).is(':checked'); + var context = $(this).data('check-all'); + var elms = $('input[type="checkbox"]', context); + for(i=elms.length-1; i>=0; --i) { // performance can be an issue here, so use native loop + var elm = elms[i]; + elm.checked = status; + highlightRow($(elm)); + } }); // Submit form when changing a select menu. @@ -102,7 +105,7 @@ $(function() { // gives the row an yellow background function highlightRow(checkbox) { - var row = checkbox.parents('tr'); + var row = checkbox.closest('tr'); if (checkbox.is(':checked')) { row.addClass('selected'); } else { diff --git a/app/controllers/suppliers_controller.rb b/app/controllers/suppliers_controller.rb index 7d234a20..088243f8 100644 --- a/app/controllers/suppliers_controller.rb +++ b/app/controllers/suppliers_controller.rb @@ -18,7 +18,7 @@ class SuppliersController < ApplicationController def new if params[:shared_supplier_id] shared_supplier = SharedSupplier.find(params[:shared_supplier_id]) - @supplier = shared_supplier.build_supplier(shared_supplier.attributes) + @supplier = shared_supplier.build_supplier(shared_supplier.autofill_attributes) else @supplier = Supplier.new end diff --git a/app/helpers/deliveries_helper.rb b/app/helpers/deliveries_helper.rb index 3682430e..6780479b 100644 --- a/app/helpers/deliveries_helper.rb +++ b/app/helpers/deliveries_helper.rb @@ -11,7 +11,7 @@ module DeliveriesHelper end def stock_articles_for_select(supplier) - supplier.stock_articles.undeleted.map {|a| ["#{a.name} (#{number_to_currency a.price}/#{a.unit})", a.id] } + supplier.stock_articles.undeleted.reorder('articles.name ASC').map {|a| ["#{a.name} (#{number_to_currency a.price}/#{a.unit})", a.id] } end end diff --git a/app/models/shared_supplier.rb b/app/models/shared_supplier.rb index fa1e582a..04eb290c 100644 --- a/app/models/shared_supplier.rb +++ b/app/models/shared_supplier.rb @@ -7,6 +7,12 @@ class SharedSupplier < ActiveRecord::Base has_one :supplier has_many :shared_articles, :foreign_key => :supplier_id - + + # These set of attributes are used to autofill attributes of new supplier, + # when created by import from shared supplier feature. + def autofill_attributes + whitelist = %w(name address phone fax email url delivery_days note) + attributes.select { |k,_v| whitelist.include?(k) } + end end