From 55f7d330140f10e3e20c4f5e923520f6f97302da Mon Sep 17 00:00:00 2001 From: Michael Johnson Date: Thu, 7 Nov 2024 11:42:17 -0700 Subject: [PATCH] Investigation and Inspection --- web/src/components/incident/DetailsPage.vue | 43 +++- .../components/incident/InvestigationForm.vue | 220 ++++++++++++++++++ web/src/components/incident/OperationMenu.vue | 12 +- .../inspection/CreateInspectionPage.vue | 177 ++++++++++++++ web/src/routes.ts | 7 + web/src/store/ReportStore.ts | 13 +- web/src/views/Home.vue | 2 + 7 files changed, 455 insertions(+), 19 deletions(-) create mode 100644 web/src/components/incident/InvestigationForm.vue create mode 100644 web/src/components/inspection/CreateInspectionPage.vue diff --git a/web/src/components/incident/DetailsPage.vue b/web/src/components/incident/DetailsPage.vue index 424a144..f471b5d 100644 --- a/web/src/components/incident/DetailsPage.vue +++ b/web/src/components/incident/DetailsPage.vue @@ -30,7 +30,7 @@ @@ -49,7 +49,7 @@ @@ -147,10 +147,13 @@ - Investigation + Save + + Start Investigation + @@ -173,6 +176,11 @@ + + @@ -181,6 +189,7 @@ import { computed, ref } from "vue"; import { storeToRefs } from "pinia"; import { DateTime } from "luxon"; import { useRoute } from "vue-router"; +import { isNil } from "lodash"; import { useDisplay } from "vuetify"; const { smAndDown } = useDisplay(); @@ -190,12 +199,13 @@ import ActionList from "@/components/action/ActionList.vue"; import HazardList from "@/components/hazard/HazardList.vue"; import ActionCreate from "@/components/action/ActionCreate.vue"; import ActionEdit from "@/components/action/ActionEdit.vue"; +import InvestigationForm from "./InvestigationForm.vue"; import { useReportStore } from "@/store/ReportStore"; const reportStore = useReportStore(); -const { initialize, loadReport, updateReport, openAttachment } = reportStore; -const { locations, urgencies, selectedReport } = storeToRefs(reportStore); +const { initialize, loadReport, updateReport, openAttachment, completeStep } = reportStore; +const { currentStep, selectedReport } = storeToRefs(reportStore); const router = useRoute(); const reportId = router.params.id; @@ -203,10 +213,20 @@ const reportId = router.params.id; await initialize(); await loadReport(reportId); +const showInvestigationDialog = ref(false); + const showActionAdd = ref(false); const showActionEdit = ref(false); const actionToEdit = ref(null); +const investigationIsActive = computed(() => { + if (currentStep.value) { + return currentStep.value.step_title.indexOf("Investig") >= 0; + } + + return false; +}); + const tickLabels = { 0: "Low", 1: "Medium", @@ -284,6 +304,17 @@ async function saveClick() { await updateReport(); } +function investigationClick() { + showInvestigationDialog.value = true; +} + +async function completeInvestigation() { + if (currentStep.value) { + await completeStep(currentStep.value); + showInvestigationDialog.value = false; + } +} + function openAttachmentClick(attachment) { openAttachment(attachment); } diff --git a/web/src/components/incident/InvestigationForm.vue b/web/src/components/incident/InvestigationForm.vue new file mode 100644 index 0000000..4599d82 --- /dev/null +++ b/web/src/components/incident/InvestigationForm.vue @@ -0,0 +1,220 @@ + + + diff --git a/web/src/components/incident/OperationMenu.vue b/web/src/components/incident/OperationMenu.vue index 7c79550..88f3086 100644 --- a/web/src/components/incident/OperationMenu.vue +++ b/web/src/components/incident/OperationMenu.vue @@ -36,17 +36,7 @@ import { useReportStore } from "@/store/ReportStore"; const reportStore = useReportStore(); const { completeStep, revertStep } = reportStore; -const { selectedReport } = storeToRefs(reportStore); - -const currentStep = computed(() => { - if (selectedReport.value) { - for (const step of selectedReport.value.steps) { - if (step.complete_date) continue; - return step; - } - } - return {}; -}); +const { currentStep, selectedReport } = storeToRefs(reportStore); const previousStep = computed(() => { if (selectedReport.value) { diff --git a/web/src/components/inspection/CreateInspectionPage.vue b/web/src/components/inspection/CreateInspectionPage.vue new file mode 100644 index 0000000..3ef45b5 --- /dev/null +++ b/web/src/components/inspection/CreateInspectionPage.vue @@ -0,0 +1,177 @@ + + + diff --git a/web/src/routes.ts b/web/src/routes.ts index 7e6b949..c9d9a1e 100644 --- a/web/src/routes.ts +++ b/web/src/routes.ts @@ -46,6 +46,13 @@ const routes: RouteRecordRaw[] = [ component: () => import("@/components/incident/DetailsPage.vue"), }, + { + path: "inspection", + component: () => import("@/components/inspection/CreateInspectionPage.vue"), + }, + + + { path: "sign-in", component: () => import("@/modules/authentication/views/SignIn.vue"), diff --git a/web/src/store/ReportStore.ts b/web/src/store/ReportStore.ts index b0e391c..5932d94 100644 --- a/web/src/store/ReportStore.ts +++ b/web/src/store/ReportStore.ts @@ -11,6 +11,17 @@ export const useReportStore = defineStore("reports", { selectedReport: undefined as Incident | undefined, isLoading: false, }), + getters: { + currentStep(state) { + if (state.selectedReport && state.selectedReport.steps) { + for (const step of state.selectedReport.steps) { + if (step.complete_date) continue; + return step; + } + } + return {}; + }, + }, actions: { async initialize() { console.log("Initializing Report Store"); @@ -66,7 +77,6 @@ export const useReportStore = defineStore("reports", { }, async addReport(report: Incident) { - console.log("ADDREPORT", report); this.myReports.push(report); const api = useApiStore(); @@ -89,7 +99,6 @@ export const useReportStore = defineStore("reports", { }, async addReportOffline(report: Incident) { - console.log("ADDREPORTOFFLINE", report); this.isLoading = true; const api = useApiStore(); diff --git a/web/src/views/Home.vue b/web/src/views/Home.vue index d758e9f..79fd96e 100644 --- a/web/src/views/Home.vue +++ b/web/src/views/Home.vue @@ -16,6 +16,8 @@

+ + Start Inspection