Browse Source

fix: reorder of input and refactor

pull/6441/head
sreehari jayaraj 1 year ago
parent
commit
00dbe012b7
  1. 8
      packages/nc-gui/components/workspace/CollaboratorsList.vue
  2. 42
      packages/nc-gui/components/workspace/InviteSection.vue

8
packages/nc-gui/components/workspace/CollaboratorsList.vue

@ -44,16 +44,16 @@ onMounted(async () => {
<template> <template>
<div class="nc-collaborator-table-container mt-4 mx-6"> <div class="nc-collaborator-table-container mt-4 mx-6">
<WorkspaceInviteSection v-if="workspaceRoles !== WorkspaceUserRoles.VIEWER" /> <!-- <div class="w-full h-1 border-t-1 border-gray-100 opacity-50 mt-6"></div> -->
<div class="w-full h-1 border-t-1 border-gray-100 opacity-50 mt-6"></div> <div class="w-full flex justify-between items-baseline mt-6.5 mb-2 pr-0.25 ml-2">
<div class="w-full flex flex-row justify-between items-baseline mt-6.5 mb-2 pr-0.25 ml-2"> <div class="text-xl">Invite Members By Email</div>
<div class="text-xl">Members</div>
<a-input v-model:value="userSearchText" class="!max-w-90 !rounded-md mr-4" placeholder="Search members"> <a-input v-model:value="userSearchText" class="!max-w-90 !rounded-md mr-4" placeholder="Search members">
<template #prefix> <template #prefix>
<PhMagnifyingGlassBold class="!h-3.5 text-gray-500" /> <PhMagnifyingGlassBold class="!h-3.5 text-gray-500" />
</template> </template>
</a-input> </a-input>
</div> </div>
<WorkspaceInviteSection v-if="workspaceRole !== WorkspaceUserRoles.VIEWER" />
<div v-if="!filterCollaborators?.length" class="w-full h-full flex flex-col items-center justify-center mt-36"> <div v-if="!filterCollaborators?.length" class="w-full h-full flex flex-col items-center justify-center mt-36">
<Empty description="No members found" /> <Empty description="No members found" />
</div> </div>

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

@ -44,6 +44,20 @@ const insertOrUpdateString = (str: string) => {
emailBadges.value.push(str) emailBadges.value.push(str)
} }
const emailInputValidation = (input: string): boolean => {
if (input.length < 1) {
emailValidation.isError = true
emailValidation.message = 'Email Should Not Be Empty'
return false
}
if (!validateEmail(input.trim())) {
emailValidation.isError = true
emailValidation.message = 'Invalid Email'
return false
}
return true
}
watch(inviteData, (newVal) => { watch(inviteData, (newVal) => {
const isNewEmail = newVal.email.charAt(newVal.email.length - 1) === ',' || newVal.email.charAt(newVal.email.length - 1) === ' ' const isNewEmail = newVal.email.charAt(newVal.email.length - 1) === ',' || newVal.email.charAt(newVal.email.length - 1) === ' '
if (isNewEmail && newVal.email.trim().length > 1) { if (isNewEmail && newVal.email.trim().length > 1) {
@ -71,16 +85,9 @@ watch(inviteData, (newVal) => {
}) })
const handleEnter = () => { const handleEnter = () => {
if (inviteData.email.length < 1) { const isEmailIsValid = emailInputValidation(inviteData.email)
emailValidation.isError = true if (!isEmailIsValid) return
emailValidation.message = 'Email Should Not Be Empty'
return
}
if (!validateEmail(inviteData.email.trim())) {
emailValidation.isError = true
emailValidation.message = 'Invalid Email'
return
}
inviteData.email += ' ' inviteData.email += ' '
emailValidation.isError = false emailValidation.isError = false
emailValidation.message = '' emailValidation.message = ''
@ -144,16 +151,10 @@ const onPaste = (e: ClipboardEvent) => {
inputArray[0] = inviteData.email += inputArray[0] inputArray[0] = inviteData.email += inputArray[0]
} }
inputArray?.forEach((el) => { inputArray?.forEach((el) => {
if (el.length < 1) { const isEmailIsValid = emailInputValidation(el)
emailValidation.isError = true
emailValidation.message = 'Email Should Not Be Empty' if (!isEmailIsValid) return
return
}
if (!validateEmail(el.trim())) {
emailValidation.isError = true
emailValidation.message = 'Invalid Email'
return
}
/** /**
if email is already enterd we delete the already if email is already enterd we delete the already
existing email and add new one existing email and add new one
@ -172,7 +173,6 @@ const onPaste = (e: ClipboardEvent) => {
<template> <template>
<div class="my-2 pt-3 ml-2" data-testid="invite"> <div class="my-2 pt-3 ml-2" data-testid="invite">
<div class="text-xl mb-4">Invite</div>
<div class="flex gap-2"> <div class="flex gap-2">
<div class="flex flex-col items-cenyet"> <div class="flex flex-col items-cenyet">
<div <div

Loading…
Cancel
Save