frontend validation of team members limitation

This commit is contained in:
Čarodej
2021-11-26 16:44:23 +01:00
parent 459087337c
commit 8456aaf01e
6 changed files with 119 additions and 26 deletions

View File

@@ -192,30 +192,23 @@
})
},
addMember() {
let email = this.email.match(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)[0]
if (!email) {
if (this.$isInvalidEmail(this.email)) {
this.$refs.teamFolderForm.setErrors({
'Email': this.$t("You have to type valid email")
});
return
return;
}
// Get team folder limitations
let limit = this.user.data.meta.limitations.max_team_members
if (limit.percentage >= 100 && ! limit.meta.allowed_emails.includes(email)) {
if ( this.$cantInviteMember(this.email, this.invitations) ) {
this.$refs.teamFolderForm.setErrors({
'Email': this.$t("You have to upgrade your account to add this new member.")
});
return
return;
}
this.$refs.teamFolderForm.reset()
this.invitations.push({
this.invitations.unshift({
type: 'invitation',
email: this.email,
permission: 'can-edit',
@@ -250,6 +243,10 @@
this.invitations = []
}, 150)
})
console.log(
);
}
}
</script>

View File

@@ -153,28 +153,23 @@
})
},
addMember() {
let email = this.email.match(/^[^\s@]+@[^\s@]+\.[^\s@]+$/)[0]
if (!email) {
if (this.$isInvalidEmail(this.email)) {
this.$refs.teamFolderForm.setErrors({
'Email': this.$t("You have to type valid email")
});
return;
}
// Get team folder limitations
let limit = this.user.data.meta.limitations.max_team_members
if (limit.percentage >= 100 && ! limit.meta.allowed_emails.includes(email)) {
if ( this.$cantInviteMember(this.email, this.invitations) ) {
this.$refs.teamFolderForm.setErrors({
'Email': this.$t("You have to upgrade your account to add this new member.")
});
return
return;
}
this.$refs.teamFolderForm.reset()
this.invitations.push({
this.invitations.unshift({
type: 'invitation',
email: this.email,
permission: 'can-edit',