Etemplate: switch to tab of first invalid input, not last

This commit is contained in:
nathangray 2021-05-05 10:09:31 -06:00
parent 47c7570862
commit d367da6ba8
2 changed files with 22 additions and 0 deletions

View File

@ -675,9 +675,13 @@ var etemplate2 = /** @class */ (function () {
var values = this.getValues(container);
// Trigger the submit event
var canSubmit = true;
var invalid = null;
if (!no_validation) {
container.iterateOver(function (_widget) {
if (_widget.submit(values) === false) {
if (!invalid && !_widget.isValid()) {
invalid = _widget;
}
canSubmit = false;
}
}, this, et2_ISubmitListener);
@ -704,6 +708,12 @@ var etemplate2 = /** @class */ (function () {
this._widgetContainer.egw().debug("warn", "Missing menuaction for submit. Values: ", values);
}
}
else if (invalid !== null) {
// Show the first invalid widget, not the last
var messages = [];
var valid = invalid.isValid(messages);
invalid.set_validation_error(messages);
}
return canSubmit;
};
/**

View File

@ -858,12 +858,17 @@ export class etemplate2
// Trigger the submit event
let canSubmit = true;
let invalid = null;
if (!no_validation)
{
container.iterateOver(function (_widget)
{
if (_widget.submit(values) === false)
{
if(!invalid && !_widget.isValid())
{
invalid = _widget;
}
canSubmit = false;
}
}, this, et2_ISubmitListener);
@ -900,6 +905,13 @@ export class etemplate2
this._widgetContainer.egw().debug("warn", "Missing menuaction for submit. Values: ", values);
}
}
else if (invalid !== null)
{
// Show the first invalid widget, not the last
let messages = [];
let valid = invalid.isValid(messages);
invalid.set_validation_error(messages);
}
return canSubmit;
}