From 41ff11f03721309b6a0293e01a96cfdafd38bcf6 Mon Sep 17 00:00:00 2001 From: sreehari jayaraj Date: Fri, 22 Sep 2023 15:26:15 +0000 Subject: [PATCH] feat: added badge creation on space --- .../components/project/InviteProjectCollabSection.vue | 8 ++++---- .../nc-gui/components/workspace/InviteSection.vue | 11 ++++++----- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/packages/nc-gui/components/project/InviteProjectCollabSection.vue b/packages/nc-gui/components/project/InviteProjectCollabSection.vue index 9c232409f4..6efedf9f69 100644 --- a/packages/nc-gui/components/project/InviteProjectCollabSection.vue +++ b/packages/nc-gui/components/project/InviteProjectCollabSection.vue @@ -26,7 +26,7 @@ const validateEmail = (email: string): boolean => { // all user input emails are stored here const emailBadges = ref>([]) watch(inviteData, (newVal) => { - if (newVal.email.includes(',')) { + if (newVal.email.includes(' ' || ',')) { if (inviteData.email.length < 1) { emailValidation.isError = true emailValidation.message = 'email should not be empty' @@ -39,11 +39,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])) { + if (emailBadges.value.includes(newVal.email.split(' ' || ',')[0])) { inviteData.email = '' return } - const emailToAdd = newVal.email.split(',')[0].trim() + const emailToAdd = newVal.email.split(' ' || ',')[0].trim() emailBadges.value.push(emailToAdd) inviteData.email = '' } @@ -159,7 +159,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(' ' || ',') inputArray?.forEach((el) => { if (el.length < 1) { emailValidation.isError = true diff --git a/packages/nc-gui/components/workspace/InviteSection.vue b/packages/nc-gui/components/workspace/InviteSection.vue index 7e67a6a862..b22e2f97d6 100644 --- a/packages/nc-gui/components/workspace/InviteSection.vue +++ b/packages/nc-gui/components/workspace/InviteSection.vue @@ -32,7 +32,7 @@ const { workspaceRoles } = useRoles() const emailBadges = ref>([]) watch(inviteData, (newVal) => { - if (newVal.email.includes(',')) { + if (newVal.email.includes(' ' || ',')) { if (newVal.email.length < 1) { emailValidation.isError = true emailValidation.message = 'EMAIL SHOULD NOT BE EMPTY' @@ -45,13 +45,14 @@ 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])) { + if (emailBadges.value.includes(inviteData.email.split(' ' || ',')[0])) { inviteData.email = '' return } - if (newVal.email.includes(',')) { - const emailToAdd = newVal.email.split(',')[0].trim() + if (newVal.email.includes(' ' || ',')) { + const emailToAdd = newVal.email.split(' ' || ',')[0].trim() + console.log(emailToAdd) emailBadges.value.push(emailToAdd) inviteData.email = '' } @@ -128,7 +129,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(' ' || ',') inputArray?.forEach((el) => { if (el.length < 1) { emailValidation.isError = true