Fix not working subtraction option for infolog-value widget

This commit is contained in:
Hadi Nategh 2016-01-08 13:35:35 +00:00
parent dc2b48c43f
commit e8bc6dcd19
2 changed files with 14 additions and 2 deletions

View File

@ -45,7 +45,7 @@ var et2_entry = et2_valueWidget.extend(
},
alternate_fields: {
name: 'Alternate fields',
description: 'colon (:) separated list of alternative fields. The first non-empty one is used if the selected field is empty',
description: 'colon (:) separated list of alternative fields. The first non-empty one is used if the selected field is empty, (-) used for subtraction',
type: 'string',
default: et2_no_init
},
@ -134,7 +134,8 @@ var et2_entry = et2_valueWidget.extend(
var fields = this.options.alternate_fields.split(':');
for(var i = 0; i < fields.length; i++)
{
var value = this.getArrayMgr('content').getEntry(fields[i]);
var value = (fields[i][0] == "-")? this.getArrayMgr('content').getEntry(fields[i].replace('-',''))*-1:
this.getArrayMgr('content').getEntry(fields[i]);
sum += parseFloat(value);
if(value && this.options.field !== 'sum')
{

View File

@ -10,6 +10,17 @@
* @version $Id$
*/
/**
* Infolog widget et2 representation:
* Both infolog-value and infolog-fields widgets are using client-side et2_widget_entry
* and the format to address them in template is as follows:
*
* <infolog-value id="fieldname" or value="@fieldname"
* options="[field(e.g. sum), compare, alternate_fields(e.g. (-)#customfileds, use '-' if we need subtraction)]"
* />
*
*/
/**
* eTemplate extension: InfoLog widget
*