changes to UI mostly

This commit is contained in:
Simon Pocrnjič
2025-09-30 22:00:03 +02:00
parent 53917f2ca0
commit db99a57030
18 changed files with 2169 additions and 777 deletions
+171 -64
View File
@@ -12,11 +12,11 @@ import DocumentsTable from "@/Components/DocumentsTable.vue";
import DocumentUploadDialog from "@/Components/DocumentUploadDialog.vue";
import DocumentViewerDialog from "@/Components/DocumentViewerDialog.vue";
import { classifyDocument } from "@/Services/documents";
import { router, useForm } from '@inertiajs/vue3';
import { router, useForm } from "@inertiajs/vue3";
import { AngleDownIcon, AngleUpIcon } from "@/Utilities/Icons";
import Pagination from "@/Components/Pagination.vue";
import ConfirmDialog from "@/Components/ConfirmDialog.vue";
import DialogModal from '@/Components/DialogModal.vue';
import DialogModal from "@/Components/DialogModal.vue";
const props = defineProps({
client: Object,
@@ -30,33 +30,55 @@ const props = defineProps({
documents: Array,
segments: { type: Array, default: () => [] },
all_segments: { type: Array, default: () => [] },
current_segment: { type: Object, default: null },
});
const showUpload = ref(false);
const openUpload = () => { showUpload.value = true; };
const closeUpload = () => { showUpload.value = false; };
const openUpload = () => {
showUpload.value = true;
};
const closeUpload = () => {
showUpload.value = false;
};
const onUploaded = () => {
// Refresh page data to include the new document
router.reload({ only: ['documents'] });
router.reload({ only: ["documents"] });
};
const viewer = ref({ open: false, src: '', title: '' });
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 = 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 }
const kind = classifyDocument(doc);
const isContractDoc = (doc?.documentable_type || "").toLowerCase().includes("contract");
if (kind === "preview") {
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 = 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 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 closeViewer = () => {
viewer.value.open = false;
viewer.value.src = "";
};
const clientDetails = ref(false);
@@ -82,17 +104,36 @@ const openDrawerAddActivity = (c = null) => {
};
// delete confirmation
const confirmDelete = ref({ show: false, contract: null })
const requestDeleteContract = (c) => { confirmDelete.value = { show: true, contract: c } }
const closeConfirmDelete = () => { confirmDelete.value.show = false; confirmDelete.value.contract = null }
const confirmDelete = ref({ show: false, contract: null });
const requestDeleteContract = (c) => {
confirmDelete.value = { show: true, contract: c };
};
const closeConfirmDelete = () => {
confirmDelete.value.show = false;
confirmDelete.value.contract = null;
};
const doDeleteContract = () => {
const c = confirmDelete.value.contract
if (!c) return closeConfirmDelete()
router.delete(route('clientCase.contract.delete', { client_case: props.client_case.uuid, uuid: c.uuid }), {
preserveScroll: true,
onFinish: () => closeConfirmDelete(),
})
}
const c = confirmDelete.value.contract;
if (!c) return closeConfirmDelete();
// Keep segment filter in redirect
const params = {};
try {
const url = new URL(window.location.href);
const seg = url.searchParams.get("segment");
if (seg) params.segment = seg;
} catch (e) {}
router.delete(
route("clientCase.contract.delete", {
client_case: props.client_case.uuid,
uuid: c.uuid,
...params,
}),
{
preserveScroll: true,
onFinish: () => closeConfirmDelete(),
}
);
};
//Close drawer (all)
const closeDrawer = () => {
@@ -109,35 +150,52 @@ const hideClietnDetails = () => {
};
// Attach segment to case
const showAttachSegment = ref(false)
const openAttachSegment = () => { showAttachSegment.value = true }
const closeAttachSegment = () => { showAttachSegment.value = false }
const attachForm = useForm({ segment_id: null })
const showAttachSegment = ref(false);
const openAttachSegment = () => {
showAttachSegment.value = true;
};
const closeAttachSegment = () => {
showAttachSegment.value = false;
};
const attachForm = useForm({ segment_id: null });
const availableSegments = computed(() => {
const current = new Set((props.segments || []).map(s => s.id))
return (props.all_segments || []).filter(s => !current.has(s.id))
})
const current = new Set((props.segments || []).map((s) => s.id));
return (props.all_segments || []).filter((s) => !current.has(s.id));
});
const submitAttachSegment = () => {
if (!attachForm.segment_id) { return }
attachForm.post(route('clientCase.segments.attach', props.client_case), {
if (!attachForm.segment_id) {
return;
}
attachForm.post(route("clientCase.segments.attach", props.client_case), {
preserveScroll: true,
only: ['segments'],
only: ["segments"],
onSuccess: () => {
closeAttachSegment()
attachForm.reset('segment_id')
}
})
}
closeAttachSegment();
attachForm.reset("segment_id");
},
});
};
</script>
<template>
<AppLayout title="Client case">
<template #header></template>
<div class="pt-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<!-- Current segment badge (right aligned, above the card) -->
<div v-if="current_segment" class="flex justify-end pb-3">
<div class="text-sm text-gray-700">
<span class="mr-2">Segment:</span>
<span
class="inline-block px-3 py-1 rounded-md border border-indigo-200 bg-indigo-50 text-indigo-800 font-medium"
>
{{ current_segment.name }}
</span>
</div>
</div>
<div
class="bg-white overflow-hidden shadow-xl sm:rounded-lg border-l-4 border-blue-500"
>
<div class="mx-auto max-w-4x1 p-3 flex justify-between">
<div class="mx-auto max-w-4x1 p-3 flex justify-between items-center">
<SectionTitle>
<template #title>
<a class="hover:text-blue-500" :href="route('client.show', client)">
@@ -175,9 +233,15 @@ const submitAttachSegment = () => {
<SectionTitle>
<template #title> Primer - oseba </template>
</SectionTitle>
<div v-if="client_case && client_case.client_ref" class="text-xs text-gray-600">
<div
v-if="client_case && client_case.client_ref"
class="text-xs text-gray-600"
>
<span class="mr-1">Ref:</span>
<span class="inline-block px-2 py-0.5 rounded border bg-gray-50 font-mono text-gray-700">{{ client_case.client_ref }}</span>
<span
class="inline-block px-2 py-0.5 rounded border bg-gray-50 font-mono text-gray-700"
>{{ client_case.client_ref }}</span
>
</div>
</div>
</div>
@@ -189,7 +253,11 @@ const submitAttachSegment = () => {
class="bg-white overflow-hidden shadow-xl sm:rounded-lg border-l-4 border-red-400"
>
<div class="mx-auto max-w-4x1 p-3">
<PersonInfoGrid :types="types" tab-color="red-600" :person="client_case.person" />
<PersonInfoGrid
:types="types"
tab-color="red-600"
:person="client_case.person"
/>
</div>
</div>
</div>
@@ -204,8 +272,16 @@ const submitAttachSegment = () => {
</SectionTitle>
<div class="flex items-center gap-2">
<FwbButton @click="openDrawerCreateContract">Nova</FwbButton>
<FwbButton color="light" :disabled="availableSegments.length === 0" @click="openAttachSegment">
{{ availableSegments.length ? 'Dodaj segment' : 'Ni razpoložljivih segmentov' }}
<FwbButton
color="light"
:disabled="availableSegments.length === 0"
@click="openAttachSegment"
>
{{
availableSegments.length
? "Dodaj segment"
: "Ni razpoložljivih segmentov"
}}
</FwbButton>
</div>
</div>
@@ -222,7 +298,7 @@ const submitAttachSegment = () => {
</div>
</div>
</div>
<div class="pt-12 pb-6">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-xl sm:rounded-lg border-l-4">
@@ -230,12 +306,16 @@ const submitAttachSegment = () => {
<div class="flex justify-between p-4">
<SectionTitle>
<template #title>Aktivnosti</template>
</SectionTitle>
<FwbButton @click="openDrawerAddActivity">Nova</FwbButton>
</div>
<ActivityTable :client_case="client_case" :activities="activities" />
<Pagination :links="activities.links" :from="activities.from" :to="activities.to" :total="activities.total" />
<Pagination
:links="activities.links"
:from="activities.from"
:to="activities.to"
:total="activities.total"
/>
</div>
</div>
</div>
@@ -254,12 +334,22 @@ const submitAttachSegment = () => {
<DocumentsTable
:documents="documents"
@view="openViewer"
: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 })
}"
: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>
@@ -272,7 +362,12 @@ const submitAttachSegment = () => {
:post-url="route('clientCase.document.store', client_case)"
:contracts="contracts"
/>
<DocumentViewerDialog :show="viewer.open" :src="viewer.src" :title="viewer.title" @close="closeViewer" />
<DocumentViewerDialog
:show="viewer.open"
:src="viewer.src"
:title="viewer.title"
@close="closeViewer"
/>
</AppLayout>
<ContractDrawer
:show="drawerCreateContract"
@@ -303,16 +398,28 @@ const submitAttachSegment = () => {
<template #content>
<div class="space-y-2">
<label class="block text-sm font-medium text-gray-700">Segment</label>
<select v-model="attachForm.segment_id" class="w-full rounded border-gray-300 focus:border-indigo-500 focus:ring-indigo-500">
<select
v-model="attachForm.segment_id"
class="w-full rounded border-gray-300 focus:border-indigo-500 focus:ring-indigo-500"
>
<option :value="null" disabled>-- izberi segment --</option>
<option v-for="s in availableSegments" :key="s.id" :value="s.id">{{ s.name }}</option>
<option v-for="s in availableSegments" :key="s.id" :value="s.id">
{{ s.name }}
</option>
</select>
<div v-if="attachForm.errors.segment_id" class="text-sm text-red-600">{{ attachForm.errors.segment_id }}</div>
<div v-if="attachForm.errors.segment_id" class="text-sm text-red-600">
{{ attachForm.errors.segment_id }}
</div>
</div>
</template>
<template #footer>
<FwbButton color="light" @click="closeAttachSegment">Prekliči</FwbButton>
<FwbButton class="ml-2" :disabled="attachForm.processing || !attachForm.segment_id" @click="submitAttachSegment">Dodaj</FwbButton>
<FwbButton
class="ml-2"
:disabled="attachForm.processing || !attachForm.segment_id"
@click="submitAttachSegment"
>Dodaj</FwbButton
>
</template>
</DialogModal>
</template>