Merge remote-tracking branch 'origin/rails3'

Conflicts:
	Gemfile
	Gemfile.lock
This commit is contained in:
Manuel Wiedenmann 2013-06-10 01:53:31 +02:00
commit 7a63394dac
6 changed files with 22 additions and 10 deletions

View file

@ -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 {

View file

@ -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

View file

@ -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

View file

@ -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