fix: implemented customListActions in all other listviews

This commit is contained in:
Shariq Ansari 2024-04-10 19:36:51 +05:30
parent 9f5bea6b22
commit 401bd8cade
12 changed files with 173 additions and 12 deletions

View File

@ -103,7 +103,7 @@ import {
Dropdown, Dropdown,
call, call,
} from 'frappe-ui' } from 'frappe-ui'
import { setupBulkActions, createToast } from '@/utils' import { setupListActions, createToast } from '@/utils'
import { globalStore } from '@/stores/global' import { globalStore } from '@/stores/global'
import { onMounted, ref, watch } from 'vue' import { onMounted, ref, watch } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
@ -181,6 +181,7 @@ function deleteValues(selections, unselectAll) {
} }
const customBulkActions = ref([]) const customBulkActions = ref([])
const customListActions = ref([])
function bulkActions(selections, unselectAll) { function bulkActions(selections, unselectAll) {
let actions = [ let actions = [
@ -209,7 +210,18 @@ function bulkActions(selections, unselectAll) {
onMounted(() => { onMounted(() => {
if (!list.value?.data) return if (!list.value?.data) return
setupBulkActions(list.value.data) setupListActions(list.value.data, {
list: list.value,
call,
createToast,
$dialog,
router,
})
customBulkActions.value = list.value?.data?.bulkActions || [] customBulkActions.value = list.value?.data?.bulkActions || []
customListActions.value = list.value?.data?.listActions || []
})
defineExpose({
customListActions,
}) })
</script> </script>

View File

@ -103,7 +103,7 @@
import PhoneIcon from '@/components/Icons/PhoneIcon.vue' import PhoneIcon from '@/components/Icons/PhoneIcon.vue'
import EditValueModal from '@/components/Modals/EditValueModal.vue' import EditValueModal from '@/components/Modals/EditValueModal.vue'
import { globalStore } from '@/stores/global' import { globalStore } from '@/stores/global'
import { createToast } from '@/utils' import { setupListActions, createToast } from '@/utils'
import { import {
Avatar, Avatar,
ListView, ListView,
@ -117,7 +117,8 @@ import {
Dropdown, Dropdown,
call, call,
} from 'frappe-ui' } from 'frappe-ui'
import { ref, watch } from 'vue' import { ref, watch, onMounted } from 'vue'
import { useRouter } from 'vue-router'
const props = defineProps({ const props = defineProps({
rows: { rows: {
@ -150,6 +151,8 @@ const emit = defineEmits([
const pageLengthCount = defineModel() const pageLengthCount = defineModel()
const list = defineModel('list') const list = defineModel('list')
const router = useRouter()
const { $dialog } = globalStore() const { $dialog } = globalStore()
watch(pageLengthCount, (val, old_value) => { watch(pageLengthCount, (val, old_value) => {
@ -199,6 +202,8 @@ function deleteValues(selections, unselectAll) {
}) })
} }
const customListActions = ref([])
function bulkActions(selections, unselectAll) { function bulkActions(selections, unselectAll) {
let actions = [ let actions = [
{ {
@ -212,4 +217,21 @@ function bulkActions(selections, unselectAll) {
] ]
return actions return actions
} }
onMounted(() => {
if (!list.value?.data) return
setupListActions(list.value.data, {
list: list.value,
call,
createToast,
$dialog,
router,
})
// customBulkActions.value = list.value?.data?.bulkActions || []
customListActions.value = list.value?.data?.listActions || []
})
defineExpose({
customListActions,
})
</script> </script>

View File

@ -146,7 +146,7 @@ import {
call, call,
Tooltip, Tooltip,
} from 'frappe-ui' } from 'frappe-ui'
import { setupBulkActions, createToast } from '@/utils' import { setupListActions, createToast } from '@/utils'
import { globalStore } from '@/stores/global' import { globalStore } from '@/stores/global'
import { onMounted, ref, watch } from 'vue' import { onMounted, ref, watch } from 'vue'
import { useRouter } from 'vue-router' import { useRouter } from 'vue-router'
@ -234,6 +234,7 @@ function deleteValues(selections, unselectAll) {
} }
const customBulkActions = ref([]) const customBulkActions = ref([])
const customListActions = ref([])
function bulkActions(selections, unselectAll) { function bulkActions(selections, unselectAll) {
let actions = [ let actions = [
@ -266,7 +267,18 @@ function bulkActions(selections, unselectAll) {
onMounted(() => { onMounted(() => {
if (!list.value?.data) return if (!list.value?.data) return
setupBulkActions(list.value.data) setupListActions(list.value.data, {
list: list.value,
call,
createToast,
$dialog,
router,
})
customBulkActions.value = list.value?.data?.bulkActions || [] customBulkActions.value = list.value?.data?.bulkActions || []
customListActions.value = list.value?.data?.listActions || []
})
defineExpose({
customListActions,
}) })
</script> </script>

View File

@ -85,7 +85,7 @@
<script setup> <script setup>
import EditValueModal from '@/components/Modals/EditValueModal.vue' import EditValueModal from '@/components/Modals/EditValueModal.vue'
import { globalStore } from '@/stores/global' import { globalStore } from '@/stores/global'
import { createToast } from '@/utils' import { setupListActions, createToast } from '@/utils'
import { import {
ListView, ListView,
ListHeader, ListHeader,
@ -98,7 +98,8 @@ import {
call, call,
Tooltip, Tooltip,
} from 'frappe-ui' } from 'frappe-ui'
import { ref, watch } from 'vue' import { ref, watch, onMounted } from 'vue'
import { useRouter } from 'vue-router'
const props = defineProps({ const props = defineProps({
rows: { rows: {
@ -132,6 +133,8 @@ const emit = defineEmits([
const pageLengthCount = defineModel() const pageLengthCount = defineModel()
const list = defineModel('list') const list = defineModel('list')
const router = useRouter()
const { $dialog } = globalStore() const { $dialog } = globalStore()
watch(pageLengthCount, (val, old_value) => { watch(pageLengthCount, (val, old_value) => {
@ -181,6 +184,8 @@ function deleteValues(selections, unselectAll) {
}) })
} }
const customListActions = ref([])
function bulkActions(selections, unselectAll) { function bulkActions(selections, unselectAll) {
let actions = [ let actions = [
{ {
@ -194,4 +199,21 @@ function bulkActions(selections, unselectAll) {
] ]
return actions return actions
} }
onMounted(() => {
if (!list.value?.data) return
setupListActions(list.value.data, {
list: list.value,
call,
createToast,
$dialog,
router,
})
// customBulkActions.value = list.value?.data?.bulkActions || []
customListActions.value = list.value?.data?.listActions || []
})
defineExpose({
customListActions,
})
</script> </script>

View File

@ -88,7 +88,7 @@
<script setup> <script setup>
import EditValueModal from '@/components/Modals/EditValueModal.vue' import EditValueModal from '@/components/Modals/EditValueModal.vue'
import { globalStore } from '@/stores/global' import { globalStore } from '@/stores/global'
import { createToast } from '@/utils' import { setupListActions, createToast } from '@/utils'
import { import {
Avatar, Avatar,
ListView, ListView,
@ -102,7 +102,8 @@ import {
Dropdown, Dropdown,
call, call,
} from 'frappe-ui' } from 'frappe-ui'
import { ref, watch } from 'vue' import { ref, watch, onMounted } from 'vue'
import { useRouter } from 'vue-router'
const props = defineProps({ const props = defineProps({
rows: { rows: {
@ -135,6 +136,8 @@ const emit = defineEmits([
const pageLengthCount = defineModel() const pageLengthCount = defineModel()
const list = defineModel('list') const list = defineModel('list')
const router = useRouter()
const { $dialog } = globalStore() const { $dialog } = globalStore()
watch(pageLengthCount, (val, old_value) => { watch(pageLengthCount, (val, old_value) => {
@ -184,6 +187,8 @@ function deleteValues(selections, unselectAll) {
}) })
} }
const customListActions = ref([])
function bulkActions(selections, unselectAll) { function bulkActions(selections, unselectAll) {
let actions = [ let actions = [
{ {
@ -197,4 +202,21 @@ function bulkActions(selections, unselectAll) {
] ]
return actions return actions
} }
onMounted(() => {
if (!list.value?.data) return
setupListActions(list.value.data, {
list: list.value,
call,
createToast,
$dialog,
router,
})
// customBulkActions.value = list.value?.data?.bulkActions || []
customListActions.value = list.value?.data?.listActions || []
})
defineExpose({
customListActions,
})
</script> </script>

View File

@ -106,7 +106,7 @@ import CalendarIcon from '@/components/Icons/CalendarIcon.vue'
import EditValueModal from '@/components/Modals/EditValueModal.vue' import EditValueModal from '@/components/Modals/EditValueModal.vue'
import { dateFormat } from '@/utils' import { dateFormat } from '@/utils'
import { globalStore } from '@/stores/global' import { globalStore } from '@/stores/global'
import { createToast } from '@/utils' import { setupListActions, createToast } from '@/utils'
import { import {
Avatar, Avatar,
ListView, ListView,
@ -120,7 +120,8 @@ import {
call, call,
Tooltip, Tooltip,
} from 'frappe-ui' } from 'frappe-ui'
import { ref, watch } from 'vue' import { ref, watch, onMounted } from 'vue'
import { useRouter } from 'vue-router'
const props = defineProps({ const props = defineProps({
rows: { rows: {
@ -154,6 +155,8 @@ const emit = defineEmits([
const pageLengthCount = defineModel() const pageLengthCount = defineModel()
const list = defineModel('list') const list = defineModel('list')
const router = useRouter()
const { $dialog } = globalStore() const { $dialog } = globalStore()
watch(pageLengthCount, (val, old_value) => { watch(pageLengthCount, (val, old_value) => {
@ -203,6 +206,8 @@ function deleteValues(selections, unselectAll) {
}) })
} }
const customListActions = ref([])
function bulkActions(selections, unselectAll) { function bulkActions(selections, unselectAll) {
let actions = [ let actions = [
{ {
@ -216,4 +221,21 @@ function bulkActions(selections, unselectAll) {
] ]
return actions return actions
} }
onMounted(() => {
if (!list.value?.data) return
setupListActions(list.value.data, {
list: list.value,
call,
createToast,
$dialog,
router,
})
// customBulkActions.value = list.value?.data?.bulkActions || []
customListActions.value = list.value?.data?.listActions || []
})
defineExpose({
customListActions,
})
</script> </script>

View File

@ -3,6 +3,12 @@
<template #left-header> <template #left-header>
<Breadcrumbs :items="breadcrumbs" /> <Breadcrumbs :items="breadcrumbs" />
</template> </template>
<template #right-header>
<CustomActions
v-if="callLogsListView?.customListActions"
:actions="callLogsListView.customListActions"
/>
</template>
</LayoutHeader> </LayoutHeader>
<ViewControls <ViewControls
ref="viewControls" ref="viewControls"
@ -13,6 +19,7 @@
doctype="CRM Call Log" doctype="CRM Call Log"
/> />
<CallLogsListView <CallLogsListView
ref="callLogsListView"
v-if="callLogs.data && rows.length" v-if="callLogs.data && rows.length"
v-model="callLogs.data.page_length_count" v-model="callLogs.data.page_length_count"
v-model:list="callLogs" v-model:list="callLogs"
@ -43,6 +50,7 @@
</template> </template>
<script setup> <script setup>
import CustomActions from '@/components/CustomActions.vue'
import PhoneIcon from '@/components/Icons/PhoneIcon.vue' import PhoneIcon from '@/components/Icons/PhoneIcon.vue'
import LayoutHeader from '@/components/LayoutHeader.vue' import LayoutHeader from '@/components/LayoutHeader.vue'
import ViewControls from '@/components/ViewControls.vue' import ViewControls from '@/components/ViewControls.vue'
@ -63,6 +71,8 @@ const { getContact, getLeadContact } = contactsStore()
const breadcrumbs = [{ label: 'Call Logs', route: { name: 'Call Logs' } }] const breadcrumbs = [{ label: 'Call Logs', route: { name: 'Call Logs' } }]
const callLogsListView = ref(null)
// callLogs data is loaded in the ViewControls component // callLogs data is loaded in the ViewControls component
const callLogs = ref({}) const callLogs = ref({})
const loadMore = ref(1) const loadMore = ref(1)

View File

@ -4,6 +4,10 @@
<Breadcrumbs :items="breadcrumbs" /> <Breadcrumbs :items="breadcrumbs" />
</template> </template>
<template #right-header> <template #right-header>
<CustomActions
v-if="contactsListView?.customListActions"
:actions="contactsListView.customListActions"
/>
<Button variant="solid" label="Create" @click="showContactModal = true"> <Button variant="solid" label="Create" @click="showContactModal = true">
<template #prefix><FeatherIcon name="plus" class="h-4" /></template> <template #prefix><FeatherIcon name="plus" class="h-4" /></template>
</Button> </Button>
@ -18,6 +22,7 @@
doctype="Contact" doctype="Contact"
/> />
<ContactsListView <ContactsListView
ref="contactsListView"
v-if="contacts.data && rows.length" v-if="contacts.data && rows.length"
v-model="contacts.data.page_length_count" v-model="contacts.data.page_length_count"
v-model:list="contacts" v-model:list="contacts"
@ -52,6 +57,7 @@
</template> </template>
<script setup> <script setup>
import CustomActions from '@/components/CustomActions.vue'
import ContactsIcon from '@/components/Icons/ContactsIcon.vue' import ContactsIcon from '@/components/Icons/ContactsIcon.vue'
import LayoutHeader from '@/components/LayoutHeader.vue' import LayoutHeader from '@/components/LayoutHeader.vue'
import ContactModal from '@/components/Modals/ContactModal.vue' import ContactModal from '@/components/Modals/ContactModal.vue'
@ -87,6 +93,8 @@ const breadcrumbs = computed(() => {
return items return items
}) })
const contactsListView = ref(null)
// contacts data is loaded in the ViewControls component // contacts data is loaded in the ViewControls component
const contacts = ref({}) const contacts = ref({})
const loadMore = ref(1) const loadMore = ref(1)

View File

@ -4,6 +4,10 @@
<Breadcrumbs :items="breadcrumbs" /> <Breadcrumbs :items="breadcrumbs" />
</template> </template>
<template #right-header> <template #right-header>
<CustomActions
v-if="dealsListView?.customListActions"
:actions="dealsListView.customListActions"
/>
<Button variant="solid" label="Create" @click="showNewDialog = true"> <Button variant="solid" label="Create" @click="showNewDialog = true">
<template #prefix><FeatherIcon name="plus" class="h-4" /></template> <template #prefix><FeatherIcon name="plus" class="h-4" /></template>
</Button> </Button>
@ -18,6 +22,7 @@
doctype="CRM Deal" doctype="CRM Deal"
/> />
<DealsListView <DealsListView
ref="dealsListView"
v-if="deals.data && rows.length" v-if="deals.data && rows.length"
v-model="deals.data.page_length_count" v-model="deals.data.page_length_count"
v-model:list="deals" v-model:list="deals"
@ -65,6 +70,7 @@
</template> </template>
<script setup> <script setup>
import CustomActions from '@/components/CustomActions.vue'
import DealsIcon from '@/components/Icons/DealsIcon.vue' import DealsIcon from '@/components/Icons/DealsIcon.vue'
import LayoutHeader from '@/components/LayoutHeader.vue' import LayoutHeader from '@/components/LayoutHeader.vue'
import DealsListView from '@/components/ListViews/DealsListView.vue' import DealsListView from '@/components/ListViews/DealsListView.vue'
@ -92,6 +98,8 @@ const { getDealStatus } = statusesStore()
const router = useRouter() const router = useRouter()
const dealsListView = ref(null)
// deals data is loaded in the ViewControls component // deals data is loaded in the ViewControls component
const deals = ref({}) const deals = ref({})
const loadMore = ref(1) const loadMore = ref(1)

View File

@ -4,6 +4,10 @@
<Breadcrumbs :items="breadcrumbs" /> <Breadcrumbs :items="breadcrumbs" />
</template> </template>
<template #right-header> <template #right-header>
<CustomActions
v-if="emailTemplatesListView?.customListActions"
:actions="emailTemplatesListView.customListActions"
/>
<Button variant="solid" label="Create" @click="showEmailTemplateModal = true"> <Button variant="solid" label="Create" @click="showEmailTemplateModal = true">
<template #prefix><FeatherIcon name="plus" class="h-4" /></template> <template #prefix><FeatherIcon name="plus" class="h-4" /></template>
</Button> </Button>
@ -18,6 +22,7 @@
doctype="Email Template" doctype="Email Template"
/> />
<EmailTemplatesListView <EmailTemplatesListView
ref="emailTemplatesListView"
v-if="emailTemplates.data && rows.length" v-if="emailTemplates.data && rows.length"
v-model="emailTemplates.data.page_length_count" v-model="emailTemplates.data.page_length_count"
v-model:list="emailTemplates" v-model:list="emailTemplates"
@ -54,6 +59,7 @@
</template> </template>
<script setup> <script setup>
import CustomActions from '@/components/CustomActions.vue'
import EmailIcon from '@/components/Icons/EmailIcon.vue' import EmailIcon from '@/components/Icons/EmailIcon.vue'
import LayoutHeader from '@/components/LayoutHeader.vue' import LayoutHeader from '@/components/LayoutHeader.vue'
import ViewControls from '@/components/ViewControls.vue' import ViewControls from '@/components/ViewControls.vue'
@ -67,6 +73,8 @@ const breadcrumbs = [
{ label: 'Email Templates', route: { name: 'Email Templates' } }, { label: 'Email Templates', route: { name: 'Email Templates' } },
] ]
const emailTemplatesListView = ref(null)
// emailTemplates data is loaded in the ViewControls component // emailTemplates data is loaded in the ViewControls component
const emailTemplates = ref({}) const emailTemplates = ref({})
const loadMore = ref(1) const loadMore = ref(1)

View File

@ -4,6 +4,10 @@
<Breadcrumbs :items="breadcrumbs" /> <Breadcrumbs :items="breadcrumbs" />
</template> </template>
<template #right-header> <template #right-header>
<CustomActions
v-if="organizationsListView?.customListActions"
:actions="organizationsListView.customListActions"
/>
<Button <Button
variant="solid" variant="solid"
label="Create" label="Create"
@ -22,6 +26,7 @@
doctype="CRM Organization" doctype="CRM Organization"
/> />
<OrganizationsListView <OrganizationsListView
ref="organizationsListView"
v-if="organizations.data && rows.length" v-if="organizations.data && rows.length"
v-model="organizations.data.page_length_count" v-model="organizations.data.page_length_count"
v-model:list="organizations" v-model:list="organizations"
@ -55,6 +60,7 @@
<OrganizationModal v-model="showOrganizationModal" /> <OrganizationModal v-model="showOrganizationModal" />
</template> </template>
<script setup> <script setup>
import CustomActions from '@/components/CustomActions.vue'
import OrganizationsIcon from '@/components/Icons/OrganizationsIcon.vue' import OrganizationsIcon from '@/components/Icons/OrganizationsIcon.vue'
import LayoutHeader from '@/components/LayoutHeader.vue' import LayoutHeader from '@/components/LayoutHeader.vue'
import OrganizationModal from '@/components/Modals/OrganizationModal.vue' import OrganizationModal from '@/components/Modals/OrganizationModal.vue'
@ -72,6 +78,7 @@ import { useRoute } from 'vue-router'
const route = useRoute() const route = useRoute()
const organizationsListView = ref(null)
const showOrganizationModal = ref(false) const showOrganizationModal = ref(false)
const currentOrganization = computed(() => { const currentOrganization = computed(() => {

View File

@ -4,6 +4,10 @@
<Breadcrumbs :items="breadcrumbs" /> <Breadcrumbs :items="breadcrumbs" />
</template> </template>
<template #right-header> <template #right-header>
<CustomActions
v-if="tasksListView?.customListActions"
:actions="tasksListView.customListActions"
/>
<Button variant="solid" label="Create" @click="createTask"> <Button variant="solid" label="Create" @click="createTask">
<template #prefix><FeatherIcon name="plus" class="h-4" /></template> <template #prefix><FeatherIcon name="plus" class="h-4" /></template>
</Button> </Button>
@ -18,6 +22,7 @@
doctype="CRM Task" doctype="CRM Task"
/> />
<TasksListView <TasksListView
ref="tasksListView"
v-if="tasks.data && rows.length" v-if="tasks.data && rows.length"
v-model="tasks.data.page_length_count" v-model="tasks.data.page_length_count"
v-model:list="tasks" v-model:list="tasks"
@ -47,6 +52,7 @@
</template> </template>
<script setup> <script setup>
import CustomActions from '@/components/CustomActions.vue'
import EmailIcon from '@/components/Icons/EmailIcon.vue' import EmailIcon from '@/components/Icons/EmailIcon.vue'
import LayoutHeader from '@/components/LayoutHeader.vue' import LayoutHeader from '@/components/LayoutHeader.vue'
import ViewControls from '@/components/ViewControls.vue' import ViewControls from '@/components/ViewControls.vue'
@ -61,6 +67,8 @@ const breadcrumbs = [{ label: 'Tasks', route: { name: 'Tasks' } }]
const { getUser } = usersStore() const { getUser } = usersStore()
const tasksListView = ref(null)
// tasks data is loaded in the ViewControls component // tasks data is loaded in the ViewControls component
const tasks = ref({}) const tasks = ref({})
const loadMore = ref(1) const loadMore = ref(1)