1
0
forked from test/crm

feat: Bulk assign from listview

This commit is contained in:
Shariq Ansari 2024-05-20 21:19:25 +05:30
parent 49178f5321
commit 458e5c1a64
2 changed files with 45 additions and 5 deletions

View File

@ -145,6 +145,14 @@
:selectedValues="selectedValues"
@reload="reload"
/>
<AssignmentModal
v-if="selectedValues"
:docs="selectedValues"
doctype="CRM Lead"
v-model="showAssignmentModal"
v-model:assignees="bulkAssignees"
@reload="reload"
/>
</template>
<script setup>
@ -152,6 +160,7 @@ import IndicatorIcon from '@/components/Icons/IndicatorIcon.vue'
import PhoneIcon from '@/components/Icons/PhoneIcon.vue'
import MultipleAvatar from '@/components/MultipleAvatar.vue'
import EditValueModal from '@/components/Modals/EditValueModal.vue'
import AssignmentModal from '@/components/Modals/AssignmentModal.vue'
import {
Avatar,
ListView,
@ -252,6 +261,15 @@ function deleteValues(selections, unselectAll) {
})
}
const showAssignmentModal = ref(false)
const bulkAssignees = ref([])
function assignValues(selections, unselectAll) {
showAssignmentModal.value = true
selectedValues.value = selections
unselectAllAction.value = unselectAll
}
const customBulkActions = ref([])
const customListActions = ref([])
@ -265,6 +283,10 @@ function bulkActions(selections, unselectAll) {
label: __('Delete'),
onClick: () => deleteValues(selections, unselectAll),
},
{
label: __('Assign To'),
onClick: () => assignValues(selections, unselectAll),
},
]
customBulkActions.value.forEach((action) => {
actions.push({

View File

@ -84,12 +84,18 @@ const props = defineProps({
type: Object,
default: null,
},
docs: {
type: Array,
default: () => [],
},
doctype: {
type: String,
default: '',
},
})
const emit = defineEmits(['reload'])
const show = defineModel()
const assignees = defineModel('assignees')
const oldAssignees = ref([])
@ -150,11 +156,23 @@ function updateAssignees() {
}
if (addedAssignees.length) {
call('frappe.desk.form.assign_to.add', {
doctype: props.doctype,
name: props.doc.name,
assign_to: addedAssignees,
})
if (props.docs.size) {
call('frappe.desk.form.assign_to.add_multiple', {
doctype: props.doctype,
name: JSON.stringify(Array.from(props.docs)),
assign_to: addedAssignees,
bulk_assign: true,
re_assign: true,
}).then(() => {
emit('reload')
})
} else {
call('frappe.desk.form.assign_to.add', {
doctype: props.doctype,
name: props.doc.name,
assign_to: addedAssignees,
})
}
}
show.value = false
}