changes 0328092025

This commit is contained in:
Simon Pocrnjič
2025-09-28 22:36:47 +02:00
parent b40ee9dcde
commit 7e8e0a479b
61 changed files with 4306 additions and 654 deletions
@@ -16,7 +16,8 @@ let header = [
C_TD.make('Odločitev', 'header'),
C_TD.make('Opomba', 'header'),
C_TD.make('Datum zapadlosti', 'header'),
C_TD.make('Znesek obljube', 'header')
C_TD.make('Znesek obljube', 'header'),
C_TD.make('Dodal', 'header')
];
const createBody = (data) => {
@@ -25,6 +26,7 @@ const createBody = (data) => {
data.forEach((p) => {
const createdDate = new Date(p.created_at).toLocaleDateString('de');
const dueDate = (p.due_date) ? new Date().toLocaleDateString('de') : null;
const userName = (p.user && p.user.name) ? p.user.name : (p.user_name || '');
const cols = [
C_TD.make(p.contract?.reference ?? ''),
@@ -33,7 +35,8 @@ const createBody = (data) => {
C_TD.make(p.decision.name, 'body'),
C_TD.make(p.note, 'body' ),
C_TD.make(dueDate, 'body' ),
C_TD.make(Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(p.amount), 'body' )
C_TD.make(Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(p.amount), 'body' ),
C_TD.make(userName, 'body')
];
body.push(
@@ -9,7 +9,8 @@ import { useForm } from '@inertiajs/vue3'
const props = defineProps({
show: { type: Boolean, default: false },
client_case: { type: Object, required: true },
contract: { type: Object, required: true },
// Contract can initially be null while dialog is hidden; make it optional to avoid prop warning
contract: { type: Object, default: null },
})
const emit = defineEmits(['close', 'created'])
@@ -23,6 +24,10 @@ const form = useForm({
})
const submit = () => {
if (!props.contract) {
// No contract selected; do nothing safely
return
}
form.post(route('clientCase.contract.object.store', { client_case: props.client_case.uuid, uuid: props.contract.uuid }), {
preserveScroll: true,
onSuccess: () => { emit('created'); form.reset(); close() },
@@ -16,7 +16,7 @@ const items = () => Array.isArray(props.contract?.objects) ? props.contract.obje
<template>
<DialogModal :show="show" @close="close">
<template #title>
Premeti
Predmeti
<span v-if="contract" class="ml-2 text-sm text-gray-500">(Pogodba: {{ contract.reference }})</span>
</template>
<template #content>
@@ -14,6 +14,7 @@ const props = defineProps({
client_case: Object,
show: { type: Boolean, default: false },
types: Array,
account_types: { type: Array, default: () => [] },
// Optional: when provided, drawer acts as edit mode
contract: { type: Object, default: null },
});
@@ -40,6 +41,7 @@ const formContract = useForm({
// nested account fields, if exists
initial_amount: props.contract?.account?.initial_amount ?? null,
balance_amount: props.contract?.account?.balance_amount ?? null,
account_type_id: props.contract?.account?.type_id ?? null,
});
// keep form in sync when switching between create and edit
@@ -51,6 +53,7 @@ const applyContract = (c) => {
formContract.description = c?.description ?? ''
formContract.initial_amount = c?.account?.initial_amount ?? null
formContract.balance_amount = c?.account?.balance_amount ?? null
formContract.account_type_id = c?.account?.type_id ?? null
}
watch(() => props.contract, (c) => {
@@ -160,6 +163,18 @@ const storeOrUpdate = () => {
Račun
</template>
</SectionTitle>
<div class="col-span-6 sm:col-span-4">
<InputLabel for="accountTypeSelect" value="Tip računa"/>
<select
id="accountTypeSelect"
v-model="formContract.account_type_id"
class="block w-full border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 rounded-md shadow-sm"
>
<option :value="null"></option>
<option v-for="at in account_types" :key="at.id" :value="at.id">{{ at.name ?? ('#' + at.id) }}</option>
</select>
<InputError :message="formContract.errors.account_type_id" />
</div>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<InputLabel for="initialAmount" value="Predani znesek"/>
@@ -1,250 +1,463 @@
<script setup>
import { FwbTable, FwbTableHead, FwbTableHeadCell, FwbTableBody, FwbTableRow, FwbTableCell } from 'flowbite-vue'
import Dropdown from '@/Components/Dropdown.vue'
import CaseObjectCreateDialog from './CaseObjectCreateDialog.vue'
import CaseObjectsDialog from './CaseObjectsDialog.vue'
import { FontAwesomeIcon } from '@fortawesome/vue-fontawesome'
import { faCircleInfo, faEllipsisVertical, faPenToSquare, faTrash, faListCheck, faPlus } from '@fortawesome/free-solid-svg-icons'
import {
FwbTable,
FwbTableHead,
FwbTableHeadCell,
FwbTableBody,
FwbTableRow,
FwbTableCell,
} from "flowbite-vue";
import Dropdown from "@/Components/Dropdown.vue";
import CaseObjectCreateDialog from "./CaseObjectCreateDialog.vue";
import CaseObjectsDialog from "./CaseObjectsDialog.vue";
import { FontAwesomeIcon } from "@fortawesome/vue-fontawesome";
import {
faCircleInfo,
faClock,
faEllipsisVertical,
faPenToSquare,
faTrash,
faListCheck,
faPlus,
} from "@fortawesome/free-solid-svg-icons";
const props = defineProps({
client_case: Object,
contract_types: Array,
contracts: { type: Array, default: () => [] },
segments: { type: Array, default: () => [] },
all_segments: { type: Array, default: () => [] },
})
client_case: Object,
contract_types: Array,
contracts: { type: Array, default: () => [] },
segments: { type: Array, default: () => [] },
all_segments: { type: Array, default: () => [] },
});
const emit = defineEmits(['edit', 'delete', 'add-activity'])
const emit = defineEmits(["edit", "delete", "add-activity"]);
const formatDate = (d) => {
if (!d) return '-'
const dt = new Date(d)
return isNaN(dt.getTime()) ? '-' : dt.toLocaleDateString('de')
}
if (!d) return "-";
const dt = new Date(d);
return isNaN(dt.getTime()) ? "-" : dt.toLocaleDateString("de");
};
const hasDesc = (c) => {
const d = c?.description
return typeof d === 'string' && d.trim().length > 0
}
const d = c?.description;
return typeof d === "string" && d.trim().length > 0;
};
const onEdit = (c) => emit('edit', c)
const onDelete = (c) => emit('delete', c)
const onAddActivity = (c) => emit('add-activity', c)
const onEdit = (c) => emit("edit", c);
const onDelete = (c) => emit("delete", c);
const onAddActivity = (c) => emit("add-activity", c);
// CaseObject dialog state
import { ref, computed } from 'vue'
import { router } from '@inertiajs/vue3'
const showObjectDialog = ref(false)
const showObjectsList = ref(false)
const selectedContract = ref(null)
const openObjectDialog = (c) => { selectedContract.value = c; showObjectDialog.value = true }
const closeObjectDialog = () => { showObjectDialog.value = false; selectedContract.value = null }
const openObjectsList = (c) => { selectedContract.value = c; showObjectsList.value = true }
const closeObjectsList = () => { showObjectsList.value = false; selectedContract.value = null }
import { ref, computed } from "vue";
import { router } from "@inertiajs/vue3";
const showObjectDialog = ref(false);
const showObjectsList = ref(false);
const selectedContract = ref(null);
const openObjectDialog = (c) => {
selectedContract.value = c;
showObjectDialog.value = true;
};
const closeObjectDialog = () => {
showObjectDialog.value = false;
selectedContract.value = null;
};
const openObjectsList = (c) => {
selectedContract.value = c;
showObjectsList.value = true;
};
const closeObjectsList = () => {
showObjectsList.value = false;
selectedContract.value = null;
};
// Promise date helpers
const todayStr = computed(() => {
const d = new Date();
const yyyy = d.getFullYear();
const mm = String(d.getMonth() + 1).padStart(2, "0");
const dd = String(d.getDate()).padStart(2, "0");
return `${yyyy}-${mm}-${dd}`;
});
const getPromiseDate = (c) => c?.account?.promise_date || null;
const promiseStatus = (c) => {
const p = getPromiseDate(c);
if (!p) return null;
if (p > todayStr.value) return "future";
if (p === todayStr.value) return "today";
return "past";
};
const promiseColorClass = (c) => {
const s = promiseStatus(c);
if (s === "future") return "text-green-600";
if (s === "today") return "text-yellow-500";
if (s === "past") return "text-red-600";
return "text-gray-400";
};
// Segment helpers
const contractActiveSegment = (c) => {
const arr = c?.segments || []
return arr.find(s => s.pivot?.active) || arr[0] || null
}
const segmentName = (id) => props.segments.find(s => s.id === id)?.name || ''
const confirmChange = ref({ show: false, contract: null, segmentId: null, fromAll: false })
const arr = c?.segments || [];
return arr.find((s) => s.pivot?.active) || arr[0] || null;
};
const segmentName = (id) => props.segments.find((s) => s.id === id)?.name || "";
const confirmChange = ref({
show: false,
contract: null,
segmentId: null,
fromAll: false,
});
const askChangeSegment = (c, segmentId, fromAll = false) => {
confirmChange.value = { show: true, contract: c, segmentId, fromAll }
}
const closeConfirm = () => { confirmChange.value = { show: false, contract: null, segmentId: null } }
confirmChange.value = { show: true, contract: c, segmentId, fromAll };
};
const closeConfirm = () => {
confirmChange.value = { show: false, contract: null, segmentId: null };
};
const doChangeSegment = () => {
const { contract, segmentId, fromAll } = confirmChange.value
if (!contract || !segmentId) return closeConfirm()
if (fromAll) {
router.post(route('clientCase.segments.attach', props.client_case), {
segment_id: segmentId,
contract_uuid: contract.uuid,
make_active_for_contract: true,
}, {
preserveScroll: true,
only: ['contracts', 'segments'],
onFinish: () => closeConfirm(),
})
} else {
router.post(route('clientCase.contract.updateSegment', { client_case: props.client_case.uuid, uuid: contract.uuid }), { segment_id: segmentId }, {
preserveScroll: true,
only: ['contracts'],
onFinish: () => closeConfirm(),
})
}
}
const { contract, segmentId, fromAll } = confirmChange.value;
if (!contract || !segmentId) return closeConfirm();
if (fromAll) {
router.post(
route("clientCase.segments.attach", props.client_case),
{
segment_id: segmentId,
contract_uuid: contract.uuid,
make_active_for_contract: true,
},
{
preserveScroll: true,
only: ["contracts", "segments"],
onFinish: () => closeConfirm(),
}
);
} else {
router.post(
route("clientCase.contract.updateSegment", {
client_case: props.client_case.uuid,
uuid: contract.uuid,
}),
{ segment_id: segmentId },
{
preserveScroll: true,
only: ["contracts"],
onFinish: () => closeConfirm(),
}
);
}
};
</script>
<template>
<div class="relative overflow-x-auto rounded-lg border border-gray-200 bg-white shadow-sm">
<FwbTable hoverable striped class="text-sm">
<FwbTableHead class="sticky top-0 z-10 bg-gray-50/90 backdrop-blur border-b border-gray-200 shadow-sm">
<FwbTableHeadCell class="uppercase text-xs font-semibold tracking-wide text-gray-700 py-3">Ref.</FwbTableHeadCell>
<FwbTableHeadCell class="uppercase text-xs font-semibold tracking-wide text-gray-700 py-3">Datum začetka</FwbTableHeadCell>
<FwbTableHeadCell class="uppercase text-xs font-semibold tracking-wide text-gray-700 py-3">Tip</FwbTableHeadCell>
<FwbTableHeadCell class="uppercase text-xs font-semibold tracking-wide text-gray-700 py-3">Segment</FwbTableHeadCell>
<FwbTableHeadCell class="uppercase text-xs font-semibold tracking-wide text-gray-700 py-3 text-right">Predano</FwbTableHeadCell>
<FwbTableHeadCell class="uppercase text-xs font-semibold tracking-wide text-gray-700 py-3 text-right">Odprto</FwbTableHeadCell>
<FwbTableHeadCell class="uppercase text-xs font-semibold tracking-wide text-gray-700 py-3 text-center">Opis</FwbTableHeadCell>
<FwbTableHeadCell class="w-px" />
</FwbTableHead>
<FwbTableBody>
<template v-for="(c, i) in contracts" :key="c.uuid || i">
<FwbTableRow>
<FwbTableCell>{{ c.reference }}</FwbTableCell>
<FwbTableCell>{{ formatDate(c.start_date) }}</FwbTableCell>
<FwbTableCell>{{ c?.type?.name }}</FwbTableCell>
<FwbTableCell>
<div class="flex items-center gap-2">
<span class="text-gray-700">{{ contractActiveSegment(c)?.name || '-' }}</span>
<Dropdown width="64" align="left">
<template #trigger>
<button
type="button"
class="inline-flex items-center justify-center h-7 w-7 rounded-full hover:bg-gray-100"
:class="{ 'opacity-50 cursor-not-allowed': !segments || segments.length === 0 }"
:title="segments && segments.length ? 'Change segment' : 'No segments available for this case'"
>
<FontAwesomeIcon :icon="faPenToSquare" class="h-4 w-4 text-gray-600" />
</button>
</template>
<template #content>
<div class="py-1">
<template v-if="segments && segments.length">
<button v-for="s in segments" :key="s.id" type="button" class="w-full px-3 py-1.5 text-left text-sm hover:bg-gray-50" @click="askChangeSegment(c, s.id)">
<span>{{ s.name }}</span>
</button>
</template>
<template v-else>
<template v-if="all_segments && all_segments.length">
<div class="px-3 py-2 text-xs text-gray-500">Ni segmentov v tem primeru. Dodaj in nastavi segment:</div>
<button v-for="s in all_segments" :key="s.id" type="button" class="w-full px-3 py-1.5 text-left text-sm hover:bg-gray-50" @click="askChangeSegment(c, s.id, true)">
<span>{{ s.name }}</span>
</button>
</template>
<template v-else>
<div class="px-3 py-2 text-sm text-gray-500">No segments configured.</div>
</template>
</template>
</div>
</template>
</Dropdown>
</div>
</FwbTableCell>
<FwbTableCell class="text-right">{{ Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(c?.account?.initial_amount ?? 0) }}</FwbTableCell>
<FwbTableCell class="text-right">{{ Intl.NumberFormat('de-DE', { style: 'currency', currency: 'EUR' }).format(c?.account?.balance_amount ?? 0) }}</FwbTableCell>
<FwbTableCell class="text-center">
<Dropdown v-if="hasDesc(c)" width="64" align="left">
<template #trigger>
<button
type="button"
class="inline-flex items-center justify-center h-8 w-8 rounded-full hover:bg-gray-100 focus:outline-none"
:title="'Pokaži opis'"
>
<FontAwesomeIcon :icon="faCircleInfo" class="h-4 w-4 text-gray-700" />
</button>
</template>
<template #content>
<div class="max-w-sm px-3 py-2 text-sm text-gray-700 whitespace-pre-wrap">
{{ c.description }}
</div>
</template>
</Dropdown>
<button
v-else
type="button"
disabled
class="inline-flex items-center justify-center h-8 w-8 rounded-full text-gray-400 cursor-not-allowed"
:title="'Ni opisa'"
>
<FontAwesomeIcon :icon="faCircleInfo" class="h-4 w-4" />
</button>
</FwbTableCell>
<FwbTableCell class="text-right whitespace-nowrap">
<Dropdown align="right" width="56">
<template #trigger>
<button
type="button"
class="inline-flex items-center justify-center h-8 w-8 rounded-full hover:bg-gray-100 focus:outline-none"
:title="'Actions'"
>
<FontAwesomeIcon :icon="faEllipsisVertical" class="h-4 w-4 text-gray-700" />
</button>
</template>
<template #content>
<button
type="button"
class="w-full px-3 py-2 text-left text-sm text-gray-700 hover:bg-gray-50 flex items-center gap-2"
@click="onEdit(c)"
>
<FontAwesomeIcon :icon="faPenToSquare" class="h-4 w-4 text-gray-600" />
<span>Edit</span>
</button>
<button
type="button"
class="w-full px-3 py-2 text-left text-sm text-gray-700 hover:bg-gray-50 flex items-center gap-2"
@click="openObjectsList(c)"
>
<FontAwesomeIcon :icon="faCircleInfo" class="h-4 w-4 text-gray-600" />
<span>Predmeti</span>
</button>
<button
type="button"
class="w-full px-3 py-2 text-left text-sm text-gray-700 hover:bg-gray-50 flex items-center gap-2"
@click="openObjectDialog(c)"
>
<FontAwesomeIcon :icon="faPlus" class="h-4 w-4 text-gray-600" />
<span>Premet</span>
</button>
<button
type="button"
class="w-full px-3 py-2 text-left text-sm text-red-700 hover:bg-red-50 flex items-center gap-2"
@click="onDelete(c)"
>
<FontAwesomeIcon :icon="faTrash" class="h-4 w-4 text-red-600" />
<span>Briši</span>
</button>
<div class="my-1 border-t border-gray-100" />
<button
type="button"
class="w-full px-3 py-2 text-left text-sm text-gray-700 hover:bg-gray-50 flex items-center gap-2"
@click="onAddActivity(c)"
>
<FontAwesomeIcon :icon="faListCheck" class="h-4 w-4 text-gray-600" />
<span>Aktivnost</span>
</button>
</template>
</Dropdown>
</FwbTableCell>
</FwbTableRow>
<div
class="relative overflow-x-auto rounded-lg border border-gray-200 bg-white shadow-sm"
>
<FwbTable hoverable striped class="text-sm">
<FwbTableHead
class="sticky top-0 z-10 bg-gray-50/90 backdrop-blur border-b border-gray-200 shadow-sm"
>
<FwbTableHeadCell
class="uppercase text-xs font-semibold tracking-wide text-gray-700 py-3"
>Ref.
</FwbTableHeadCell>
<FwbTableHeadCell
class="uppercase text-xs font-semibold tracking-wide text-gray-700 py-3"
>Datum začetka
</FwbTableHeadCell>
<FwbTableHeadCell
class="uppercase text-xs font-semibold tracking-wide text-gray-700 py-3"
>Tip
</FwbTableHeadCell>
<FwbTableHeadCell
class="uppercase text-xs font-semibold tracking-wide text-gray-700 py-3"
>Segment
</FwbTableHeadCell>
<FwbTableHeadCell
class="uppercase text-xs font-semibold tracking-wide text-gray-700 py-3 text-right"
>
Predano</FwbTableHeadCell
>
<FwbTableHeadCell
class="uppercase text-xs font-semibold tracking-wide text-gray-700 py-3 text-right"
>
Odprto</FwbTableHeadCell
>
<FwbTableHeadCell
class="uppercase text-xs font-semibold tracking-wide text-gray-700 py-3 text-center"
>
Opis</FwbTableHeadCell
>
<FwbTableHeadCell class="w-px" />
</FwbTableHead>
<FwbTableBody>
<template v-for="(c, i) in contracts" :key="c.uuid || i">
<FwbTableRow>
<FwbTableCell>{{ c.reference }}</FwbTableCell>
<FwbTableCell>{{ formatDate(c.start_date) }}</FwbTableCell>
<FwbTableCell>{{ c?.type?.name }}</FwbTableCell>
<FwbTableCell>
<div class="flex items-center gap-2">
<span class="text-gray-700">{{
contractActiveSegment(c)?.name || "-"
}}</span>
<Dropdown width="64" align="left">
<template #trigger>
<button
type="button"
class="inline-flex items-center justify-center h-7 w-7 rounded-full hover:bg-gray-100"
:class="{
'opacity-50 cursor-not-allowed':
!segments || segments.length === 0,
}"
:title="
segments && segments.length
? 'Change segment'
: 'No segments available for this case'
"
>
<FontAwesomeIcon
:icon="faPenToSquare"
class="h-4 w-4 text-gray-600"
/>
</button>
</template>
<template #content>
<div class="py-1">
<template v-if="segments && segments.length">
<button
v-for="s in segments"
:key="s.id"
type="button"
class="w-full px-3 py-1.5 text-left text-sm hover:bg-gray-50"
@click="askChangeSegment(c, s.id)"
>
<span>{{ s.name }}</span>
</button>
</template>
<template v-else>
<template v-if="all_segments && all_segments.length">
<div class="px-3 py-2 text-xs text-gray-500">
Ni segmentov v tem primeru. Dodaj in nastavi segment:
</div>
<button
v-for="s in all_segments"
:key="s.id"
type="button"
class="w-full px-3 py-1.5 text-left text-sm hover:bg-gray-50"
@click="askChangeSegment(c, s.id, true)"
>
<span>{{ s.name }}</span>
</button>
</template>
<template v-else>
<div class="px-3 py-2 text-sm text-gray-500">
No segments configured.
</div>
</template>
</template>
</div>
</template>
</Dropdown>
</div>
</FwbTableCell>
<FwbTableCell class="text-right">{{
Intl.NumberFormat("de-DE", {
style: "currency",
currency: "EUR",
}).format(c?.account?.initial_amount ?? 0)
}}</FwbTableCell>
<FwbTableCell class="text-right">{{
Intl.NumberFormat("de-DE", {
style: "currency",
currency: "EUR",
}).format(c?.account?.balance_amount ?? 0)
}}</FwbTableCell>
<FwbTableCell class="text-center">
<div class="inline-flex items-center justify-center gap-0.5">
<Dropdown width="64" align="left">
<template #trigger>
<button
type="button"
class="inline-flex items-center justify-center h-5 w-5 rounded-full"
:title="'Pokaži opis'"
:disabled="!hasDesc(c)"
:class="hasDesc(c) ? 'hover:bg-gray-100 focus:outline-none' : text-gray-400"
>
<FontAwesomeIcon
:icon="faCircleInfo"
class="h-4 w-4"
:class="hasDesc(c) ? 'text-gray-700' : 'text-gray-400'"
/>
</button>
</template>
<template #content>
<div
class="max-w-sm px-3 py-2 text-sm text-gray-700 whitespace-pre-wrap"
>
{{ c.description }}
</div>
</template>
</Dropdown>
<!-- Promise date indicator -->
<Dropdown width="64" align="left">
<template #trigger>
<button
type="button"
class="inline-flex items-center justify-center h-5 w-5 rounded-full hover:bg-gray-100 focus:outline-none"
:title="
getPromiseDate(c)
? 'Obljubljen datum plačila'
: 'Ni obljubljenega datuma'
"
:disabled="!getPromiseDate(c)"
>
<FontAwesomeIcon
:icon="faClock"
class="h-4 w-4"
:class="promiseColorClass(c)"
/>
</button>
</template>
<template #content>
<div class="px-3 py-2 text-sm text-gray-700">
<div class="flex items-center gap-2">
<FontAwesomeIcon
:icon="faClock"
class="h-4 w-4"
:class="promiseColorClass(c)"
/>
<span class="font-medium">Obljubljeno plačilo</span>
</div>
<div class="mt-1">
<span class="text-gray-500">Datum:</span>
<span class="ml-1">{{ formatDate(getPromiseDate(c)) }}</span>
</div>
<div class="mt-1" v-if="promiseStatus(c) === 'future'">
<span class="text-green-600">V prihodnosti</span>
</div>
<div class="mt-1" v-else-if="promiseStatus(c) === 'today'">
<span class="text-yellow-600">Danes</span>
</div>
<div class="mt-1" v-else-if="promiseStatus(c) === 'past'">
<span class="text-red-600">Zapadlo</span>
</div>
<div class="mt-1 text-gray-500" v-else>
Ni nastavljenega datuma.
</div>
</div>
</template>
</Dropdown>
</div>
</FwbTableCell>
<FwbTableCell class="text-right whitespace-nowrap">
<Dropdown align="right" width="56">
<template #trigger>
<button
type="button"
class="inline-flex items-center justify-center h-5 w-5 rounded-full hover:bg-gray-100 focus:outline-none"
:title="'Actions'"
>
<FontAwesomeIcon
:icon="faEllipsisVertical"
class="h-4 w-4 text-gray-700"
/>
</button>
</template>
</FwbTableBody>
</FwbTable>
<div v-if="!contracts || contracts.length === 0" class="p-6 text-center text-sm text-gray-500">No contracts.</div>
<template #content>
<button
type="button"
class="w-full px-3 py-2 text-left text-sm text-gray-700 hover:bg-gray-50 flex items-center gap-2"
@click="onEdit(c)"
>
<FontAwesomeIcon
:icon="faPenToSquare"
class="h-4 w-4 text-gray-600"
/>
<span>Edit</span>
</button>
<button
type="button"
class="w-full px-3 py-2 text-left text-sm text-gray-700 hover:bg-gray-50 flex items-center gap-2"
@click="openObjectsList(c)"
>
<FontAwesomeIcon :icon="faCircleInfo" class="h-4 w-4 text-gray-600" />
<span>Predmeti</span>
</button>
<button
type="button"
class="w-full px-3 py-2 text-left text-sm text-gray-700 hover:bg-gray-50 flex items-center gap-2"
@click="openObjectDialog(c)"
>
<FontAwesomeIcon :icon="faPlus" class="h-4 w-4 text-gray-600" />
<span>Predmeti</span>
</button>
<button
type="button"
class="w-full px-3 py-2 text-left text-sm text-red-700 hover:bg-red-50 flex items-center gap-2"
@click="onDelete(c)"
>
<FontAwesomeIcon :icon="faTrash" class="h-4 w-4 text-red-600" />
<span>Briši</span>
</button>
<div class="my-1 border-t border-gray-100" />
<button
type="button"
class="w-full px-3 py-2 text-left text-sm text-gray-700 hover:bg-gray-50 flex items-center gap-2"
@click="onAddActivity(c)"
>
<FontAwesomeIcon :icon="faListCheck" class="h-4 w-4 text-gray-600" />
<span>Aktivnost</span>
</button>
</template>
</Dropdown>
</FwbTableCell>
</FwbTableRow>
</template>
</FwbTableBody>
</FwbTable>
<div
v-if="!contracts || contracts.length === 0"
class="p-6 text-center text-sm text-gray-500"
>
No contracts.
</div>
<!-- Confirm change segment -->
<div v-if="confirmChange.show" class="fixed inset-0 z-50 flex items-center justify-center bg-black/30">
<div class="bg-white rounded-lg shadow-lg p-4 w-full max-w-sm">
<div class="text-sm text-gray-800">
Ali želite spremeniti segment za pogodbo <span class="font-medium">{{ confirmChange.contract?.reference }}</span>?
</div>
<div class="mt-4 flex justify-end gap-2">
<button class="px-4 py-2 rounded bg-gray-200 hover:bg-gray-300" @click="closeConfirm">Prekliči</button>
<button class="px-4 py-2 rounded bg-indigo-600 text-white hover:bg-indigo-700" @click="doChangeSegment">Potrdi</button>
</div>
</div>
</div>
<CaseObjectCreateDialog
:show="showObjectDialog"
@close="closeObjectDialog"
:client_case="client_case"
:contract="selectedContract"
/>
<CaseObjectsDialog
:show="showObjectsList"
@close="closeObjectsList"
:client_case="client_case"
:contract="selectedContract"
/>
</template>
</div>
<!-- Confirm change segment -->
<div
v-if="confirmChange.show"
class="fixed inset-0 z-50 flex items-center justify-center bg-black/30"
>
<div class="bg-white rounded-lg shadow-lg p-4 w-full max-w-sm">
<div class="text-sm text-gray-800">
Ali želite spremeniti segment za pogodbo
<span class="font-medium">{{ confirmChange.contract?.reference }}</span
>?
</div>
<div class="mt-4 flex justify-end gap-2">
<button
class="px-4 py-2 rounded bg-gray-200 hover:bg-gray-300"
@click="closeConfirm"
>
Prekliči
</button>
<button
class="px-4 py-2 rounded bg-indigo-600 text-white hover:bg-indigo-700"
@click="doChangeSegment"
>
Potrdi
</button>
</div>
</div>
</div>
<CaseObjectCreateDialog
:show="showObjectDialog"
@close="closeObjectDialog"
:client_case="client_case"
:contract="selectedContract"
/>
<CaseObjectsDialog
:show="showObjectsList"
@close="closeObjectsList"
:client_case="client_case"
:contract="selectedContract"
/>
</template>
+18 -6
View File
@@ -24,6 +24,7 @@ const props = defineProps({
contracts: Array,
activities: Object,
contract_types: Array,
account_types: { type: Array, default: () => [] },
actions: Array,
types: Object,
documents: Array,
@@ -42,15 +43,19 @@ const onUploaded = () => {
const viewer = ref({ open: false, src: '', title: '' });
const openViewer = (doc) => {
const kind = classifyDocument(doc)
const isContractDoc = (doc?.documentable_type || '').toLowerCase().includes('contract')
if (kind === 'preview') {
const url = route('clientCase.document.view', { client_case: props.client_case.uuid, document: doc.uuid })
viewer.value = { open: true, src: url, title: doc.original_name || doc.name };
const url = isContractDoc && doc.contract_uuid
? route('contract.document.view', { contract: doc.contract_uuid, document: doc.uuid })
: route('clientCase.document.view', { client_case: props.client_case.uuid, document: doc.uuid })
viewer.value = { open: true, src: url, title: doc.original_name || doc.name }
} else {
const url = route('clientCase.document.download', { client_case: props.client_case.uuid, document: doc.uuid })
// immediate download: navigate to URL
const url = isContractDoc && doc.contract_uuid
? route('contract.document.download', { contract: doc.contract_uuid, document: doc.uuid })
: route('clientCase.document.download', { client_case: props.client_case.uuid, document: doc.uuid })
window.location.href = url
}
};
}
const closeViewer = () => { viewer.value.open = false; viewer.value.src = ''; };
const clientDetails = ref(false);
@@ -245,7 +250,12 @@ const submitAttachSegment = () => {
<DocumentsTable
:documents="documents"
@view="openViewer"
:download-url-builder="doc => route('clientCase.document.download', { client_case: client_case.uuid, document: doc.uuid })"
:download-url-builder="doc => {
const isContractDoc = (doc?.documentable_type || '').toLowerCase().includes('contract')
return isContractDoc && doc.contract_uuid
? route('contract.document.download', { contract: doc.contract_uuid, document: doc.uuid })
: route('clientCase.document.download', { client_case: client_case.uuid, document: doc.uuid })
}"
/>
</div>
</div>
@@ -256,6 +266,7 @@ const submitAttachSegment = () => {
@close="closeUpload"
@uploaded="onUploaded"
:post-url="route('clientCase.document.store', client_case)"
:contracts="contracts"
/>
<DocumentViewerDialog :show="viewer.open" :src="viewer.src" :title="viewer.title" @close="closeViewer" />
</AppLayout>
@@ -263,6 +274,7 @@ const submitAttachSegment = () => {
:show="drawerCreateContract"
@close="closeDrawer"
:types="contract_types"
:account_types="account_types"
:client_case="client_case"
:contract="contractEditing"
/>