Browse Source

feat: added support for space in email invite

pull/6441/head
sreehari jayaraj 1 year ago
parent
commit
e33cc96a15
  1. 11
      packages/nc-gui/components/project/InviteProjectCollabSection.vue
  2. 14
      packages/nc-gui/components/workspace/InviteSection.vue

11
packages/nc-gui/components/project/InviteProjectCollabSection.vue

@ -26,7 +26,8 @@ const validateEmail = (email: string): boolean => {
// all user input emails are stored here
const emailBadges = ref<Array<string>>([])
watch(inviteData, (newVal) => {
if (newVal.email.includes(' ')) {
const isNewEmail = newVal.email.includes(' ') || newVal.email.includes(',')
if (isNewEmail) {
if (inviteData.email.length < 1) {
emailValidation.isError = true
emailValidation.message = 'email should not be empty'
@ -39,11 +40,11 @@ watch(inviteData, (newVal) => {
}
// if email is already enterd we just ignore the input
// no error is thrown
if (emailBadges.value.includes(newVal.email.split(' ')[0])) {
const emailToAdd = newVal.email.split(',')[0].trim() || newVal.email.split(' ')[0].trim()
if (emailBadges.value.includes(emailToAdd)) {
inviteData.email = ''
return
}
const emailToAdd = newVal.email.split(' ')[0].trim()
emailBadges.value.push(emailToAdd)
inviteData.email = ''
}
@ -167,7 +168,7 @@ onKeyStroke('Backspace', () => {
// when bulk email is pasted
const onPaste = (e: ClipboardEvent) => {
const pastedText = e.clipboardData?.getData('text')
const inputArray = pastedText?.split(' ')
const inputArray = pastedText?.split(',') || pastedText?.split(' ')
inputArray?.forEach((el) => {
if (el.length < 1) {
emailValidation.isError = true
@ -287,7 +288,7 @@ const onPaste = (e: ClipboardEvent) => {
<a-button
type="primary"
class="!rounded-md"
:disabled="!inviteData.email?.length || isInvitingCollaborators"
:disabled="!emailBadges.length || isInvitingCollaborators || emailValidation.isErro"
@click="inviteCollaborator"
>
<div class="flex flex-row items-center gap-x-2 pr-1">

14
packages/nc-gui/components/workspace/InviteSection.vue

@ -32,7 +32,8 @@ const { workspaceRoles } = useRoles()
const emailBadges = ref<Array<string>>([])
watch(inviteData, (newVal) => {
if (newVal.email.includes(' ')) {
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'
@ -45,18 +46,15 @@ watch(inviteData, (newVal) => {
}
// if email is already enterd we just ignore the input
// no error is thrown
if (emailBadges.value.includes(inviteData.email.split(' ')[0])) {
const emailToAdd = newVal.email.split(',')[0].trim() || newVal.email.split(' ')[0].trim()
if (emailBadges.value.includes(emailToAdd)) {
inviteData.email = ''
return
}
if (newVal.email.includes(' ')) {
const emailToAdd = newVal.email.split(' ')[0].trim()
console.log(emailToAdd)
emailBadges.value.push(emailToAdd)
inviteData.email = ''
}
}
if (newVal.email.length < 1 && emailValidation.isError) {
emailValidation.isError = false
}
@ -129,7 +127,7 @@ onKeyStroke('Backspace', () => {
// when bulk email is pasted
const onPaste = (e: ClipboardEvent) => {
const pastedText = e.clipboardData?.getData('text')
const inputArray = pastedText?.split(' ')
const inputArray = pastedText?.split(',') || pastedText?.split(' ')
inputArray?.forEach((el) => {
if (el.length < 1) {
emailValidation.isError = true

Loading…
Cancel
Save