@7365admin1/layer-common 4.28.1-staging.359 → 4.29.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.
Files changed (70) hide show
  1. package/CHANGELOG.md +22 -4
  2. package/assets/css/robot-hero.css +466 -0
  3. package/components/AccessCardAddForm.vue +4 -5
  4. package/components/AccessCardAssignToUnitForm.vue +2 -3
  5. package/components/AccessCardPreviewDialog.vue +3 -4
  6. package/components/Dialog/UpdateMoreAction.vue +1 -11
  7. package/components/DocumentForm.vue +112 -407
  8. package/components/DocumentManagement.vue +12 -213
  9. package/components/EntryPass/QrTemplatePreview.vue +25 -21
  10. package/components/EntryPassInformation.vue +24 -119
  11. package/components/Facility/BookingSetup.vue +0 -63
  12. package/components/HidAccessLogDashboard.vue +8 -41
  13. package/components/HidIntercomManagement.vue +14 -148
  14. package/components/HidReaderManagement.vue +0 -26
  15. package/components/HidReaderUserRoster.vue +3 -44
  16. package/components/HidUserEnrollment.vue +155 -845
  17. package/components/InvitationClientForm.vue +1 -19
  18. package/components/NotificationBell.vue +3 -39
  19. package/components/Robot/Battery.vue +18 -0
  20. package/components/Robot/CapabilityTag.vue +14 -0
  21. package/components/Robot/Card.vue +56 -0
  22. package/components/Robot/CommandBar.vue +47 -0
  23. package/components/Robot/CredentialField.vue +37 -0
  24. package/components/Robot/FaultBadge.vue +26 -0
  25. package/components/Robot/FloorLabel.vue +12 -0
  26. package/components/Robot/Hero.vue +32 -0
  27. package/components/Robot/LiftQueueRow.vue +28 -0
  28. package/components/Robot/MapToolbar.vue +53 -0
  29. package/components/Robot/NoMonitoring.vue +14 -0
  30. package/components/Robot/Reconnecting.vue +7 -0
  31. package/components/Robot/StatusChip.vue +15 -0
  32. package/components/Robot/SummaryCell.vue +64 -0
  33. package/components/Robot/SummaryStrip.vue +19 -0
  34. package/components/Robot/Table.vue +115 -0
  35. package/components/Robot/Toast.vue +27 -0
  36. package/components/Robot/ViewOnlyNotice.vue +3 -0
  37. package/components/RolePermissionFormCreate.vue +1 -78
  38. package/components/RolePermissionFormPreviewUpdate.vue +2 -83
  39. package/components/VehicleManagement.vue +10 -150
  40. package/components/VisitorManagement.vue +5 -267
  41. package/composables/useAccessManagement.ts +0 -5
  42. package/composables/useDocument.ts +0 -7
  43. package/composables/useFacility.ts +0 -11
  44. package/composables/useHidAmico.ts +0 -117
  45. package/composables/useHidNavigation.ts +1 -25
  46. package/composables/usePeople.ts +0 -19
  47. package/composables/useSiteEntryPassSettings.ts +0 -26
  48. package/composables/useWebUsb.ts +11 -14
  49. package/package.json +1 -1
  50. package/pages/[org]/[site]/access-mgmt/administrator/index.vue +1 -1
  51. package/pages/[org]/[site]/access-mgmt/hid-cards/index.vue +1 -1
  52. package/pages/[org]/[site]/access-mgmt/hid-readers/index.vue +1 -1
  53. package/plugins/API.ts +2 -7
  54. package/plugins/vuetify.ts +8 -1
  55. package/types/document.d.ts +0 -14
  56. package/types/facility.d.ts +0 -4
  57. package/types/people.d.ts +1 -28
  58. package/types/vehicle.d.ts +0 -11
  59. package/utils/robot-display.ts +304 -0
  60. package/utils/theme.ts +152 -0
  61. package/components/HidAccessPermissions.vue +0 -424
  62. package/components/HidProfileQrCode.vue +0 -332
  63. package/composables/useHidReaderSelection.ts +0 -50
  64. package/composables/useSiteCategory.ts +0 -45
  65. package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +0 -23
  66. package/utils/hid-permission-assignments.ts +0 -190
  67. package/utils/hid-reader-selection.ts +0 -52
  68. package/utils/notification-target.ts +0 -75
  69. package/utils/occupancy-role.ts +0 -109
  70. package/utils/permission-refusal.ts +0 -40
@@ -0,0 +1,115 @@
1
+ <template>
2
+ <!--
3
+ The robot table: server-side pages (never every robot at once), sortable
4
+ columns, optional grouping, skeleton rows while loading and a plain empty
5
+ state. Every v-data-table-server prop, event and item slot passes through.
6
+ -->
7
+ <div class="hero-table" :class="{ 'hero-table--compact': compact }">
8
+ <v-data-table-server
9
+ v-bind="$attrs"
10
+ :headers="columns"
11
+ :items="loading ? [] : items"
12
+ :items-length="itemsLength"
13
+ :page="range.page"
14
+ :items-per-page="itemsPerPage"
15
+ :loading="loading"
16
+ :group-by="groupBy"
17
+ hide-default-footer
18
+ @update:page="emit('update:page', $event)"
19
+ >
20
+ <template v-for="name in passSlots" #[name]="scope">
21
+ <slot :name="name" v-bind="scope ?? {}" />
22
+ </template>
23
+
24
+ <template #loading>
25
+ <div class="hero-skel" aria-label="Loading robots">
26
+ <div v-for="i in skeletonRows" :key="i" class="hero-skel__row" />
27
+ </div>
28
+ </template>
29
+
30
+ <template #no-data>
31
+ <slot name="no-data">
32
+ <div class="hero-empty">
33
+ <div class="hero-empty__title">{{ emptyTitle }}</div>
34
+ <div v-if="emptyHint" class="hero-empty__hint">{{ emptyHint }}</div>
35
+ </div>
36
+ </slot>
37
+ </template>
38
+
39
+ <template #group-header="scope">
40
+ <slot name="group-header" v-bind="scope">
41
+ <tr class="hero-table__group" @vue:mounted="openOnMount(scope)">
42
+ <td :colspan="scope.columns.length">
43
+ <button type="button" :aria-expanded="scope.isGroupOpen(scope.item)" @click="scope.toggleGroup(scope.item)">
44
+ {{ scope.item.value }} <span class="hero-muted">· {{ scope.item.items.length }} {{ noun }}</span>
45
+ </button>
46
+ </td>
47
+ </tr>
48
+ </slot>
49
+ </template>
50
+ </v-data-table-server>
51
+
52
+ <div v-if="!loading && range.total" class="hero-table__foot">
53
+ <span>{{ range.text }}</span>
54
+ <div v-if="range.pages > 1" class="hero-table__pager">
55
+ <v-btn variant="outlined" :disabled="!range.hasPrev" @click="emit('update:page', range.page - 1)">Prev</v-btn>
56
+ <v-btn variant="outlined" :disabled="!range.hasNext" @click="emit('update:page', range.page + 1)">Next</v-btn>
57
+ </div>
58
+ </div>
59
+ </div>
60
+ </template>
61
+
62
+ <script setup lang="ts">
63
+ import { computed, useSlots } from "vue";
64
+ import { pageRange } from "../../utils/robot-display";
65
+
66
+ defineOptions({ inheritAttrs: false });
67
+
68
+ const props = withDefaults(
69
+ defineProps<{
70
+ headers: any[];
71
+ items: any[];
72
+ /** The server's total, not the page's length. */
73
+ itemsLength: number;
74
+ /** 1-based, like Vuetify. */
75
+ page?: number;
76
+ itemsPerPage?: number;
77
+ loading?: boolean;
78
+ groupBy?: Array<{ key: string; order?: "asc" | "desc" }>;
79
+ noun?: string;
80
+ emptyTitle?: string;
81
+ emptyHint?: string;
82
+ skeletonRows?: number;
83
+ /** 12.5px rows, for the Network table. */
84
+ compact?: boolean;
85
+ }>(),
86
+ {
87
+ page: 1,
88
+ itemsPerPage: 25,
89
+ loading: false,
90
+ groupBy: () => [],
91
+ noun: "robots",
92
+ emptyTitle: "No robots match",
93
+ emptyHint: "",
94
+ skeletonRows: 6,
95
+ compact: false,
96
+ },
97
+ );
98
+ const emit = defineEmits<{ "update:page": [page: number] }>();
99
+
100
+ const OWN = new Set(["loading", "no-data", "group-header"]);
101
+ const slots = useSlots();
102
+ const passSlots = computed(() => Object.keys(slots).filter((n) => !OWN.has(n)));
103
+
104
+ // Vuetify adds its own "Group" column when grouping; the handoff has none, so
105
+ // an empty, zero-width one is supplied in its place.
106
+ const GROUP_COL = { key: "data-table-group", title: "", sortable: false, headerProps: { class: "hero-table__groupcol" }, cellProps: { class: "hero-table__groupcol" } };
107
+ const columns = computed(() => (props.groupBy.length ? [GROUP_COL, ...props.headers] : props.headers));
108
+
109
+ // The handoff lists grouped rows under their header, so a group starts open.
110
+ function openOnMount(scope: any) {
111
+ if (!scope.isGroupOpen(scope.item)) scope.toggleGroup(scope.item);
112
+ }
113
+
114
+ const range = computed(() => pageRange(props.page, props.itemsPerPage, props.itemsLength, props.noun));
115
+ </script>
@@ -0,0 +1,27 @@
1
+ <template>
2
+ <div v-if="modelValue" class="hero-toast" role="status" aria-live="polite">
3
+ <span class="hero-toast__square" aria-hidden="true" />{{ modelValue }}
4
+ </div>
5
+ </template>
6
+
7
+ <script setup lang="ts">
8
+ import { onBeforeUnmount, watch } from "vue";
9
+
10
+ /** The message; the toast clears it after `timeout` ms (2.6s, the handoff's). */
11
+ const props = withDefaults(defineProps<{ modelValue?: string; timeout?: number }>(), {
12
+ modelValue: "",
13
+ timeout: 2600,
14
+ });
15
+ const emit = defineEmits<{ "update:modelValue": [value: string] }>();
16
+
17
+ let timer: ReturnType<typeof setTimeout> | undefined;
18
+ watch(
19
+ () => props.modelValue,
20
+ (msg) => {
21
+ clearTimeout(timer);
22
+ if (msg && props.timeout > 0) timer = setTimeout(() => emit("update:modelValue", ""), props.timeout);
23
+ },
24
+ { immediate: true },
25
+ );
26
+ onBeforeUnmount(() => clearTimeout(timer));
27
+ </script>
@@ -0,0 +1,3 @@
1
+ <template>
2
+ <div class="hero-notice" role="note">View-only access — commands and edits are not available for your role.</div>
3
+ </template>
@@ -89,29 +89,11 @@
89
89
  have already ticked is still selected and will still be saved.
90
90
  </div>
91
91
 
92
- <!--
93
- Matched, but every match is switched off and off is hidden. A
94
- blank panel would read as the search having failed, which is a
95
- different thing with a different remedy.
96
- -->
97
- <div
98
- v-else-if="!hasShownModules"
99
- class="pa-6 text-center text-body-2 text-medium-emphasis"
100
- >
101
- Nothing is switched on yet. Show the switched-off modules to
102
- start granting.
103
- </div>
104
-
105
92
  <template
106
93
  v-for="(actions, resourceKey, resourceIndex) in visiblePermissions"
107
94
  :key="resourceKey"
108
95
  >
109
- <v-divider
110
- v-if="
111
- isModuleShown(String(resourceKey)) &&
112
- String(resourceKey) !== firstShownResource
113
- "
114
- />
96
+ <v-divider v-if="resourceIndex > 0" />
115
97
 
116
98
  <!--
117
99
  Category row. The whole row is the accordion header: one
@@ -120,7 +102,6 @@
120
102
  granting a module is never confused with looking at it.
121
103
  -->
122
104
  <v-list-item
123
- v-if="isModuleShown(String(resourceKey))"
124
105
  density="compact"
125
106
  :ripple="false"
126
107
  :class="[
@@ -222,19 +203,6 @@
222
203
  </div>
223
204
 
224
205
  <div class="role-create__footer">
225
- <AppButton
226
- v-if="disabledModuleCount > 0 || !showDisabledModules"
227
- variant="ghost"
228
- class="role-create__footer-left"
229
- @click="showDisabledModules = !showDisabledModules"
230
- >
231
- {{
232
- showDisabledModules
233
- ? "Hide switched-off modules"
234
- : `Show ${disabledModuleCount} switched-off`
235
- }}
236
- </AppButton>
237
-
238
206
  <AppButton variant="ghost" @click="cancel">{{ props.cancelText }}</AppButton>
239
207
  <AppButton :disabled="!validForm || disable" @click="submit">Submit</AppButton>
240
208
  </div>
@@ -500,7 +468,6 @@ function cancel() {
500
468
  name.value = "";
501
469
  permState.value = { selected: [], enabled: [] };
502
470
  expandedResource.value = null;
503
- showDisabledModules.value = true;
504
471
  // A query left behind would greet the next person with a filtered list and
505
472
  // no obvious reason for it.
506
473
  moduleSearch.value = "";
@@ -558,46 +525,6 @@ const visiblePermissions = computed(() => {
558
525
  return matches;
559
526
  });
560
527
 
561
- /*
562
- * HIDING THE MODULES THIS ROLE DOES NOT TOUCH -- the same button the update
563
- * dialog carries.
564
- *
565
- * DEFAULTS THE OTHER WAY HERE, and deliberately. A role being CREATED has
566
- * nothing switched on, so hiding the switched-off modules would open this
567
- * dialog on an empty list and put a click between the user and the only thing
568
- * they came to do. Reading an existing role is the opposite case: the four
569
- * granted modules are the point and the other 27 are noise.
570
- *
571
- * PURELY WHAT IS DRAWN. `visiblePermissions` -- not this -- is what Select All
572
- * and `isAllSelected` act on, so hiding a row never changes what a click grants
573
- * and never changes what is saved.
574
- */
575
- const showDisabledModules = ref(true);
576
-
577
- function isModuleShown(resource: string) {
578
- return showDisabledModules.value || isCategoryEnabled(resource);
579
- }
580
-
581
- /** The modules actually drawn, in order -- so the divider knows which is first. */
582
- const shownResources = computed(() =>
583
- Object.keys(visiblePermissions.value).filter((resource) =>
584
- isModuleShown(resource)
585
- )
586
- );
587
-
588
- const firstShownResource = computed(() => shownResources.value[0] ?? "");
589
-
590
- const hasShownModules = computed(() => shownResources.value.length > 0);
591
-
592
- const disabledModuleCount = computed(
593
- () =>
594
- Object.keys(visiblePermissions.value).filter(
595
- (resource) => !isCategoryEnabled(resource)
596
- ).length
597
- );
598
-
599
-
600
-
601
528
  const hasVisiblePermissions = computed(
602
529
  () => Object.keys(visiblePermissions.value).length > 0
603
530
  );
@@ -700,10 +627,6 @@ const isAllSelected = computed(() => {
700
627
  /* The design's dialog footer. Deliberately not the shared
701
628
  `.screen-modal__footer` - that class is on the batch-D branch (#1150), not
702
629
  on this base, and a second copy in `screens.css` would collide with it. */
703
- .role-create__footer-left {
704
- margin-right: auto;
705
- }
706
-
707
630
  .role-create__footer {
708
631
  display: flex;
709
632
  justify-content: flex-end;
@@ -53,29 +53,11 @@
53
53
  role already holds is untouched and will still be saved.
54
54
  </div>
55
55
 
56
- <!--
57
- Matched, but every match is switched off and off is hidden. A
58
- blank panel here would read as the search having failed, which
59
- is a different thing and has a different remedy.
60
- -->
61
- <div
62
- v-else-if="!hasShownModules"
63
- class="pa-6 text-center text-body-2 text-medium-emphasis"
64
- >
65
- This role grants nothing here yet. Show the switched-off modules
66
- to grant one.
67
- </div>
68
-
69
56
  <template
70
57
  v-for="(actions, resourceKey, resourceIndex) in visiblePermissions"
71
58
  :key="resourceKey"
72
59
  >
73
- <v-divider
74
- v-if="
75
- isModuleShown(String(resourceKey)) &&
76
- String(resourceKey) !== firstShownResource
77
- "
78
- />
60
+ <v-divider v-if="resourceIndex > 0" />
79
61
  <!--
80
62
  The whole row is the accordion header: one module is open at
81
63
  a time, so clicking this one closes whichever was open. The
@@ -84,7 +66,6 @@
84
66
  mode works the same way, without the switch being live.
85
67
  -->
86
68
  <v-list-item
87
- v-if="isModuleShown(String(resourceKey))"
88
69
  density="compact"
89
70
  :ripple="false"
90
71
  :class="[
@@ -226,19 +207,6 @@
226
207
  </div>
227
208
 
228
209
  <div class="role-perm__footer">
229
- <AppButton
230
- v-if="disabledModuleCount > 0 || showDisabledModules"
231
- variant="ghost"
232
- class="role-perm__footer-left"
233
- @click="showDisabledModules = !showDisabledModules"
234
- >
235
- {{
236
- showDisabledModules
237
- ? "Hide switched-off modules"
238
- : `Show ${disabledModuleCount} switched-off`
239
- }}
240
- </AppButton>
241
-
242
210
  <AppButton v-if="!edit" variant="ghost" @click="emit('cancel')">Close</AppButton>
243
211
  <AppButton v-else variant="ghost" @click="cancelEdit()">Cancel</AppButton>
244
212
 
@@ -512,43 +480,6 @@ const sortedNotOffered = computed(() =>
512
480
  sortResourcesByLabel(props.notOfferedPermissions as Record<string, any>)
513
481
  );
514
482
 
515
- /*
516
- * HIDING THE MODULES THIS ROLE DOES NOT TOUCH.
517
- *
518
- * 31 modules, four of them granted: the 27 greyed rows were the bulk of the
519
- * scroll and none of them said anything. Off is hidden by default and the
520
- * footer button brings them back.
521
- *
522
- * PURELY WHAT IS DRAWN. `visiblePermissions` -- not this -- is what Select All
523
- * and `isAllSelected` act on, so hiding a row never changes what a click grants
524
- * and never changes what is saved.
525
- */
526
- const showDisabledModules = ref(false);
527
-
528
- function isModuleShown(resource: string) {
529
- return showDisabledModules.value || isCategoryEnabled(resource);
530
- }
531
-
532
- /** The modules actually drawn, in order -- so the divider knows which is first. */
533
- const shownResources = computed(() =>
534
- Object.keys(visiblePermissions.value).filter((resource) =>
535
- isModuleShown(resource)
536
- )
537
- );
538
-
539
- const firstShownResource = computed(() => shownResources.value[0] ?? "");
540
-
541
- const hasShownModules = computed(() => shownResources.value.length > 0);
542
-
543
- const disabledModuleCount = computed(
544
- () =>
545
- Object.keys(visiblePermissions.value).filter(
546
- (resource) => !isCategoryEnabled(resource)
547
- ).length
548
- );
549
-
550
-
551
-
552
483
  const hasNotOffered = computed(
553
484
  () => Object.keys(props.notOfferedPermissions || {}).length > 0
554
485
  );
@@ -557,13 +488,7 @@ const hasVisiblePermissions = computed(
557
488
  () => Object.keys(visiblePermissions.value).length > 0
558
489
  );
559
490
 
560
- /**
561
- * The `resource:action` keys the search matched -- NOT the subset currently
562
- * drawn. Hiding the switched-off modules is a view convenience; Select All
563
- * still means every module the query matched, or the whole catalogue with no
564
- * query. Tying it to the drawn subset would make Select All a no-op exactly
565
- * when it is most useful.
566
- */
491
+ /** The `resource:action` keys currently on screen. */
567
492
  const visibleKeys = computed(() =>
568
493
  Object.entries(visiblePermissions.value).flatMap(([resource, actions]) =>
569
494
  Object.keys((actions as Record<string, unknown>) || {}).map(
@@ -639,8 +564,6 @@ function cancelEdit() {
639
564
  function resetExpansion() {
640
565
  expandedResources.value = [];
641
566
  expandedResource.value = null;
642
- // Back to the quiet default: the next role is read before it is edited.
643
- showDisabledModules.value = false;
644
567
  }
645
568
 
646
569
  // Reopening the dialog on another role must not inherit the last one's open
@@ -768,10 +691,6 @@ async function submit() {
768
691
  /* The design's dialog footer. Deliberately not the shared
769
692
  `.screen-modal__footer` - that class is on the batch-D branch (#1150), not
770
693
  on this base, and a second copy in `screens.css` would collide with it. */
771
- .role-perm__footer-left {
772
- margin-right: auto;
773
- }
774
-
775
694
  .role-perm__footer {
776
695
  display: flex;
777
696
  justify-content: flex-end;
@@ -153,11 +153,7 @@
153
153
  the colour word keeps the width and lets the edge fall back to
154
154
  `--v-border-color`, which is the design's `--border` in each theme. -->
155
155
  <v-card flat outlined class="pa-2" border="sm" :loading="loadingPlateNumberDetails">
156
- <!-- `hide-default-footer` alone kept Vuetify's default page size of
157
- 10 with no pager, so a resident with 54 plates showed only the
158
- first 10 here while the row menu listed all 54. Show every plate. -->
159
- <v-data-table :items="selectedVehicleObject[key]" :headers="plateHeadersView"
160
- :items-per-page="-1" hide-default-footer>
156
+ <v-data-table :items="selectedVehicleObject[key]" :headers="plateHeadersView" hide-default-footer>
161
157
  <!-- A season pass's dates, large enough to read at a
162
158
  glance: green while valid, red once expired. -->
163
159
  <template #item.passDates="{ item: pass }">
@@ -296,34 +292,13 @@
296
292
  {{ value ? formatDate(value) : "" }}
297
293
  </template>
298
294
  <template #item.action="{ value }">
299
- <span class="history-action" :class="`history-action--${value}`">
300
- {{ historyActionLabel(value) }}
301
- </span>
295
+ {{ historyActionLabel(value) }}
302
296
  </template>
303
297
  <template #item.updatedByName="{ item: entry }">
304
298
  {{ entry.updatedByName || (entry.updatedBy ? "Unknown user" : "System") }}
305
299
  </template>
306
- <!-- "Status: from Blocked to Unblocked", one change per line, only
307
- the values bold. Created lists what it was saved with. Entries
308
- written before values were kept list the field names only. -->
309
- <template #item.fields="{ item: entry }">
310
- <div v-if="visibleChanges(entry).length" class="history-changes">
311
- <div v-for="change in visibleChanges(entry)" :key="change.field">
312
- <span class="history-label">{{ formatCamelCaseToWords(change.field) }}:</span>
313
- <template v-if="entry.action === 'created'">
314
- <span class="history-value">{{ formatHistoryValue(change, "to") }}</span>
315
- </template>
316
- <template v-else>
317
- <span class="history-word">from</span>
318
- <span class="history-value history-value--from">{{ formatHistoryValue(change, "from") }}</span>
319
- <span class="history-word">to</span>
320
- <span class="history-value">{{ formatHistoryValue(change, "to") }}</span>
321
- </template>
322
- </div>
323
- </div>
324
- <span v-else class="history-legacy">
325
- {{ formatHistoryFields(entry.fields) }}<template v-if="entry.fields?.length"> (values not recorded)</template>
326
- </span>
300
+ <template #item.fields="{ value }">
301
+ {{ formatHistoryFields(value) }}
327
302
  </template>
328
303
  </v-data-table>
329
304
  </v-card-text>
@@ -347,7 +322,6 @@ import {
347
322
  // `error.message` put ofetch's own developer string in the delete dialog:
348
323
  // `[PUT] "/api/vehicles/6a9691f25648d7633171c9e3": 502`.
349
324
  import { errorConverter } from '../utils/data';
350
- import { isPermissionRefusalError } from '../utils/permission-refusal';
351
325
 
352
326
 
353
327
 
@@ -426,7 +400,7 @@ const historyHeaders = [
426
400
  { title: "Date", value: "updatedAt" },
427
401
  { title: "Updated By", value: "updatedByName" },
428
402
  { title: "Action", value: "action" },
429
- { title: "Changes", value: "fields", sortable: false, minWidth: "280px" },
403
+ { title: "Fields Updated", value: "fields", sortable: false },
430
404
  ]
431
405
 
432
406
  /**
@@ -731,8 +705,6 @@ const HISTORY_ACTIONS: Record<string, string> = {
731
705
  blocked: "Blocked",
732
706
  unblocked: "Unblocked",
733
707
  deleted: "Deleted",
734
- moved: "Moved",
735
- synced: "Synced",
736
708
  };
737
709
 
738
710
  function historyActionLabel(action: string) {
@@ -740,42 +712,9 @@ function historyActionLabel(action: string) {
740
712
  return HISTORY_ACTIONS[action] ?? action.charAt(0).toUpperCase() + action.slice(1);
741
713
  }
742
714
 
743
- const HISTORY_DATE_FIELDS = new Set(["start", "end", "deletedAt", "expiredAt"]);
744
-
745
- /** Bookkeeping fields the reader has no use for - not shown in History. */
746
- const HISTORY_HIDDEN_FIELDS = new Set(["blockedFrom", "deletedAt", "recNo", "anprCameras"]);
747
-
748
- function visibleChanges(entry: TVehicleHistoryEntry) {
749
- return (entry.changes ?? []).filter((change) => !HISTORY_HIDDEN_FIELDS.has(change.field));
750
- }
751
-
752
- /** One side of a change, read the way the rest of the screen reads it. */
753
- function formatHistoryValue(change: TVehicleFieldChange, side: "from" | "to") {
754
- const value = change[side];
755
- const name = side === "from" ? change.fromName : change.toName;
756
- if (value === null || value === undefined || value === "") return "-";
757
- switch (change.field) {
758
- case "block":
759
- case "level":
760
- case "unit":
761
- return name || "(removed)";
762
- case "status":
763
- return formatVehicleStatus(String(value) as TVehicleStatus).label || String(value);
764
- case "category":
765
- case "type":
766
- return formatValues(change.field, value);
767
- case "seasonPassType":
768
- case "blockedFrom":
769
- return formatCamelCaseToWords(String(value));
770
- }
771
- if (HISTORY_DATE_FIELDS.has(change.field)) return formatDate(String(value));
772
- return String(value);
773
- }
774
-
775
715
  function formatHistoryFields(fields: string[] | undefined) {
776
- const shown = (fields ?? []).filter((f) => !HISTORY_HIDDEN_FIELDS.has(f));
777
- if (!shown.length) return "-";
778
- return shown.map((f) => formatCamelCaseToWords(f)).join(", ");
716
+ if (!Array.isArray(fields) || !fields.length) return "-";
717
+ return fields.map((f) => formatCamelCaseToWords(f)).join(", ");
779
718
  }
780
719
 
781
720
  /** Fetches the plate's own record: the list does not carry `history`. */
@@ -804,31 +743,11 @@ async function openHistory(item: TPlateNumber) {
804
743
  * the host app's `useLocalPermission()`.
805
744
  */
806
745
  const vehiclePermissions = computed(() => ({
807
- canUpdateVehicle: props.canUpdateVehicle && !revoked.update,
808
- canDeleteVehicle: props.canDeleteVehicle && !revoked.delete,
809
- canApproveVehicle: props.canApproveVehicle && !revoked.approve,
746
+ canUpdateVehicle: props.canUpdateVehicle,
747
+ canDeleteVehicle: props.canDeleteVehicle,
748
+ canApproveVehicle: props.canApproveVehicle,
810
749
  }));
811
750
 
812
- /**
813
- * Rights the SERVER has just refused, hidden at once.
814
- *
815
- * The role on screen was read at page load; if an administrator has since
816
- * unticked a right, the server refuses the action. `plugins/API.ts` re-reads
817
- * the role in the background so the props catch up, but that is a round trip
818
- * (and skipped inside its cool-down), so the refused item is taken off the
819
- * menus here immediately. Whenever the host sends a fresh answer for that gate
820
- * the local override is dropped and the host's answer stands again - so a
821
- * right given back is not kept hidden.
822
- */
823
- const revoked = reactive({ update: false, delete: false, approve: false });
824
- watch(() => props.canUpdateVehicle, () => { revoked.update = false; });
825
- watch(() => props.canDeleteVehicle, () => { revoked.delete = false; });
826
- watch(() => props.canApproveVehicle, () => { revoked.approve = false; });
827
-
828
- function revokeOnRefusal(error: unknown, right: keyof typeof revoked) {
829
- if (isPermissionRefusalError(error)) revoked[right] = true;
830
- }
831
-
832
751
  /**
833
752
  * One entry point for every menu item, in both menus, so a new action can only
834
753
  * be added in one place and cannot be forgotten in the other.
@@ -934,8 +853,6 @@ async function submitDelete() {
934
853
  // raising the snackbar - and `error.response._data` throws on a network
935
854
  // error - so a refused delete showed the operator nothing at all.
936
855
  deleteError.value = errorConverter(error);
937
- // Refused for want of the right: take Delete off both menus now.
938
- revokeOnRefusal(error, "delete");
939
856
  // The dialog stays open and the row stays in the table - nothing is removed
940
857
  // optimistically, so what is on screen still matches the database.
941
858
  } finally {
@@ -987,7 +904,6 @@ async function submitBlock() {
987
904
  await getVehiclesRefresh();
988
905
  } catch (error: any) {
989
906
  actionError.value = errorConverter(error);
990
- revokeOnRefusal(error, "update");
991
907
  } finally {
992
908
  blockingVehicle.value = false;
993
909
  }
@@ -1010,7 +926,6 @@ async function submitUnblock() {
1010
926
  await getVehiclesRefresh();
1011
927
  } catch (error: any) {
1012
928
  actionError.value = errorConverter(error);
1013
- revokeOnRefusal(error, "update");
1014
929
  } finally {
1015
930
  unblockingVehicle.value = false;
1016
931
  }
@@ -1036,7 +951,6 @@ async function submitApprove() {
1036
951
  await getVehiclesRefresh();
1037
952
  } catch (error: any) {
1038
953
  actionError.value = errorConverter(error);
1039
- revokeOnRefusal(error, "approve");
1040
954
  } finally {
1041
955
  approvingVehicle.value = false;
1042
956
  }
@@ -1058,60 +972,6 @@ watch(activeTab, () => {
1058
972
  </script>
1059
973
 
1060
974
  <style scoped>
1061
- .history-changes {
1062
- display: flex;
1063
- flex-direction: column;
1064
- gap: 4px;
1065
- padding: 6px 0;
1066
- line-height: 1.5;
1067
- white-space: normal;
1068
- }
1069
- .history-label {
1070
- opacity: 0.65;
1071
- margin-right: 4px;
1072
- }
1073
- .history-word {
1074
- font-weight: 400;
1075
- opacity: 0.55;
1076
- margin: 0 4px;
1077
- }
1078
- .history-value {
1079
- font-weight: 700;
1080
- }
1081
- .history-value--from {
1082
- opacity: 0.75;
1083
- }
1084
- .history-legacy {
1085
- font-style: italic;
1086
- opacity: 0.6;
1087
- }
1088
- /* Action badges, as in the approved sample. Tinted from the theme's own
1089
- colours so they read in light and dark. */
1090
- .history-action {
1091
- display: inline-block;
1092
- font-size: 12px;
1093
- font-weight: 600;
1094
- padding: 2px 10px;
1095
- border-radius: 12px;
1096
- white-space: nowrap;
1097
- background: rgba(var(--v-theme-on-surface), 0.08);
1098
- }
1099
- .history-action--created,
1100
- .history-action--approved,
1101
- .history-action--restored {
1102
- background: rgba(var(--v-theme-success), 0.15);
1103
- color: rgb(var(--v-theme-success));
1104
- }
1105
- .history-action--blocked,
1106
- .history-action--deleted {
1107
- background: rgba(var(--v-theme-error), 0.15);
1108
- color: rgb(var(--v-theme-error));
1109
- }
1110
- .history-action--moved,
1111
- .history-action--updated {
1112
- background: rgba(var(--v-theme-primary), 0.15);
1113
- color: rgb(var(--v-theme-primary));
1114
- }
1115
975
  .plate-remarks {
1116
976
  display: inline-block;
1117
977
  max-width: 220px;