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

View File

@ -84,12 +84,18 @@ const props = defineProps({
type: Object, type: Object,
default: null, default: null,
}, },
docs: {
type: Array,
default: () => [],
},
doctype: { doctype: {
type: String, type: String,
default: '', default: '',
}, },
}) })
const emit = defineEmits(['reload'])
const show = defineModel() const show = defineModel()
const assignees = defineModel('assignees') const assignees = defineModel('assignees')
const oldAssignees = ref([]) const oldAssignees = ref([])
@ -150,12 +156,24 @@ function updateAssignees() {
} }
if (addedAssignees.length) { if (addedAssignees.length) {
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', { call('frappe.desk.form.assign_to.add', {
doctype: props.doctype, doctype: props.doctype,
name: props.doc.name, name: props.doc.name,
assign_to: addedAssignees, assign_to: addedAssignees,
}) })
} }
}
show.value = false show.value = false
} }