@7365admin1/layer-common 4.33.0 → 4.34.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 CHANGED
@@ -1,5 +1,32 @@
1
1
  # @iservice365/layer-common
2
2
 
3
+ ## 4.34.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b45cddc: Security roles and permissions for vehicles, work orders and feedback (DV-0396).
8
+
9
+ - When the backend refuses a request (401/403 "You do not have permission…"), the app re-reads the user's role so buttons update without logging in again (`utils/permission-refusal.ts`, `plugins/API.ts`).
10
+ - Vehicle Management:
11
+ - An action the backend refused is faded straight away and shows the reason when clicked, without sending the request again.
12
+ - The Preview plate list shows every plate.
13
+ - Restore wording includes the ANPR camera counts.
14
+ - History shows each change on its own line as "from X to Y".
15
+ - Clicking a row without See Vehicle Details shows a message.
16
+ - A list the backend refused shows why in the empty table.
17
+ - Vehicle Form:
18
+ - After a refusal, Submit/Update stays faded and repeats the message.
19
+ - Closing the matching-records dialog without picking one unlocks NRIC and Name.
20
+ - `ReusablePrompt` / `DeleteConfirmation`: new `noPermission` option; ReusablePrompt also gets `messageError` to show its message in red.
21
+ - Vehicle actions: Restore needs Approve Vehicle, and a deleted blocklist plate only offers Restore.
22
+ - Delete Work Order and Delete Feedback are now offered only in the Property Management permissions. They're removed from Security and the trade apps (Cleaning, Landscaping, M&E, Pest Control, Pool Maintenance).
23
+
24
+ ## 4.33.1
25
+
26
+ ### Patch Changes
27
+
28
+ - 498481c: HERO robot rules for the mobile apps: `scripts/sync-robot-rules.mjs` writes a generated, hash-stamped copy of `utils/robot-display.ts` (+ lift-queue rows, HERO_PALETTE) and shared test vectors into iClean365, iMA365 and iSecure365. Repo tooling only; nothing a consuming app loads changes.
29
+
3
30
  ## 4.33.0
4
31
 
5
32
  ### Minor Changes
@@ -1381,11 +1408,11 @@
1381
1408
  `utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
1382
1409
  own rule from two endpoints the console already calls, unprojected:
1383
1410
 
1384
- GET /api/members/user/:user/app/admin the Seven365 staff membership
1385
- GET /api/roles/id/:role that membership's role document
1411
+ GET /api/members/user/:user/app/admin the Seven365 staff membership
1412
+ GET /api/roles/id/:role that membership's role document
1386
1413
 
1387
- owner = member.type === "admin" && role.type === "admin" && role.default === true
1388
- staff = member.type === "admin" && role.type === "admin"
1414
+ owner = member.type === "admin" && role.type === "admin" && role.default === true
1415
+ staff = member.type === "admin" && role.type === "admin"
1389
1416
 
1390
1417
  `role.default` is the marker because it is the only property of a platform
1391
1418
  staff role no API caller can set - `role.controller.ts` validates create and
package/README.md CHANGED
@@ -71,3 +71,22 @@ pnpm preview
71
71
  ```
72
72
 
73
73
  Checkout the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
74
+
75
+ ## HERO robot rules for the mobile apps
76
+
77
+ `utils/robot-display.ts` is the canonical home of the HERO robot display rules.
78
+ The React Native apps (iClean365, iMA365, iSecure365) cannot consume this layer
79
+ and no separate npm package is published for them, so
80
+ `scripts/sync-robot-rules.mjs` writes a dependency-free copy into each app
81
+ (`src/shared/robot-rules/robot-rules.ts`, GENERATED, with a sha256 header) plus
82
+ `robot-rules.vectors.json` - this repo's own answers for every case. Each app's
83
+ test re-hashes the copy and runs the vectors, so a hand edit fails there.
84
+
85
+ After changing `utils/robot-display.ts` (or the lift-queue section of
86
+ `utils/robot-building.ts`, or `HERO_PALETTE` in `utils/theme.ts`):
87
+
88
+ node scripts/sync-robot-rules.mjs ../iservice365-hygiene-mobile-app ../iservice365-ma-mobile-app ../isecure365-mobile-app
89
+ node scripts/sync-robot-rules.mjs --check ../iservice365-hygiene-mobile-app ../iservice365-ma-mobile-app ../isecure365-mobile-app
90
+
91
+ and open a PR in each app with the two regenerated files. `test/robot-rules-sync.test.mjs`
92
+ checks the generator here. The script is not part of the published package.
@@ -27,7 +27,8 @@
27
27
  Cancel
28
28
  </v-btn>
29
29
 
30
- <v-btn class="screen-btn-primary" variant="flat" @click="emit('delete')">
30
+ <v-btn class="screen-btn-primary" :class="{ 'no-permission': noPermission }"
31
+ :aria-disabled="noPermission || undefined" variant="flat" @click="emit('delete')">
31
32
  Delete
32
33
  </v-btn>
33
34
  </div>
@@ -47,6 +48,15 @@ const props = defineProps({
47
48
  loading: {
48
49
  type: Boolean,
49
50
  default: false
51
+ },
52
+ /**
53
+ * The action is not allowed (the server has refused it for want of the
54
+ * right). The confirm is drawn disabled but still takes the click, so the
55
+ * caller can say why - without sending the request again.
56
+ */
57
+ noPermission: {
58
+ type: Boolean,
59
+ default: false
50
60
  }
51
61
  })
52
62
 
@@ -54,4 +64,9 @@ const emit = defineEmits(["close", "delete"])
54
64
 
55
65
  </script>
56
66
 
57
- <style scoped></style>
67
+ <style scoped>
68
+ .no-permission {
69
+ opacity: 0.45;
70
+ cursor: not-allowed;
71
+ }
72
+ </style>
@@ -3,7 +3,10 @@
3
3
  <v-card-text class="screen-modal__body pa-5 my-5 px-7 text-center">
4
4
  <span class="screen-card-title d-block">{{ promptTitle }}</span>
5
5
 
6
- <span v-if="message" class="d-block mt-5">
6
+ <!-- Red (`text-error`, the theme's error token) when the caller says
7
+ the message is a failure; other callers pass notes, so it stays
8
+ plain by default. -->
9
+ <span v-if="message" class="d-block mt-5" :class="{ 'text-error': messageError }">
7
10
  {{ message }}
8
11
  </span>
9
12
  </v-card-text>
@@ -25,7 +28,8 @@
25
28
  draws no destructive button, so overriding it here would be
26
29
  inventing a control the design never named. Left as it renders
27
30
  today and raised for a design decision. -->
28
- <v-btn :class="confirmButtonColor ? 'text-none' : 'screen-btn-primary'"
31
+ <v-btn :class="[confirmButtonColor ? 'text-none' : 'screen-btn-primary', { 'no-permission': noPermission }]"
32
+ :aria-disabled="noPermission || undefined"
29
33
  variant="flat" :color="confirmButtonColor || undefined" @click="emit('proceed')">
30
34
  {{ confirmLabel }}
31
35
  </v-btn>
@@ -54,6 +58,20 @@ const props = defineProps({
54
58
  confirmButtonColor: {
55
59
  type: String,
56
60
  default: ""
61
+ },
62
+ /**
63
+ * The action is not allowed (the server has refused it for want of the
64
+ * right). The confirm is drawn disabled but still takes the click, so the
65
+ * caller can say why - without sending the request again.
66
+ */
67
+ noPermission: {
68
+ type: Boolean,
69
+ default: false
70
+ },
71
+ /** `message` is a refusal or failure: drawn in the error colour. */
72
+ messageError: {
73
+ type: Boolean,
74
+ default: false
57
75
  }
58
76
 
59
77
  })
@@ -62,4 +80,9 @@ const emit = defineEmits(["close", "proceed"])
62
80
 
63
81
  </script>
64
82
 
65
- <style scoped></style>
83
+ <style scoped>
84
+ .no-permission {
85
+ opacity: 0.45;
86
+ cursor: not-allowed;
87
+ }
88
+ </style>
@@ -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
- <AppButton :disabled="processing" @click="submit">
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" @click="confirmExistingUpdate">Update</AppButton>
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="`Are you sure want to restore this vehicle - ${selectedPlateNumberObject?.plateNumber}?`"
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) {
@@ -7,8 +7,8 @@ export default function useCleaningPermission() {
7
7
  const {
8
8
  rolePermissions,
9
9
  memberPermissions,
10
- feedbackPermissions,
11
- workOrderPermissions,
10
+ tradeFeedbackPermissions,
11
+ tradeWorkOrderPermissions,
12
12
  invitationPermissions,
13
13
  bulletinBoardPermissions,
14
14
 
@@ -17,8 +17,8 @@ export default function useCleaningPermission() {
17
17
  const permissions: TPermissions = {
18
18
  inventory: inventoryPermissions,
19
19
  members: memberPermissions,
20
- feedbacks: feedbackPermissions,
21
- work_order: workOrderPermissions,
20
+ feedbacks: tradeFeedbackPermissions,
21
+ work_order: tradeWorkOrderPermissions,
22
22
  roles: rolePermissions,
23
23
  invitations: invitationPermissions,
24
24
  "bulletin-board": bulletinBoardPermissions,
@@ -120,6 +120,20 @@ export function useCommonPermissions() {
120
120
  },
121
121
  };
122
122
 
123
+ /*
124
+ * The same rights WITHOUT "delete-work-order", for every trade other than
125
+ * Property Management. Deleting a work order is for Property Management and
126
+ * the work order's creator only (Harris, 2026-09-23), so the service
127
+ * providers' role editors no longer offer the box. Property keeps
128
+ * `workOrderPermissions` as it is.
129
+ */
130
+ const { "delete-work-order": _propertyOnly, ...tradeWorkOrderPermissions } =
131
+ workOrderPermissions;
132
+
133
+ /** Feedback the same way: "delete-feedback" is Property Management's only. */
134
+ const { "delete-feedback": _propertyOnlyFeedback, ...tradeFeedbackPermissions } =
135
+ feedbackPermissions;
136
+
123
137
  const visitorManagementPermissions: Record<string, TPermission> = {
124
138
  "add-visitor": {
125
139
  check: true,
@@ -323,7 +337,9 @@ export function useCommonPermissions() {
323
337
  memberPermissions,
324
338
  rolePermissions,
325
339
  feedbackPermissions,
340
+ tradeFeedbackPermissions,
326
341
  workOrderPermissions,
342
+ tradeWorkOrderPermissions,
327
343
  visitorManagementPermissions,
328
344
  buildingManagementPermissions,
329
345
  buildingUnitManagementPermissions,
@@ -25,8 +25,8 @@ export default function useLandscapingPermission() {
25
25
  invitationPermissions,
26
26
  memberPermissions,
27
27
  rolePermissions,
28
- feedbackPermissions,
29
- workOrderPermissions,
28
+ tradeFeedbackPermissions,
29
+ tradeWorkOrderPermissions,
30
30
  bulletinBoardPermissions,
31
31
  serviceProviderPermissions,
32
32
 
@@ -37,8 +37,8 @@ export default function useLandscapingPermission() {
37
37
  members: memberPermissions,
38
38
  roles: rolePermissions,
39
39
  invitations: invitationPermissions,
40
- feedbacks: feedbackPermissions,
41
- work_orders: workOrderPermissions,
40
+ feedbacks: tradeFeedbackPermissions,
41
+ work_orders: tradeWorkOrderPermissions,
42
42
  "bulletin-board": bulletinBoardPermissions,
43
43
  "service-provider-mgmt": serviceProviderPermissions,
44
44
  // Owner decision 3A, 2026-09-11: Emergency Contacts is offered in the
@@ -26,8 +26,8 @@ export default function useMechanicalElectricalPermission() {
26
26
  invitationPermissions,
27
27
  memberPermissions,
28
28
  rolePermissions,
29
- feedbackPermissions,
30
- workOrderPermissions,
29
+ tradeFeedbackPermissions,
30
+ tradeWorkOrderPermissions,
31
31
  bulletinBoardPermissions,
32
32
 
33
33
  inventoryPermissions,
@@ -39,8 +39,8 @@ export default function useMechanicalElectricalPermission() {
39
39
  members: memberPermissions,
40
40
  roles: rolePermissions,
41
41
  invitations: invitationPermissions,
42
- feedbacks: feedbackPermissions,
43
- work_orders: workOrderPermissions,
42
+ feedbacks: tradeFeedbackPermissions,
43
+ work_orders: tradeWorkOrderPermissions,
44
44
  "bulletin-board": bulletinBoardPermissions,
45
45
  // This app's sidebar gates Area, Unit and Settings on `area-mgmt`,
46
46
  // `unit-mgmt` and `site-settings`, and its pages exist -- but the catalogue
@@ -25,8 +25,8 @@ export default function usePestControlPermission() {
25
25
  invitationPermissions,
26
26
  memberPermissions,
27
27
  rolePermissions,
28
- feedbackPermissions,
29
- workOrderPermissions,
28
+ tradeFeedbackPermissions,
29
+ tradeWorkOrderPermissions,
30
30
  bulletinBoardPermissions,
31
31
  serviceProviderPermissions,
32
32
 
@@ -37,8 +37,8 @@ export default function usePestControlPermission() {
37
37
  members: memberPermissions,
38
38
  roles: rolePermissions,
39
39
  invitations: invitationPermissions,
40
- feedbacks: feedbackPermissions,
41
- work_orders: workOrderPermissions,
40
+ feedbacks: tradeFeedbackPermissions,
41
+ work_orders: tradeWorkOrderPermissions,
42
42
  "bulletin-board": bulletinBoardPermissions,
43
43
  "service-provider-mgmt": serviceProviderPermissions,
44
44
  // Owner answer Q5, 2026-09-11: Emergency Contacts is offered in the Pest
@@ -25,8 +25,8 @@ export default function usePoolMaintenancePermission() {
25
25
  invitationPermissions,
26
26
  memberPermissions,
27
27
  rolePermissions,
28
- feedbackPermissions,
29
- workOrderPermissions,
28
+ tradeFeedbackPermissions,
29
+ tradeWorkOrderPermissions,
30
30
  bulletinBoardPermissions,
31
31
  serviceProviderPermissions,
32
32
 
@@ -37,8 +37,8 @@ export default function usePoolMaintenancePermission() {
37
37
  members: memberPermissions,
38
38
  roles: rolePermissions,
39
39
  invitations: invitationPermissions,
40
- feedbacks: feedbackPermissions,
41
- work_orders: workOrderPermissions,
40
+ feedbacks: tradeFeedbackPermissions,
41
+ work_orders: tradeWorkOrderPermissions,
42
42
  "bulletin-board": bulletinBoardPermissions,
43
43
  "service-provider-mgmt": serviceProviderPermissions,
44
44
  // Owner answer Q5, 2026-09-11: Emergency Contacts is offered in the Pool
@@ -63,11 +63,8 @@ export default function useSecurityPermission() {
63
63
  check: true,
64
64
  description: "Allows the user to update feedback details.",
65
65
  },
66
- "delete-feedback": {
67
- check: true,
68
- description:
69
- "Allows the user to remove a feedback from the system permanently.",
70
- },
66
+ // No "delete-feedback": deleting a feedback is for Property Management
67
+ // and the feedback's creator only - the same rule as work orders.
71
68
  },
72
69
 
73
70
  work_orders: {
@@ -88,11 +85,8 @@ export default function useSecurityPermission() {
88
85
  check: true,
89
86
  description: "Allows the user to update work-order details.",
90
87
  },
91
- "delete-work-order": {
92
- check: true,
93
- description:
94
- "Allows the user to remove a work-order from the system permanently.",
95
- },
88
+ // No "delete-work-order": deleting a work order is for Property
89
+ // Management and the work order's creator only (Harris, 2026-09-23).
96
90
  },
97
91
 
98
92
  "building-mgmt": {
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@7365admin1/layer-common",
3
3
  "license": "MIT",
4
4
  "type": "module",
5
- "version": "4.33.0",
5
+ "version": "4.34.0",
6
6
  "author": "7365admin1",
7
7
  "main": "./nuxt.config.ts",
8
8
  "//files": "What a consumer extending this layer actually loads. Without this npm ships the whole working tree - the changesets, the CI workflows, the render harness in tools/ and any scratch directory that happened to exist at publish time. Nuxt resolves a layer by directory, so every runtime directory below has to stay listed; adding a new top-level runtime directory means adding it here too.",
@@ -96,9 +96,12 @@ export function vehiclePlateActions(
96
96
  });
97
97
  }
98
98
 
99
- // Restore is deliberately NOT gated on `canUpdateVehicle`: it was ungated
100
- // before and narrowing a gate is a separate, role-data decision.
101
- if (isRestorable) {
99
+ // Restore goes through the approve endpoint (`submitRestore` ->
100
+ // `approveVehicle`), which the server gates on "Approve Vehicle" and refuses
101
+ // with "You do not have permission to approve vehicles." without it. It
102
+ // used to be offered to everyone, so a role without the right saw Restore,
103
+ // pressed it and was refused - and it could not be hidden on that refusal.
104
+ if (permissions.canApproveVehicle && isRestorable) {
102
105
  actions.push({
103
106
  key: "restore",
104
107
  title: "Restore",
@@ -110,7 +113,12 @@ export function vehiclePlateActions(
110
113
  // Any record that is not already blocked (and is not waiting for approval)
111
114
  // can be blocked - including an unblocked or deleted one, which is how the
112
115
  // same plate is blocked again without a second record.
113
- if (canUpdate && (isAllowed || isUnblocked || isRestorable)) {
116
+ // A deleted BLOCKLIST plate (Block Listed tab) is not offered Block: Restore
117
+ // already puts it back on every camera's blocklist, so the two would do the
118
+ // same thing. A deleted whitelist plate keeps Block - that turns it into a
119
+ // blocked plate, which Restore (back to allowed) does not.
120
+ const restoresToBlocked = isRestorable && type === "blocklist";
121
+ if (canUpdate && (isAllowed || isUnblocked || (isRestorable && !restoresToBlocked))) {
114
122
  actions.push({
115
123
  key: "block",
116
124
  title: "Block",