Skip to content

Commit 31e6368

Browse files
committed
Changes for committee
1 parent c126a17 commit 31e6368

16 files changed

+847
-18
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import * as knex from "knex";
2+
3+
export async function up(knex: knex.Knex) {
4+
await knex.schema.alterTable("actions", function (table) {
5+
table.integer("is_committee_task").nullable();
6+
table.string("committee_supervisor_response", 500).nullable();
7+
table.string("committee_task_rationale", 2000).nullable();
8+
table.text("comments").nullable();
9+
});
10+
11+
await knex("actions").whereNull("is_committee_task").update({ is_committee_task: 0 });
12+
}
13+
14+
export async function down(knex: knex.Knex) {
15+
await knex.schema.alterTable("actions", function (table) {
16+
table.dropColumn("is_committee_task");
17+
table.dropColumn("committee_supervisor_response");
18+
table.dropColumn("committee_task_rationale");
19+
table.dropColumn("comments");
20+
});
21+
}

api/src/data/models/action-model.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ export interface Action {
2626
categories?: string | string[];
2727
title?: string | null;
2828

29+
is_committee_task?: number;
30+
committee_supervisor_response?: string;
31+
committee_task_rationale?: string;
32+
comments?: string;
33+
2934
type?: ActionType;
3035
status?: ActionStatus;
3136
actor_display_name?: string;

api/src/data/models/incident-model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export interface Incident {
3535
attachments?: any[];
3636
steps?: IncidentStep[];
3737
actions?: Action[];
38+
committee_actions?: Action[];
3839
hazards?: IncidentHazard[];
3940
investigation?: Investigation;
4041
location?: Location;

api/src/routes/action-router.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ actionRouter.post("/", async (req: Request, res: Response) => {
125125
control,
126126
categories,
127127
title,
128+
is_committee_task,
128129
} = req.body;
129130

130131
const incident = await knex("incidents")
@@ -154,6 +155,7 @@ actionRouter.post("/", async (req: Request, res: Response) => {
154155
control,
155156
categories: newCategories.join(","),
156157
title,
158+
is_committee_task: is_committee_task ?? 0,
157159
} as Action;
158160

159161
await knex("actions").insert(action);
@@ -181,6 +183,9 @@ actionRouter.put("/:slug", async (req: Request, res: Response) => {
181183
control,
182184
categories,
183185
title,
186+
committee_supervisor_response,
187+
committee_task_rationale,
188+
comments,
184189
} = req.body;
185190
let { actor_user_id } = req.body;
186191

@@ -216,6 +221,9 @@ actionRouter.put("/:slug", async (req: Request, res: Response) => {
216221
control,
217222
categories: newCategories.join(","),
218223
title,
224+
committee_supervisor_response,
225+
committee_task_rationale,
226+
comments,
219227
});
220228

221229
await updateActionHazards(action, status_code, urgency_code, control);

api/src/routes/report-router.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -561,21 +561,23 @@ reportRouter.post("/:id/send-committee-request", async (req: Request, res: Respo
561561

562562
const incidentSteps = await knex("incident_steps").where({ incident_id: id }).orderBy("order");
563563

564-
const notificationStep = incidentSteps.find((step: IncidentStep) => step.step_title == "Employee Notification");
564+
const implementedStep = incidentSteps.find((step: IncidentStep) => step.step_title == "Controls Implemented");
565565
const requestStep = incidentSteps.find((step: IncidentStep) => step.step_title == "Committee Review");
566566

567567
if (!isNil(requestStep)) return res.status(400).send("Step already exists");
568568

569569
const newStep = {
570570
incident_id: id,
571571
step_title: "Committee Review",
572-
order: notificationStep.order,
572+
order: implementedStep.order,
573573
activate_date: new Date(),
574574
};
575575

576-
await knex("incident_steps")
577-
.where({ id: notificationStep.id })
578-
.update({ order: notificationStep.order + 1 });
576+
await knex.raw(`UPDATE "incident_steps" SET "order" = "order" + 1 WHERE "incident_id" = ? AND "order" >= ?`, [
577+
id,
578+
implementedStep.order,
579+
]);
580+
579581
await knex("incident_steps").insert(newStep);
580582

581583
for (const user of committeeUsers) {

api/src/services/incident-service.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class IncidentService {
7171
.select("id", "incident_id", "added_by_email", "file_name", "file_type", "file_size", "added_date");
7272

7373
item.steps = await db("incident_steps").where({ incident_id: item.id }).orderBy("order");
74-
item.actions = await db("actions").where({ incident_id: item.id }).orderBy("due_date").orderBy("id");
74+
const allActions = await db("actions").where({ incident_id: item.id }).orderBy("due_date").orderBy("id");
7575
item.investigation = await db("investigations").where({ incident_id: item.id }).first();
7676
item.access = await db("incident_users_view").where({
7777
incident_id: item.id,
@@ -100,7 +100,7 @@ export class IncidentService {
100100
.first();
101101
}
102102

103-
for (let action of item.actions) {
103+
for (let action of allActions) {
104104
if (action.actor_role_type_id) {
105105
action.actor_display_name = (
106106
await db("role_types").where({ id: action.actor_role_type_id }).first()
@@ -112,9 +112,12 @@ export class IncidentService {
112112
}
113113

114114
action.categories = action.categories ?? [];
115-
if (!isArray(action.categories)) action.categories = action.categories.split(",").filter((c) => c);
115+
if (!isArray(action.categories)) action.categories = action.categories.split(",").filter((c: string) => c);
116116
}
117117

118+
item.actions = allActions.filter((a) => a.is_committee_task !== 1);
119+
item.committee_actions = allActions.filter((a) => a.is_committee_task === 1);
120+
118121
return item;
119122
}
120123

web/src/components/action/ActionCompleteForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="pa-4">
2+
<div>
33
<v-row>
44
<v-col cols="12">
55
<v-label>Title</v-label>

web/src/components/action/ActionDialog.vue

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,12 @@
1616
</v-card-text>
1717

1818
<v-card-text v-else>
19-
<div class="bg-white" style="border: 1px #ddd solid; border-radius: 4px">
20-
<ActionCompleteForm :action="action" :readonly="readonly" @do-close="closeClick" />
21-
</div>
19+
<ActionCompleteForm
20+
v-if="action.is_committee_task == 0"
21+
:action="action"
22+
:readonly="readonly"
23+
@do-close="closeClick" />
24+
<CommitteeActionCompleteForm v-else :action="action" :readonly="readonly" @do-close="closeClick" />
2225

2326
<div v-if="hazardId" class="mt-5">
2427
<v-label>Attachments</v-label>
@@ -65,6 +68,7 @@ const emit = defineEmits(["doClose"]);
6568
import { useHazardStore } from "@/store/HazardStore";
6669
import ActionCompleteForm from "./ActionCompleteForm.vue";
6770
import ActionClassifyForm from "./ActionClassifyForm.vue";
71+
import CommitteeActionCompleteForm from "./CommitteeActionCompleteForm.vue";
6872
6973
const hazardStore = useHazardStore();
7074
const { attachments } = storeToRefs(hazardStore);

0 commit comments

Comments
 (0)