fix: send invitation, show pending ivitation, delete pending invitation
This commit is contained in:
parent
53501143df
commit
3c10b952b2
@ -20,23 +20,107 @@
|
|||||||
:options="[
|
:options="[
|
||||||
{ label: __('Regular Access'), value: 'Sales User' },
|
{ label: __('Regular Access'), value: 'Sales User' },
|
||||||
{ label: __('Manager Access'), value: 'Sales Manager' },
|
{ label: __('Manager Access'), value: 'Sales Manager' },
|
||||||
{ label: __('Admin Access'), value: 'Administrator' },
|
|
||||||
]"
|
]"
|
||||||
|
:description="description"
|
||||||
/>
|
/>
|
||||||
<ErrorMessage class="mt-2" v-if="error" :message="error" />
|
<ErrorMessage class="mt-2" v-if="error" :message="error" />
|
||||||
|
<template v-if="pendingInvitations.data?.length && !invitees.length">
|
||||||
|
<div
|
||||||
|
class="mt-4 flex items-center justify-between border-b py-2 text-base text-gray-600"
|
||||||
|
>
|
||||||
|
<div class="w-4/5">{{ __('Pending Invites') }}</div>
|
||||||
|
</div>
|
||||||
|
<ul class="divide-y overflow-auto">
|
||||||
|
<li
|
||||||
|
class="flex items-center justify-between py-2"
|
||||||
|
v-for="user in pendingInvitations.data"
|
||||||
|
:key="user.name"
|
||||||
|
>
|
||||||
|
<div class="w-4/5 text-base">
|
||||||
|
<span class="text-gray-900">
|
||||||
|
{{ user.email }}
|
||||||
|
</span>
|
||||||
|
<span class="text-gray-600"> ({{ roleMap[user.role] }}) </span>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<Tooltip text="Delete Invitation">
|
||||||
|
<Button
|
||||||
|
icon="x"
|
||||||
|
:loading="
|
||||||
|
pendingInvitations.delete.loading &&
|
||||||
|
pendingInvitations.delete.params.name === user.name
|
||||||
|
"
|
||||||
|
@click="pendingInvitations.delete.submit(user.name)"
|
||||||
|
/>
|
||||||
|
</Tooltip>
|
||||||
|
</div>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex flex-row-reverse">
|
<div class="flex flex-row-reverse">
|
||||||
<Button :label="__('Send Invites')" variant="solid" @click="update" />
|
<Button
|
||||||
|
:label="__('Send Invites')"
|
||||||
|
variant="solid"
|
||||||
|
@click="inviteByEmail.submit()"
|
||||||
|
:loading="inviteByEmail.loading"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup>
|
<script setup>
|
||||||
import MultiValueInput from '@/components/Controls/MultiValueInput.vue'
|
import MultiValueInput from '@/components/Controls/MultiValueInput.vue'
|
||||||
import { validateEmail } from '@/utils'
|
import { validateEmail, convertArrayToString } from '@/utils'
|
||||||
import { FormControl } from 'frappe-ui'
|
import {
|
||||||
import { ref } from 'vue'
|
createListResource,
|
||||||
|
createResource,
|
||||||
|
FormControl,
|
||||||
|
Tooltip,
|
||||||
|
} from 'frappe-ui'
|
||||||
|
import { ref, computed } from 'vue'
|
||||||
|
|
||||||
const invitees = ref([])
|
const invitees = ref([])
|
||||||
const role = ref('Sales User')
|
const role = ref('Sales User')
|
||||||
const error = ref(null)
|
const error = ref(null)
|
||||||
|
|
||||||
|
const description = computed(() => {
|
||||||
|
return {
|
||||||
|
'Sales Manager':
|
||||||
|
'Can manage and invite new members, and create public & private views (reports).',
|
||||||
|
'Sales User':
|
||||||
|
'Can work with leads and deals and create private views (reports).',
|
||||||
|
}[role.value]
|
||||||
|
})
|
||||||
|
|
||||||
|
const roleMap = {
|
||||||
|
'Sales User': __('Regular Access'),
|
||||||
|
'Sales Manager': __('Manager Access'),
|
||||||
|
}
|
||||||
|
|
||||||
|
const inviteByEmail = createResource({
|
||||||
|
url: 'crm.api.invite_by_email',
|
||||||
|
makeParams() {
|
||||||
|
return {
|
||||||
|
emails: convertArrayToString(invitees.value),
|
||||||
|
role: role.value,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
onSuccess() {
|
||||||
|
invitees.value = []
|
||||||
|
role.value = 'Sales User'
|
||||||
|
error.value = null
|
||||||
|
pendingInvitations.reload()
|
||||||
|
},
|
||||||
|
onError(error) {
|
||||||
|
error.value = error
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const pendingInvitations = createListResource({
|
||||||
|
type: 'list',
|
||||||
|
doctype: 'CRM Invitation',
|
||||||
|
filters: { status: 'Pending' },
|
||||||
|
fields: ['name', 'email', 'role'],
|
||||||
|
auto: true,
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -21,7 +21,12 @@
|
|||||||
</span>
|
</span>
|
||||||
</slot>
|
</slot>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<Tooltip :text="label" placement="right" :disabled="isCollapsed" :hoverDelay="1.5">
|
<Tooltip
|
||||||
|
:text="label"
|
||||||
|
placement="right"
|
||||||
|
:disabled="isCollapsed"
|
||||||
|
:hoverDelay="1.5"
|
||||||
|
>
|
||||||
<span
|
<span
|
||||||
class="flex-1 flex-shrink-0 truncate text-sm duration-300 ease-in-out"
|
class="flex-1 flex-shrink-0 truncate text-sm duration-300 ease-in-out"
|
||||||
:class="
|
:class="
|
||||||
@ -50,7 +55,7 @@ const route = useRoute()
|
|||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
icon: {
|
icon: {
|
||||||
type: Object,
|
type: [Object, String],
|
||||||
},
|
},
|
||||||
label: {
|
label: {
|
||||||
type: String,
|
type: String,
|
||||||
|
|||||||
@ -216,3 +216,7 @@ export function isEmoji(str) {
|
|||||||
export function isTouchScreenDevice() {
|
export function isTouchScreenDevice() {
|
||||||
return "ontouchstart" in document.documentElement;
|
return "ontouchstart" in document.documentElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function convertArrayToString(array) {
|
||||||
|
return array.map((item) => item).join(',')
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user