@7365admin1/layer-common 4.32.1-staging.366 → 4.33.0
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/README.md +0 -19
- package/components/AccessCardAddForm.vue +4 -5
- package/components/AccessCardAssignToUnitForm.vue +2 -3
- package/components/AccessCardPreviewDialog.vue +3 -4
- package/components/Dialog/DeleteConfirmation.vue +2 -17
- package/components/Dialog/ReusablePrompt.vue +3 -26
- package/components/Dialog/UpdateMoreAction.vue +1 -11
- package/components/DocumentForm.vue +112 -407
- package/components/DocumentManagement.vue +12 -213
- package/components/EntryPass/QrTemplatePreview.vue +25 -21
- package/components/EntryPassInformation.vue +24 -119
- package/components/Facility/BookingSetup.vue +0 -63
- package/components/HidAccessLogDashboard.vue +8 -41
- package/components/HidIntercomManagement.vue +14 -148
- package/components/HidReaderManagement.vue +0 -26
- package/components/HidReaderUserRoster.vue +3 -44
- package/components/HidUserEnrollment.vue +155 -845
- package/components/InvitationClientForm.vue +1 -19
- package/components/NotificationBell.vue +3 -39
- package/components/VehicleForm.vue +2 -45
- package/components/VehicleManagement.vue +10 -95
- package/components/VisitorManagement.vue +5 -267
- package/composables/useAccessManagement.ts +0 -5
- package/composables/useCleaningPermission.ts +4 -4
- package/composables/useCommonPermission.ts +0 -16
- package/composables/useDocument.ts +0 -7
- package/composables/useFacility.ts +0 -11
- package/composables/useHidAmico.ts +0 -117
- package/composables/useHidNavigation.ts +1 -25
- package/composables/useLandscapingPermission.ts +4 -4
- package/composables/useMechanicalElectricalPermission.ts +4 -4
- package/composables/usePeople.ts +0 -19
- package/composables/usePestControlPermission.ts +4 -4
- package/composables/usePoolMaintenancePermission.ts +4 -4
- package/composables/useSecurityPermission.ts +10 -4
- package/composables/useSiteEntryPassSettings.ts +0 -26
- package/composables/useWebUsb.ts +11 -14
- package/package.json +1 -1
- 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-readers/index.vue +1 -1
- package/types/document.d.ts +0 -14
- package/types/facility.d.ts +0 -4
- package/types/people.d.ts +1 -28
- package/utils/vehicle-actions.ts +4 -12
- package/components/HidAccessPermissions.vue +0 -424
- package/components/HidProfileQrCode.vue +0 -332
- package/composables/useHidReaderSelection.ts +0 -50
- package/composables/useSiteCategory.ts +0 -45
- package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +0 -23
- package/utils/hid-permission-assignments.ts +0 -190
- package/utils/hid-reader-selection.ts +0 -52
- package/utils/notification-target.ts +0 -75
- package/utils/occupancy-role.ts +0 -109
|
@@ -388,27 +388,9 @@ watch(
|
|
|
388
388
|
const roles = ref<any[]>([])
|
|
389
389
|
const { getRoles } = useRole()
|
|
390
390
|
|
|
391
|
-
/*
|
|
392
|
-
* `type` is the ROLE type, not the service the client subscribes to, and the
|
|
393
|
-
* only caller (`ClientMain.vue` "Invite Client") passes no `app` prop -- so
|
|
394
|
-
* this sent `type: ""` and the endpoint applied no type filter at all. The
|
|
395
|
-
* dropdown therefore listed every org-less role of every type, which includes
|
|
396
|
-
* the platform's OWN staff roles (`type: "admin"` -- the two rows the console's
|
|
397
|
-
* `/super-admin/role-permissions` screen edits). Offering a Seven365 console
|
|
398
|
-
* staff role on a CLIENT invitation is the defect.
|
|
399
|
-
*
|
|
400
|
-
* A client admin's role is `type: "organization"`, which is what the client
|
|
401
|
-
* roles screen (`org/[organization]/roles-permissions.vue`) already lists. This
|
|
402
|
-
* narrows to exactly that. It is a narrowing of this one picker only: no role
|
|
403
|
-
* changes, no permission changes, and the org-less `organization` roles that
|
|
404
|
-
* were already being picked are all still offered.
|
|
405
|
-
*
|
|
406
|
-
* Keying off the selected service instead would empty the dropdown -- no
|
|
407
|
-
* org-less role carries a service type -- so `props.app` is not the filter.
|
|
408
|
-
*/
|
|
409
391
|
const { data: roleData, refresh: refreshRoles } = await useLazyAsyncData(
|
|
410
392
|
"roles",
|
|
411
|
-
() => getRoles({ org: org.value?._id, type:
|
|
393
|
+
() => getRoles({ org: org.value?._id, type: props.app, limit: 50 }),
|
|
412
394
|
{ watch: [() => props.app] }
|
|
413
395
|
)
|
|
414
396
|
|
|
@@ -134,7 +134,6 @@ import {
|
|
|
134
134
|
timeAgo,
|
|
135
135
|
type TInboxItem,
|
|
136
136
|
} from "../utils/notification-inbox";
|
|
137
|
-
import { notificationTarget } from "../utils/notification-target";
|
|
138
137
|
|
|
139
138
|
/**
|
|
140
139
|
* The top-bar notification feed for the web, in every signed-in app.
|
|
@@ -166,8 +165,6 @@ defineProps({
|
|
|
166
165
|
|
|
167
166
|
const { getAll, getUnreadCount, markAsRead, markAllAsRead } = useNotification();
|
|
168
167
|
const { currentUser } = useLocalAuth();
|
|
169
|
-
const route = useRoute();
|
|
170
|
-
const router = useRouter();
|
|
171
168
|
|
|
172
169
|
const open = ref(false);
|
|
173
170
|
const loading = ref(false);
|
|
@@ -272,49 +269,16 @@ function announce(fresh: TInboxItem[]) {
|
|
|
272
269
|
}
|
|
273
270
|
}
|
|
274
271
|
|
|
275
|
-
/**
|
|
276
|
-
* Clicking a row does two separate things, and the second one is why the row is
|
|
277
|
-
* a button at all: mark it read, and go to what it is about.
|
|
278
|
-
*
|
|
279
|
-
* They are kept apart deliberately. Marking read is best-effort and reverts on
|
|
280
|
-
* failure; navigation must not wait on that round trip, and must still happen
|
|
281
|
-
* for a row that was ALREADY read — a person re-opening the bell to find the
|
|
282
|
-
* order they were told about is the ordinary case, and the old early-return on
|
|
283
|
-
* `hasRead` would have sent them nowhere.
|
|
284
|
-
*/
|
|
285
272
|
async function openNotification(item: Record<string, any>) {
|
|
286
|
-
markRead(item);
|
|
287
|
-
await goToSubject(item);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function markRead(item: Record<string, any>) {
|
|
291
273
|
if (item.hasRead) return;
|
|
292
274
|
// Marked locally first: waiting on a round trip to move the dot reads as a dead control.
|
|
293
275
|
item.hasRead = true;
|
|
294
276
|
unread.value = Math.max(0, unread.value - 1);
|
|
295
|
-
markAsRead(String(item._id), userId.value).catch(() => {
|
|
296
|
-
item.hasRead = false;
|
|
297
|
-
unread.value += 1;
|
|
298
|
-
});
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
/**
|
|
302
|
-
* `hasRoute` is the whole reason an org-app route name may live in the shared
|
|
303
|
-
* layer: the ten apps that have no order queue simply do not match it, and the
|
|
304
|
-
* click there stays what it always was.
|
|
305
|
-
*/
|
|
306
|
-
async function goToSubject(item: Record<string, any>) {
|
|
307
|
-
const target = notificationTarget(item as any, {
|
|
308
|
-
organization: String(route.params?.organization ?? ""),
|
|
309
|
-
});
|
|
310
|
-
if (!target) return;
|
|
311
|
-
if (typeof router.hasRoute !== "function" || !router.hasRoute(target.name)) return;
|
|
312
|
-
|
|
313
|
-
open.value = false;
|
|
314
277
|
try {
|
|
315
|
-
await
|
|
278
|
+
await markAsRead(String(item._id), userId.value);
|
|
316
279
|
} catch {
|
|
317
|
-
|
|
280
|
+
item.hasRead = false;
|
|
281
|
+
unread.value += 1;
|
|
318
282
|
}
|
|
319
283
|
}
|
|
320
284
|
|
|
@@ -396,10 +396,7 @@
|
|
|
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
|
-
|
|
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">
|
|
399
|
+
<AppButton :disabled="processing" @click="submit">
|
|
403
400
|
{{ prop.mode == "add" ? "Submit" : "Update" }}
|
|
404
401
|
</AppButton>
|
|
405
402
|
</div>
|
|
@@ -443,8 +440,7 @@
|
|
|
443
440
|
</div>
|
|
444
441
|
<div class="vehicle-form__footer">
|
|
445
442
|
<AppButton variant="ghost" :disabled="processing" @click="cancelExistingUpdate">Cancel</AppButton>
|
|
446
|
-
<AppButton :disabled="processing"
|
|
447
|
-
:aria-disabled="!!refusedMessage || undefined" @click="confirmExistingUpdate">Update</AppButton>
|
|
443
|
+
<AppButton :disabled="processing" @click="confirmExistingUpdate">Update</AppButton>
|
|
448
444
|
</div>
|
|
449
445
|
</v-card>
|
|
450
446
|
</v-dialog>
|
|
@@ -521,7 +517,6 @@
|
|
|
521
517
|
|
|
522
518
|
<script setup lang="ts">
|
|
523
519
|
import { errorConverter } from "../utils/data";
|
|
524
|
-
import { isPermissionRefusalError } from "../utils/permission-refusal";
|
|
525
520
|
const prop = defineProps({
|
|
526
521
|
type: {
|
|
527
522
|
type: String as PropType<TVehicleType | "seasonpass">,
|
|
@@ -602,28 +597,8 @@ const emit = defineEmits([
|
|
|
602
597
|
"error",
|
|
603
598
|
"close",
|
|
604
599
|
"close:all",
|
|
605
|
-
// The server refused for want of the right: "create" or "update".
|
|
606
|
-
"refused",
|
|
607
600
|
]);
|
|
608
601
|
|
|
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
|
-
|
|
627
602
|
const vehicle = reactive<
|
|
628
603
|
Omit<ExceptPartial<TVehicle>, "type"> & { type: TVehicleType | "seasonpass" }
|
|
629
604
|
>({
|
|
@@ -1167,10 +1142,6 @@ function cancelExistingUpdate() {
|
|
|
1167
1142
|
async function confirmExistingUpdate() {
|
|
1168
1143
|
const payload = pendingPayload.value;
|
|
1169
1144
|
if (!payload) return;
|
|
1170
|
-
if (refusedAlready()) {
|
|
1171
|
-
showExistingDialog.value = false;
|
|
1172
|
-
return;
|
|
1173
|
-
}
|
|
1174
1145
|
|
|
1175
1146
|
errorMessage.value = "";
|
|
1176
1147
|
processing.value = true;
|
|
@@ -1197,14 +1168,12 @@ async function confirmExistingUpdate() {
|
|
|
1197
1168
|
// Shown under the form. A record moved before the failure stays moved.
|
|
1198
1169
|
showExistingDialog.value = false;
|
|
1199
1170
|
errorMessage.value = errorConverter(error);
|
|
1200
|
-
noteRefusal(error);
|
|
1201
1171
|
} finally {
|
|
1202
1172
|
processing.value = false;
|
|
1203
1173
|
}
|
|
1204
1174
|
}
|
|
1205
1175
|
|
|
1206
1176
|
async function submit() {
|
|
1207
|
-
if (refusedAlready()) return;
|
|
1208
1177
|
errorMessage.value = "";
|
|
1209
1178
|
|
|
1210
1179
|
// Ask the form first. `validate()` marks each failing field, so the person
|
|
@@ -1357,7 +1326,6 @@ async function submit() {
|
|
|
1357
1326
|
// with nothing), returns a plain sentence instead of ofetch's
|
|
1358
1327
|
// `[POST] "/api/vehicles": 502`.
|
|
1359
1328
|
errorMessage.value = errorConverter(error);
|
|
1360
|
-
noteRefusal(error);
|
|
1361
1329
|
} finally {
|
|
1362
1330
|
processing.value = false;
|
|
1363
1331
|
}
|
|
@@ -1540,12 +1508,6 @@ function handleCloseMatchDialog() {
|
|
|
1540
1508
|
// The panel's own close button never did that; the two now agree. Backing out
|
|
1541
1509
|
// of a picker is not a decision to discard what you already had.
|
|
1542
1510
|
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;
|
|
1549
1511
|
}
|
|
1550
1512
|
|
|
1551
1513
|
onMounted(() => {
|
|
@@ -1585,11 +1547,6 @@ onMounted(() => {
|
|
|
1585
1547
|
});
|
|
1586
1548
|
</script>
|
|
1587
1549
|
<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
|
-
}
|
|
1593
1550
|
.button-outline-class {
|
|
1594
1551
|
border: 1px solid rgba(var(--v-theme-primary));
|
|
1595
1552
|
}
|
|
@@ -20,16 +20,6 @@
|
|
|
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
|
-
|
|
33
23
|
<!-- Residents / Season Passes / Block Listed, on the toolbar row the way
|
|
34
24
|
the other screens draw their tabs. Each tab shows every status. -->
|
|
35
25
|
<template #tabs>
|
|
@@ -125,19 +115,19 @@
|
|
|
125
115
|
<v-dialog v-model="dialog.createVehicle" v-if="vehicleType" width="450" persistent>
|
|
126
116
|
<VehicleForm :type="vehicleType" :mode="mode" :vehicle-data="selectedVehicleObject"
|
|
127
117
|
:plate-number-id="selectedPlateNumberId" :name-hints="nameHints" @back="handleBackToSelection" @done="handleAddVehicleComplete"
|
|
128
|
-
:org="org" :site="props.site" @close:all="handleCloseAll"
|
|
118
|
+
:org="org" :site="props.site" @close:all="handleCloseAll" />
|
|
129
119
|
</v-dialog>
|
|
130
120
|
|
|
131
121
|
<v-dialog v-model="dialog.updateVehicle" v-if="vehicleType" width="450" persistent>
|
|
132
122
|
<VehicleForm :type="vehicleType" :mode="mode" :vehicle-data="selectedPlateNumberObject"
|
|
133
123
|
:plate-number-id="selectedPlateNumberId" :name-hints="nameHints" @back="handleBackToSelection" @done="handleAddVehicleComplete"
|
|
134
|
-
:org="org" :site="props.site" @close:all="handleCloseAll" @
|
|
124
|
+
:org="org" :site="props.site" @close:all="handleCloseAll" @close="handleCloseAll" />
|
|
135
125
|
</v-dialog>
|
|
136
126
|
|
|
137
127
|
<!-- <v-dialog v-model="dialog.updateVehicle" v-if="vehicleType" width="450" persistent>
|
|
138
128
|
<VehicleForm :type="vehicleType" mode="edit" :vehicle-data="selectedVehicleObject"
|
|
139
129
|
@back="dialog.updateVehicle = false" @close="dialog.updateVehicle = false" @done="handleUpdateVehicleComplete"
|
|
140
|
-
:org="org" :site="site" @close:all="handleCloseAll"
|
|
130
|
+
:org="org" :site="site" @close:all="handleCloseAll" />
|
|
141
131
|
</v-dialog> -->
|
|
142
132
|
|
|
143
133
|
<v-dialog v-if="canViewVehicleDetails" v-model="dialog.showMoreActions" width="800" persistent>
|
|
@@ -254,7 +244,7 @@
|
|
|
254
244
|
when the ANPR revoke could not be confirmed - the dialog stays open on
|
|
255
245
|
that path so the operator can read it and retry.
|
|
256
246
|
-->
|
|
257
|
-
<DialogDeleteConfirmation :loading="deletingVehicle" :message="deleteError"
|
|
247
|
+
<DialogDeleteConfirmation :loading="deletingVehicle" :message="deleteError"
|
|
258
248
|
: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.`"
|
|
259
249
|
@delete="submitDelete" @close="closeDeleteDialog" />
|
|
260
250
|
</v-dialog>
|
|
@@ -265,26 +255,24 @@
|
|
|
265
255
|
operator has to read and act on - it was going to a five-second
|
|
266
256
|
snackbar, along with the device's raw `{"ErrorCode":...}` reply.
|
|
267
257
|
-->
|
|
268
|
-
<DialogReusablePrompt :loading="approvingVehicle" :message="actionError"
|
|
258
|
+
<DialogReusablePrompt :loading="approvingVehicle" :message="actionError"
|
|
269
259
|
:prompt-title="`Are you sure want to approve this vehicle - ${selectedPlateNumberObject?.plateNumber}?`"
|
|
270
260
|
@proceed="submitApprove" @close="closeActionDialog('approveVehicle')" />
|
|
271
261
|
</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. -->
|
|
274
262
|
<v-dialog v-model="dialog.restoreVehicle" persistent width="540">
|
|
275
|
-
<DialogReusablePrompt :loading="restoringVehicle" :message="actionError"
|
|
276
|
-
:prompt-title="
|
|
263
|
+
<DialogReusablePrompt :loading="restoringVehicle" :message="actionError"
|
|
264
|
+
:prompt-title="`Are you sure want to restore this vehicle - ${selectedPlateNumberObject?.plateNumber}?`"
|
|
277
265
|
@proceed="submitRestore" @close="closeActionDialog('restoreVehicle')" />
|
|
278
266
|
</v-dialog>
|
|
279
267
|
<!-- Block / Unblock say what happens on the cameras, because that is the
|
|
280
268
|
part the operator cannot see from here. -->
|
|
281
269
|
<v-dialog v-model="dialog.blockVehicle" persistent width="540">
|
|
282
|
-
<DialogReusablePrompt :loading="blockingVehicle" :message="actionError"
|
|
270
|
+
<DialogReusablePrompt :loading="blockingVehicle" :message="actionError"
|
|
283
271
|
: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.`"
|
|
284
272
|
@proceed="submitBlock" @close="closeActionDialog('blockVehicle')" />
|
|
285
273
|
</v-dialog>
|
|
286
274
|
<v-dialog v-model="dialog.unblockVehicle" persistent width="540">
|
|
287
|
-
<DialogReusablePrompt :loading="unblockingVehicle" :message="actionError"
|
|
275
|
+
<DialogReusablePrompt :loading="unblockingVehicle" :message="actionError"
|
|
288
276
|
: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.`"
|
|
289
277
|
@proceed="submitUnblock" @close="closeActionDialog('unblockVehicle')" />
|
|
290
278
|
</v-dialog>
|
|
@@ -641,7 +629,7 @@ const nameHints = computed<Record<string, string>>(() => {
|
|
|
641
629
|
return hints;
|
|
642
630
|
})
|
|
643
631
|
|
|
644
|
-
const { data: getVehiclesReq, refresh: getVehiclesRefresh, pending: getVehiclesPending
|
|
632
|
+
const { data: getVehiclesReq, refresh: getVehiclesRefresh, pending: getVehiclesPending } =
|
|
645
633
|
await useLazyAsyncData(
|
|
646
634
|
`get-all-vehicles-${props.site}`,
|
|
647
635
|
() =>
|
|
@@ -657,18 +645,6 @@ const { data: getVehiclesReq, refresh: getVehiclesRefresh, pending: getVehiclesP
|
|
|
657
645
|
);
|
|
658
646
|
|
|
659
647
|
|
|
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
|
-
|
|
672
648
|
watch(getVehiclesReq, (newData: any) => {
|
|
673
649
|
loadActiveCameraCounts();
|
|
674
650
|
items.value = newData?.items || [];
|
|
@@ -677,12 +653,6 @@ watch(getVehiclesReq, (newData: any) => {
|
|
|
677
653
|
})
|
|
678
654
|
|
|
679
655
|
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
|
-
}
|
|
686
656
|
selectedVehicleId.value = data?.item?._id;
|
|
687
657
|
dialog.showMoreActions = true;
|
|
688
658
|
message.value = "";
|
|
@@ -859,29 +829,6 @@ function revokeOnRefusal(error: unknown, right: keyof typeof revoked) {
|
|
|
859
829
|
if (isPermissionRefusalError(error)) revoked[right] = true;
|
|
860
830
|
}
|
|
861
831
|
|
|
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
|
-
|
|
885
832
|
/**
|
|
886
833
|
* One entry point for every menu item, in both menus, so a new action can only
|
|
887
834
|
* be added in one place and cannot be forgotten in the other.
|
|
@@ -963,7 +910,6 @@ const formatPlateNumbers = (value: any) => {
|
|
|
963
910
|
};
|
|
964
911
|
|
|
965
912
|
async function submitDelete() {
|
|
966
|
-
if (refusedAlready("delete", deleteError)) return;
|
|
967
913
|
|
|
968
914
|
const plateNumberId = selectedPlateNumberObject.value?._id;
|
|
969
915
|
const type = selectedPlateNumberObject.value?.type as TVehicleType;
|
|
@@ -999,33 +945,7 @@ async function submitDelete() {
|
|
|
999
945
|
|
|
1000
946
|
|
|
1001
947
|
|
|
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
|
-
|
|
1027
948
|
async function submitRestore() {
|
|
1028
|
-
if (refusedAlready("approve", actionError)) return;
|
|
1029
949
|
|
|
1030
950
|
const vehicleId = selectedPlateNumberObject.value?._id;
|
|
1031
951
|
|
|
@@ -1045,8 +965,6 @@ async function submitRestore() {
|
|
|
1045
965
|
await getVehiclesRefresh();
|
|
1046
966
|
} catch (error: any) {
|
|
1047
967
|
actionError.value = errorConverter(error);
|
|
1048
|
-
// Restore is the approve endpoint: a refusal is the Approve right gone.
|
|
1049
|
-
revokeOnRefusal(error, "approve");
|
|
1050
968
|
} finally {
|
|
1051
969
|
restoringVehicle.value = false;
|
|
1052
970
|
}
|
|
@@ -1054,7 +972,6 @@ async function submitRestore() {
|
|
|
1054
972
|
|
|
1055
973
|
|
|
1056
974
|
async function submitBlock() {
|
|
1057
|
-
if (refusedAlready("update", actionError)) return;
|
|
1058
975
|
const vehicleId = selectedPlateNumberObject.value?._id;
|
|
1059
976
|
if (!vehicleId) {
|
|
1060
977
|
showMessage("Invalid vehicle selected for blocking.", "error");
|
|
@@ -1078,7 +995,6 @@ async function submitBlock() {
|
|
|
1078
995
|
|
|
1079
996
|
|
|
1080
997
|
async function submitUnblock() {
|
|
1081
|
-
if (refusedAlready("update", actionError)) return;
|
|
1082
998
|
const vehicleId = selectedPlateNumberObject.value?._id;
|
|
1083
999
|
if (!vehicleId) {
|
|
1084
1000
|
showMessage("Invalid vehicle selected for unblocking.", "error");
|
|
@@ -1102,7 +1018,6 @@ async function submitUnblock() {
|
|
|
1102
1018
|
|
|
1103
1019
|
|
|
1104
1020
|
async function submitApprove() {
|
|
1105
|
-
if (refusedAlready("approve", actionError)) return;
|
|
1106
1021
|
|
|
1107
1022
|
const plateNumberId = selectedPlateNumberObject.value?._id;
|
|
1108
1023
|
if (!plateNumberId) {
|