@7365admin1/layer-common 4.97.1-staging.540 → 4.97.1-staging.542

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/CHANGELOG.md +4 -4
  2. package/components/AddPassKeyToVisitor.vue +5 -0
  3. package/components/DocumentManagement.vue +62 -3
  4. package/components/FeedbackHandlingSettings.vue +385 -0
  5. package/components/HandoverChecklistRecords.vue +223 -0
  6. package/components/HandoverChecklistSetup.vue +224 -0
  7. package/components/IncidentReport/Attachments.vue +116 -0
  8. package/components/IncidentReport/IncidentInformation.vue +11 -0
  9. package/components/IncidentReport/IncidentInformationDownload.vue +279 -152
  10. package/components/IncidentReportEmailsSettings.vue +88 -0
  11. package/components/KeyPressFilter.vue +43 -0
  12. package/components/KeyPressName.vue +14 -0
  13. package/components/KeyPressSelect.vue +31 -0
  14. package/components/KeySettingsPanel.vue +156 -0
  15. package/components/ListCsvExport.vue +71 -0
  16. package/components/MaStaffRegistrationSettings.vue +61 -0
  17. package/components/PassInformation.vue +5 -0
  18. package/components/Robot/Detail.vue +10 -7
  19. package/components/Robot/SiteScreen.vue +6 -5
  20. package/components/RolePermissionFormCreate.vue +33 -0
  21. package/components/SiteDataRetention.vue +286 -0
  22. package/components/SiteSettings.vue +48 -0
  23. package/components/SiteSettingsVisitorRegistration.vue +118 -0
  24. package/components/VisitorForm.vue +38 -3
  25. package/components/VisitorManagement.vue +3 -1
  26. package/composables/useDataRetention.ts +43 -0
  27. package/composables/useDocument.ts +13 -0
  28. package/composables/useFeedback.ts +12 -0
  29. package/composables/useHandoverChecklist.ts +111 -0
  30. package/composables/useIncidentCompany.ts +20 -0
  31. package/composables/useKeyPresses.ts +57 -0
  32. package/composables/usePassKey.ts +4 -0
  33. package/composables/useSiteFeatureSettings.ts +37 -0
  34. package/composables/useVisitor.ts +22 -0
  35. package/package.json +2 -2
  36. package/types/key-log.d.ts +2 -0
  37. package/types/passKey.d.ts +2 -0
  38. package/utils/feedback-handling-settings.ts +139 -0
  39. package/utils/incident-company.ts +7 -0
  40. package/utils/inventory-presets.ts +64 -0
  41. package/utils/key-presses.ts +55 -0
  42. package/utils/list-export.ts +39 -0
@@ -1,157 +1,198 @@
1
1
  <template>
2
- <v-row no-gutters class="px-5 pt-4">
3
- <!-- Site Information -->
4
- <p
5
- class="text-uppercase text-center w-100 text-h6 bg-error text-on-error"
6
- style="padding: 10px"
7
- >
8
- Incident Report
9
- </p>
10
- <v-row no-gutters class="mt-5 border pb-5">
11
- <p
12
- class="w-100 text-h6 pa-2 text-center bg-warning text-on-warning"
13
- >
14
- Incident Information
2
+ <div class="ir-doc px-5 pt-4">
3
+ <!-- Report header: title with the status inside it, so the two never float apart. -->
4
+ <div class="ir-title bg-error text-on-error">
5
+ <p class="text-uppercase text-h6 ma-0">Incident Report</p>
6
+ <p v-if="status" class="ir-status ma-0 mt-2" :class="`ir-status--${statusKey}`">
7
+ Status: {{ String(status).toUpperCase() }}
15
8
  </p>
16
-
17
- <v-col cols="6" class="pa-3 border-b border-e">
18
- <p class="font-weight-bold">Site</p>
19
- <p>{{ siteName || "-" }}</p>
20
- </v-col>
21
- <v-col cols="6" class="pa-3 border-b">
22
- <p class="font-weight-bold">Reference</p>
23
- <p>{{ incidentInformation?.siteInfo?.irNumber || "-" }}</p>
24
- </v-col>
25
-
26
- <v-col cols="6" class="pa-3 border-b border-e">
27
- <p class="font-weight-bold">Place of Incident</p>
28
- <p>
29
- {{ incidentInformation?.placeOfIncident?.incidentLocation || "-" }}
30
- </p>
31
- </v-col>
32
- <v-col cols="6" class="pa-3 border-b">
33
- <p class="font-weight-bold">Type of Incident</p>
34
- <p>
35
- {{ incidentInformation?.incidentTypeAndTime?.typeOfIncident || "-" }}
36
- </p>
37
- </v-col>
38
-
39
- <v-col cols="6" class="pa-3 border-b border-e">
40
- <p class="font-weight-bold">Date of Incident</p>
41
- <p>
42
- {{
43
- toLocalDate(
44
- incidentInformation?.incidentTypeAndTime?.dateOfIncident
45
- ) || "NA"
46
- }}
47
- </p>
48
- </v-col>
49
- <v-col cols="6" class="pa-3 border-b">
50
- <p class="font-weight-bold">Incident Start Time</p>
51
- <p>
52
- {{ incidentInformation?.incidentTypeAndTime?.incidentStart || "-" }}
53
- </p>
54
- </v-col>
55
-
56
- <v-col cols="6" class="pa-3 border-b border-e">
57
- <p class="font-weight-bold">Time of Response (From 1st Contact)</p>
58
- <p>
59
- {{ incidentInformation?.incidentTypeAndTime?.timeOfResponse || "-" }}
60
- </p>
61
- </v-col>
62
- <v-col cols="6" class="pa-3 border-b">
63
- <p class="font-weight-bold">Incident End Time</p>
64
- <p>
65
- {{ incidentInformation?.incidentTypeAndTime?.incidentEnd || "-" }}
66
- </p>
67
- </v-col>
68
-
69
- <v-col cols="6" class="pa-3 border-b border-e">
70
- <p class="font-weight-bold">Date of Report Submission</p>
71
- {{
72
- toLocalDate(incidentInformation?.submissionForm?.dateOfReport) || "NA"
73
- }}
74
- </v-col>
75
- <v-col cols="6" class="pa-3 border-b">
76
- <p class="font-weight-bold">Time of Report Submission</p>
77
- <p>{{ incidentInformation?.submissionForm?.time || "-" }}</p>
78
- </v-col>
79
-
80
- <v-col cols="6" class="pa-3 border-b border-e">
81
- <p class="font-weight-bold">Report Submitted By</p>
82
- <p>{{ incidentInformation?.siteInfo?.submittedBy || "-" }}</p>
83
- </v-col>
84
- <v-col cols="6" class="pa-3 border-b">
85
- <p class="font-weight-bold">Designation</p>
86
- <p>{{ incidentInformation?.siteInfo?.designation || "-" }}</p>
87
- </v-col>
88
-
89
- <v-col cols="4" class="pa-3 border-b border-e">
90
- <p class="font-weight-bold">Name of Informant/Complainant</p>
91
- <p>{{ incidentInformation?.complaintInfo?.complainant || "-" }}</p>
92
- </v-col>
93
- <v-col cols="4" class="pa-3 border-b border-e">
94
- <p class="font-weight-bold">Contact No.</p>
95
- <p>{{ incidentInformation?.complaintInfo?.contact || "-" }}</p>
96
- </v-col>
97
- <v-col cols="4" class="pa-3 border-b">
98
- <p class="font-weight-bold">NRIC/WP No.</p>
99
- <p>
100
- {{
101
- showNRICComplainant
102
- ? incidentInformation?.complaintInfo?.nric || "-"
103
- : maskNRIC(incidentInformation?.complaintInfo?.nric)
104
- }}
105
- </p>
106
- </v-col>
107
-
108
- <v-col cols="4" class="pa-3 border-b border-e">
109
- <p class="font-weight-bold">
110
- Name of Recipient of Complaint (1st Contact)
111
- </p>
112
- <p>{{ incidentInformation?.recipientOfComplaint?.recipient || "-" }}</p>
113
- </v-col>
114
- <v-col cols="4" class="pa-3 border-b border-e">
115
- <p class="font-weight-bold">Contact No.</p>
116
- <p>{{ incidentInformation?.recipientOfComplaint?.contact || "-" }}</p>
117
- </v-col>
118
- <v-col cols="4" class="pa-3 border-b">
119
- <p class="font-weight-bold">NRIC/WP No.</p>
120
- <p>
121
- {{
122
- showNRICRecipient
123
- ? incidentInformation?.recipientOfComplaint?.nric || "-"
124
- : maskNRIC(incidentInformation?.recipientOfComplaint?.nric)
125
- }}
126
- </p>
127
- </v-col>
128
-
129
- <v-col cols="12" class="pa-3 border-b border-e">
130
- <p class="font-weight-bold">Complaint Received through</p>
131
- <p
132
- v-if="
9
+ <p v-if="companyName" class="ma-0 mt-2 ir-company">
10
+ Reported by: {{ companyName }}
11
+ </p>
12
+ </div>
13
+ <table class="ir-table mt-5">
14
+ <colgroup>
15
+ <col style="width: 8.3333%" />
16
+ <col style="width: 8.3333%" />
17
+ <col style="width: 8.3333%" />
18
+ <col style="width: 8.3333%" />
19
+ <col style="width: 8.3333%" />
20
+ <col style="width: 8.3333%" />
21
+ <col style="width: 8.3333%" />
22
+ <col style="width: 8.3333%" />
23
+ <col style="width: 8.3333%" />
24
+ <col style="width: 8.3333%" />
25
+ <col style="width: 8.3333%" />
26
+ <col style="width: 8.3333%" />
27
+ </colgroup>
28
+ <thead>
29
+ <tr>
30
+ <th colspan="12" class="ir-section text-h6 pa-2 text-center bg-warning text-on-warning">Incident Information</th>
31
+ </tr>
32
+ </thead>
33
+ <tbody>
34
+ <tr>
35
+ <td colspan="6" class="pa-3 ir-cell">
36
+ <p class="font-weight-bold">Site</p>
37
+ <p>{{ siteName || "-" }}</p>
38
+ </td>
39
+ <td colspan="6" class="pa-3 ir-cell">
40
+ <p class="font-weight-bold">Reference</p>
41
+ <p>{{ incidentInformation?.siteInfo?.irNumber || "-" }}</p>
42
+ </td>
43
+ </tr>
44
+ <tr v-if="companyName">
45
+ <td colspan="12" class="pa-3 ir-cell">
46
+ <p class="font-weight-bold">Reported by (Company)</p>
47
+ <p>{{ companyName }}</p>
48
+ </td>
49
+ </tr>
50
+ <tr>
51
+ <td colspan="6" class="pa-3 ir-cell">
52
+ <p class="font-weight-bold">Place of Incident</p>
53
+ <p>
54
+ {{ incidentInformation?.placeOfIncident?.incidentLocation || "-" }}
55
+ </p>
56
+ </td>
57
+ <td colspan="6" class="pa-3 ir-cell">
58
+ <p class="font-weight-bold">Type of Incident</p>
59
+ <p>
60
+ {{ incidentInformation?.incidentTypeAndTime?.typeOfIncident || "-" }}
61
+ </p>
62
+ </td>
63
+ </tr>
64
+ <tr>
65
+ <td colspan="6" class="pa-3 ir-cell">
66
+ <p class="font-weight-bold">Date of Incident</p>
67
+ <p>
68
+ {{
69
+ toLocalDate(
70
+ incidentInformation?.incidentTypeAndTime?.dateOfIncident
71
+ ) || "NA"
72
+ }}
73
+ </p>
74
+ </td>
75
+ <td colspan="6" class="pa-3 ir-cell">
76
+ <p class="font-weight-bold">Incident Start Time</p>
77
+ <p>
78
+ {{ incidentInformation?.incidentTypeAndTime?.incidentStart || "-" }}
79
+ </p>
80
+ </td>
81
+ </tr>
82
+ <tr>
83
+ <td colspan="6" class="pa-3 ir-cell">
84
+ <p class="font-weight-bold">Time of Response (From 1st Contact)</p>
85
+ <p>
86
+ {{ incidentInformation?.incidentTypeAndTime?.timeOfResponse || "-" }}
87
+ </p>
88
+ </td>
89
+ <td colspan="6" class="pa-3 ir-cell">
90
+ <p class="font-weight-bold">Incident End Time</p>
91
+ <p>
92
+ {{ incidentInformation?.incidentTypeAndTime?.incidentEnd || "-" }}
93
+ </p>
94
+ </td>
95
+ </tr>
96
+ <tr>
97
+ <td colspan="6" class="pa-3 ir-cell">
98
+ <p class="font-weight-bold">Date of Report Submission</p>
99
+ <p>
100
+ {{
101
+ toLocalDate(incidentInformation?.submissionForm?.dateOfReport) ||
102
+ "NA"
103
+ }}
104
+ </p>
105
+ </td>
106
+ <td colspan="6" class="pa-3 ir-cell">
107
+ <p class="font-weight-bold">Time of Report Submission</p>
108
+ <p>{{ incidentInformation?.submissionForm?.time || "-" }}</p>
109
+ </td>
110
+ </tr>
111
+ <tr>
112
+ <td colspan="6" class="pa-3 ir-cell">
113
+ <p class="font-weight-bold">Report Submitted By</p>
114
+ <p>{{ incidentInformation?.siteInfo?.submittedBy || "-" }}</p>
115
+ </td>
116
+ <td colspan="6" class="pa-3 ir-cell">
117
+ <p class="font-weight-bold">Designation</p>
118
+ <p>{{ incidentInformation?.siteInfo?.designation || "-" }}</p>
119
+ </td>
120
+ </tr>
121
+ <tr>
122
+ <td colspan="4" class="pa-3 ir-cell">
123
+ <p class="font-weight-bold">Name of Informant/Complainant</p>
124
+ <p>{{ incidentInformation?.complaintInfo?.complainant || "-" }}</p>
125
+ </td>
126
+ <td colspan="4" class="pa-3 ir-cell">
127
+ <p class="font-weight-bold">Contact No.</p>
128
+ <p>{{ incidentInformation?.complaintInfo?.contact || "-" }}</p>
129
+ </td>
130
+ <td colspan="4" class="pa-3 ir-cell">
131
+ <p class="font-weight-bold">NRIC/WP No.</p>
132
+ <p>
133
+ {{
134
+ showNRICComplainant
135
+ ? incidentInformation?.complaintInfo?.nric || "-"
136
+ : maskNRIC(incidentInformation?.complaintInfo?.nric)
137
+ }}
138
+ </p>
139
+ </td>
140
+ </tr>
141
+ <tr>
142
+ <td colspan="4" class="pa-3 ir-cell">
143
+ <p class="font-weight-bold">
144
+ Name of Recipient of Complaint (1st Contact)
145
+ </p>
146
+ <p>{{ incidentInformation?.recipientOfComplaint?.recipient || "-" }}</p>
147
+ </td>
148
+ <td colspan="4" class="pa-3 ir-cell">
149
+ <p class="font-weight-bold">Contact No.</p>
150
+ <p>{{ incidentInformation?.recipientOfComplaint?.contact || "-" }}</p>
151
+ </td>
152
+ <td colspan="4" class="pa-3 ir-cell">
153
+ <p class="font-weight-bold">NRIC/WP No.</p>
154
+ <p>
155
+ {{
156
+ showNRICRecipient
157
+ ? incidentInformation?.recipientOfComplaint?.nric || "-"
158
+ : maskNRIC(incidentInformation?.recipientOfComplaint?.nric)
159
+ }}
160
+ </p>
161
+ </td>
162
+ </tr>
163
+ <tr v-if="
133
164
  incidentInformation?.complaintReceivedTo?.receivedVia != 'others'
134
- "
135
- >
136
- {{ incidentInformation?.complaintReceivedTo?.receivedVia || "-" }}
137
- </p>
138
-
139
- <p v-else>
140
- {{
141
- incidentInformation?.complaintReceivedTo?.otherDescription || "-"
142
- }}
143
- </p>
144
- </v-col>
145
- <v-col cols="12" class="pa-3">
146
- <p class="font-weight-bold">Brief Description</p>
147
- <p>
148
- {{
149
- incidentInformation?.complaintReceivedTo?.briefDescription || "-"
150
- }}
151
- </p>
152
- </v-col>
153
- </v-row>
154
- </v-row>
165
+ ">
166
+ <td colspan="12" class="pa-3 ir-cell">
167
+ <p class="font-weight-bold">Complaint Received through</p>
168
+ <p
169
+ v-if="
170
+ incidentInformation?.complaintReceivedTo?.receivedVia != 'others'
171
+ "
172
+ >
173
+ {{ incidentInformation?.complaintReceivedTo?.receivedVia || "-" }}
174
+ </p>
175
+
176
+ <p v-else>
177
+ {{
178
+ incidentInformation?.complaintReceivedTo?.otherDescription || "-"
179
+ }}
180
+ </p>
181
+ </td>
182
+ </tr>
183
+ <tr>
184
+ <td colspan="12" class="pa-3 ir-cell">
185
+ <p class="font-weight-bold">Brief Description</p>
186
+ <p>
187
+ {{
188
+ incidentInformation?.complaintReceivedTo?.briefDescription || "-"
189
+ }}
190
+ </p>
191
+ </td>
192
+ </tr>
193
+ </tbody>
194
+ </table>
195
+ </div>
155
196
  </template>
156
197
 
157
198
  <script lang="ts" setup>
@@ -162,8 +203,22 @@ const props = defineProps({
162
203
  type: Object as PropType<Record<string, any> | null>,
163
204
  required: true,
164
205
  },
206
+ // Optional report status (pending/approved/rejected), printed inside the header.
207
+ status: {
208
+ type: String,
209
+ default: "",
210
+ },
211
+ // The report's `organization` id: the company that filed it.
212
+ organizationId: {
213
+ type: String,
214
+ default: "",
215
+ },
165
216
  });
166
217
 
218
+ const companyName = useIncidentCompany(() => props.organizationId);
219
+
220
+ const statusKey = computed(() => String(props.status || "").toLowerCase());
221
+
167
222
  // utilities
168
223
  const { getSiteById } = useSiteSettings();
169
224
  const route = useRoute();
@@ -204,11 +259,16 @@ watch(
204
259
  { immediate: true }
205
260
  );
206
261
 
262
+ // DD/MM/YYYY in Singapore time. The PDF is rendered on a server whose clock is
263
+ // UTC, so without the zone an 8 Oct (SGT) date prints as 07/10.
207
264
  function toLocalDate(utcString: string) {
208
- return new Date(utcString).toLocaleString("en-US", {
265
+ const d = new Date(utcString);
266
+ if (!utcString || isNaN(d.getTime())) return "";
267
+ return d.toLocaleDateString("en-GB", {
209
268
  year: "numeric",
210
269
  month: "2-digit",
211
270
  day: "2-digit",
271
+ timeZone: "Asia/Singapore",
212
272
  });
213
273
  }
214
274
 
@@ -218,3 +278,70 @@ const maskNRIC = (value: any) => {
218
278
  return value.replace(/.(?=.{3})/g, "*");
219
279
  };
220
280
  </script>
281
+
282
+ <style scoped>
283
+ /* One consistent 1px grey rule for every cell edge; rows never split across pages. */
284
+ .ir-title {
285
+ text-align: center;
286
+ padding: 10px;
287
+ }
288
+ .ir-status {
289
+ display: inline-block;
290
+ background: #fff;
291
+ color: #b26a00;
292
+ border: 1px solid currentColor;
293
+ border-radius: 4px;
294
+ padding: 2px 14px;
295
+ font-size: 0.95rem;
296
+ font-weight: 700;
297
+ letter-spacing: 0.03em;
298
+ }
299
+ .ir-company {
300
+ font-size: 1rem;
301
+ font-weight: 600;
302
+ }
303
+ .ir-status--approved { color: #2e7d32; }
304
+ .ir-status--rejected { color: #c62828; }
305
+ /* One table. Each cell paints its own right/bottom rule (the first cell also the
306
+ left one) and the heading cell all four, so borders are never painted outside
307
+ the cell that owns them: collapsed borders left a ghost of the repeated
308
+ heading in the page margin. The heading row is the table header, so it repeats
309
+ at the top of every page; rows never split. */
310
+ .ir-table {
311
+ width: 100%;
312
+ table-layout: fixed;
313
+ border-collapse: separate;
314
+ border-spacing: 0;
315
+ }
316
+ .ir-table thead {
317
+ display: table-header-group;
318
+ }
319
+ .ir-table tr {
320
+ break-inside: avoid;
321
+ page-break-inside: avoid;
322
+ }
323
+ .ir-cell {
324
+ border-right: 1px solid #8a8a8a;
325
+ border-bottom: 1px solid #8a8a8a;
326
+ vertical-align: top;
327
+ }
328
+ .ir-cell:first-child {
329
+ border-left: 1px solid #8a8a8a;
330
+ }
331
+ /* A label always travels with its value. */
332
+ .ir-cell p:first-child {
333
+ break-after: avoid;
334
+ page-break-after: avoid;
335
+ }
336
+ /* The heading is a solid bar with no stroke: when the repeated heading is laid
337
+ out at the foot of the previous page Chrome paints a clipped ghost of it
338
+ there, and a stroke on that ghost showed as a thin line. */
339
+ .ir-section {
340
+ /* A white top border with the colour clipped to the padding box: the ghost then
341
+ starts 2px lower than the page foot, so not even a 0.2pt sliver is painted. */
342
+ border: 0;
343
+ border-top: 2px solid #fff;
344
+ background-clip: padding-box;
345
+ font-weight: 400;
346
+ }
347
+ </style>
@@ -0,0 +1,88 @@
1
+ <template>
2
+ <div data-test="incident-report-emails">
3
+ <p class="text-body-2 mb-3">For people who do not use the app, e.g. your HQ or insurer.</p>
4
+ <v-combobox
5
+ v-model="emails"
6
+ label="Also email every incident report to"
7
+ placeholder="Type an email address and press Enter"
8
+ multiple
9
+ chips
10
+ closable-chips
11
+ hide-no-data
12
+ :readonly="readOnly"
13
+ :rules="[validRule]"
14
+ :hint="`Up to ${MAX} addresses.`"
15
+ persistent-hint
16
+ density="comfortable"
17
+ variant="outlined"
18
+ />
19
+ <v-btn
20
+ v-if="!readOnly"
21
+ class="screen-btn-primary mt-4"
22
+ color="primary-button"
23
+ variant="flat"
24
+ text="Save"
25
+ :loading="saving"
26
+ :disabled="!loaded || validRule(emails) !== true"
27
+ @click="save"
28
+ />
29
+ <Snackbar v-model="toast.show" :text="toast.message" :color="toast.color" />
30
+ </div>
31
+ </template>
32
+
33
+ <script setup lang="ts">
34
+ import useSiteFeatureSettings from "../composables/useSiteFeatureSettings";
35
+
36
+ /**
37
+ * Site setting `metadata.incidentReportEmails` (core site-feature-settings).
38
+ * Empty = today: only app users who switched on incident report emails get one.
39
+ */
40
+ const props = defineProps({
41
+ siteId: { type: String, required: true },
42
+ saved: { type: Array as PropType<string[]>, default: () => [] },
43
+ readOnly: { type: Boolean, default: false },
44
+ /** The site has been read; Save stays off until then. */
45
+ loaded: { type: Boolean, default: false },
46
+ });
47
+ const emit = defineEmits(["saved"]);
48
+
49
+ const MAX = 10;
50
+ const EMAIL = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
51
+
52
+ const emails = ref<string[]>([]);
53
+ watch(
54
+ () => props.saved,
55
+ (v) => (emails.value = Array.isArray(v) ? [...v] : []),
56
+ { immediate: true },
57
+ );
58
+
59
+ function validRule(list: string[]) {
60
+ const clean = (list ?? []).map((e) => String(e).trim());
61
+ if (clean.length > MAX) return `Up to ${MAX} addresses.`;
62
+ const bad = clean.find((e) => !EMAIL.test(e));
63
+ return bad ? `"${bad}" is not a valid email address.` : true;
64
+ }
65
+
66
+ const { saveSiteFeature } = useSiteFeatureSettings();
67
+ const saving = ref(false);
68
+ const toast = reactive({ show: false, message: "", color: "" });
69
+
70
+ async function save() {
71
+ if (!props.loaded) return;
72
+ saving.value = true;
73
+ try {
74
+ const value = [...new Set(emails.value.map((e) => String(e).trim().toLowerCase()))];
75
+ await saveSiteFeature(props.siteId, "incidentReportEmails", value);
76
+ Object.assign(toast, { show: true, message: "Incident report emails saved.", color: "success" });
77
+ emit("saved");
78
+ } catch (e: any) {
79
+ Object.assign(toast, {
80
+ show: true,
81
+ message: e?.data?.message || "Could not save the incident report emails.",
82
+ color: "error",
83
+ });
84
+ } finally {
85
+ saving.value = false;
86
+ }
87
+ }
88
+ </script>
@@ -0,0 +1,43 @@
1
+ <template>
2
+ <!-- Shown only when the site has key presses. Tells the list whether it
3
+ has any (`available`), so the list can add its Key press column. -->
4
+ <v-select
5
+ v-if="cabinets.length"
6
+ :model-value="modelValue"
7
+ :items="items"
8
+ item-title="name"
9
+ item-value="id"
10
+ label="Filter by key press"
11
+ multiple
12
+ clearable
13
+ hide-details
14
+ density="compact"
15
+ menu-icon="mdi-chevron-down"
16
+ style="max-width: 220px; min-width: 150px"
17
+ data-test="key-press-filter"
18
+ @update:model-value="(v: string[] | null) => emit('update:modelValue', v ?? [])"
19
+ />
20
+ </template>
21
+
22
+ <script setup lang="ts">
23
+ import type { PropType } from "vue";
24
+ import useKeyPresses from "../composables/useKeyPresses";
25
+
26
+ const props = defineProps({
27
+ site: { type: String, required: true },
28
+ modelValue: { type: Array as PropType<string[]>, default: () => [] },
29
+ });
30
+ const emit = defineEmits<{
31
+ (e: "update:modelValue", value: string[]): void;
32
+ (e: "update:available", value: boolean): void;
33
+ }>();
34
+
35
+ const { cabinets } = useKeyPresses(() => props.site);
36
+ // "" = keys kept in no named press.
37
+ const items = computed(() => [...cabinets.value, { id: "", name: "No key press" }]);
38
+ watch(
39
+ () => cabinets.value.length > 0,
40
+ (has) => emit("update:available", has),
41
+ { immediate: true },
42
+ );
43
+ </script>
@@ -0,0 +1,14 @@
1
+ <template>
2
+ <span>{{ nameOf(id) }}</span>
3
+ </template>
4
+
5
+ <script setup lang="ts">
6
+ import useKeyPresses from "../composables/useKeyPresses";
7
+
8
+ // The key's press name in a list cell. One site read per page, shared.
9
+ const props = defineProps({
10
+ site: { type: String, required: true },
11
+ id: { type: String, default: "" },
12
+ });
13
+ const { nameOf } = useKeyPresses(() => props.site);
14
+ </script>
@@ -0,0 +1,31 @@
1
+ <template>
2
+ <!-- Shown only when the site has key presses; otherwise nothing changes. -->
3
+ <div v-if="cabinets.length">
4
+ <div class="text-subtitle-1 text-medium-emphasis">Key press</div>
5
+ <v-select
6
+ :model-value="modelValue || null"
7
+ :items="cabinets"
8
+ item-title="name"
9
+ item-value="id"
10
+ placeholder="Choose a key press"
11
+ density="comfortable"
12
+ hint="Where this key is kept."
13
+ persistent-hint
14
+ clearable
15
+ data-test="key-press-select"
16
+ @update:model-value="(v: string | null) => emit('update:modelValue', v ?? '')"
17
+ />
18
+ </div>
19
+ </template>
20
+
21
+ <script setup lang="ts">
22
+ import useKeyPresses from "../composables/useKeyPresses";
23
+
24
+ const props = defineProps({
25
+ site: { type: String, required: true },
26
+ modelValue: { type: String, default: "" },
27
+ });
28
+ const emit = defineEmits<{ (e: "update:modelValue", value: string): void }>();
29
+
30
+ const { cabinets } = useKeyPresses(() => props.site);
31
+ </script>