field job added option to add multiple contracts to user at once
This commit is contained in:
@@ -18,6 +18,12 @@ const form = useForm({
|
||||
end_date: null,
|
||||
});
|
||||
|
||||
// Bulk selection form
|
||||
const bulkForm = useForm({
|
||||
contract_uuids: [],
|
||||
assigned_user_id: null,
|
||||
});
|
||||
|
||||
// Global search (applies to both tables)
|
||||
const search = ref("");
|
||||
|
||||
@@ -68,6 +74,16 @@ function assign(contract) {
|
||||
form.post(route("fieldjobs.assign"));
|
||||
}
|
||||
|
||||
function assignSelected() {
|
||||
// Use the same selected user as in the single-assign dropdown
|
||||
bulkForm.assigned_user_id = form.assigned_user_id;
|
||||
bulkForm.post(route("fieldjobs.assign-bulk"), {
|
||||
onSuccess: () => {
|
||||
bulkForm.contract_uuids = [];
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
function cancelAssignment(contract) {
|
||||
const payload = { contract_uuid: contract.uuid };
|
||||
form.transform(() => payload).post(route("fieldjobs.cancel"));
|
||||
@@ -154,6 +170,7 @@ watch([search, assignedFilterUserId], () => {
|
||||
|
||||
// Column definitions for DataTableClient
|
||||
const unassignedColumns = [
|
||||
{ key: "_select", label: "", class: "w-8" },
|
||||
{ key: "reference", label: "Pogodba", sortable: true, class: "w-32" },
|
||||
{
|
||||
key: "case_person",
|
||||
@@ -307,6 +324,22 @@ const assignedRows = computed(() =>
|
||||
<div v-if="form.errors.assigned_user_id" class="text-red-600 text-sm mt-1">
|
||||
{{ form.errors.assigned_user_id }}
|
||||
</div>
|
||||
<div class="mt-3 flex items-center gap-2">
|
||||
<button
|
||||
class="px-3 py-2 text-sm rounded bg-indigo-600 text-white disabled:opacity-50"
|
||||
:disabled="!bulkForm.contract_uuids.length || !form.assigned_user_id"
|
||||
@click="assignSelected"
|
||||
>
|
||||
Dodeli izbrane ({{ bulkForm.contract_uuids.length }})
|
||||
</button>
|
||||
<button
|
||||
class="px-3 py-2 text-sm rounded border border-gray-300 disabled:opacity-50"
|
||||
:disabled="!bulkForm.contract_uuids.length"
|
||||
@click="bulkForm.contract_uuids = []"
|
||||
>
|
||||
Počisti izbor
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<DataTableClient
|
||||
:columns="unassignedColumns"
|
||||
@@ -317,6 +350,14 @@ const assignedRows = computed(() =>
|
||||
v-model:page="unassignedPage"
|
||||
v-model:pageSize="unassignedPageSize"
|
||||
>
|
||||
<template #cell-_select="{ row }">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="h-4 w-4"
|
||||
:value="row.uuid"
|
||||
v-model="bulkForm.contract_uuids"
|
||||
/>
|
||||
</template>
|
||||
<template #cell-case_person="{ row }">
|
||||
<Link
|
||||
v-if="row.client_case?.uuid"
|
||||
|
||||
Reference in New Issue
Block a user