fixing the fix

there is probably a nicer solution to let the calling widget know that getValues() is running
triggering a custom event won't help, as getValues() is not async and can't be made to wait for the widget handling the event
This commit is contained in:
ralf 2024-02-05 16:19:12 +02:00
parent 639c8748ca
commit 512b0bd4e6
3 changed files with 17 additions and 14 deletions

View File

@ -547,7 +547,7 @@ export class et2_htmlarea extends et2_editableWidget implements et2_IResizeable
{
// are we called by etemplate2.getValues() (has a closure result)
// not always setting it, as getValue() is called a lot, e.g. to test input is dirty
if (this.options.applyDefaultFont && typeof result !== 'undefined')
if (this.options.applyDefaultFont && this.getInstanceManager().get_values)
{
this.applyDefaultFont();
}

View File

@ -1220,15 +1220,23 @@ export class etemplate2
}
}
/**
* Flag that getValues() is running
*/
get_values = false;
/**
* Fetches all input element values and returns them in an associative
* array. Widgets which introduce namespacing can use the internal _target
* parameter to add another layer.
*
* @param {et2_widget} _root widget to start iterating
* @param {boolean} skip_reset_dirty true: do NOT reset dirty status
*/
getValues(_root : et2_widget)
getValues(_root : et2_widget, skip_reset_dirty : boolean)
{
this.get_values = true;
const result = {};
// Iterate over the widget tree
@ -1324,10 +1332,15 @@ export class etemplate2
}
delete _target[path[path.length - 1]];
}
_widget.resetDirty();
if (!skip_reset_dirty)
{
_widget.resetDirty();
}
}, this, et2_IInput);
this.get_values = false;
egw().debug("info", "Value", result);
return result;
}

View File

@ -4059,17 +4059,7 @@ app.classes.mail = AppJS.extend(
action = _egw_action.id;
}
var widgets = ['from','to','cc','bcc','subject','folder','replyto','mailaccount',
'mail_htmltext', 'mail_plaintext', 'lastDrafted', 'filemode', 'expiration', 'password'];
var widget = {};
for (var index in widgets)
{
widget = self.et2.getWidgetById(widgets[index]);
if (widget)
{
content[widgets[index]] = widget.get_value();
}
}
Object.assign(content, self.et2.getInstanceManager().getValues(self.et2, true));
if (content)
{