mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
Validation changes:
- Fix multiplying messages on focus/blur - Server-side (Manual) messages do not block submit. Server set it, we'll let server check it.
This commit is contained in:
parent
e4592e822e
commit
3423e680b8
@ -285,7 +285,17 @@ const Et2InputWidgetMixin = <T extends Constructor<LitElement>>(superclass : T)
|
||||
}
|
||||
|
||||
// Collect any ManualMessages
|
||||
this._messagesHeldWhileFocused = (this.validators || []).filter((validator) => (validator instanceof ManualMessage));
|
||||
this._messagesHeldWhileFocused = (this.validators || []).filter(
|
||||
(validator) => (validator instanceof ManualMessage)
|
||||
);
|
||||
// Remove ManualMessages from validators list
|
||||
for(let i = 0; i < this.validators.length; i++)
|
||||
{
|
||||
if(this._messagesHeldWhileFocused.indexOf(this.validators[i]) != -1)
|
||||
{
|
||||
this.validators.splice(i, 1);
|
||||
}
|
||||
}
|
||||
|
||||
this.updateComplete.then(() =>
|
||||
{
|
||||
@ -501,8 +511,10 @@ const Et2InputWidgetMixin = <T extends Constructor<LitElement>>(superclass : T)
|
||||
*
|
||||
* We handle validation errors from the server with ManualMessages, which always "fail".
|
||||
* If the value is empty, we only validate if the field is required.
|
||||
*
|
||||
* @param skipManual Do not run any manual validators, used during submit check. We don't want manual validators to block submit.
|
||||
*/
|
||||
async validate()
|
||||
async validate(skipManual = false)
|
||||
{
|
||||
if(this.readonly)
|
||||
{
|
||||
@ -563,7 +575,10 @@ const Et2InputWidgetMixin = <T extends Constructor<LitElement>>(superclass : T)
|
||||
// Run manual validation messages just once, doesn't usually matter what the value is
|
||||
if(validator instanceof ManualMessage)
|
||||
{
|
||||
doCheck(values, validator);
|
||||
if(!skipManual)
|
||||
{
|
||||
doCheck(values, validator);
|
||||
}
|
||||
}
|
||||
// Only validate if field is required, or not required and has a value
|
||||
// Don't bother to validate empty fields
|
||||
|
Loading…
Reference in New Issue
Block a user