mirror of
https://github.com/appwrite/appwrite
synced 2026-05-23 17:08:45 +00:00
Reset custom validity before validation check
This commit is contained in:
parent
3da244b3dd
commit
1974c422ce
1 changed files with 16 additions and 9 deletions
|
|
@ -34,15 +34,7 @@
|
|||
});
|
||||
},
|
||||
addPermission(formId, role, permissions) {
|
||||
if (Object.values(permissions).every(p => p === false)) {
|
||||
document.getElementById(`${formId}Input`)
|
||||
.setCustomValidity('No permissions selected');
|
||||
}
|
||||
if (this.permissions.some(p => p.role === role)) {
|
||||
document.getElementById(`${formId}Input`)
|
||||
.setCustomValidity('Role entry already exists');
|
||||
}
|
||||
if (!document.getElementById(formId).reportValidity()) {
|
||||
if (!this.validate(formId, role, permissions)) {
|
||||
return;
|
||||
}
|
||||
Object.entries(permissions).forEach(entry => {
|
||||
|
|
@ -113,6 +105,21 @@
|
|||
return 'delete';
|
||||
}
|
||||
return key;
|
||||
},
|
||||
validate(formId, role, permissions) {
|
||||
const form = document.getElementById(formId);
|
||||
const input = document.getElementById(`${formId}Input`);
|
||||
|
||||
input.setCustomValidity('');
|
||||
|
||||
if (!Object.values(permissions).some(p => p)) {
|
||||
input.setCustomValidity('No permissions selected');
|
||||
}
|
||||
if (this.permissions.some(p => p.role === role)) {
|
||||
input.setCustomValidity('Role entry already exists');
|
||||
}
|
||||
|
||||
return form.reportValidity();
|
||||
}
|
||||
}));
|
||||
Alpine.data('permissionsRow', () => ({
|
||||
|
|
|
|||
Loading…
Reference in a new issue