Changes to import and notifications
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<script setup>
|
||||
import { ref, watch } from "vue";
|
||||
import { ref } from "vue";
|
||||
import AppLayout from "@/Layouts/AppLayout.vue";
|
||||
import PrimaryButton from "@/Components/PrimaryButton.vue";
|
||||
import InputLabel from "@/Components/InputLabel.vue";
|
||||
@@ -7,8 +7,7 @@ import TextInput from "@/Components/TextInput.vue";
|
||||
import { Link, useForm, router } from "@inertiajs/vue3";
|
||||
import ActionMessage from "@/Components/ActionMessage.vue";
|
||||
import DialogModal from "@/Components/DialogModal.vue";
|
||||
import Pagination from "@/Components/Pagination.vue";
|
||||
import { debounce } from "lodash";
|
||||
import DataTableServer from "@/Components/DataTable/DataTableServer.vue";
|
||||
|
||||
const props = defineProps({
|
||||
clients: Object,
|
||||
@@ -41,25 +40,8 @@ const formClient = useForm({
|
||||
//Create client drawer
|
||||
const drawerCreateClient = ref(false);
|
||||
|
||||
// Search state (table-friendly, SPA)
|
||||
const search = ref(props.filters?.search || "");
|
||||
const applySearch = debounce((term) => {
|
||||
const params = Object.fromEntries(
|
||||
new URLSearchParams(window.location.search).entries()
|
||||
);
|
||||
if (term) {
|
||||
params.search = term;
|
||||
} else {
|
||||
delete params.search;
|
||||
}
|
||||
delete params.page; // reset pagination
|
||||
router.get(route("client"), params, {
|
||||
preserveState: true,
|
||||
replace: true,
|
||||
preserveScroll: true,
|
||||
});
|
||||
}, 300);
|
||||
watch(search, (v) => applySearch(v));
|
||||
// Initial search (passed to DataTable toolbar)
|
||||
const initialSearch = ref(props.filters?.search || "");
|
||||
|
||||
//Open drawer create client
|
||||
const openDrawerCreateClient = () => {
|
||||
@@ -105,74 +87,86 @@ const fmtCurrency = (v) => {
|
||||
<div class="py-12">
|
||||
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
|
||||
<div class="px-3 bg-white overflow-hidden shadow-xl sm:rounded-lg">
|
||||
<div class="mx-auto max-w-4x1 py-3">
|
||||
<div class="mx-auto max-w-4x1 py-3 space-y-3">
|
||||
<!-- Top actions -->
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<PrimaryButton @click="openDrawerCreateClient" class="bg-blue-400"
|
||||
<PrimaryButton
|
||||
@click="openDrawerCreateClient"
|
||||
class="bg-blue-600 hover:bg-blue-700"
|
||||
>Dodaj</PrimaryButton
|
||||
>
|
||||
<input
|
||||
v-model="search"
|
||||
type="text"
|
||||
placeholder="Iskanje po imenu"
|
||||
class="w-full sm:w-80 rounded border-gray-300 focus:border-indigo-500 focus:ring-indigo-500 px-3 py-2 text-sm"
|
||||
/>
|
||||
</div>
|
||||
<div class="overflow-x-auto mt-3">
|
||||
<table class="min-w-full text-left text-sm">
|
||||
<thead>
|
||||
<tr class="border-b">
|
||||
<th class="py-2 pr-4">Št.</th>
|
||||
<th class="py-2 pr-4">Naročnik</th>
|
||||
<th class="py-2 pr-4 text-right">Primeri z aktivnimi pogodbami</th>
|
||||
<th class="py-2 pr-4 text-right">Skupaj stanje</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr
|
||||
v-for="client in clients.data"
|
||||
:key="client.uuid"
|
||||
class="border-b last:border-0"
|
||||
|
||||
<!-- DataTable (server-side) -->
|
||||
<DataTableServer
|
||||
:columns="[
|
||||
{ key: 'nu', label: 'Št.', sortable: false, class: 'w-40' },
|
||||
{ key: 'name', label: 'Naročnik', sortable: false },
|
||||
{
|
||||
key: 'cases',
|
||||
label: 'Primeri z aktivnimi pogodbami',
|
||||
sortable: false,
|
||||
align: 'right',
|
||||
},
|
||||
{
|
||||
key: 'balance',
|
||||
label: 'Skupaj stanje',
|
||||
sortable: false,
|
||||
align: 'right',
|
||||
},
|
||||
]"
|
||||
:rows="clients.data || []"
|
||||
:meta="{
|
||||
current_page: clients.current_page,
|
||||
per_page: clients.per_page,
|
||||
total: clients.total,
|
||||
last_page: clients.last_page,
|
||||
}"
|
||||
:sort="{
|
||||
key: props.filters?.sort || null,
|
||||
direction: props.filters?.direction || null,
|
||||
}"
|
||||
:search="initialSearch"
|
||||
route-name="client"
|
||||
row-key="uuid"
|
||||
:page-size-options="[clients.per_page]"
|
||||
:only-props="['clients']"
|
||||
>
|
||||
<template #cell-nu="{ row }">
|
||||
{{ row.person?.nu || "-" }}
|
||||
</template>
|
||||
<template #cell-name="{ row }">
|
||||
<Link
|
||||
:href="route('client.show', { uuid: row.uuid })"
|
||||
class="text-indigo-600 hover:underline"
|
||||
>
|
||||
{{ row.person?.full_name || "-" }}
|
||||
</Link>
|
||||
<div v-if="!row.person" class="mt-1">
|
||||
<PrimaryButton
|
||||
class="!py-0.5 !px-2 bg-red-500 hover:bg-red-600 text-xs"
|
||||
@click.prevent="
|
||||
router.post(route('client.emergencyPerson', { uuid: row.uuid }))
|
||||
"
|
||||
>Add Person</PrimaryButton
|
||||
>
|
||||
<td class="py-2 pr-4">{{ client.person?.nu || "-" }}</td>
|
||||
<td class="py-2 pr-4">
|
||||
<Link
|
||||
:href="route('client.show', { uuid: client.uuid })"
|
||||
class="text-indigo-600 hover:underline"
|
||||
>
|
||||
{{ client.person?.full_name || "-" }}
|
||||
</Link>
|
||||
<div v-if="!client.person" class="mt-1">
|
||||
<PrimaryButton
|
||||
class="!py-0.5 !px-2 bg-red-500 hover:bg-red-600 text-xs"
|
||||
@click.prevent="
|
||||
router.post(
|
||||
route('client.emergencyPerson', { uuid: client.uuid })
|
||||
)
|
||||
"
|
||||
>Add Person</PrimaryButton
|
||||
>
|
||||
</div>
|
||||
</td>
|
||||
<td class="py-2 pr-4 text-right">
|
||||
{{ client.cases_with_active_contracts_count ?? 0 }}
|
||||
</td>
|
||||
<td class="py-2 pr-4 text-right">
|
||||
{{ fmtCurrency(client.active_contracts_balance_sum) }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!clients.data || clients.data.length === 0">
|
||||
<td colspan="4" class="py-4 text-gray-500">Ni zadetkov.</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template #cell-cases="{ row }">
|
||||
<div class="text-right">
|
||||
{{ row.cases_with_active_contracts_count ?? 0 }}
|
||||
</div>
|
||||
</template>
|
||||
<template #cell-balance="{ row }">
|
||||
<div class="text-right">
|
||||
{{ fmtCurrency(row.active_contracts_balance_sum) }}
|
||||
</div>
|
||||
</template>
|
||||
<template #empty>
|
||||
<div class="p-6 text-center text-gray-500">Ni zadetkov.</div>
|
||||
</template>
|
||||
</DataTableServer>
|
||||
</div>
|
||||
<Pagination
|
||||
:links="clients.links"
|
||||
:from="clients.from"
|
||||
:to="clients.to"
|
||||
:total="clients.total"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user