Activity client case archived contract not auto-selected

This commit is contained in:
Simon Pocrnjič
2026-05-17 23:55:17 +02:00
parent 32fe2fbc9b
commit 256b311c43
@@ -54,7 +54,9 @@ const form = useInertiaForm({
props.actions[0].decisions.length > 0 props.actions[0].decisions.length > 0
? props.actions[0].decisions[0].id ? props.actions[0].decisions[0].id
: null, : null,
contract_uuids: props.contractUuid ? [props.contractUuid] : (props.contracts || []).map((c) => c.uuid), contract_uuids: props.contractUuid
? [props.contractUuid]
: (props.contracts || []).filter((item) => item.active == 1).map((c) => c.uuid),
send_auto_mail: true, send_auto_mail: true,
attach_documents: false, attach_documents: false,
attachment_document_ids: [], attachment_document_ids: [],
@@ -98,7 +100,9 @@ watch(
watch( watch(
() => props.contractUuid, () => props.contractUuid,
(cu) => { (cu) => {
form.contract_uuids = cu ? [cu] : (props.contracts || []).map((c) => c.uuid); form.contract_uuids = cu
? [cu]
: (props.contracts || []).filter((item) => item.active == 1).map((c) => c.uuid);
} }
); );
@@ -106,7 +110,9 @@ watch(
() => props.show, () => props.show,
(visible) => { (visible) => {
if (visible) { if (visible) {
form.contract_uuids = props.contractUuid ? [props.contractUuid] : (props.contracts || []).map((c) => c.uuid); form.contract_uuids = props.contractUuid
? [props.contractUuid]
: (props.contracts || []).filter((item) => item.active == 1).map((c) => c.uuid);
} }
} }
); );
@@ -131,15 +137,15 @@ const store = async () => {
const buildCallBackAt = (date, time) => { const buildCallBackAt = (date, time) => {
if (!date) return null; if (!date) return null;
const t = time || '00:00'; const t = time || "00:00";
const [h, m] = t.split(':'); const [h, m] = t.split(":");
const d = date instanceof Date ? date : new Date(date); const d = date instanceof Date ? date : new Date(date);
if (isNaN(d.getTime())) return null; if (isNaN(d.getTime())) return null;
const y = d.getFullYear(); const y = d.getFullYear();
const mo = String(d.getMonth() + 1).padStart(2, '0'); const mo = String(d.getMonth() + 1).padStart(2, "0");
const dy = String(d.getDate()).padStart(2, '0'); const dy = String(d.getDate()).padStart(2, "0");
const hh = String(Number(h || 0)).padStart(2, '0'); const hh = String(Number(h || 0)).padStart(2, "0");
const mm = String(Number(m || 0)).padStart(2, '0'); const mm = String(Number(m || 0)).padStart(2, "0");
return `${y}-${mo}-${dy} ${hh}:${mm}:00`; return `${y}-${mo}-${dy} ${hh}:${mm}:00`;
}; };
@@ -163,7 +169,14 @@ const store = async () => {
.post(route("clientCase.activity.store", props.client_case), { .post(route("clientCase.activity.store", props.client_case), {
onSuccess: () => { onSuccess: () => {
close(); close();
form.reset("due_date", "amount", "note", "contract_uuids", "call_back_at_date", "call_back_at_time"); form.reset(
"due_date",
"amount",
"note",
"contract_uuids",
"call_back_at_date",
"call_back_at_time"
);
emit("saved"); emit("saved");
}, },
}); });
@@ -181,7 +194,7 @@ const currentDecision = () => {
const hasCallLaterEvent = computed(() => { const hasCallLaterEvent = computed(() => {
const d = currentDecision(); const d = currentDecision();
if (!d) return false; if (!d) return false;
return Array.isArray(d.events) && d.events.some((e) => e.key === 'add_call_later'); return Array.isArray(d.events) && d.events.some((e) => e.key === "add_call_later");
}); });
watch( watch(
@@ -215,7 +228,7 @@ const autoMailRequiresContract = computed(() => {
const contractItems = computed(() => { const contractItems = computed(() => {
return pageContracts.value.map((c) => ({ return pageContracts.value.map((c) => ({
value: c.uuid, value: c.uuid,
label: `${c.reference}${c.name ? ` - ${c.name}` : ""}`, label: c.active == 1 ? `${c.reference}` : `${c.reference} (Arhivirano)`,
})); }));
}); });