mirror of
https://github.com/nocodb/nocodb.git
synced 2026-05-02 18:07:51 +00:00
fix: initial space causing errors
This commit is contained in:
@@ -31,24 +31,34 @@ const { workspaceRoles } = useRoles()
|
||||
// all user input emails are stored here
|
||||
const emailBadges = ref<Array<string>>([])
|
||||
|
||||
const insertOrUpdateString = (str: string) => {
|
||||
// Check if the string already exists in the array
|
||||
const index = emailBadges.value.indexOf(str)
|
||||
|
||||
if (index !== -1) {
|
||||
// If the string exists, remove it
|
||||
emailBadges.value.splice(index, 1)
|
||||
}
|
||||
|
||||
// Add the new string to the array
|
||||
emailBadges.value.push(str)
|
||||
}
|
||||
|
||||
watch(inviteData, (newVal) => {
|
||||
const isNewEmail = newVal.email.includes(' ') || newVal.email.includes(',')
|
||||
if (isNewEmail) {
|
||||
if (newVal.email.length < 1) {
|
||||
emailValidation.isError = true
|
||||
emailValidation.message = 'EMAIL SHOULD NOT BE EMPTY'
|
||||
return
|
||||
}
|
||||
if (!validateEmail(newVal.email.trim())) {
|
||||
const isNewEmail = newVal.email.charAt(newVal.email.length - 1) === ',' || newVal.email.charAt(newVal.email.length - 1) === ' '
|
||||
if (isNewEmail && newVal.email.trim().length > 1) {
|
||||
const emailToAdd = newVal.email.split(',')[0].trim() || newVal.email.split(' ')[0].trim()
|
||||
if (!validateEmail(emailToAdd)) {
|
||||
emailValidation.isError = true
|
||||
emailValidation.message = 'INVALID EMAIL'
|
||||
return
|
||||
}
|
||||
// if email is already enterd we just ignore the input
|
||||
// no error is thrown
|
||||
const emailToAdd = newVal.email.split(',')[0].trim() || newVal.email.split(' ')[0].trim()
|
||||
|
||||
/**
|
||||
if email is already enterd we delete the already
|
||||
existing email and add new one
|
||||
**/
|
||||
if (emailBadges.value.includes(emailToAdd)) {
|
||||
insertOrUpdateString(emailToAdd)
|
||||
inviteData.email = ''
|
||||
return
|
||||
}
|
||||
@@ -139,9 +149,12 @@ const onPaste = (e: ClipboardEvent) => {
|
||||
emailValidation.message = 'INVALID EMAIL'
|
||||
return
|
||||
}
|
||||
// if email is already enterd we just ignore the input
|
||||
// no error is thrown
|
||||
/**
|
||||
if email is already enterd we delete the already
|
||||
existing email and add new one
|
||||
**/
|
||||
if (emailBadges.value.includes(el)) {
|
||||
insertOrUpdateString(el)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user