@7365admin1/layer-common 4.4.2-staging.292 → 4.5.1-staging.293
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,34 @@
|
|
|
1
1
|
# @iservice365/layer-common
|
|
2
2
|
|
|
3
|
+
## 4.5.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 6f6dd02: Show modules and actions by name in the role editor (R5).
|
|
8
|
+
|
|
9
|
+
The editor showed raw catalogue keys — `work_orders`, `SOA-mgmt`,
|
|
10
|
+
`buildingUnitManagement` — and asked a client to build a role out of them.
|
|
11
|
+
`utils/permission-labels.ts` derives a readable name from the key rather than
|
|
12
|
+
hand-listing 47 of them, so a module added to the catalogue is named
|
|
13
|
+
automatically; acronyms are not sentence-cased into nonsense.
|
|
14
|
+
|
|
15
|
+
Both role dialogs previously carried their own weaker copy of this and now share
|
|
16
|
+
one rule. Display only — every stored value and every `resource:action` string
|
|
17
|
+
is unchanged.
|
|
18
|
+
|
|
19
|
+
- 6f6dd02: Narrow the role editor by the SITE's modules, not only the organisation's (R1 tier three).
|
|
20
|
+
|
|
21
|
+
When the editor is scoped to a site it now offers the intersection of
|
|
22
|
+
`organizations.modules` and `sites.metadata.modules`, so a site role cannot be
|
|
23
|
+
given a module the site was not given. `effectiveModules` is the client copy of
|
|
24
|
+
core's `effectiveSiteModules`.
|
|
25
|
+
|
|
26
|
+
Fails open at every step: absent at either tier means everything, as do an
|
|
27
|
+
unreadable list, a failed request, and an intersection that matches nothing
|
|
28
|
+
(that falls back to the organisation's list). The site is only fetched when the
|
|
29
|
+
editor is scoped to one, so an organisation-level editor pays for no extra
|
|
30
|
+
request.
|
|
31
|
+
|
|
3
32
|
## 4.4.1
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
|
@@ -866,11 +895,11 @@
|
|
|
866
895
|
`utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
|
|
867
896
|
own rule from two endpoints the console already calls, unprojected:
|
|
868
897
|
|
|
869
|
-
|
|
870
|
-
|
|
898
|
+
GET /api/members/user/:user/app/admin the Seven365 staff membership
|
|
899
|
+
GET /api/roles/id/:role that membership's role document
|
|
871
900
|
|
|
872
|
-
|
|
873
|
-
|
|
901
|
+
owner = member.type === "admin" && role.type === "admin" && role.default === true
|
|
902
|
+
staff = member.type === "admin" && role.type === "admin"
|
|
874
903
|
|
|
875
904
|
`role.default` is the marker because it is the only property of a platform
|
|
876
905
|
staff role no API caller can set - `role.controller.ts` validates create and
|
|
@@ -46,10 +46,38 @@
|
|
|
46
46
|
</AppButton>
|
|
47
47
|
</v-col>
|
|
48
48
|
|
|
49
|
+
<v-col cols="12">
|
|
50
|
+
<!--
|
|
51
|
+
R5: a client builds a role out of up to 47 modules in a modal.
|
|
52
|
+
Matches the NAMES a person reads as well as the raw keys, so
|
|
53
|
+
"statements" and "soa" both find `SOA-mgmt`.
|
|
54
|
+
|
|
55
|
+
Display only - a permission ticked and then filtered out of view
|
|
56
|
+
is still ticked and still saved.
|
|
57
|
+
-->
|
|
58
|
+
<v-text-field
|
|
59
|
+
v-model="moduleSearch"
|
|
60
|
+
class="filter-field"
|
|
61
|
+
density="comfortable"
|
|
62
|
+
placeholder="Search modules and permissions"
|
|
63
|
+
prepend-inner-icon="mdi-magnify"
|
|
64
|
+
clearable
|
|
65
|
+
hide-details
|
|
66
|
+
/>
|
|
67
|
+
</v-col>
|
|
68
|
+
|
|
49
69
|
<v-col cols="12" class="mt-3">
|
|
50
70
|
<div class="role-create__list">
|
|
71
|
+
<div
|
|
72
|
+
v-if="!hasVisiblePermissions"
|
|
73
|
+
class="pa-6 text-center text-body-2 text-medium-emphasis"
|
|
74
|
+
>
|
|
75
|
+
No module matches “{{ moduleSearch }}”. Anything you
|
|
76
|
+
have already ticked is still selected and will still be saved.
|
|
77
|
+
</div>
|
|
78
|
+
|
|
51
79
|
<template
|
|
52
|
-
v-for="(actions, resourceKey, resourceIndex) in
|
|
80
|
+
v-for="(actions, resourceKey, resourceIndex) in visiblePermissions"
|
|
53
81
|
:key="resourceKey"
|
|
54
82
|
>
|
|
55
83
|
<v-divider v-if="resourceIndex > 0" />
|
|
@@ -235,27 +263,44 @@ function toggleAction(resource: string, action: string, value: boolean | null) {
|
|
|
235
263
|
}
|
|
236
264
|
|
|
237
265
|
function toggleSelectAll(value: boolean) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
266
|
+
/*
|
|
267
|
+
* Select All acts on what is SHOWN. With no search that is the whole
|
|
268
|
+
* catalogue, so this is unchanged for every screen that works today; with a
|
|
269
|
+
* search active it does what the words on the button say.
|
|
270
|
+
*
|
|
271
|
+
* Unselect All is the half that matters: it used to write `selected: []`,
|
|
272
|
+
* which with a search active would silently discard every tick outside the
|
|
273
|
+
* filter. It now removes only the visible keys.
|
|
274
|
+
*/
|
|
275
|
+
const perms = visiblePermissions.value;
|
|
244
276
|
if (!perms) return;
|
|
245
277
|
|
|
246
|
-
const
|
|
247
|
-
const
|
|
278
|
+
const visibleKeys: string[] = [];
|
|
279
|
+
const visibleResources: string[] = [];
|
|
248
280
|
|
|
249
281
|
for (const [resource, actions] of Object.entries(perms)) {
|
|
250
282
|
if (!resource || !actions || typeof actions !== "object") continue;
|
|
251
|
-
|
|
283
|
+
visibleResources.push(resource);
|
|
252
284
|
for (const action of Object.keys(actions)) {
|
|
253
|
-
if (action)
|
|
285
|
+
if (action) visibleKeys.push(`${resource}:${action}`);
|
|
254
286
|
}
|
|
255
287
|
}
|
|
256
288
|
|
|
289
|
+
const { selected, enabled } = permState.value;
|
|
290
|
+
|
|
291
|
+
if (!value) {
|
|
292
|
+
permState.value = {
|
|
293
|
+
selected: selected.filter((key) => !visibleKeys.includes(key)),
|
|
294
|
+
enabled: enabled.filter((resource) => !visibleResources.includes(resource)),
|
|
295
|
+
};
|
|
296
|
+
return;
|
|
297
|
+
}
|
|
298
|
+
|
|
257
299
|
// 1 assignment to trigger reactivity only once
|
|
258
|
-
permState.value = {
|
|
300
|
+
permState.value = {
|
|
301
|
+
selected: [...new Set([...selected, ...visibleKeys])],
|
|
302
|
+
enabled: [...new Set([...enabled, ...visibleResources])],
|
|
303
|
+
};
|
|
259
304
|
}
|
|
260
305
|
|
|
261
306
|
const siteName = ref("");
|
|
@@ -307,10 +352,61 @@ async function submit() {
|
|
|
307
352
|
function cancel() {
|
|
308
353
|
name.value = "";
|
|
309
354
|
permState.value = { selected: [], enabled: [] };
|
|
355
|
+
// A query left behind would greet the next person with a filtered list and
|
|
356
|
+
// no obvious reason for it.
|
|
357
|
+
moduleSearch.value = "";
|
|
310
358
|
message.value = "";
|
|
311
359
|
emit("cancel");
|
|
312
360
|
}
|
|
313
361
|
|
|
362
|
+
/*
|
|
363
|
+
* FINDING A MODULE IN A LIST OF 47 — owner requirement R5, 2026-09-10.
|
|
364
|
+
*
|
|
365
|
+
* A client builds a role out of the whole catalogue: up to 47 modules and about
|
|
366
|
+
* 127 actions, in a modal. Production has 238 distinct role names across 390
|
|
367
|
+
* roles, every one assembled by scrolling that list.
|
|
368
|
+
*
|
|
369
|
+
* The search matches the NAMES a person reads (`formatResourceLabel` /
|
|
370
|
+
* `formatActionLabel`) as well as the raw keys, so typing "statements" finds
|
|
371
|
+
* `SOA-mgmt` and typing "soa" finds it too.
|
|
372
|
+
*
|
|
373
|
+
* ## It filters the DISPLAY only
|
|
374
|
+
*
|
|
375
|
+
* `permState.selected` is what gets saved (`permissions: permState.value.selected`),
|
|
376
|
+
* and the search never touches it. A permission ticked and then filtered out of
|
|
377
|
+
* view is still ticked and still saved — losing a tick because somebody typed in
|
|
378
|
+
* a box would be far worse than the scrolling this replaces.
|
|
379
|
+
*/
|
|
380
|
+
const moduleSearch = ref("");
|
|
381
|
+
|
|
382
|
+
/** `safePermissions`, narrowed to what the search box matches. */
|
|
383
|
+
const visiblePermissions = computed(() => {
|
|
384
|
+
const query = moduleSearch.value.trim().toLowerCase();
|
|
385
|
+
const all = safePermissions.value;
|
|
386
|
+
if (!query) return all;
|
|
387
|
+
|
|
388
|
+
const matches: Record<string, any> = {};
|
|
389
|
+
for (const [resource, actions] of Object.entries(all)) {
|
|
390
|
+
const haystack = [
|
|
391
|
+
resource,
|
|
392
|
+
formatResourceLabel(resource),
|
|
393
|
+
...Object.keys(actions ?? {}).flatMap((action) => [
|
|
394
|
+
action,
|
|
395
|
+
formatActionLabel(action),
|
|
396
|
+
]),
|
|
397
|
+
]
|
|
398
|
+
.join(" ")
|
|
399
|
+
.toLowerCase();
|
|
400
|
+
|
|
401
|
+
if (haystack.includes(query)) matches[resource] = actions;
|
|
402
|
+
}
|
|
403
|
+
return matches;
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
const hasVisiblePermissions = computed(
|
|
407
|
+
() => Object.keys(visiblePermissions.value).length > 0
|
|
408
|
+
);
|
|
409
|
+
|
|
314
410
|
const safePermissions = computed(() => {
|
|
315
411
|
const p = props.permissions || {};
|
|
316
412
|
const cleaned: Record<string, any> = {};
|
|
@@ -327,7 +423,8 @@ const safePermissions = computed(() => {
|
|
|
327
423
|
});
|
|
328
424
|
|
|
329
425
|
const isAllSelected = computed(() => {
|
|
330
|
-
|
|
426
|
+
// The VISIBLE set, so the button's label describes the button's effect.
|
|
427
|
+
const perms = visiblePermissions.value;
|
|
331
428
|
const allKeys: string[] = [];
|
|
332
429
|
|
|
333
430
|
Object.entries(perms).forEach(([resource, actions]) => {
|
|
@@ -15,9 +15,32 @@
|
|
|
15
15
|
>
|
|
16
16
|
{{ isAllSelected ? "Unselect All" : "Select All" }}
|
|
17
17
|
</AppButton>
|
|
18
|
+
<!--
|
|
19
|
+
R5: the same search the create dialog has. Display only - a
|
|
20
|
+
permission ticked and then filtered out of view is still ticked
|
|
21
|
+
and still saved.
|
|
22
|
+
-->
|
|
23
|
+
<v-text-field
|
|
24
|
+
v-model="moduleSearch"
|
|
25
|
+
class="filter-field mb-2"
|
|
26
|
+
density="comfortable"
|
|
27
|
+
placeholder="Search modules and permissions"
|
|
28
|
+
prepend-inner-icon="mdi-magnify"
|
|
29
|
+
clearable
|
|
30
|
+
hide-details
|
|
31
|
+
/>
|
|
32
|
+
|
|
18
33
|
<div class="role-perm__list">
|
|
34
|
+
<div
|
|
35
|
+
v-if="!hasVisiblePermissions"
|
|
36
|
+
class="pa-6 text-center text-body-2 text-medium-emphasis"
|
|
37
|
+
>
|
|
38
|
+
No module matches “{{ moduleSearch }}”. Anything this
|
|
39
|
+
role already holds is untouched and will still be saved.
|
|
40
|
+
</div>
|
|
41
|
+
|
|
19
42
|
<template
|
|
20
|
-
v-for="(actions, resourceKey, resourceIndex) in
|
|
43
|
+
v-for="(actions, resourceKey, resourceIndex) in visiblePermissions"
|
|
21
44
|
:key="resourceKey"
|
|
22
45
|
>
|
|
23
46
|
<v-divider v-if="resourceIndex > 0" />
|
|
@@ -233,11 +256,60 @@ function toggleAction(resource: string, action: string, value: boolean | null) {
|
|
|
233
256
|
|
|
234
257
|
const safePermissions = computed(() => props.permissions || {});
|
|
235
258
|
|
|
259
|
+
/*
|
|
260
|
+
* FINDING A MODULE IN A LIST OF 47 — owner requirement R5, 2026-09-10. The same
|
|
261
|
+
* search the create dialog has, and deliberately the same rule: the two dialogs
|
|
262
|
+
* render the same tree, and a client who learns one must not find the other
|
|
263
|
+
* behaving differently.
|
|
264
|
+
*
|
|
265
|
+
* Matches the NAMES a person reads as well as the raw keys, so "statements" and
|
|
266
|
+
* "soa" both find `SOA-mgmt`.
|
|
267
|
+
*
|
|
268
|
+
* FILTERS THE DISPLAY ONLY. `definedModel` is what gets saved, and the search
|
|
269
|
+
* never touches it — a permission ticked and then filtered out of view is still
|
|
270
|
+
* ticked and still saved. That matters more here than in the create dialog:
|
|
271
|
+
* this one is editing a role somebody already relies on.
|
|
272
|
+
*/
|
|
273
|
+
const moduleSearch = ref("");
|
|
274
|
+
|
|
275
|
+
const visiblePermissions = computed(() => {
|
|
276
|
+
const query = moduleSearch.value.trim().toLowerCase();
|
|
277
|
+
const all = safePermissions.value;
|
|
278
|
+
if (!query) return all;
|
|
279
|
+
|
|
280
|
+
const matches: Record<string, any> = {};
|
|
281
|
+
for (const [resource, actions] of Object.entries(all)) {
|
|
282
|
+
const haystack = [
|
|
283
|
+
resource,
|
|
284
|
+
formatResourceLabel(resource),
|
|
285
|
+
...Object.keys((actions as Record<string, unknown>) ?? {}).flatMap(
|
|
286
|
+
(action) => [action, formatActionLabel(action)]
|
|
287
|
+
),
|
|
288
|
+
]
|
|
289
|
+
.join(" ")
|
|
290
|
+
.toLowerCase();
|
|
291
|
+
|
|
292
|
+
if (haystack.includes(query)) matches[resource] = actions;
|
|
293
|
+
}
|
|
294
|
+
return matches;
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
const hasVisiblePermissions = computed(
|
|
298
|
+
() => Object.keys(visiblePermissions.value).length > 0
|
|
299
|
+
);
|
|
300
|
+
|
|
301
|
+
/** The `resource:action` keys currently on screen. */
|
|
302
|
+
const visibleKeys = computed(() =>
|
|
303
|
+
Object.entries(visiblePermissions.value).flatMap(([resource, actions]) =>
|
|
304
|
+
Object.keys((actions as Record<string, unknown>) || {}).map(
|
|
305
|
+
(action) => `${resource}:${action}`
|
|
306
|
+
)
|
|
307
|
+
)
|
|
308
|
+
);
|
|
309
|
+
|
|
236
310
|
const isAllSelected = computed(() => {
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
Object.keys(actions || {}).map((action) => `${resource}:${action}`)
|
|
240
|
-
);
|
|
311
|
+
// The VISIBLE set, so the button's label describes the button's effect.
|
|
312
|
+
const keys = visibleKeys.value;
|
|
241
313
|
return (
|
|
242
314
|
keys.length > 0 &&
|
|
243
315
|
keys.every((key) => holdsPermission(definedModel.value, key))
|
|
@@ -245,17 +317,31 @@ const isAllSelected = computed(() => {
|
|
|
245
317
|
});
|
|
246
318
|
|
|
247
319
|
function toggleSelectAll(value: boolean) {
|
|
320
|
+
/*
|
|
321
|
+
* Acts on what is SHOWN. With no search that is the whole catalogue, so this
|
|
322
|
+
* is unchanged for every screen that works today.
|
|
323
|
+
*
|
|
324
|
+
* Unselect All is the half that matters: it used to write `[]`, which with a
|
|
325
|
+
* search active would silently discard every permission the role holds
|
|
326
|
+
* outside the filter — on a role somebody is already using.
|
|
327
|
+
*/
|
|
328
|
+
const keys = visibleKeys.value;
|
|
329
|
+
const resources = Object.keys(visiblePermissions.value);
|
|
330
|
+
|
|
248
331
|
if (!value) {
|
|
249
|
-
definedModel.value =
|
|
250
|
-
|
|
332
|
+
definedModel.value = definedModel.value.filter(
|
|
333
|
+
(key) => !keys.includes(key)
|
|
334
|
+
);
|
|
335
|
+
expandedResources.value = expandedResources.value.filter(
|
|
336
|
+
(resource) => !resources.includes(resource)
|
|
337
|
+
);
|
|
251
338
|
return;
|
|
252
339
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
expandedResources.value = Object.keys(safePermissions.value);
|
|
340
|
+
|
|
341
|
+
definedModel.value = [...new Set([...definedModel.value, ...keys])];
|
|
342
|
+
expandedResources.value = [
|
|
343
|
+
...new Set([...expandedResources.value, ...resources]),
|
|
344
|
+
];
|
|
259
345
|
}
|
|
260
346
|
|
|
261
347
|
const emit = defineEmits(["success", "cancel"]);
|
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.
|
|
5
|
+
"version": "4.5.1-staging.293",
|
|
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.",
|