Commit 621300fb authored by KR Moorhouse's avatar KR Moorhouse Committed by Kenny Hall

Added radio listener for reset of fieldCollection into calculations to prevent...

Added radio listener for reset of fieldCollection into calculations to prevent breakdown of merge tags when save progress is active. Added string cast into decimal trim function to prevent uncaught errors of trim function call on a non-string value. (#3121)
parent 9471b5b4
......@@ -8,6 +8,9 @@ define(['models/calcCollection'], function( CalcCollection ) {
this.displayFields = {};
// When our form initialises, check to see if there are any calculations that need to be tracked.
this.listenTo( nfRadio.channel( 'form' ), 'loaded', this.registerCalcs );
// When our collection gets reset, reset calculation tracking as well.
this.listenTo( nfRadio.channel( 'fields' ), 'reset:collection', this.resetCalcs );
// When a calc model is initialised, run a setup function.
// this.listenTo( nfRadio.channel( 'calc' ), 'init:model', this.setupCalc );
......@@ -33,6 +36,19 @@ define(['models/calcCollection'], function( CalcCollection ) {
// Set an init variable so that we only call reRender on the display field on change, not on init.
this.init = {};
},
/**
* Passthrough function to reset tracking of calculations when the fieldCollection is reset.
*
* @since 3.2
* @param backbone.collection fieldCollection
* @return void
*/
resetCalcs: function( fieldCollection ) {
if( 'undefined' != typeof( fieldCollection.options.formModel ) ) {
this.registerCalcs( fieldCollection.options.formModel );
}
},
/**
* When our form loads, create a collection out of any calculations.
......
......@@ -7,7 +7,7 @@ define( ['models/calcModel'], function( CalcModel ) {
this.options = options;
_.each( models, function( model ) {
if( 'undefined' == typeof model.dec ) return;
if ( '' === model.dec.trim() ) model.dec = 2;
if ( '' === model.dec.toString().trim() ) model.dec = 2;
model.dec = parseInt( model.dec );
} );
/*
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment