@7365admin1/layer-common 4.181.0 → 4.182.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,18 @@
1
1
  # @iservice365/layer-common
2
2
 
3
+ ## 4.182.0
4
+
5
+ ### Minor Changes
6
+
7
+ - c015e55: Block No can now carry one letter (12A). Add Block is a text field (digits plus at most one letter) instead of a dropdown capped by the site's number of blocks. People form block lookups keep the letter. Types widened to number or string. Release after core and API-core.
8
+ - 08d0401: Building Management: remove the separate Block Name field. A block is now just its Block No (shown as "Blk N"); the stored name is derived from the number. Units table shows a Block column; the units import hint is updated to Block No, Level, Unit Number.
9
+ - b406923: Property-management role editor can grant incident report add and update rights; the ANPR Camera settings panel is hidden when the client has neither the Vehicle nor the Visitor module.
10
+
11
+ ### Patch Changes
12
+
13
+ - 9730f45: Module gate: typing the URL of a page whose module the Super Admin removed from a client no longer opens it. Added Pass & Key (keys), Cards and QR Tagging (access-mgmt), service providers, Property Management's Marketplace, CCTV Engine and Security Ops to the route map.
14
+ - Role editor: modules the client's list removed (including a list saved with nothing ticked) are no longer offered.
15
+
3
16
  ## 4.181.0
4
17
 
5
18
  ### Minor Changes
@@ -3992,11 +4005,11 @@ Monthly report: a month that had patrols opens the list of that month's patrol r
3992
4005
  `utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
3993
4006
  own rule from two endpoints the console already calls, unprojected:
3994
4007
 
3995
- GET /api/members/user/:user/app/admin the Seven365 staff membership
3996
- GET /api/roles/id/:role that membership's role document
4008
+ GET /api/members/user/:user/app/admin the Seven365 staff membership
4009
+ GET /api/roles/id/:role that membership's role document
3997
4010
 
3998
- owner = member.type === "admin" && role.type === "admin" && role.default === true
3999
- staff = member.type === "admin" && role.type === "admin"
4011
+ owner = member.type === "admin" && role.type === "admin" && role.default === true
4012
+ staff = member.type === "admin" && role.type === "admin"
4000
4013
 
4001
4014
  `role.default` is the marker because it is the only property of a platform
4002
4015
  staff role no API caller can set - `role.controller.ts` validates create and
@@ -7,33 +7,14 @@
7
7
  <v-card-text class="screen-modal__body pa-0">
8
8
  <v-form v-model="validForm" :disabled="disable">
9
9
  <v-row no-gutters class="px-6 pt-4">
10
- <v-col cols="12" class="mt-2">
11
- <v-row no-gutters>
12
- <InputLabel class="text-capitalize font-weight-bold" title="Block Name" required />
13
- <v-col cols="12">
14
- <v-text-field v-model="building.name" class="filter-field" density="comfortable" :rules="[requiredRule]"></v-text-field>
15
- </v-col>
16
- </v-row>
17
- </v-col>
18
-
19
10
  <v-col v-if="prop.mode === 'add'" cols="12">
20
11
  <v-row>
21
12
  <v-col cols="6" class="mt-2">
22
13
  <v-row no-gutters>
23
14
  <InputLabel class="text-capitalize font-weight-bold" title="Block No." required />
24
15
  <v-col cols="12">
25
- <v-select v-model.number="building.block" :items="blocks" item-title="label" item-value="value"
26
- class="filter-field" density="comfortable" :rules="[
27
- requiredRule,
28
- () =>
29
- (building.block && building.block > 0) ||
30
- 'Block is required',
31
- ]" type="number">
32
- <template v-slot:item="{ props: itemProps, item }">
33
- <v-list-item v-bind="itemProps" :disabled="item?.raw?.disabled"></v-list-item>
34
- </template>
35
-
36
- </v-select>
16
+ <v-text-field v-model.trim="building.block" class="filter-field" density="comfortable"
17
+ placeholder="e.g. 12 or 12A" maxlength="5" :rules="[requiredRule, blockRule]"></v-text-field>
37
18
  </v-col>
38
19
  </v-row>
39
20
  </v-col>
@@ -206,6 +187,7 @@
206
187
 
207
188
  <script setup lang="ts">
208
189
  import InputLabel from './InputLabel.vue';
190
+ import { blockLabel, normaliseBlock, BLOCK_NO_MESSAGE } from "../utils/building-block";
209
191
 
210
192
  const prop = defineProps({
211
193
  site: {
@@ -232,40 +214,11 @@ const prop = defineProps({
232
214
  },
233
215
  });
234
216
 
235
- const { getSiteById } = useSite();
236
217
  const { getFileById } = useFile();
237
218
  const { deleteById, batchUpdateLevels } = useBuildingLevel();
238
219
 
239
- const site = ref<TSite | null>(null);
240
-
241
- const { data: getSiteReq } = useLazyAsyncData(
242
- "get-site-by-id-" + prop.site,
243
- async () => getSiteById(prop.site)
244
- );
245
-
246
- watchEffect(() => {
247
- if (getSiteReq.value) {
248
- site.value = getSiteReq.value;
249
- }
250
- });
251
-
252
- const blocks = computed(() => {
253
- if (!site.value) return [];
254
- // return
255
- // return [ { label: "1", value: 1, disabled: true }, { label: "2", value: 2 }, { label: "3", value: 3 } ];
256
- const array = Array.from({ length: site.value?.metadata?.block || 0 }, (_, i) => i + 1);
257
-
258
- const formattedArray = array.map((num) => {
259
- const isDisabled = prop.blocks.some((block) => block.block === num)
260
- return {
261
- label: num.toString(),
262
- value: num,
263
- disabled: isDisabled
264
- };
265
- });
266
-
267
- return formattedArray;
268
- });
220
+ // Block No: digits with at most one letter (12, 12A). The site's "number of blocks" no longer caps it.
221
+ const blockRule = (v: unknown) => normaliseBlock(v) !== null || BLOCK_NO_MESSAGE;
269
222
 
270
223
  const emit = defineEmits(["cancel", "success", "success:create-more", "refresh"]);
271
224
 
@@ -400,10 +353,26 @@ async function submit() {
400
353
  try {
401
354
  if (prop.mode === "add") {
402
355
  const buildingPayload = { ...building.value };
356
+ // One block field only: the stored name is derived from the number ("Blk 3").
357
+ const blockNo = normaliseBlock(buildingPayload.block);
358
+ if (blockNo === null) {
359
+ message.value = BLOCK_NO_MESSAGE;
360
+ return;
361
+ }
362
+ buildingPayload.block = blockNo;
363
+ if (prop.blocks.some((b) => normaliseBlock(b.block) === blockNo)) {
364
+ message.value = `Block ${blockNo} already exists. Choose a different Block No.`;
365
+ return;
366
+ }
367
+ const name = blockLabel(blockNo);
368
+ if (prop.blocks.some((b) => b.name?.trim().toLowerCase() === name.toLowerCase() && b.block !== blockNo)) {
369
+ message.value = `Another block is already named "${name}". Rename it first, or choose a different Block No.`;
370
+ return;
371
+ }
403
372
 
404
373
  let payload: TBuildingPayload = {
405
374
  site: buildingPayload.site,
406
- name: buildingPayload.name,
375
+ name,
407
376
  block: buildingPayload.block,
408
377
  levels: [...newLevelsArray.value],
409
378
  buildingFiles: (building.value.buildingFiles as string[] || []).map((id) => ({ id, name: buildingFilesNames.value[id] ?? "" }))
@@ -22,6 +22,7 @@
22
22
  <template #prepend-additional>
23
23
  <AppField v-model="searchInput" search compact placeholder="Search" klass="app-toolbar__search" />
24
24
  </template>
25
+ <template #item.block="{ value }">{{ value ? blockLabel(value) : "" }}</template>
25
26
  <template #item.createdAt="{ value }">
26
27
  {{ new Date(value).toLocaleDateString() }}
27
28
  </template>
@@ -52,13 +53,9 @@
52
53
  <v-card width="100%">
53
54
  <v-card-text style="max-height: 100vh; overflow-y: auto" class="pb-0">
54
55
  <v-row no-gutters class="mb-4">
55
- <v-col cols="12">
56
- <strong>Name:</strong> {{ selectedBuilding?.name ?? "N/A" }}
57
- </v-col>
58
-
59
56
  <v-col cols="12">
60
57
  <strong>Block:</strong>
61
- {{ selectedBuilding?.block ?? "N/A" }}
58
+ {{ selectedBuilding?.block ? blockLabel(selectedBuilding.block) : "N/A" }}
62
59
  </v-col>
63
60
 
64
61
  <v-col cols="12">
@@ -161,16 +158,13 @@
161
158
  // Relative import, never Nuxt auto-import: this layer's `utils/` are auto-imported
162
159
  // into the consuming apps but not reliably into the layer's own components.
163
160
  import { levelCount } from "../../utils/data";
161
+ import { blockLabel } from "../../utils/building-block";
164
162
 
165
163
 
166
164
  const props = defineProps({
167
165
  headers: {
168
166
  type: Array as PropType<Array<Record<string, any>>>,
169
167
  default: () => [
170
- {
171
- title: "Name",
172
- value: "name",
173
- },
174
168
  {
175
169
  title: "Block",
176
170
  value: "block",
@@ -30,8 +30,8 @@
30
30
  v-model="showImport"
31
31
  title="Import Blocks, Levels and Units from Excel"
32
32
  noun="rows"
33
- name-label="Building / Level / Unit"
34
- fill-hint="One row per unit: building name, level and unit. Pick Building Name and Level from the dropdowns (type a new name for a new building). No block number needed — an existing building keeps its own and a new one gets the next free number."
33
+ name-label="Block / Level / Unit"
34
+ fill-hint="One row per unit: Block No, Level and Unit Number. Pick Level from the dropdown where it already exists. A new Block No creates a new block (Blk 1, Blk 2 ...); an existing block keeps its name."
35
35
  duplicate-note="Units already on that level are skipped and left unchanged."
36
36
  template-file-name="units-import-template.xlsx"
37
37
  :download-template="() => downloadTemplate('building-units', { site })"
@@ -50,7 +50,7 @@
50
50
  <AppField v-model="searchInput" search compact placeholder="Search" klass="app-toolbar__search" />
51
51
  </template>
52
52
  <template #item.block="{ value, item }">
53
- {{ value ? `Block ${value}` : "" }}
53
+ {{ value ? blockLabel(value) : "" }}
54
54
  </template>
55
55
  </TableMain>
56
56
 
@@ -174,6 +174,7 @@
174
174
 
175
175
  <script setup lang="ts">
176
176
  import useImportTemplates from "../../composables/useImportTemplates";
177
+ import { blockLabel } from "../../utils/building-block";
177
178
  import { saveBlob } from "../../composables/useInventory";
178
179
  import { useDisplay } from 'vuetify/lib/composables/display.mjs';
179
180
 
@@ -189,13 +190,9 @@ const props = defineProps({
189
190
  title: "Level",
190
191
  value: "level.name",
191
192
  },
192
- // {
193
- // title: "Block",
194
- // value: "block",
195
- // },
196
193
  {
197
- title: "Block Name",
198
- value: "buildingName",
194
+ title: "Block",
195
+ value: "block",
199
196
  },
200
197
 
201
198
  // {
@@ -1489,7 +1489,7 @@ type OccupiedLevel = { _id: string; name: string; units?: OccupiedUnit[] };
1489
1489
  type OccupiedBlock = {
1490
1490
  _id: string;
1491
1491
  name: string;
1492
- block: number | null;
1492
+ block: number | string | null;
1493
1493
  levels?: OccupiedLevel[];
1494
1494
  };
1495
1495
  type UnitPerson = {
@@ -119,6 +119,7 @@
119
119
 
120
120
  <script setup lang="ts">
121
121
  import { property } from 'zod/v4';
122
+ import { normaliseBlock } from '../utils/building-block';
122
123
 
123
124
  const prop = defineProps({
124
125
  org: {
@@ -205,14 +206,14 @@ const { data: levelsData, refresh: refreshLevelsData, status: levelsStatus } = u
205
206
  `fetch-levels-data-${prop.site}-${form.block}`,
206
207
  async () => {
207
208
  if (!form.block) return Promise.resolve(null);
208
- return await getSiteLevels(prop.site, { block: Number(form.block) })
209
+ return await getSiteLevels(prop.site, { block: normaliseBlock(form.block) ?? form.block })
209
210
  }, { watch: [() => form.block],});
210
211
 
211
212
  const { data: unitsData, refresh: refreshUnitsData, status: unitsStatus } = useLazyAsyncData(
212
213
  `fetch-units-data-${prop.site}-${form.level}`,
213
214
  async () => {
214
215
  if (!form.level) return Promise.resolve(null);
215
- return await getSiteUnits(prop.site, Number(form.block), form.level)
216
+ return await getSiteUnits(prop.site, normaliseBlock(form.block) ?? form.block, form.level)
216
217
  }, { watch: [()=> form.level]});
217
218
 
218
219
  watch(
@@ -226,6 +226,7 @@ import {
226
226
  ownerGrant,
227
227
  siteModulesForOrg,
228
228
  } from "../utils/org-modules";
229
+ import { withoutDeniedResources } from "../utils/module-routes";
229
230
 
230
231
  const props = defineProps({
231
232
  orgId: {
@@ -406,9 +407,17 @@ const { data: grantRole } = useLazyAsyncData(
406
407
  { watch: [grantRoleId] }
407
408
  );
408
409
 
410
+ /*
411
+ * The deny list the server computed for this person (owner, 2026-11-16): a
412
+ * module the client's list removed - including a list saved with nothing
413
+ * ticked - is not offered either. Seven365 staff get an empty list, so the
414
+ * Super Admin still sees everything.
415
+ */
416
+ const { userAppModulesDenied: deniedForEditor } = useLocalSetup();
417
+
409
418
  /** `props.permissions`, narrowed to what this client - and this site - was given. */
410
419
  const offeredPermissions = computed(() =>
411
- catalogueForOwnerGrant(
420
+ withoutDeniedResources(catalogueForOwnerGrant(
412
421
  catalogueForOrg(
413
422
  props.permissions ?? {},
414
423
  effectiveModules(
@@ -418,7 +427,7 @@ const offeredPermissions = computed(() =>
418
427
  )
419
428
  ),
420
429
  ownerGrant(orgForModules.value as any, grantRole.value as any, props.type)
421
- )
430
+ ), deniedForEditor?.value)
422
431
  );
423
432
 
424
433
  const { getRoles: _getRoles } = useRole();
@@ -109,7 +109,7 @@
109
109
  </v-expansion-panel>
110
110
 
111
111
  <!-- ANPR CAMERA -->
112
- <v-expansion-panel v-if="showAnprCamera && canManageANPRCamera">
112
+ <v-expansion-panel v-if="showAnprCamera && canManageANPRCamera && anprModuleOn">
113
113
  <v-expansion-panel-title>
114
114
  <v-icon class="mr-2">mdi-camera</v-icon>
115
115
  ANPR Camera
@@ -319,6 +319,7 @@ import useSiteSettings from "../composables/useSiteSettings";
319
319
  import useUtils from "../composables/useUtils";
320
320
  import useANPRSettings from "../composables/useANPRSettings";
321
321
  import useVehicle from "../composables/useVehicle";
322
+ import { permissionsDenied } from "../utils/module-routes";
322
323
  import { SERIAL_DEFAULT_DIGITS, SERIAL_PREFIX_PATTERN, cleanSerialPrefix, formatStickerSerial } from "../utils/vehicle-qr-blank";
323
324
 
324
325
  const props = defineProps({
@@ -347,6 +348,9 @@ const { canManageSiteInformation,
347
348
  canManageSiteSettings: canManageAnySiteSetting,
348
349
  } = useSettingsPermission();
349
350
  const { canManageHidSettings } = useHidAccessPermission();
351
+ // ANPR serves vehicles and visitors: hide the panel when the client has neither module (denied list, same as the menu gate).
352
+ const { userAppModulesDenied } = useLocalSetup();
353
+ const anprModuleOn = computed(() => !permissionsDenied(["vehicle-mgmt:x", "visitor-mgmt:x"], userAppModulesDenied?.value));
350
354
 
351
355
  const { getSiteById, updateSitebyId, updateSiteInformation } =
352
356
  useSiteSettings();
@@ -438,6 +438,14 @@ export default function usePropertyPermission() {
438
438
  check: true,
439
439
  description: "Allows the user to approve or reject incident report.",
440
440
  },
441
+ "add-incident-report": {
442
+ check: true,
443
+ description: "Allows the user to add a new incident report.",
444
+ },
445
+ "update-incident-report": {
446
+ check: true,
447
+ description: "Allows the user to update an incident report.",
448
+ },
441
449
  },
442
450
 
443
451
  "vehicle-mgmt": {
@@ -1,6 +1,6 @@
1
1
  export default function(){
2
2
 
3
- const formatLocation = ({block, level, unit}: {block: number, level: string, unit: string | TBuildingUnit}) => {
3
+ const formatLocation = ({block, level, unit}: {block: number | string, level: string, unit: string | TBuildingUnit}) => {
4
4
  const parts = [];
5
5
 
6
6
  if (block?.name) parts.push(`${block.name}`);
@@ -8,7 +8,7 @@ export default function () {
8
8
  );
9
9
  }
10
10
 
11
- async function getSiteLevels(siteId: string, query: { block: number }) {
11
+ async function getSiteLevels(siteId: string, query: { block: number | string }) {
12
12
  return await useNuxtApp().$api<Record<string, any>>(
13
13
  `/api/buildings/site/${siteId}`,
14
14
  {
@@ -18,7 +18,7 @@ export default function () {
18
18
  );
19
19
  }
20
20
 
21
- async function getSiteUnits(siteId: string, block: number, level: string) {
21
+ async function getSiteUnits(siteId: string, block: number | string, level: string) {
22
22
  return await useNuxtApp().$api<Record<string, any>>(
23
23
  `/api/building-units/site/${siteId}/block/${block}/level/${level}`,
24
24
  {
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.181.0",
5
+ "version": "4.182.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.",
@@ -2,7 +2,7 @@ declare type TBuilding = {
2
2
  _id?: string;
3
3
  site: string;
4
4
  name: string;
5
- block: number | null;
5
+ block: number | string | null;
6
6
  levels: { _id: string; name: string }[];
7
7
  buildingFiles: { id: string, name: string }[] | string[];
8
8
  };
@@ -15,7 +15,7 @@ declare type TBuildingUnit = {
15
15
  ownerName?: string;
16
16
  building: string;
17
17
  buildingName?: string;
18
- block: number | null;
18
+ block: number | string | null;
19
19
  level: { _id: string; name: string } | null;
20
20
  category: string;
21
21
  status: string;
@@ -0,0 +1,19 @@
1
+ /** The one block label used everywhere: "Blk 3", "Blk 12A". Block names are no longer typed; they come from the number. */
2
+ export const blockLabel = (block: number | string | null | undefined): string => `Blk ${block}`;
3
+
4
+ export const BLOCK_NO_MESSAGE = "Block No must be a number from 1 to 9999, optionally followed by one letter (for example 12 or 12A).";
5
+
6
+ /**
7
+ * Block No: 1-4 digits and at most one capital letter. Same rule as the API (core): trim, capitals,
8
+ * drop "Blk"/"Block" and leading zeros. Digits only -> a number; with a letter -> a string ("12A").
9
+ */
10
+ export function normaliseBlock(input: unknown): number | string | null {
11
+ if (typeof input === "number") return Number.isInteger(input) && input >= 1 && input <= 9999 ? input : null;
12
+ if (typeof input !== "string") return null;
13
+ const s = input.trim().toUpperCase().replace(/^(BLK|BLOCK)\.?\s*/, "").replace(/^0+(?=\d)/, "");
14
+ const m = /^(\d{1,4})([A-Z]?)$/.exec(s);
15
+ if (!m) return null;
16
+ const n = Number(m[1]);
17
+ if (n < 1) return null;
18
+ return m[2] ? `${n}${m[2]}` : n;
19
+ }
@@ -10,11 +10,19 @@
10
10
  * FAILS OPEN. A route that is not listed here is allowed whatever the list says.
11
11
  * Only prefixes whose page each app gates on exactly one module are listed
12
12
  * (checked against every app's own `useLocalPermission` nav gate, 2026-09-11).
13
- * Shared or ambiguous pages stay out: calendar, keys (gated on `site-settings`),
14
- * the Cards and QR Tagging pages under access-mgmt (each app's own
15
- * `access-card-mgmt` gate), equipment and inventory, service-providers and
16
- * support tickets. The HID pages under access-mgmt ARE listed, one by one,
17
- * because each is gated on `hid-mgmt` alone (`useHidAccessPermission`).
13
+ * Shared or ambiguous pages stay out: equipment (every app's Equipment URL is a
14
+ * redirect to Inventory, no page of its own), the service-provider inventory
15
+ * page, support tickets and the org-level marketplace (vendor side, not
16
+ * `marketplace-mgmt`). The Pass & Key pages (`keys`) are gated on
17
+ * `passes-and-keys-mgmt` alone in both apps that have them (DV-0396), Cards and
18
+ * QR Tagging on `access-card-mgmt`, the service-provider list on
19
+ * `service-provider-mgmt`, Property Management's site Marketplace on
20
+ * `marketplace-mgmt`, CCTV Engine on `cctv-engine` and the four Security Ops
21
+ * pages on `security-ops`, so those ARE listed (2026-11-16). `cctv-mgmt` is
22
+ * catalogue-only: no page reads it, so there is nothing to map. The HID pages
23
+ * under access-mgmt are listed one by one, because each is gated on `hid-mgmt`
24
+ * alone (`useHidAccessPermission`); Cards is the bare `access-mgmt` route, so
25
+ * every page beside it MUST be listed or it would fall under the card module.
18
26
  *
19
27
  * NEVER MAPPED: the dashboard, settings, members, invitations and roles. A client
20
28
  * must always be able to run its own people and roles; the server never denies
@@ -71,9 +79,21 @@ export const MODULE_ROUTES: Readonly<Record<string, string>> = Object.freeze({
71
79
  "org-site-pool-schedule-area": "area-mgmt",
72
80
  "org-site-pool-schedule-unit": "unit-mgmt",
73
81
  "org-site-service-provider-mgmt": "service-provider-mgmt",
82
+ // The shared service-provider list in Security, Hygiene and the other trade apps
83
+ // (and Property Management): every app's menu reads `useServiceProviderPermission`,
84
+ // which is `service-provider-mgmt` (alias `service-provider`, same spelling group).
85
+ "org-site-service-providers": "service-provider-mgmt",
86
+ "org-site-marketplace": "marketplace-mgmt",
87
+ "org-site-keys": "passes-and-keys-mgmt",
88
+ "org-site-cctv-engine": "cctv-engine",
89
+ "org-site-security-ops": "security-ops",
90
+ // Cards is the bare `access-mgmt` route; every HID page and QR Tagging below
91
+ // is longer, so it wins. A new page under access-mgmt needs its own entry.
92
+ "org-site-access-mgmt": "access-card-mgmt",
93
+ "org-site-access-mgmt-qr-tagging": "access-card-mgmt",
74
94
  // HID access management (decision of 2026-10-16): the seven HID pages under
75
- // `access-mgmt`, named one by one so the Cards and QR Tagging pages beside
76
- // them stay unmapped. `hid-mgmt` is a governed module in core, so a client
95
+ // `access-mgmt`, named one by one so they stay apart from Cards and
96
+ // QR Tagging beside them. `hid-mgmt` is a governed module in core, so a client
77
97
  // that was not given it loses the pages and the drawer group together.
78
98
  "org-site-access-mgmt-hid-readers": "hid-mgmt",
79
99
  "org-site-access-mgmt-administrator": "hid-mgmt",
@@ -133,6 +153,9 @@ export function permissionsDenied(
133
153
  return permissions.every((p) => denied.includes(String(p).split(":")[0]));
134
154
  }
135
155
 
156
+ /** Carved-out pages: shown to anyone, but never the only thing left in a trimmed group. */
157
+ const ROUTES_THAT_DONT_KEEP_A_GROUP = ["org-site-facility-settings"];
158
+
136
159
  type TRouted = { route?: { name?: unknown } | null; children?: TRouted[] };
137
160
 
138
161
  /** A menu without the pages the client was not given; a group left empty goes too. */
@@ -145,6 +168,30 @@ export function withoutDeniedRoutes<T extends TRouted>(
145
168
  if (routeDenied(item.route?.name, denied)) return [];
146
169
  if (!item.children?.length) return [item];
147
170
  const children = withoutDeniedRoutes(item.children as T[], denied);
148
- return children.length ? [{ ...item, children }] : [];
171
+ // A page carved out of its module (Facility Settings) must not keep a group
172
+ // alive on its own once the group's module pages were taken away.
173
+ const lost = children.length < item.children.length;
174
+ const stray = children.every((c) => ROUTES_THAT_DONT_KEEP_A_GROUP.includes(String(c.route?.name)));
175
+ return children.length && !(lost && stray) ? [{ ...item, children }] : [];
149
176
  });
150
177
  }
178
+
179
+ /**
180
+ * A permission catalogue (`{ resource: actions }`, what `RolePermissionMain`
181
+ * takes) without the modules the client's list took away, so a role editor
182
+ * never offers a box the client cannot use (owner, 2026-11-16). `denied` is the
183
+ * server's deny list (`useLocalSetup().userAppModulesDenied`), which already
184
+ * covers a list saved with nothing ticked and never holds an always-allowed
185
+ * module. No deny list: the same object back.
186
+ */
187
+ export function withoutDeniedResources<T extends Record<string, unknown>>(
188
+ catalogue: T,
189
+ denied: readonly string[] | null | undefined,
190
+ ): T {
191
+ if (!Array.isArray(denied) || !denied.length || !catalogue || typeof catalogue !== "object") {
192
+ return catalogue;
193
+ }
194
+ return Object.fromEntries(
195
+ Object.entries(catalogue).filter(([resource]) => !denied.includes(resource.trim())),
196
+ ) as T;
197
+ }