@7365admin1/layer-common 4.97.1-staging.541 → 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.
- package/components/AddPassKeyToVisitor.vue +5 -0
- package/components/DocumentManagement.vue +56 -3
- package/components/FeedbackHandlingSettings.vue +385 -0
- package/components/HandoverChecklistRecords.vue +223 -0
- package/components/HandoverChecklistSetup.vue +224 -0
- package/components/IncidentReportEmailsSettings.vue +88 -0
- package/components/KeyPressFilter.vue +43 -0
- package/components/KeyPressName.vue +14 -0
- package/components/KeyPressSelect.vue +31 -0
- package/components/KeySettingsPanel.vue +156 -0
- package/components/ListCsvExport.vue +71 -0
- package/components/MaStaffRegistrationSettings.vue +61 -0
- package/components/PassInformation.vue +5 -0
- package/components/RolePermissionFormCreate.vue +33 -0
- package/components/SiteDataRetention.vue +286 -0
- package/components/SiteSettings.vue +48 -0
- package/components/SiteSettingsVisitorRegistration.vue +118 -0
- package/components/VisitorForm.vue +38 -3
- package/components/VisitorManagement.vue +3 -1
- package/composables/useDataRetention.ts +43 -0
- package/composables/useDocument.ts +13 -0
- package/composables/useFeedback.ts +12 -0
- package/composables/useHandoverChecklist.ts +111 -0
- package/composables/useKeyPresses.ts +57 -0
- package/composables/usePassKey.ts +4 -0
- package/composables/useSiteFeatureSettings.ts +37 -0
- package/composables/useVisitor.ts +22 -0
- package/package.json +2 -2
- package/types/key-log.d.ts +2 -0
- package/types/passKey.d.ts +2 -0
- package/utils/feedback-handling-settings.ts +139 -0
- package/utils/inventory-presets.ts +64 -0
- package/utils/key-presses.ts +55 -0
- package/utils/list-export.ts +39 -0
|
@@ -219,6 +219,51 @@
|
|
|
219
219
|
</v-expansion-panel-text>
|
|
220
220
|
</v-expansion-panel>
|
|
221
221
|
|
|
222
|
+
<!-- The per-site client switches below are drawn only by the hosts that set
|
|
223
|
+
`showSiteSwitches` (Property Management and Security); the other
|
|
224
|
+
service-provider apps show no new panel. -->
|
|
225
|
+
<v-expansion-panel v-if="showSiteSwitches && canManageSiteSettings">
|
|
226
|
+
<v-expansion-panel-title>
|
|
227
|
+
<v-icon class="mr-2">mdi-card-account-details-outline</v-icon>
|
|
228
|
+
Visitor registration
|
|
229
|
+
</v-expansion-panel-title>
|
|
230
|
+
<v-expansion-panel-text>
|
|
231
|
+
<SiteSettingsVisitorRegistration :site-id="siteId" :site-data="siteData"
|
|
232
|
+
:can-manage="canManageSiteSettings" @saved="refreshSiteData" @message="show" />
|
|
233
|
+
</v-expansion-panel-text>
|
|
234
|
+
</v-expansion-panel>
|
|
235
|
+
|
|
236
|
+
<!-- Passes & keys (TLR B8 / D2): key presses, daily unreturned list,
|
|
237
|
+
check-out block. All off until a site saves them. Gated like Site
|
|
238
|
+
Information; saving needs site-settings rights (the server checks
|
|
239
|
+
it too). -->
|
|
240
|
+
<v-expansion-panel v-if="showSiteSwitches && canManageSiteInformation">
|
|
241
|
+
<v-expansion-panel-title>
|
|
242
|
+
<v-icon class="mr-2">mdi-key-chain</v-icon>
|
|
243
|
+
Passes & keys
|
|
244
|
+
</v-expansion-panel-title>
|
|
245
|
+
<v-expansion-panel-text>
|
|
246
|
+
<KeySettingsPanel
|
|
247
|
+
:site="siteId"
|
|
248
|
+
:site-data="siteData"
|
|
249
|
+
:read-only="!canManageSiteSettings"
|
|
250
|
+
@message="show"
|
|
251
|
+
@saved="refreshSiteData"
|
|
252
|
+
/>
|
|
253
|
+
</v-expansion-panel-text>
|
|
254
|
+
</v-expansion-panel>
|
|
255
|
+
|
|
256
|
+
<v-expansion-panel v-if="showSiteSwitches && canManageAnySiteSetting">
|
|
257
|
+
<v-expansion-panel-title>
|
|
258
|
+
<v-icon class="mr-2">mdi-email-alert-outline</v-icon>
|
|
259
|
+
Incident report emails
|
|
260
|
+
</v-expansion-panel-title>
|
|
261
|
+
<v-expansion-panel-text>
|
|
262
|
+
<IncidentReportEmailsSettings :site-id="siteId" :saved="(siteData as any)?.metadata?.incidentReportEmails"
|
|
263
|
+
:loaded="!!siteData" :read-only="!canManageSiteSettings" @saved="refreshSiteData" />
|
|
264
|
+
</v-expansion-panel-text>
|
|
265
|
+
</v-expansion-panel>
|
|
266
|
+
|
|
222
267
|
<slot
|
|
223
268
|
name="panels"
|
|
224
269
|
:can-manage="canManageSiteSettings"
|
|
@@ -246,6 +291,8 @@ const props = defineProps({
|
|
|
246
291
|
showCctvCamera: { type: Boolean, default: false },
|
|
247
292
|
showDeliveryCompanies: { type: Boolean, default: false },
|
|
248
293
|
showResidentVisitors: { type: Boolean, default: false },
|
|
294
|
+
/** Visitor registration, Passes & keys and Incident report emails: PM and Security only. */
|
|
295
|
+
showSiteSwitches: { type: Boolean, default: false },
|
|
249
296
|
});
|
|
250
297
|
|
|
251
298
|
const openPanels = ref([]); // default open first
|
|
@@ -255,6 +302,7 @@ const { canManageSiteInformation,
|
|
|
255
302
|
canManageDeliveryCompanies,
|
|
256
303
|
canManageResidentVisitors,
|
|
257
304
|
canManageVehicleQr,
|
|
305
|
+
canManageSiteSettings: canManageAnySiteSetting,
|
|
258
306
|
} = useSettingsPermission();
|
|
259
307
|
|
|
260
308
|
const { getSiteById, updateSitebyId, updateSiteInformation } =
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!--
|
|
3
|
+
Guardhouse registration switches (`site.metadata.visitorFields`). A site
|
|
4
|
+
that never saved them shows "as usual" everywhere and behaves as today.
|
|
5
|
+
-->
|
|
6
|
+
<div data-test="visitor-registration-settings">
|
|
7
|
+
<v-switch
|
|
8
|
+
v-model="askNric"
|
|
9
|
+
label="Ask for NRIC / FIN"
|
|
10
|
+
color="primary"
|
|
11
|
+
hide-details
|
|
12
|
+
:disabled="saving || !canManage"
|
|
13
|
+
data-test="visitor-fields-nric"
|
|
14
|
+
/>
|
|
15
|
+
<p class="text-caption text-medium-emphasis mb-4">
|
|
16
|
+
Turn off if your site does not collect ID numbers. Existing records are not changed.
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<v-select
|
|
20
|
+
v-model="contact"
|
|
21
|
+
:items="contactItems"
|
|
22
|
+
label="Contact number"
|
|
23
|
+
density="comfortable"
|
|
24
|
+
variant="outlined"
|
|
25
|
+
hide-details
|
|
26
|
+
:disabled="saving || !canManage"
|
|
27
|
+
data-test="visitor-fields-contact"
|
|
28
|
+
/>
|
|
29
|
+
<p class="text-caption text-medium-emphasis mt-1 mb-4">
|
|
30
|
+
"Always required" means a visitor cannot be saved without a contact number.
|
|
31
|
+
</p>
|
|
32
|
+
|
|
33
|
+
<v-select
|
|
34
|
+
v-model="vehicle"
|
|
35
|
+
:items="vehicleItems"
|
|
36
|
+
label="Vehicle number"
|
|
37
|
+
density="comfortable"
|
|
38
|
+
variant="outlined"
|
|
39
|
+
hide-details
|
|
40
|
+
:disabled="saving || !canManage"
|
|
41
|
+
data-test="visitor-fields-vehicle"
|
|
42
|
+
/>
|
|
43
|
+
<p class="text-caption text-medium-emphasis mt-1 mb-4">
|
|
44
|
+
"Always required" means a visitor cannot be saved without a plate number. Walk-in visitors are not asked.
|
|
45
|
+
</p>
|
|
46
|
+
|
|
47
|
+
<v-btn
|
|
48
|
+
v-if="canManage"
|
|
49
|
+
class="screen-btn-primary text-none"
|
|
50
|
+
variant="flat"
|
|
51
|
+
:loading="saving"
|
|
52
|
+
:disabled="!siteData"
|
|
53
|
+
data-test="visitor-fields-save"
|
|
54
|
+
@click="save"
|
|
55
|
+
>
|
|
56
|
+
Save
|
|
57
|
+
</v-btn>
|
|
58
|
+
</div>
|
|
59
|
+
</template>
|
|
60
|
+
|
|
61
|
+
<script setup lang="ts">
|
|
62
|
+
import type { PropType } from "vue";
|
|
63
|
+
import useSiteFeatureSettings from "../composables/useSiteFeatureSettings";
|
|
64
|
+
import { getVisitorFieldSwitches } from "../composables/useVisitor";
|
|
65
|
+
|
|
66
|
+
const props = defineProps({
|
|
67
|
+
siteId: { type: String, required: true },
|
|
68
|
+
siteData: { type: Object as PropType<Record<string, any> | null>, default: null },
|
|
69
|
+
canManage: { type: Boolean, default: false },
|
|
70
|
+
});
|
|
71
|
+
const emit = defineEmits<{ (e: "saved"): void; (e: "message", text: string, color: string): void }>();
|
|
72
|
+
|
|
73
|
+
const contactItems = [
|
|
74
|
+
{ title: "Ask as usual", value: "default" },
|
|
75
|
+
{ title: "Don't ask", value: "hidden" },
|
|
76
|
+
{ title: "Always required", value: "required" },
|
|
77
|
+
];
|
|
78
|
+
const vehicleItems = [
|
|
79
|
+
{ title: "As usual", value: "default" },
|
|
80
|
+
{ title: "Always required", value: "required" },
|
|
81
|
+
];
|
|
82
|
+
|
|
83
|
+
const askNric = ref(true);
|
|
84
|
+
const contact = ref("default");
|
|
85
|
+
const vehicle = ref("default");
|
|
86
|
+
const saving = ref(false);
|
|
87
|
+
|
|
88
|
+
watch(
|
|
89
|
+
() => props.siteData,
|
|
90
|
+
(site) => {
|
|
91
|
+
const v = getVisitorFieldSwitches(site);
|
|
92
|
+
askNric.value = v.nric !== "hidden";
|
|
93
|
+
contact.value = v.contact;
|
|
94
|
+
vehicle.value = v.vehicle;
|
|
95
|
+
},
|
|
96
|
+
{ immediate: true }
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
const { saveSiteFeature } = useSiteFeatureSettings();
|
|
100
|
+
|
|
101
|
+
async function save() {
|
|
102
|
+
if (!props.siteData) return;
|
|
103
|
+
saving.value = true;
|
|
104
|
+
try {
|
|
105
|
+
await saveSiteFeature(props.siteId, "visitorFields", {
|
|
106
|
+
nric: askNric.value ? "default" : "hidden",
|
|
107
|
+
contact: contact.value,
|
|
108
|
+
vehicle: vehicle.value,
|
|
109
|
+
});
|
|
110
|
+
emit("message", "Visitor registration settings saved", "success");
|
|
111
|
+
emit("saved");
|
|
112
|
+
} catch (e: any) {
|
|
113
|
+
emit("message", e?.data?.message || "Could not save the visitor registration settings", "error");
|
|
114
|
+
} finally {
|
|
115
|
+
saving.value = false;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
</script>
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
content-class="visitor-form__menu">
|
|
94
94
|
<template #activator="{ props }">
|
|
95
95
|
<InputVehicleNumber v-bind="props" v-model="visitor.plateNumber" density="comfortable"
|
|
96
|
-
:rules="[
|
|
96
|
+
:rules="[vehicleRule]"
|
|
97
97
|
@update:model-value="handleUpdateVehicleNumber" @focus="handleFocusPlateNumber"
|
|
98
98
|
@blur="isPlateNumberFieldFocused = false" />
|
|
99
99
|
</template>
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
<InputLabel class="text-capitalize" title="Contractor Type (Required)" required />
|
|
122
122
|
<v-combobox v-model="contractorTypeObj" v-model:search="contractorTypeInput" ref="contractorTypeCombo"
|
|
123
123
|
autocomplete="off" :hide-no-data="false" @update:focused="handleFocusedContractorType"
|
|
124
|
-
:items="
|
|
124
|
+
:items="contractorTypeItems" :rules="[requiredRule]" item-value="value"
|
|
125
125
|
@update:model-value="handleSelectContractorType" variant="outlined" density="comfortable" persistent-hint
|
|
126
126
|
small-chips>
|
|
127
127
|
<template v-slot:no-data>
|
|
@@ -613,7 +613,7 @@ import useUtils from "../composables/useUtils";
|
|
|
613
613
|
import useSiteSettings from "../composables/useSiteSettings";
|
|
614
614
|
import useLocalAuth from "../composables/useLocalAuth";
|
|
615
615
|
import useBuilding from "../composables/useBuilding";
|
|
616
|
-
import useVisitor from "../composables/useVisitor";
|
|
616
|
+
import useVisitor, { getVisitorFieldSwitches, VEHICLE_REQUIRED_MESSAGE } from "../composables/useVisitor";
|
|
617
617
|
import useSiteEntryPassSettings from "../composables/useSiteEntryPassSettings";
|
|
618
618
|
import useAccessManagement from "../composables/useAccessManagement";
|
|
619
619
|
import usePeople from "../composables/usePeople";
|
|
@@ -845,10 +845,18 @@ const formFieldsExcluded: Partial<Record<TVisitorType, string[]>> = {
|
|
|
845
845
|
guest: ["purpose"],
|
|
846
846
|
};
|
|
847
847
|
|
|
848
|
+
// The site's registration switches (Site Settings -> Visitor registration).
|
|
849
|
+
// A site that never saved them reads all "default" = the per-type rules below.
|
|
850
|
+
const visitorFieldSwitches = computed(() =>
|
|
851
|
+
getVisitorFieldSwitches(siteData.value)
|
|
852
|
+
);
|
|
853
|
+
|
|
848
854
|
const isFormField = (
|
|
849
855
|
fieldKey: keyof TVisitorPayload | "delivery-company"
|
|
850
856
|
) => {
|
|
851
857
|
if (formFieldsExcluded[prop.type]?.includes(fieldKey)) return false;
|
|
858
|
+
if (fieldKey === "nric" && visitorFieldSwitches.value.nric === "hidden") return false;
|
|
859
|
+
if (fieldKey === "contact" && visitorFieldSwitches.value.contact === "hidden") return false;
|
|
852
860
|
return !!typeFieldMap[prop.type]?.includes(fieldKey);
|
|
853
861
|
};
|
|
854
862
|
|
|
@@ -892,13 +900,22 @@ const requireNRIC = computed(() => {
|
|
|
892
900
|
});
|
|
893
901
|
|
|
894
902
|
const requireContact = computed(() => {
|
|
903
|
+
if (visitorFieldSwitches.value.contact === "required") return true;
|
|
895
904
|
return ["contractor", "delivery"].includes(prop.type);
|
|
896
905
|
});
|
|
897
906
|
|
|
907
|
+
// "Always required" only reaches types whose form has a plate field (not walk-in).
|
|
898
908
|
const isVehicleRequired = computed(() => {
|
|
909
|
+
if (visitorFieldSwitches.value.vehicle === "required") return true;
|
|
899
910
|
return ["guest", "pick-up", "drop-off"].includes(prop.type);
|
|
900
911
|
});
|
|
901
912
|
|
|
913
|
+
const vehicleRule = (v: string) => {
|
|
914
|
+
if (visitorFieldSwitches.value.vehicle === "required")
|
|
915
|
+
return !!String(v ?? "").trim() || VEHICLE_REQUIRED_MESSAGE;
|
|
916
|
+
return isVehicleRequired.value ? requiredRule(v) : true;
|
|
917
|
+
};
|
|
918
|
+
|
|
902
919
|
const requireCompany = computed(() => {
|
|
903
920
|
return prop.type === "contractor";
|
|
904
921
|
});
|
|
@@ -1012,6 +1029,10 @@ const formTitle = computed(() => {
|
|
|
1012
1029
|
|
|
1013
1030
|
function handleSelectContractorType(obj: { title: string; value: string }) {
|
|
1014
1031
|
visitor.contractorType = obj.value ?? "";
|
|
1032
|
+
// Managing agent staff (site switch): fill in the MA's company if empty.
|
|
1033
|
+
if (obj?.value === MA_STAFF_CONTRACTOR_TYPE && !visitor.company) {
|
|
1034
|
+
visitor.company = maStaffRegistration.value.company;
|
|
1035
|
+
}
|
|
1015
1036
|
}
|
|
1016
1037
|
|
|
1017
1038
|
function handleFocusedContractorType() {
|
|
@@ -1511,6 +1532,20 @@ const {
|
|
|
1511
1532
|
getSiteById(prop.site)
|
|
1512
1533
|
);
|
|
1513
1534
|
|
|
1535
|
+
// "Managing agent staff" is offered only where the site switched it on
|
|
1536
|
+
// (`metadata.maStaffRegistration`); it is saved as a contractor, so older app
|
|
1537
|
+
// builds still list it. Off = the list is exactly as before.
|
|
1538
|
+
const MA_STAFF_CONTRACTOR_TYPE = "managing-agent-staff";
|
|
1539
|
+
const maStaffRegistration = computed(() => {
|
|
1540
|
+
const m = (siteData.value as any)?.metadata?.maStaffRegistration;
|
|
1541
|
+
return { enabled: m?.enabled === true, company: typeof m?.company === "string" ? m.company : "" };
|
|
1542
|
+
});
|
|
1543
|
+
const contractorTypeItems = computed(() =>
|
|
1544
|
+
maStaffRegistration.value.enabled
|
|
1545
|
+
? [...contractorTypes, { title: "Managing agent staff", value: MA_STAFF_CONTRACTOR_TYPE }]
|
|
1546
|
+
: contractorTypes
|
|
1547
|
+
);
|
|
1548
|
+
|
|
1514
1549
|
// Has to sit BELOW `siteData`, not beside `hidQrConfiguredReaderId` up at the HID block.
|
|
1515
1550
|
// `hidQrConfiguredReaderId` reads `hidQrCodePassConfig`, which reads `siteData`, and Vue
|
|
1516
1551
|
// runs a watcher's source getter the moment `watch()` is called - so declared
|
|
@@ -162,7 +162,9 @@
|
|
|
162
162
|
<template v-slot:item.type-company="{ item }">
|
|
163
163
|
<span class="d-flex align-center ga-2">
|
|
164
164
|
<v-icon icon="mdi-user" size="15" />
|
|
165
|
-
<
|
|
165
|
+
<v-chip v-if="item.type === 'contractor' && item.contractorType === 'managing-agent-staff'" size="x-small"
|
|
166
|
+
color="primary" variant="tonal">MA staff</v-chip>
|
|
167
|
+
<span v-else-if="item.type === 'contractor'" class="text-capitalize">{{
|
|
166
168
|
formatCamelCaseToWords(item.contractorType)
|
|
167
169
|
}}</span>
|
|
168
170
|
<span v-else class="text-capitalize">{{ formatType(item) }}</span>
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PDPA data retention per site (`/api/data-retention`, API-core). The setting
|
|
3
|
+
* itself is one site switch (`metadata.dataRetention`, useSiteFeatureSettings).
|
|
4
|
+
* Documents are not part of data retention in this version.
|
|
5
|
+
*/
|
|
6
|
+
export type TRetentionRule = { dataType: string; keepMonths: number };
|
|
7
|
+
|
|
8
|
+
export const RETENTION_TYPES = [
|
|
9
|
+
{ value: "visitors", label: "Visitor records" },
|
|
10
|
+
{ value: "feedback", label: "Feedback" },
|
|
11
|
+
{ value: "work-orders", label: "Work orders" },
|
|
12
|
+
{ value: "incident-reports", label: "Incident reports" },
|
|
13
|
+
{ value: "occurrence-books", label: "Occurrence books" },
|
|
14
|
+
{ value: "attendance", label: "Attendance" },
|
|
15
|
+
] as const;
|
|
16
|
+
|
|
17
|
+
export default function useDataRetention() {
|
|
18
|
+
const api = () => useNuxtApp().$api;
|
|
19
|
+
|
|
20
|
+
/** Read-only counts of what the given (or saved) rules would remove today. */
|
|
21
|
+
function previewDataRetention(site: string, body: { rules?: TRetentionRule[] } = {}) {
|
|
22
|
+
return api()<Record<string, any>>("/api/data-retention/preview", { method: "POST", body: { site, ...body } });
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function listDataPurgeRecords(site: string) {
|
|
26
|
+
return api()<Record<string, any>>("/api/data-retention/records", { method: "GET", query: { site } });
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
async function downloadDataPurgeCertificate(site: string, id: string) {
|
|
30
|
+
const res = await api()<Blob>(`/api/data-retention/records/${id}/certificate`, { method: "GET", query: { site } });
|
|
31
|
+
if (!res) throw new Error("Could not download the certificate.");
|
|
32
|
+
const url = window.URL.createObjectURL(res);
|
|
33
|
+
const a = document.createElement("a");
|
|
34
|
+
a.href = url;
|
|
35
|
+
a.download = `data-removal-record-${id}.pdf`;
|
|
36
|
+
document.body.appendChild(a);
|
|
37
|
+
a.click();
|
|
38
|
+
a.remove();
|
|
39
|
+
window.URL.revokeObjectURL(url);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return { previewDataRetention, listDataPurgeRecords, downloadDataPurgeCertificate };
|
|
43
|
+
}
|
|
@@ -7,6 +7,7 @@ export default function useDocument() {
|
|
|
7
7
|
site = "",
|
|
8
8
|
parentId = "",
|
|
9
9
|
expiry = "all",
|
|
10
|
+
archived = false,
|
|
10
11
|
}: {
|
|
11
12
|
page?: number;
|
|
12
13
|
search?: string;
|
|
@@ -19,6 +20,8 @@ export default function useDocument() {
|
|
|
19
20
|
* Document (Expired). Defaults to "all" so existing callers are unaffected.
|
|
20
21
|
*/
|
|
21
22
|
expiry?: string;
|
|
23
|
+
/** The Archived tab (core document archive). Left out = the normal lists. */
|
|
24
|
+
archived?: boolean;
|
|
22
25
|
} = {}) {
|
|
23
26
|
const query: Record<string, any> = {
|
|
24
27
|
page,
|
|
@@ -28,6 +31,7 @@ export default function useDocument() {
|
|
|
28
31
|
site,
|
|
29
32
|
parentId,
|
|
30
33
|
expiry,
|
|
34
|
+
...(archived ? { archived: true } : {}),
|
|
31
35
|
};
|
|
32
36
|
|
|
33
37
|
return useNuxtApp().$api<Record<string, any>>(`/api/documents`, {
|
|
@@ -60,6 +64,14 @@ export default function useDocument() {
|
|
|
60
64
|
});
|
|
61
65
|
}
|
|
62
66
|
|
|
67
|
+
/** Archive keeps the document but hides it from the main list; restore brings it back. */
|
|
68
|
+
function setArchived(id: string, archived: boolean) {
|
|
69
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
70
|
+
`/api/documents/${id}/${archived ? "archive" : "unarchive"}`,
|
|
71
|
+
{ method: "PUT" }
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
63
75
|
function getById(id: string) {
|
|
64
76
|
return useNuxtApp().$api<Record<string, any>>(`/api/documents/${id}`, {
|
|
65
77
|
method: "GET",
|
|
@@ -108,6 +120,7 @@ export default function useDocument() {
|
|
|
108
120
|
add,
|
|
109
121
|
deleteById,
|
|
110
122
|
updateById,
|
|
123
|
+
setArchived,
|
|
111
124
|
getDocumentsBySiteId,
|
|
112
125
|
create,
|
|
113
126
|
createFolder,
|
|
@@ -162,6 +162,17 @@ export default function useFeedback() {
|
|
|
162
162
|
);
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
+
/** A linked copy of this feedback for another provider at the same site. */
|
|
166
|
+
function sendToProvider(id: string, provider: string) {
|
|
167
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
168
|
+
"/api/feedbacks2/send-to-provider",
|
|
169
|
+
{
|
|
170
|
+
method: "POST",
|
|
171
|
+
body: { _id: id, provider },
|
|
172
|
+
}
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
165
176
|
function addFeedBackWorkOrder(payload: any) {
|
|
166
177
|
return useNuxtApp().$api<Record<string, any>>(
|
|
167
178
|
"/api/feedbacks2/create-work-order",
|
|
@@ -204,5 +215,6 @@ export default function useFeedback() {
|
|
|
204
215
|
updateStatusComplete,
|
|
205
216
|
addFeedBackWorkOrder,
|
|
206
217
|
updateStatusFeedback,
|
|
218
|
+
sendToProvider,
|
|
207
219
|
};
|
|
208
220
|
}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Room handover / takeover checklists (API-core `/api/handover-checklists`).
|
|
3
|
+
* The managing agent sets up a checklist per room; guards fill one in at each
|
|
4
|
+
* handover (before use) and takeover (after use). No facility booking needed.
|
|
5
|
+
*/
|
|
6
|
+
export type THandoverItem = {
|
|
7
|
+
label: string;
|
|
8
|
+
quantity?: number | null;
|
|
9
|
+
tagNo?: string | null;
|
|
10
|
+
referencePhotoId?: string | null;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type THandoverTemplate = {
|
|
14
|
+
_id?: string;
|
|
15
|
+
title: string;
|
|
16
|
+
description?: string | null;
|
|
17
|
+
items: THandoverItem[];
|
|
18
|
+
updatedAt?: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export type THandoverRecordItem = THandoverItem & {
|
|
22
|
+
result: "in-order" | "not-in-order";
|
|
23
|
+
remarks?: string | null;
|
|
24
|
+
damagePhotoIds?: string[];
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export type THandoverRecord = {
|
|
28
|
+
_id: string;
|
|
29
|
+
templateId: string;
|
|
30
|
+
title: string;
|
|
31
|
+
stage: "handover" | "takeover";
|
|
32
|
+
items?: THandoverRecordItem[];
|
|
33
|
+
notInOrderCount?: number;
|
|
34
|
+
photoIds?: string[];
|
|
35
|
+
remarks?: string | null;
|
|
36
|
+
officerName?: string | null;
|
|
37
|
+
completedAt: string;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export const HANDOVER_STAGE_LABELS: Record<string, string> = {
|
|
41
|
+
handover: "Handover (before use)",
|
|
42
|
+
takeover: "Takeover (after use)",
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Ready-made checklists an MA can start from (renovation, move in / out). They
|
|
47
|
+
* only open the editor pre-filled; nothing is saved until the MA clicks Save.
|
|
48
|
+
*/
|
|
49
|
+
export const HANDOVER_STARTERS: Array<{ name: string; template: THandoverTemplate }> = [
|
|
50
|
+
{
|
|
51
|
+
name: "Lift & lobby protection (renovation)",
|
|
52
|
+
template: {
|
|
53
|
+
title: "Lift & lobby protection (renovation)",
|
|
54
|
+
description: "Check before renovation works start and again after they finish. Take photos of any damage.",
|
|
55
|
+
items: [
|
|
56
|
+
{ label: "Lift protection in place (wall panels and floor)" },
|
|
57
|
+
{ label: "Lobby floor protection in place" },
|
|
58
|
+
{ label: "Lift interior condition (walls, doors, floor, buttons)" },
|
|
59
|
+
{ label: "Lobby walls, doors and fittings condition" },
|
|
60
|
+
{ label: "Common corridor clean, no debris" },
|
|
61
|
+
],
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "Move in / move out",
|
|
66
|
+
template: {
|
|
67
|
+
title: "Move in / move out",
|
|
68
|
+
description: "Check before the move starts and again after it ends. Take photos of any damage.",
|
|
69
|
+
items: [
|
|
70
|
+
{ label: "Lift protection in place" },
|
|
71
|
+
{ label: "Lobby floor protection in place" },
|
|
72
|
+
{ label: "Lift interior condition (walls, doors, floor, buttons)" },
|
|
73
|
+
{ label: "Lobby and corridor condition" },
|
|
74
|
+
{ label: "Loading bay / driveway clear and undamaged" },
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
];
|
|
79
|
+
|
|
80
|
+
export default function useHandoverChecklist() {
|
|
81
|
+
const base = "/api/handover-checklists";
|
|
82
|
+
|
|
83
|
+
function getTemplates(site: string) {
|
|
84
|
+
return useNuxtApp().$api<THandoverTemplate[]>(`${base}/templates/site/${site}`, { method: "GET" });
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function addTemplate(site: string, body: THandoverTemplate) {
|
|
88
|
+
return useNuxtApp().$api<{ _id: string }>(`${base}/templates/site/${site}`, { method: "POST", body });
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function updateTemplate(id: string, body: THandoverTemplate) {
|
|
92
|
+
return useNuxtApp().$api<Record<string, any>>(`${base}/templates/${id}`, { method: "PUT", body });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function deleteTemplate(id: string) {
|
|
96
|
+
return useNuxtApp().$api<Record<string, any>>(`${base}/templates/${id}`, { method: "DELETE" });
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function getRecords(site: string, query: { page?: number; limit?: number; templateId?: string } = {}) {
|
|
100
|
+
return useNuxtApp().$api<{ items: THandoverRecord[]; total: number; page: number; limit: number }>(
|
|
101
|
+
`${base}/site/${site}`,
|
|
102
|
+
{ method: "GET", query },
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function getRecord(id: string) {
|
|
107
|
+
return useNuxtApp().$api<THandoverRecord>(`${base}/${id}`, { method: "GET" });
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return { getTemplates, addTemplate, updateTemplate, deleteTemplate, getRecords, getRecord };
|
|
111
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { readKeySettings, keyPressName, type TKeyPress } from "../utils/key-presses";
|
|
2
|
+
import useSite from "./useSite";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* One read per site per page load, shared by every caller (a list draws one
|
|
6
|
+
* press name per row). ponytail: never expires; a press added in another tab
|
|
7
|
+
* shows after a reload.
|
|
8
|
+
*/
|
|
9
|
+
const presses = new Map<string, Promise<TKeyPress[]>>();
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The site's key presses (`metadata.keySettings.cabinets`). Empty for a site
|
|
13
|
+
* that has none, which is every site until it adds one - every screen that
|
|
14
|
+
* uses this then looks exactly as before.
|
|
15
|
+
*/
|
|
16
|
+
export default function useKeyPresses(site: MaybeRefOrGetter<string>) {
|
|
17
|
+
const cabinets = ref<TKeyPress[]>([]);
|
|
18
|
+
const { getSiteById } = useSite();
|
|
19
|
+
|
|
20
|
+
async function load() {
|
|
21
|
+
const id = toValue(site);
|
|
22
|
+
// No site, or a site whose list is now empty: no press names left over.
|
|
23
|
+
if (!id) {
|
|
24
|
+
cabinets.value = [];
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (!presses.has(id)) {
|
|
28
|
+
presses.set(
|
|
29
|
+
id,
|
|
30
|
+
getSiteById(id)
|
|
31
|
+
.then((site) => readKeySettings(site).cabinets)
|
|
32
|
+
.catch(() => {
|
|
33
|
+
presses.delete(id);
|
|
34
|
+
return [];
|
|
35
|
+
}),
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
const list = await presses.get(id)!;
|
|
39
|
+
// A slower answer for a site the caller has since left is dropped.
|
|
40
|
+
if (toValue(site) === id) cabinets.value = Array.isArray(list) ? list : [];
|
|
41
|
+
}
|
|
42
|
+
watch(() => toValue(site), load, { immediate: true });
|
|
43
|
+
|
|
44
|
+
const nameOf = (id?: string | null) => keyPressName(cabinets.value, id);
|
|
45
|
+
/** For a key autocomplete's `item-props`: the press as the item's second line. */
|
|
46
|
+
const keyItemProps = (item: any) => {
|
|
47
|
+
const name = nameOf(item?.cabinet);
|
|
48
|
+
return name ? { subtitle: name } : {};
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
/** After the site's presses are saved: read them again. */
|
|
52
|
+
function forget(id: string = toValue(site)) {
|
|
53
|
+
presses.delete(id);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return { cabinets, nameOf, keyItemProps, load, forget };
|
|
57
|
+
}
|
|
@@ -125,6 +125,7 @@ export default function usePassKey() {
|
|
|
125
125
|
statuses = [],
|
|
126
126
|
sortBy,
|
|
127
127
|
prefixAndName,
|
|
128
|
+
cabinets,
|
|
128
129
|
}: {
|
|
129
130
|
_ids?: any;
|
|
130
131
|
page?: number;
|
|
@@ -137,6 +138,8 @@ export default function usePassKey() {
|
|
|
137
138
|
statuses?: string[] | null;
|
|
138
139
|
sortBy?: object;
|
|
139
140
|
prefixAndName?: string;
|
|
141
|
+
/** Key press ids; "" = keys in no press. Left out = no press filter. */
|
|
142
|
+
cabinets?: string[];
|
|
140
143
|
}) {
|
|
141
144
|
return useNuxtApp().$api("/api/keys/search/v1", {
|
|
142
145
|
method: "POST",
|
|
@@ -152,6 +155,7 @@ export default function usePassKey() {
|
|
|
152
155
|
statuses,
|
|
153
156
|
sortBy,
|
|
154
157
|
prefixAndName,
|
|
158
|
+
...(cabinets?.length ? { cabinets } : {}),
|
|
155
159
|
},
|
|
156
160
|
});
|
|
157
161
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Per-site switches (`site.metadata.<key>`, core `site-feature-settings.util.ts`).
|
|
3
|
+
*
|
|
4
|
+
* Every settings panel that writes one saves ONLY its own switch through
|
|
5
|
+
* `PATCH /api/sites/:id/feature-settings` `{ field: "metadata.<key>", value }`.
|
|
6
|
+
* Never the whole `metadata`: a panel that sends back what it read could wipe
|
|
7
|
+
* a switch another panel (or another person) saved in the meantime. The
|
|
8
|
+
* server validates the value and refuses data retention and feedback handling
|
|
9
|
+
* changes from anyone but the site's owner (or Seven365).
|
|
10
|
+
*/
|
|
11
|
+
export const SITE_FEATURE_KEYS = [
|
|
12
|
+
"visitorFields",
|
|
13
|
+
"keySettings",
|
|
14
|
+
"incidentReportEmails",
|
|
15
|
+
"feedbackSettings",
|
|
16
|
+
"dataRetention",
|
|
17
|
+
"maStaffRegistration",
|
|
18
|
+
] as const;
|
|
19
|
+
|
|
20
|
+
export type TSiteFeatureKey = (typeof SITE_FEATURE_KEYS)[number];
|
|
21
|
+
|
|
22
|
+
/** The request body for one switch. */
|
|
23
|
+
export function siteFeatureSettingBody(key: TSiteFeatureKey, value: unknown) {
|
|
24
|
+
if (!SITE_FEATURE_KEYS.includes(key)) throw new Error(`Unknown site setting: ${key}`);
|
|
25
|
+
return { field: `metadata.${key}`, value };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default function useSiteFeatureSettings() {
|
|
29
|
+
async function saveSiteFeature(siteId: string, key: TSiteFeatureKey, value: unknown) {
|
|
30
|
+
return await useNuxtApp().$api<Record<string, any>>(`/api/sites/${siteId}/feature-settings`, {
|
|
31
|
+
method: "PATCH",
|
|
32
|
+
body: siteFeatureSettingBody(key, value),
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return { saveSiteFeature };
|
|
37
|
+
}
|
|
@@ -273,3 +273,25 @@ export default function () {
|
|
|
273
273
|
visitorDataFromScannedQRCodeCheckIn,
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* The site's guardhouse registration switches (`site.metadata.visitorFields`).
|
|
279
|
+
* Anything a site never saved reads as "default" = today's form.
|
|
280
|
+
*/
|
|
281
|
+
export type TVisitorFieldSwitches = {
|
|
282
|
+
nric: "default" | "hidden";
|
|
283
|
+
contact: "default" | "hidden" | "required";
|
|
284
|
+
vehicle: "default" | "required";
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
export function getVisitorFieldSwitches(site: any): TVisitorFieldSwitches {
|
|
288
|
+
const v = site?.metadata?.visitorFields ?? {};
|
|
289
|
+
return {
|
|
290
|
+
nric: v.nric === "hidden" ? "hidden" : "default",
|
|
291
|
+
contact: v.contact === "hidden" || v.contact === "required" ? v.contact : "default",
|
|
292
|
+
vehicle: v.vehicle === "required" ? "required" : "default",
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
/** Same words as the server's refusal, so the guard reads one message. */
|
|
297
|
+
export const VEHICLE_REQUIRED_MESSAGE = "This site requires a vehicle number for every visitor.";
|