@7365admin1/layer-common 4.31.0 → 4.32.1-staging.364
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/CHANGELOG.md +10 -4
- package/assets/css/robot-hero.css +227 -1
- package/components/AccessCardAddForm.vue +5 -4
- package/components/AccessCardAssignToUnitForm.vue +3 -2
- package/components/AccessCardPreviewDialog.vue +4 -3
- package/components/Dialog/DeleteConfirmation.vue +17 -2
- package/components/Dialog/ReusablePrompt.vue +26 -3
- package/components/Dialog/UpdateMoreAction.vue +11 -1
- package/components/DocumentForm.vue +407 -112
- package/components/DocumentManagement.vue +213 -12
- package/components/EntryPass/QrTemplatePreview.vue +21 -25
- package/components/EntryPassInformation.vue +119 -24
- package/components/Facility/BookingSetup.vue +63 -0
- package/components/HidAccessLogDashboard.vue +41 -8
- package/components/HidAccessPermissions.vue +424 -0
- package/components/HidIntercomManagement.vue +148 -14
- package/components/HidProfileQrCode.vue +332 -0
- package/components/HidReaderManagement.vue +26 -0
- package/components/HidReaderUserRoster.vue +44 -3
- package/components/HidUserEnrollment.vue +845 -155
- package/components/InvitationClientForm.vue +19 -1
- package/components/NotificationBell.vue +39 -3
- package/components/Robot/BuildingMap.vue +403 -0
- package/components/Robot/LiftQueue.vue +247 -0
- package/components/Robot/MapEditor.vue +233 -0
- package/components/Robot/PatrolRoutes.vue +3 -3
- package/components/Robot/SiteScreen.vue +36 -1
- package/components/VehicleForm.vue +45 -2
- package/components/VehicleManagement.vue +95 -10
- package/components/VisitorManagement.vue +267 -5
- package/composables/useAccessManagement.ts +5 -0
- package/composables/useCleaningPermission.ts +4 -4
- package/composables/useCommonPermission.ts +16 -0
- package/composables/useDocument.ts +7 -0
- package/composables/useFacility.ts +11 -0
- package/composables/useHidAmico.ts +117 -0
- package/composables/useHidNavigation.ts +25 -1
- package/composables/useHidReaderSelection.ts +50 -0
- package/composables/useLandscapingPermission.ts +4 -4
- package/composables/useMechanicalElectricalPermission.ts +4 -4
- package/composables/usePeople.ts +19 -0
- package/composables/usePestControlPermission.ts +4 -4
- package/composables/usePoolMaintenancePermission.ts +4 -4
- package/composables/useRobotBuilding.ts +66 -0
- package/composables/useSecurityPermission.ts +4 -10
- package/composables/useSiteCategory.ts +45 -0
- package/composables/useSiteEntryPassSettings.ts +26 -0
- package/composables/useWebUsb.ts +14 -11
- package/package.json +2 -2
- package/pages/[org]/[site]/access-mgmt/administrator/index.vue +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-cards/index.vue +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +23 -0
- package/pages/[org]/[site]/access-mgmt/hid-readers/index.vue +1 -1
- package/types/document.d.ts +14 -0
- package/types/facility.d.ts +4 -0
- package/types/people.d.ts +28 -1
- package/utils/hid-permission-assignments.ts +190 -0
- package/utils/hid-reader-selection.ts +52 -0
- package/utils/notification-target.ts +75 -0
- package/utils/occupancy-role.ts +109 -0
- package/utils/robot-building.ts +521 -0
- package/utils/robot-display.ts +29 -6
- package/utils/vehicle-actions.ts +12 -4
|
@@ -396,7 +396,10 @@
|
|
|
396
396
|
to find out why. The click now runs the validation, which paints every
|
|
397
397
|
offending field and writes the reason above.
|
|
398
398
|
-->
|
|
399
|
-
|
|
399
|
+
<!-- Refused by the server for want of the right: drawn disabled, and a
|
|
400
|
+
press only repeats the reason - nothing is sent again. -->
|
|
401
|
+
<AppButton :disabled="processing" :class="{ 'no-permission': !!refusedMessage }"
|
|
402
|
+
:aria-disabled="!!refusedMessage || undefined" @click="submit">
|
|
400
403
|
{{ prop.mode == "add" ? "Submit" : "Update" }}
|
|
401
404
|
</AppButton>
|
|
402
405
|
</div>
|
|
@@ -440,7 +443,8 @@
|
|
|
440
443
|
</div>
|
|
441
444
|
<div class="vehicle-form__footer">
|
|
442
445
|
<AppButton variant="ghost" :disabled="processing" @click="cancelExistingUpdate">Cancel</AppButton>
|
|
443
|
-
<AppButton :disabled="processing"
|
|
446
|
+
<AppButton :disabled="processing" :class="{ 'no-permission': !!refusedMessage }"
|
|
447
|
+
:aria-disabled="!!refusedMessage || undefined" @click="confirmExistingUpdate">Update</AppButton>
|
|
444
448
|
</div>
|
|
445
449
|
</v-card>
|
|
446
450
|
</v-dialog>
|
|
@@ -517,6 +521,7 @@
|
|
|
517
521
|
|
|
518
522
|
<script setup lang="ts">
|
|
519
523
|
import { errorConverter } from "../utils/data";
|
|
524
|
+
import { isPermissionRefusalError } from "../utils/permission-refusal";
|
|
520
525
|
const prop = defineProps({
|
|
521
526
|
type: {
|
|
522
527
|
type: String as PropType<TVehicleType | "seasonpass">,
|
|
@@ -597,8 +602,28 @@ const emit = defineEmits([
|
|
|
597
602
|
"error",
|
|
598
603
|
"close",
|
|
599
604
|
"close:all",
|
|
605
|
+
// The server refused for want of the right: "create" or "update".
|
|
606
|
+
"refused",
|
|
600
607
|
]);
|
|
601
608
|
|
|
609
|
+
/**
|
|
610
|
+
* The server's "You do not have permission to ..." once it has refused this
|
|
611
|
+
* form. From then on the confirm is drawn disabled and a press only shows the
|
|
612
|
+
* sentence again - no second request. The host is told (`refused`) so it can
|
|
613
|
+
* take the matching action off its menus.
|
|
614
|
+
*/
|
|
615
|
+
const refusedMessage = ref("");
|
|
616
|
+
function noteRefusal(error: unknown) {
|
|
617
|
+
if (!isPermissionRefusalError(error)) return;
|
|
618
|
+
refusedMessage.value = errorMessage.value;
|
|
619
|
+
emit("refused", prop.mode === "add" ? "create" : "update");
|
|
620
|
+
}
|
|
621
|
+
function refusedAlready() {
|
|
622
|
+
if (!refusedMessage.value) return false;
|
|
623
|
+
errorMessage.value = refusedMessage.value;
|
|
624
|
+
return true;
|
|
625
|
+
}
|
|
626
|
+
|
|
602
627
|
const vehicle = reactive<
|
|
603
628
|
Omit<ExceptPartial<TVehicle>, "type"> & { type: TVehicleType | "seasonpass" }
|
|
604
629
|
>({
|
|
@@ -1142,6 +1167,10 @@ function cancelExistingUpdate() {
|
|
|
1142
1167
|
async function confirmExistingUpdate() {
|
|
1143
1168
|
const payload = pendingPayload.value;
|
|
1144
1169
|
if (!payload) return;
|
|
1170
|
+
if (refusedAlready()) {
|
|
1171
|
+
showExistingDialog.value = false;
|
|
1172
|
+
return;
|
|
1173
|
+
}
|
|
1145
1174
|
|
|
1146
1175
|
errorMessage.value = "";
|
|
1147
1176
|
processing.value = true;
|
|
@@ -1168,12 +1197,14 @@ async function confirmExistingUpdate() {
|
|
|
1168
1197
|
// Shown under the form. A record moved before the failure stays moved.
|
|
1169
1198
|
showExistingDialog.value = false;
|
|
1170
1199
|
errorMessage.value = errorConverter(error);
|
|
1200
|
+
noteRefusal(error);
|
|
1171
1201
|
} finally {
|
|
1172
1202
|
processing.value = false;
|
|
1173
1203
|
}
|
|
1174
1204
|
}
|
|
1175
1205
|
|
|
1176
1206
|
async function submit() {
|
|
1207
|
+
if (refusedAlready()) return;
|
|
1177
1208
|
errorMessage.value = "";
|
|
1178
1209
|
|
|
1179
1210
|
// Ask the form first. `validate()` marks each failing field, so the person
|
|
@@ -1326,6 +1357,7 @@ async function submit() {
|
|
|
1326
1357
|
// with nothing), returns a plain sentence instead of ofetch's
|
|
1327
1358
|
// `[POST] "/api/vehicles": 502`.
|
|
1328
1359
|
errorMessage.value = errorConverter(error);
|
|
1360
|
+
noteRefusal(error);
|
|
1329
1361
|
} finally {
|
|
1330
1362
|
processing.value = false;
|
|
1331
1363
|
}
|
|
@@ -1508,6 +1540,12 @@ function handleCloseMatchDialog() {
|
|
|
1508
1540
|
// The panel's own close button never did that; the two now agree. Backing out
|
|
1509
1541
|
// of a picker is not a decision to discard what you already had.
|
|
1510
1542
|
showMatchingPeopleDialog.value = false;
|
|
1543
|
+
// Closed WITHOUT picking a record: the person is someone new at this unit,
|
|
1544
|
+
// so NRIC and Full Name are typed in by hand. They were left locked by the
|
|
1545
|
+
// lookup (`disablePrefilledInputs`), with no way to unlock them short of
|
|
1546
|
+
// choosing a different unit. A picked record still locks them
|
|
1547
|
+
// (`selectPeopleRecord`).
|
|
1548
|
+
if (!vehicle.peopleId) disablePrefilledInputs.value = false;
|
|
1511
1549
|
}
|
|
1512
1550
|
|
|
1513
1551
|
onMounted(() => {
|
|
@@ -1547,6 +1585,11 @@ onMounted(() => {
|
|
|
1547
1585
|
});
|
|
1548
1586
|
</script>
|
|
1549
1587
|
<style scoped>
|
|
1588
|
+
/* Refused: faded, but still takes the click so it can say why. */
|
|
1589
|
+
.no-permission {
|
|
1590
|
+
opacity: 0.45;
|
|
1591
|
+
cursor: not-allowed;
|
|
1592
|
+
}
|
|
1550
1593
|
.button-outline-class {
|
|
1551
1594
|
border: 1px solid rgba(var(--v-theme-primary));
|
|
1552
1595
|
}
|
|
@@ -20,6 +20,16 @@
|
|
|
20
20
|
show-header @row-click="handleRowClick"
|
|
21
21
|
@update:page="handleUpdatePage">
|
|
22
22
|
|
|
23
|
+
<!-- Empty table: say WHY when the server refused the list ("You do not
|
|
24
|
+
have permission to view vehicles."), rather than "No data
|
|
25
|
+
available", which reads as an empty site. -->
|
|
26
|
+
<template #no-data>
|
|
27
|
+
<div class="table-card__empty" :class="{ 'text-error': !!listError }">
|
|
28
|
+
<v-icon :icon="listError ? 'mdi-lock-outline' : 'mdi-magnify-close'" size="32" />
|
|
29
|
+
<span>{{ listError || "No data available" }}</span>
|
|
30
|
+
</div>
|
|
31
|
+
</template>
|
|
32
|
+
|
|
23
33
|
<!-- Residents / Season Passes / Block Listed, on the toolbar row the way
|
|
24
34
|
the other screens draw their tabs. Each tab shows every status. -->
|
|
25
35
|
<template #tabs>
|
|
@@ -115,19 +125,19 @@
|
|
|
115
125
|
<v-dialog v-model="dialog.createVehicle" v-if="vehicleType" width="450" persistent>
|
|
116
126
|
<VehicleForm :type="vehicleType" :mode="mode" :vehicle-data="selectedVehicleObject"
|
|
117
127
|
:plate-number-id="selectedPlateNumberId" :name-hints="nameHints" @back="handleBackToSelection" @done="handleAddVehicleComplete"
|
|
118
|
-
:org="org" :site="props.site" @close:all="handleCloseAll" />
|
|
128
|
+
:org="org" :site="props.site" @close:all="handleCloseAll" @refused="handleFormRefused" />
|
|
119
129
|
</v-dialog>
|
|
120
130
|
|
|
121
131
|
<v-dialog v-model="dialog.updateVehicle" v-if="vehicleType" width="450" persistent>
|
|
122
132
|
<VehicleForm :type="vehicleType" :mode="mode" :vehicle-data="selectedPlateNumberObject"
|
|
123
133
|
:plate-number-id="selectedPlateNumberId" :name-hints="nameHints" @back="handleBackToSelection" @done="handleAddVehicleComplete"
|
|
124
|
-
:org="org" :site="props.site" @close:all="handleCloseAll" @close="handleCloseAll" />
|
|
134
|
+
:org="org" :site="props.site" @close:all="handleCloseAll" @refused="handleFormRefused" @close="handleCloseAll" />
|
|
125
135
|
</v-dialog>
|
|
126
136
|
|
|
127
137
|
<!-- <v-dialog v-model="dialog.updateVehicle" v-if="vehicleType" width="450" persistent>
|
|
128
138
|
<VehicleForm :type="vehicleType" mode="edit" :vehicle-data="selectedVehicleObject"
|
|
129
139
|
@back="dialog.updateVehicle = false" @close="dialog.updateVehicle = false" @done="handleUpdateVehicleComplete"
|
|
130
|
-
:org="org" :site="site" @close:all="handleCloseAll" />
|
|
140
|
+
:org="org" :site="site" @close:all="handleCloseAll" @refused="handleFormRefused" />
|
|
131
141
|
</v-dialog> -->
|
|
132
142
|
|
|
133
143
|
<v-dialog v-if="canViewVehicleDetails" v-model="dialog.showMoreActions" width="800" persistent>
|
|
@@ -244,7 +254,7 @@
|
|
|
244
254
|
when the ANPR revoke could not be confirmed - the dialog stays open on
|
|
245
255
|
that path so the operator can read it and retry.
|
|
246
256
|
-->
|
|
247
|
-
<DialogDeleteConfirmation :loading="deletingVehicle" :message="deleteError"
|
|
257
|
+
<DialogDeleteConfirmation :loading="deletingVehicle" :message="deleteError" :no-permission="revoked.delete"
|
|
248
258
|
:prompt-title="`Remove vehicle number ${selectedPlateNumberObject?.plateNumber} from this record? This revokes its ANPR access - it will no longer open the barrier. The resident and any other vehicle numbers on this record are not affected.`"
|
|
249
259
|
@delete="submitDelete" @close="closeDeleteDialog" />
|
|
250
260
|
</v-dialog>
|
|
@@ -255,24 +265,26 @@
|
|
|
255
265
|
operator has to read and act on - it was going to a five-second
|
|
256
266
|
snackbar, along with the device's raw `{"ErrorCode":...}` reply.
|
|
257
267
|
-->
|
|
258
|
-
<DialogReusablePrompt :loading="approvingVehicle" :message="actionError"
|
|
268
|
+
<DialogReusablePrompt :loading="approvingVehicle" :message="actionError" message-error :no-permission="revoked.approve"
|
|
259
269
|
:prompt-title="`Are you sure want to approve this vehicle - ${selectedPlateNumberObject?.plateNumber}?`"
|
|
260
270
|
@proceed="submitApprove" @close="closeActionDialog('approveVehicle')" />
|
|
261
271
|
</v-dialog>
|
|
272
|
+
<!-- Like Delete, Restore says what it does at the barrier: a whitelist
|
|
273
|
+
plate goes back on the allowed list and opens it again. -->
|
|
262
274
|
<v-dialog v-model="dialog.restoreVehicle" persistent width="540">
|
|
263
|
-
<DialogReusablePrompt :loading="restoringVehicle" :message="actionError"
|
|
264
|
-
:prompt-title="
|
|
275
|
+
<DialogReusablePrompt :loading="restoringVehicle" :message="actionError" message-error :no-permission="revoked.approve"
|
|
276
|
+
:prompt-title="restorePrompt"
|
|
265
277
|
@proceed="submitRestore" @close="closeActionDialog('restoreVehicle')" />
|
|
266
278
|
</v-dialog>
|
|
267
279
|
<!-- Block / Unblock say what happens on the cameras, because that is the
|
|
268
280
|
part the operator cannot see from here. -->
|
|
269
281
|
<v-dialog v-model="dialog.blockVehicle" persistent width="540">
|
|
270
|
-
<DialogReusablePrompt :loading="blockingVehicle" :message="actionError"
|
|
282
|
+
<DialogReusablePrompt :loading="blockingVehicle" :message="actionError" message-error :no-permission="revoked.update"
|
|
271
283
|
:prompt-title="`Block vehicle ${selectedPlateNumberObject?.plateNumber}? It is added to every ANPR camera's blocklist and taken off the allowed list. Its status becomes Blocked and its category Block Listed.`"
|
|
272
284
|
@proceed="submitBlock" @close="closeActionDialog('blockVehicle')" />
|
|
273
285
|
</v-dialog>
|
|
274
286
|
<v-dialog v-model="dialog.unblockVehicle" persistent width="540">
|
|
275
|
-
<DialogReusablePrompt :loading="unblockingVehicle" :message="actionError"
|
|
287
|
+
<DialogReusablePrompt :loading="unblockingVehicle" :message="actionError" message-error :no-permission="revoked.update"
|
|
276
288
|
:prompt-title="`Unblock vehicle ${selectedPlateNumberObject?.plateNumber}? It is taken off every ANPR camera's blocklist. It is NOT whitelisted - the record stays with status Unblocked.`"
|
|
277
289
|
@proceed="submitUnblock" @close="closeActionDialog('unblockVehicle')" />
|
|
278
290
|
</v-dialog>
|
|
@@ -629,7 +641,7 @@ const nameHints = computed<Record<string, string>>(() => {
|
|
|
629
641
|
return hints;
|
|
630
642
|
})
|
|
631
643
|
|
|
632
|
-
const { data: getVehiclesReq, refresh: getVehiclesRefresh, pending: getVehiclesPending } =
|
|
644
|
+
const { data: getVehiclesReq, refresh: getVehiclesRefresh, pending: getVehiclesPending, error: getVehiclesError } =
|
|
633
645
|
await useLazyAsyncData(
|
|
634
646
|
`get-all-vehicles-${props.site}`,
|
|
635
647
|
() =>
|
|
@@ -645,6 +657,18 @@ const { data: getVehiclesReq, refresh: getVehiclesRefresh, pending: getVehiclesP
|
|
|
645
657
|
);
|
|
646
658
|
|
|
647
659
|
|
|
660
|
+
/** The server's reason when the list itself was refused or failed. */
|
|
661
|
+
const listError = computed(() =>
|
|
662
|
+
getVehiclesError.value ? errorConverter(getVehiclesError.value) : "",
|
|
663
|
+
);
|
|
664
|
+
watch(getVehiclesError, (error) => {
|
|
665
|
+
// A refused list must not keep showing the rows from before the refusal.
|
|
666
|
+
if (!error) return;
|
|
667
|
+
items.value = [];
|
|
668
|
+
pages.value = 0;
|
|
669
|
+
pageRange.value = "-- - -- of --";
|
|
670
|
+
});
|
|
671
|
+
|
|
648
672
|
watch(getVehiclesReq, (newData: any) => {
|
|
649
673
|
loadActiveCameraCounts();
|
|
650
674
|
items.value = newData?.items || [];
|
|
@@ -653,6 +677,12 @@ watch(getVehiclesReq, (newData: any) => {
|
|
|
653
677
|
})
|
|
654
678
|
|
|
655
679
|
function handleRowClick(data: any) {
|
|
680
|
+
// Without "See Vehicle Details" the Preview dialog is not rendered at all,
|
|
681
|
+
// so a click used to do nothing and gave no reason. Say why instead.
|
|
682
|
+
if (!props.canViewVehicleDetails) {
|
|
683
|
+
showMessage("You do not have permission to view vehicle details.", "error");
|
|
684
|
+
return;
|
|
685
|
+
}
|
|
656
686
|
selectedVehicleId.value = data?.item?._id;
|
|
657
687
|
dialog.showMoreActions = true;
|
|
658
688
|
message.value = "";
|
|
@@ -829,6 +859,29 @@ function revokeOnRefusal(error: unknown, right: keyof typeof revoked) {
|
|
|
829
859
|
if (isPermissionRefusalError(error)) revoked[right] = true;
|
|
830
860
|
}
|
|
831
861
|
|
|
862
|
+
/** The server's own sentences, reused so a repeat press sends nothing. */
|
|
863
|
+
const NO_PERMISSION: Record<keyof typeof revoked, string> = {
|
|
864
|
+
update: "You do not have permission to edit vehicles.",
|
|
865
|
+
delete: "You do not have permission to delete vehicles.",
|
|
866
|
+
approve: "You do not have permission to approve vehicles.",
|
|
867
|
+
};
|
|
868
|
+
|
|
869
|
+
/**
|
|
870
|
+
* True (and the reason shown in the dialog) when this right was already
|
|
871
|
+
* refused: the confirm is drawn disabled, and pressing it again only repeats
|
|
872
|
+
* the message - no request goes to the server.
|
|
873
|
+
*/
|
|
874
|
+
/** The add/edit form was refused: an edit refusal takes Edit/Block/Unblock off. */
|
|
875
|
+
function handleFormRefused(kind: "create" | "update") {
|
|
876
|
+
if (kind === "update") revoked.update = true;
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
function refusedAlready(right: keyof typeof revoked, target: typeof actionError) {
|
|
880
|
+
if (!revoked[right]) return false;
|
|
881
|
+
target.value = NO_PERMISSION[right];
|
|
882
|
+
return true;
|
|
883
|
+
}
|
|
884
|
+
|
|
832
885
|
/**
|
|
833
886
|
* One entry point for every menu item, in both menus, so a new action can only
|
|
834
887
|
* be added in one place and cannot be forgotten in the other.
|
|
@@ -910,6 +963,7 @@ const formatPlateNumbers = (value: any) => {
|
|
|
910
963
|
};
|
|
911
964
|
|
|
912
965
|
async function submitDelete() {
|
|
966
|
+
if (refusedAlready("delete", deleteError)) return;
|
|
913
967
|
|
|
914
968
|
const plateNumberId = selectedPlateNumberObject.value?._id;
|
|
915
969
|
const type = selectedPlateNumberObject.value?.type as TVehicleType;
|
|
@@ -945,7 +999,33 @@ async function submitDelete() {
|
|
|
945
999
|
|
|
946
1000
|
|
|
947
1001
|
|
|
1002
|
+
/**
|
|
1003
|
+
* What Restore will do on the cameras, from the site's live camera counts:
|
|
1004
|
+
* a whitelist plate (or season pass) goes back on the allowed list and opens
|
|
1005
|
+
* the barrier again; a blocklist plate goes back on the blocklist.
|
|
1006
|
+
*/
|
|
1007
|
+
const restorePrompt = computed(() => {
|
|
1008
|
+
const plate = selectedPlateNumberObject.value;
|
|
1009
|
+
const number = plate?.plateNumber ?? "";
|
|
1010
|
+
const blocklist = String(plate?.type ?? "").toLowerCase() === "blocklist";
|
|
1011
|
+
const counts = activeCameraCounts.value;
|
|
1012
|
+
const cameras = counts ? (blocklist ? counts.blocked : counts.allowed) : null;
|
|
1013
|
+
const onCameras =
|
|
1014
|
+
cameras === null
|
|
1015
|
+
? "every ANPR camera"
|
|
1016
|
+
: `${cameras} ANPR camera${cameras === 1 ? "" : "s"}`;
|
|
1017
|
+
|
|
1018
|
+
if (cameras === 0) {
|
|
1019
|
+
return `Restore vehicle ${number}? There is no active ANPR camera for it at this site, so barrier access does not change until one is added.`;
|
|
1020
|
+
}
|
|
1021
|
+
if (blocklist) {
|
|
1022
|
+
return `Restore vehicle ${number}? It is added back to the blocklist on ${onCameras} - the barrier will stay closed for it. Its status becomes Blocked.`;
|
|
1023
|
+
}
|
|
1024
|
+
return `Restore vehicle ${number}? This gives back its ANPR access on ${onCameras} - it will open the barrier again. Only this vehicle number is affected.`;
|
|
1025
|
+
});
|
|
1026
|
+
|
|
948
1027
|
async function submitRestore() {
|
|
1028
|
+
if (refusedAlready("approve", actionError)) return;
|
|
949
1029
|
|
|
950
1030
|
const vehicleId = selectedPlateNumberObject.value?._id;
|
|
951
1031
|
|
|
@@ -965,6 +1045,8 @@ async function submitRestore() {
|
|
|
965
1045
|
await getVehiclesRefresh();
|
|
966
1046
|
} catch (error: any) {
|
|
967
1047
|
actionError.value = errorConverter(error);
|
|
1048
|
+
// Restore is the approve endpoint: a refusal is the Approve right gone.
|
|
1049
|
+
revokeOnRefusal(error, "approve");
|
|
968
1050
|
} finally {
|
|
969
1051
|
restoringVehicle.value = false;
|
|
970
1052
|
}
|
|
@@ -972,6 +1054,7 @@ async function submitRestore() {
|
|
|
972
1054
|
|
|
973
1055
|
|
|
974
1056
|
async function submitBlock() {
|
|
1057
|
+
if (refusedAlready("update", actionError)) return;
|
|
975
1058
|
const vehicleId = selectedPlateNumberObject.value?._id;
|
|
976
1059
|
if (!vehicleId) {
|
|
977
1060
|
showMessage("Invalid vehicle selected for blocking.", "error");
|
|
@@ -995,6 +1078,7 @@ async function submitBlock() {
|
|
|
995
1078
|
|
|
996
1079
|
|
|
997
1080
|
async function submitUnblock() {
|
|
1081
|
+
if (refusedAlready("update", actionError)) return;
|
|
998
1082
|
const vehicleId = selectedPlateNumberObject.value?._id;
|
|
999
1083
|
if (!vehicleId) {
|
|
1000
1084
|
showMessage("Invalid vehicle selected for unblocking.", "error");
|
|
@@ -1018,6 +1102,7 @@ async function submitUnblock() {
|
|
|
1018
1102
|
|
|
1019
1103
|
|
|
1020
1104
|
async function submitApprove() {
|
|
1105
|
+
if (refusedAlready("approve", actionError)) return;
|
|
1021
1106
|
|
|
1022
1107
|
const plateNumberId = selectedPlateNumberObject.value?._id;
|
|
1023
1108
|
if (!plateNumberId) {
|
|
@@ -742,11 +742,35 @@
|
|
|
742
742
|
class="visitor-preview__row"
|
|
743
743
|
>
|
|
744
744
|
<div class="visitor-preview__label">{{ label }}</div>
|
|
745
|
-
<div
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
745
|
+
<div>
|
|
746
|
+
<!-- Was a hover tooltip on the value: the full NRIC only
|
|
747
|
+
reachable by hovering, which says nothing is there to
|
|
748
|
+
reach and cannot be reached at all on a touch screen.
|
|
749
|
+
The eye alone, at the 14px the Incident Report screens
|
|
750
|
+
draw it, is a 14px target - the floor is 24px. So the
|
|
751
|
+
NUMBER is the control and the eye is its affordance:
|
|
752
|
+
the whole masked value is pressable, which makes the
|
|
753
|
+
target the width of the digits rather than of a glyph,
|
|
754
|
+
and being a real `button` it also takes a tab stop,
|
|
755
|
+
which a `v-icon` with a click handler never did. -->
|
|
756
|
+
<button
|
|
757
|
+
type="button"
|
|
758
|
+
class="visitor-preview__reveal"
|
|
759
|
+
:aria-label="showVisitorNric ? 'Hide NRIC' : 'Show NRIC'"
|
|
760
|
+
:aria-pressed="showVisitorNric"
|
|
761
|
+
@click="showVisitorNric = !showVisitorNric"
|
|
762
|
+
>
|
|
763
|
+
<span class="visitor-preview__value">
|
|
764
|
+
{{
|
|
765
|
+
showVisitorNric
|
|
766
|
+
? selectedVisitorObject[key]
|
|
767
|
+
: maskNRIC(selectedVisitorObject[key])
|
|
768
|
+
}}
|
|
769
|
+
</span>
|
|
770
|
+
<v-icon size="16" class="visitor-preview__eye">
|
|
771
|
+
{{ showVisitorNric ? "mdi-eye-off-outline" : "mdi-eye-outline" }}
|
|
772
|
+
</v-icon>
|
|
773
|
+
</button>
|
|
750
774
|
</div>
|
|
751
775
|
</div>
|
|
752
776
|
|
|
@@ -796,6 +820,84 @@
|
|
|
796
820
|
</div>
|
|
797
821
|
</div>
|
|
798
822
|
|
|
823
|
+
<!--
|
|
824
|
+
THE CONTRACTOR'S PARTY.
|
|
825
|
+
|
|
826
|
+
The list row has always said `( +2 members)` beside the name
|
|
827
|
+
and then had nowhere to send you for the names themselves. The
|
|
828
|
+
block spans both columns rather than sitting in the 116px
|
|
829
|
+
value track: a member is a record, not a value, and several of
|
|
830
|
+
them in a 250px column is unreadable.
|
|
831
|
+
|
|
832
|
+
Read off `selectedVisitorDataObject` (the raw row) and not
|
|
833
|
+
`selectedVisitorObject`, which filters itself down to
|
|
834
|
+
`typeFieldMap` plus five fixed keys - `members` is on neither
|
|
835
|
+
list, and widening that computed would change what four other
|
|
836
|
+
dialogs on this screen see.
|
|
837
|
+
-->
|
|
838
|
+
<div
|
|
839
|
+
v-else-if="key === 'members' && selectedVisitorMembers.length"
|
|
840
|
+
class="visitor-preview__row visitor-preview__row--block"
|
|
841
|
+
>
|
|
842
|
+
<div class="visitor-preview__label">
|
|
843
|
+
{{ label }} ({{ selectedVisitorMembers.length }})
|
|
844
|
+
</div>
|
|
845
|
+
<div class="visitor-preview__members">
|
|
846
|
+
<div
|
|
847
|
+
v-for="(member, index) in selectedVisitorMembers"
|
|
848
|
+
:key="member?.nric || member?.name || index"
|
|
849
|
+
class="visitor-preview__member"
|
|
850
|
+
>
|
|
851
|
+
<div class="visitor-preview__value">
|
|
852
|
+
{{ member?.name || "N/A" }}
|
|
853
|
+
</div>
|
|
854
|
+
<template v-for="field in memberDetailFields" :key="field.key">
|
|
855
|
+
<div
|
|
856
|
+
v-if="member?.[field.key]"
|
|
857
|
+
class="visitor-preview__member-line"
|
|
858
|
+
>
|
|
859
|
+
<span class="visitor-preview__member-key">
|
|
860
|
+
{{ field.label }}
|
|
861
|
+
</span>
|
|
862
|
+
<!-- A member's NRIC is the same class of data as the
|
|
863
|
+
visitor's, so it gets the same control. Each
|
|
864
|
+
member reveals separately - one toggle for the
|
|
865
|
+
whole card would show three people's NRICs to
|
|
866
|
+
read one. -->
|
|
867
|
+
<button
|
|
868
|
+
v-if="field.key === 'nric'"
|
|
869
|
+
type="button"
|
|
870
|
+
class="visitor-preview__reveal"
|
|
871
|
+
:aria-label="
|
|
872
|
+
isMemberNricShown(index)
|
|
873
|
+
? `Hide NRIC for ${member?.name || 'this member'}`
|
|
874
|
+
: `Show NRIC for ${member?.name || 'this member'}`
|
|
875
|
+
"
|
|
876
|
+
:aria-pressed="isMemberNricShown(index)"
|
|
877
|
+
@click="toggleMemberNric(index)"
|
|
878
|
+
>
|
|
879
|
+
<span>
|
|
880
|
+
{{
|
|
881
|
+
isMemberNricShown(index)
|
|
882
|
+
? member.nric
|
|
883
|
+
: maskNRIC(member.nric)
|
|
884
|
+
}}
|
|
885
|
+
</span>
|
|
886
|
+
<v-icon size="16" class="visitor-preview__eye">
|
|
887
|
+
{{
|
|
888
|
+
isMemberNricShown(index)
|
|
889
|
+
? "mdi-eye-off-outline"
|
|
890
|
+
: "mdi-eye-outline"
|
|
891
|
+
}}
|
|
892
|
+
</v-icon>
|
|
893
|
+
</button>
|
|
894
|
+
<span v-else>{{ member[field.key] }}</span>
|
|
895
|
+
</div>
|
|
896
|
+
</template>
|
|
897
|
+
</div>
|
|
898
|
+
</div>
|
|
899
|
+
</div>
|
|
900
|
+
|
|
799
901
|
<!-- The vehicle number, with Block on its right: the Registered
|
|
800
902
|
tab only, for someone who may add vehicles. It opens the
|
|
801
903
|
Vehicle Mgmt Block Listed form with the category taken from
|
|
@@ -2088,6 +2190,71 @@ const isSelectedVisitorPendingApproval = computed(
|
|
|
2088
2190
|
() => selectedVisitorStatus.value === "pending"
|
|
2089
2191
|
);
|
|
2090
2192
|
|
|
2193
|
+
/**
|
|
2194
|
+
* The members a contractor brought with them. Not gated on the Guests tab: the
|
|
2195
|
+
* list row's own `( +N members)` count is not either, and a contractor with a
|
|
2196
|
+
* party has one wherever the screen shows it.
|
|
2197
|
+
*
|
|
2198
|
+
* Blank entries are dropped rather than drawn as an empty card - the payload
|
|
2199
|
+
* carries `""` for every detail nobody filled in, so a member with no name and
|
|
2200
|
+
* no details would otherwise render as a bare inset box.
|
|
2201
|
+
*/
|
|
2202
|
+
const selectedVisitorMembers = computed<Record<string, any>[]>(() => {
|
|
2203
|
+
const members = selectedVisitorDataObject.value?.members;
|
|
2204
|
+
if (!Array.isArray(members)) return [];
|
|
2205
|
+
|
|
2206
|
+
return members.filter(
|
|
2207
|
+
(member: Record<string, any>) =>
|
|
2208
|
+
member?.name || member?.nric || member?.contact || member?.plateNumber
|
|
2209
|
+
);
|
|
2210
|
+
});
|
|
2211
|
+
|
|
2212
|
+
/**
|
|
2213
|
+
* WHICH NRICs ARE UNCOVERED RIGHT NOW.
|
|
2214
|
+
*
|
|
2215
|
+
* Per member and not per card, so revealing one person's number does not
|
|
2216
|
+
* uncover the rest of the party's. Both are cleared when the dialog closes -
|
|
2217
|
+
* a preview must not open on the next visitor with the last one's NRIC
|
|
2218
|
+
* already showing, and it is the same `selectedVisitorId` that would carry it
|
|
2219
|
+
* across if the same row were reopened.
|
|
2220
|
+
*/
|
|
2221
|
+
const showVisitorNric = ref(false);
|
|
2222
|
+
const shownMemberNrics = ref<number[]>([]);
|
|
2223
|
+
|
|
2224
|
+
function isMemberNricShown(index: number) {
|
|
2225
|
+
return shownMemberNrics.value.includes(index);
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2228
|
+
function toggleMemberNric(index: number) {
|
|
2229
|
+
shownMemberNrics.value = isMemberNricShown(index)
|
|
2230
|
+
? shownMemberNrics.value.filter((x) => x !== index)
|
|
2231
|
+
: [...shownMemberNrics.value, index];
|
|
2232
|
+
}
|
|
2233
|
+
|
|
2234
|
+
watch(
|
|
2235
|
+
() => dialog.viewVisitor,
|
|
2236
|
+
(open) => {
|
|
2237
|
+
if (open) return;
|
|
2238
|
+
showVisitorNric.value = false;
|
|
2239
|
+
shownMemberNrics.value = [];
|
|
2240
|
+
}
|
|
2241
|
+
);
|
|
2242
|
+
|
|
2243
|
+
/**
|
|
2244
|
+
* What a member row prints under the name, in order. `plateNumber` is in here
|
|
2245
|
+
* because the API returns it on `members[]` even though neither
|
|
2246
|
+
* `TMemberInfo` (this package) nor `TContractorMembers` (API-core's visitor
|
|
2247
|
+
* model, name and nric only) declares it - the two types have drifted from the
|
|
2248
|
+
* document and from each other. Reading the key defensively costs nothing and
|
|
2249
|
+
* shows the vehicle a member actually arrived in; the types are somebody's to
|
|
2250
|
+
* reconcile separately.
|
|
2251
|
+
*/
|
|
2252
|
+
const memberDetailFields = [
|
|
2253
|
+
{ key: "nric", label: "NRIC" },
|
|
2254
|
+
{ key: "contact", label: "Contact" },
|
|
2255
|
+
{ key: "plateNumber", label: "Vehicle" },
|
|
2256
|
+
] as const;
|
|
2257
|
+
|
|
2091
2258
|
const formatType = (item: any) =>
|
|
2092
2259
|
(item.deliveryType ? item.deliveryType + "-" : "") + item.type;
|
|
2093
2260
|
|
|
@@ -2101,6 +2268,7 @@ const formattedFields = {
|
|
|
2101
2268
|
level: "Level",
|
|
2102
2269
|
unit: "Unit",
|
|
2103
2270
|
purpose: "Purpose",
|
|
2271
|
+
members: "Members",
|
|
2104
2272
|
checkIn: "Check In",
|
|
2105
2273
|
snapshotEntryImage: "Entry Image",
|
|
2106
2274
|
checkOut: "Check Out",
|
|
@@ -3092,6 +3260,100 @@ watchEffect(async () => {
|
|
|
3092
3260
|
word-break: break-word;
|
|
3093
3261
|
}
|
|
3094
3262
|
|
|
3263
|
+
/* A row whose value is a set of records rather than a value - it drops the
|
|
3264
|
+
two-column grid and runs the full width of the card body. */
|
|
3265
|
+
.visitor-preview__row--block {
|
|
3266
|
+
display: block;
|
|
3267
|
+
}
|
|
3268
|
+
|
|
3269
|
+
.visitor-preview__members {
|
|
3270
|
+
display: flex;
|
|
3271
|
+
flex-direction: column;
|
|
3272
|
+
gap: 8px;
|
|
3273
|
+
margin-top: 8px;
|
|
3274
|
+
}
|
|
3275
|
+
|
|
3276
|
+
/*
|
|
3277
|
+
* An added member reads as an inset on the card it sits in - `--hover` on
|
|
3278
|
+
* `--border` at the inner radius. Those are `Card/MemberInfoSummary`'s three
|
|
3279
|
+
* decisions, unchanged, so a member looks the same in the preview as it does
|
|
3280
|
+
* in the form that created it. Only the TYPE differs: that card still prints
|
|
3281
|
+
* `<strong>Label:</strong> value`, which is the pattern this dialog just moved
|
|
3282
|
+
* off, so the lines below are set on the scale rather than inherited.
|
|
3283
|
+
*/
|
|
3284
|
+
.visitor-preview__member {
|
|
3285
|
+
padding: 9px 12px;
|
|
3286
|
+
border: 1px solid var(--border);
|
|
3287
|
+
border-radius: var(--r-inner);
|
|
3288
|
+
background: var(--hover);
|
|
3289
|
+
}
|
|
3290
|
+
|
|
3291
|
+
.visitor-preview__member-line {
|
|
3292
|
+
display: flex;
|
|
3293
|
+
gap: 8px;
|
|
3294
|
+
margin-top: 3px;
|
|
3295
|
+
font-size: var(--fs-breadcrumb);
|
|
3296
|
+
color: var(--text2);
|
|
3297
|
+
word-break: break-word;
|
|
3298
|
+
}
|
|
3299
|
+
|
|
3300
|
+
.visitor-preview__member-key {
|
|
3301
|
+
flex: 0 0 52px;
|
|
3302
|
+
color: var(--muted);
|
|
3303
|
+
}
|
|
3304
|
+
|
|
3305
|
+
/*
|
|
3306
|
+
* THE NRIC REVEAL.
|
|
3307
|
+
*
|
|
3308
|
+
* The pressable thing is the masked number, not the glyph beside it: an eye on
|
|
3309
|
+
* its own is a 14-16px target where 24px is the floor, and on a 12.5px member
|
|
3310
|
+
* line an `AppButton variant="icon"` - the layer's 32px icon square - would
|
|
3311
|
+
* make the NRIC line half again the height of the Contact line under it.
|
|
3312
|
+
* Pressing the digits gives a target the width of the value at no cost to the
|
|
3313
|
+
* rhythm, and reads the right way round: the number is what changes.
|
|
3314
|
+
*
|
|
3315
|
+
* It inherits its type rather than setting any, so the visitor's NRIC stays on
|
|
3316
|
+
* `--fs-cell` and a member's on the `--fs-breadcrumb` of the line it sits in.
|
|
3317
|
+
* The negative margin pays back the padding, so a revealed value starts on the
|
|
3318
|
+
* same left edge as every other value in the card.
|
|
3319
|
+
*/
|
|
3320
|
+
.visitor-preview__reveal {
|
|
3321
|
+
display: inline-flex;
|
|
3322
|
+
align-items: center;
|
|
3323
|
+
gap: 6px;
|
|
3324
|
+
margin: -3px -7px;
|
|
3325
|
+
padding: 3px 7px;
|
|
3326
|
+
border: none;
|
|
3327
|
+
border-radius: var(--r-inner-sm);
|
|
3328
|
+
background: transparent;
|
|
3329
|
+
font: inherit;
|
|
3330
|
+
color: inherit;
|
|
3331
|
+
text-align: left;
|
|
3332
|
+
cursor: pointer;
|
|
3333
|
+
transition: background var(--motion) ease;
|
|
3334
|
+
}
|
|
3335
|
+
|
|
3336
|
+
.visitor-preview__reveal:hover {
|
|
3337
|
+
background: var(--hover);
|
|
3338
|
+
}
|
|
3339
|
+
|
|
3340
|
+
.visitor-preview__reveal:focus-visible {
|
|
3341
|
+
outline: 2px solid var(--accent);
|
|
3342
|
+
outline-offset: 1px;
|
|
3343
|
+
}
|
|
3344
|
+
|
|
3345
|
+
/* The design's interactive ink - not Vuetify's fixed blue, which is one colour
|
|
3346
|
+
on both themes. `affectedEntities` gives its NRIC eye the same value. */
|
|
3347
|
+
.visitor-preview__eye {
|
|
3348
|
+
color: var(--accent-text);
|
|
3349
|
+
}
|
|
3350
|
+
|
|
3351
|
+
@media (prefers-reduced-motion: reduce) {
|
|
3352
|
+
.visitor-preview__reveal {
|
|
3353
|
+
transition: none;
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
|
|
3095
3357
|
/* The width the type filter carried as `max-width="200"` on the v-select. */
|
|
3096
3358
|
.visitor-type-filter {
|
|
3097
3359
|
max-width: 200px;
|
|
@@ -228,7 +228,11 @@ export default function useAccessManagement() {
|
|
|
228
228
|
unitId: string;
|
|
229
229
|
page?: number;
|
|
230
230
|
limit?: number;
|
|
231
|
+
/** Card-number search. Sent only when non-empty; API-core does not read
|
|
232
|
+
* it yet, so until it does the list comes back unfiltered. */
|
|
233
|
+
search?: string;
|
|
231
234
|
}) {
|
|
235
|
+
const search = params.search?.trim();
|
|
232
236
|
return useNuxtApp().$api<Record<string, any>>(
|
|
233
237
|
`/api/access-management/available-card-contractor/${params.type}`,
|
|
234
238
|
{
|
|
@@ -238,6 +242,7 @@ export default function useAccessManagement() {
|
|
|
238
242
|
unitId: params.unitId,
|
|
239
243
|
page: params.page ?? 1,
|
|
240
244
|
limit: params.limit ?? 100,
|
|
245
|
+
...(search ? { search } : {}),
|
|
241
246
|
},
|
|
242
247
|
}
|
|
243
248
|
);
|