From 15cf0ca1ff926e93032f2dbc6e14a25088c3af00 Mon Sep 17 00:00:00 2001 From: nathan Date: Thu, 13 Jul 2023 10:38:58 -0600 Subject: [PATCH] Api: Fix et2_widget_entry sum & compare Options property is deprecated for webComponents, and cannot be changed. --- api/js/etemplate/et2_widget_entry.ts | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/api/js/etemplate/et2_widget_entry.ts b/api/js/etemplate/et2_widget_entry.ts index b4eb0ba9a5..1932488b02 100644 --- a/api/js/etemplate/et2_widget_entry.ts +++ b/api/js/etemplate/et2_widget_entry.ts @@ -148,16 +148,16 @@ export class et2_entry extends et2_valueWidget // If value was set, find the record explicitly. if(typeof this.options.value == 'string') { - widget.options.value = this.getArrayMgr('content').getEntry(this.id+'['+this.options.field+']') || - this.getRoot().getArrayMgr('content').getEntry(et2_entry.prefix+this.options.value + '['+this.options.field+']'); + widget.value = this.getArrayMgr('content').getEntry(this.id + '[' + this.options.field + ']') || + this.getRoot().getArrayMgr('content').getEntry(et2_entry.prefix + this.options.value + '[' + this.options.field + ']'); } else if (this.options.field && this.options.value && this.options.value[this.options.field]) { - widget.options.value = this.options.value[this.options.field]; + widget.value = this.options.value[this.options.field]; } if(this.options.compare) { - widget.options.value = widget.options.value == this.options.compare ? 'X' : ''; + widget.value = widget.options.value == this.options.compare ? 'X' : ''; } if(this.options.alternate_fields) { @@ -170,14 +170,24 @@ export class et2_entry extends et2_valueWidget sum += typeof value === 'undefined' ? 0 : (parseFloat(value) * (negate ? -1 : 1)); if(value && this.options.field !== 'sum') { - widget.options.value = value; + widget.value = value; break; } } if(this.options.field == 'sum') { - if (this.options.precision && jQuery.isNumeric(sum)) sum = parseFloat(sum).toFixed(this.options.precision); - widget.options.value = sum; + if(this.options.precision && !isNaN(sum)) + { + sum = parseFloat(sum).toFixed(this.options.precision); + } + // use decimal separator from user prefs + const format = this.egw().preference('number_format'); + const sep = format ? format[0] : '.'; + if(typeof sum === 'string' && format && sep && sep !== '.') + { + sum = sum.replace('.', sep); + } + widget.value = sum; } } }