mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-08 00:54:15 +01:00
Et2Select: Fix manual message was repeated for each selected value. Once is enough.
This commit is contained in:
parent
6eed7b5a0e
commit
523c785049
@ -18,6 +18,7 @@ import {Et2WithSearchMixin} from "./SearchMixin";
|
||||
import {Et2Tag} from "./Tag/Et2Tag";
|
||||
import {LionValidationFeedback} from "@lion/form-core";
|
||||
import {RowLimitedMixin} from "../Layout/RowLimitedMixin";
|
||||
import {ManualMessage} from "../Validators/ManualMessage";
|
||||
|
||||
// export Et2WidgetWithSelect which is used as type in other modules
|
||||
export class Et2WidgetWithSelect extends RowLimitedMixin(Et2widgetWithSelectMixin(SlSelect))
|
||||
@ -441,6 +442,7 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
|
||||
let validators = [...(this.validators || []), ...(this.defaultValidators || [])];
|
||||
let fieldName = this.id;
|
||||
let feedbackData = [];
|
||||
let resultPromises = [];
|
||||
this.querySelector("lion-validation-feedback")?.remove();
|
||||
const doValidate = async function(validator, value)
|
||||
{
|
||||
@ -458,19 +460,7 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
|
||||
feedbackData.push({message, type: validator.type, validator});
|
||||
});
|
||||
}.bind(this);
|
||||
let resultPromises = [];
|
||||
validators.map(async validator =>
|
||||
{
|
||||
let values = this.value;
|
||||
if(!Array.isArray(values))
|
||||
{
|
||||
values = [values];
|
||||
}
|
||||
if(!values.length)
|
||||
{
|
||||
values = [''];
|
||||
} // so required validation works
|
||||
values.forEach(async value =>
|
||||
const doCheck = async(value, validator) =>
|
||||
{
|
||||
const result = validator.execute(value, validator.param, {node: this});
|
||||
if(result === true)
|
||||
@ -482,7 +472,30 @@ export class Et2Select extends Et2WithSearchMixin(Et2WidgetWithSelect)
|
||||
result.then(doValidate(validator, value));
|
||||
resultPromises.push(result);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
validators.map(async validator =>
|
||||
{
|
||||
let values = this.value;
|
||||
if(!Array.isArray(values))
|
||||
{
|
||||
values = [values];
|
||||
}
|
||||
if(!values.length)
|
||||
{
|
||||
values = [''];
|
||||
} // so required validation works
|
||||
|
||||
// Run manual validation messages just once, doesn't usually matter what the value is
|
||||
if(validator instanceof ManualMessage)
|
||||
{
|
||||
doCheck(values, validator);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Validate each individual item
|
||||
values.forEach((value) => doCheck(value, validator));
|
||||
}
|
||||
});
|
||||
await Promise.all(resultPromises);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user