From e888f65b4dc06c427bb1db9e276ede31dfad24fb Mon Sep 17 00:00:00 2001 From: George Stephanis Date: Thu, 13 Aug 2015 11:59:34 -0400 Subject: [PATCH] Simplify how we're tracking single value changes as well. --- .../js/admin/settings-views-html-settings-tax.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/assets/js/admin/settings-views-html-settings-tax.js b/assets/js/admin/settings-views-html-settings-tax.js index 71e71e40966..1c0acd89992 100644 --- a/assets/js/admin/settings-views-html-settings-tax.js +++ b/assets/js/admin/settings-views-html-settings-tax.js @@ -23,17 +23,16 @@ WCTaxTableModelConstructor = Backbone.Model.extend({ changes : {}, setRateAttribute : function( rateID, attribute, value ) { - var rates = _.indexBy( this.get( 'rates' ), 'tax_rate_id' ); + var rates = _.indexBy( this.get( 'rates' ), 'tax_rate_id' ), + changes = {}; if ( rates[ rateID ][ attribute ] !== value ) { - rates[ rateID ][ attribute ] = value; - this.set( 'rates', rates ); - this.trigger( 'change:rates' ); // Why is this necessary? Shouldn't the previous line trigger it? - - // Store it in a changes array to potentially simplify saving? - this.changes[ rateID ] = this.changes[ rateID ] || {}; - this.changes[ rateID ][ attribute ] = value; + changes[ rateID ] = {}; + changes[ rateID ][ attribute ] = value; + rates[ rateID ][ attribute ] = value; } + + this.logChanges( changes ); }, logChanges : function( changedRows ) { var changes = this.changes || {};