Big changes added events for decisions
This commit is contained in:
@@ -6,13 +6,13 @@ import PersonDetailPhone from "@/Components/PersonDetailPhone.vue";
|
||||
// import DocumentsTable from '@/Components/DocumentsTable.vue';
|
||||
import DocumentViewerDialog from "@/Components/DocumentViewerDialog.vue";
|
||||
import { classifyDocument } from "@/Services/documents";
|
||||
import { reactive, ref, computed } from "vue";
|
||||
import { reactive, ref, computed, watch, onMounted } from "vue";
|
||||
import DialogModal from "@/Components/DialogModal.vue";
|
||||
import InputLabel from "@/Components/InputLabel.vue";
|
||||
import TextInput from "@/Components/TextInput.vue";
|
||||
import PrimaryButton from "@/Components/PrimaryButton.vue";
|
||||
import BasicButton from "@/Components/buttons/BasicButton.vue";
|
||||
import { useForm } from "@inertiajs/vue3";
|
||||
import { useForm, router } from "@inertiajs/vue3";
|
||||
import ActivityDrawer from "@/Pages/Cases/Partials/ActivityDrawer.vue";
|
||||
import ConfirmationModal from "@/Components/ConfirmationModal.vue";
|
||||
|
||||
@@ -112,6 +112,37 @@ const closeDrawer = () => {
|
||||
drawerAddActivity.value = false;
|
||||
};
|
||||
|
||||
// After an activity is saved, if there are no contracts left for this case (assigned to me),
|
||||
// redirect back to the Phone index to pick the next case.
|
||||
const onActivitySaved = () => {
|
||||
// Inertia onSuccess already refreshed props, so props.contracts reflects current state.
|
||||
const count = Array.isArray(props.contracts) ? props.contracts.length : 0;
|
||||
if (count === 0) {
|
||||
router.visit(route("phone.index"));
|
||||
}
|
||||
};
|
||||
|
||||
// Also react if the page is reloaded with zero contracts (e.g., after EndFieldJob moves the only contract):
|
||||
const redirectIfNoContracts = () => {
|
||||
const count = Array.isArray(props.contracts) ? props.contracts.length : 0;
|
||||
if (count === 0) {
|
||||
router.visit(route("phone.index"));
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => {
|
||||
redirectIfNoContracts();
|
||||
});
|
||||
|
||||
watch(
|
||||
() => (Array.isArray(props.contracts) ? props.contracts.length : null),
|
||||
(len) => {
|
||||
if (len === 0) {
|
||||
router.visit(route("phone.index"));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Document upload state
|
||||
const docDialogOpen = ref(false);
|
||||
const docForm = useForm({
|
||||
@@ -533,6 +564,7 @@ const clientSummary = computed(() => {
|
||||
<ActivityDrawer
|
||||
:show="drawerAddActivity"
|
||||
@close="closeDrawer"
|
||||
@saved="onActivitySaved"
|
||||
:client_case="client_case"
|
||||
:actions="actions"
|
||||
:contract-uuid="activityContractUuid"
|
||||
|
||||
Reference in New Issue
Block a user