mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 16:03:47 +01:00
refactor client-side form is not valid/submittable check of submit method into an own method isInvalid()
This commit is contained in:
parent
fb88f8846b
commit
db83cc437c
@ -839,6 +839,38 @@ export class etemplate2
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there is an invalid widget / all widgets are valid
|
||||
*
|
||||
* @param container
|
||||
* @param values
|
||||
* @return et2_widget|null first invalid widget or null, if all are valid
|
||||
*/
|
||||
isInvalid(container : et2_container|undefined, values : object|undefined) : et2_widget|null
|
||||
{
|
||||
if (typeof container === 'undefined')
|
||||
{
|
||||
container = this._widgetContainer;
|
||||
}
|
||||
if (typeof values === 'undefined')
|
||||
{
|
||||
values = this.getValues(container);
|
||||
}
|
||||
let invalid = null;
|
||||
container.iterateOver(function (_widget)
|
||||
{
|
||||
if (_widget.submit(values) === false)
|
||||
{
|
||||
if(!invalid && !_widget.isValid([]))
|
||||
{
|
||||
invalid = _widget;
|
||||
}
|
||||
}
|
||||
}, this, et2_ISubmitListener);
|
||||
|
||||
return invalid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit form via ajax
|
||||
*
|
||||
@ -867,17 +899,7 @@ export class etemplate2
|
||||
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);
|
||||
canSubmit = !(invalid = this.isInvalid(container, values));
|
||||
}
|
||||
|
||||
if (canSubmit)
|
||||
@ -1082,7 +1104,6 @@ export class etemplate2
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* "Intelligently" refresh the template based on the given ID
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user