Commit 1ed2385e authored by KR Moorhouse's avatar KR Moorhouse

Resolved merge conflicts.

parents fe8fa77f 36f3275f
......@@ -335,7 +335,22 @@ define(['models/calcCollection'], function( CalcCollection ) {
var that = this;
if ( 'undefined' != typeof this.displayFields[ calcModel.get( 'name' ) ] ) {
_.each( this.displayFields[ calcModel.get( 'name' ) ], function( fieldModel ) {
var value = fieldModel.get( 'default' );
var value = fieldModel.get( 'value' );
/*
This is a fix for the issue of the merge tags being
display'd
*/
// Find spans with calc data-key values
var spans = value.match( new RegExp( /<span data-key="calc:(.*?)<\/span>/g ));
_.each( spans, function( spanVar ) {
// transform the span back into a merge tag
var tmpCalcTag = "{" + spanVar.replace("<span" +
" data-key=\"", "" ).replace( /">(.*?)<\/span>/, "" ) + "}";
value = value.replace( spanVar, tmpCalcTag );
} );
var calcs = value.match( new RegExp( /{calc:(.*?)}/g ) );
_.each( calcs, function( calc ) {
// var rounding = false;
......@@ -361,7 +376,13 @@ define(['models/calcCollection'], function( CalcCollection ) {
if( 'undefined' != typeof( calcValue ) ) {
calcValue = that.applyLocaleFormatting( calcValue );
}
value = value.replace( re, calcValue );
/*
* We replace the merge tag with the value
* surrounded by a span so that we can still find it
* and not affect itself or other field merge tags
*/
value = value.replace( re, "<span data-key=\"calc:" + name + "\">"
+ calcValue + "</span>" );
} );
fieldModel.set( 'value', value );
if ( ! that.init[ calcModel.get( 'name' ) ] ) {
......
......@@ -34,10 +34,31 @@ define([], function() {
updateFieldMergeTags: function( fieldModel ) {
_.each( this.htmlFields, function( htmlFieldModel ){
var value = htmlFieldModel.get( 'default' );
var value = htmlFieldModel.get( 'value' );
_.each( this.trackedMergeTags, function( fieldModel ){
/* Search the value for any spans with mergetag data-key
* values
*/
var spans = value.match( new RegExp( /<span data-key="field:(.*?)<\/span>/g ) );
_.each( spans, function( spanVar ) {
/* See if the span string contains the current
* fieldModel's key. If so replace the span with a
* merge tag for evaluation.
*/
if( -1 < spanVar.indexOf( "data-key=\"field:" + fieldModel.get( 'key' ) ) ) {
value = value.replace( spanVar, "{field:" + fieldModel.get( 'key' ) + "}" );
}
} );
var mergeTag = '{field:' + fieldModel.get( 'key' ) + '}';
value = value.replace( mergeTag, fieldModel.get( 'value' ) );
/* We replace the merge tag with the value
* surrounded by a span so that we can still find it
* and not affect itself or other field merge tags
*/
value = value.replace( mergeTag, "<span data-key=\"field:"
+ fieldModel.get( 'key' ) + "\">"
+ fieldModel.get( 'value' ) + "</span>" );
}, this ) ;
htmlFieldModel.set( 'value', value );
htmlFieldModel.trigger( 'reRender' );
......
File mode changed from 100644 to 100755
File mode changed from 100755 to 100644
File mode changed from 100644 to 100755
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
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