@7365admin1/layer-common 4.5.1-staging.302 → 4.5.1-staging.303
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.
|
@@ -108,6 +108,41 @@
|
|
|
108
108
|
</template>
|
|
109
109
|
</template>
|
|
110
110
|
</div>
|
|
111
|
+
|
|
112
|
+
<!--
|
|
113
|
+
F5: grants the role HOLDS that this client's module list no
|
|
114
|
+
longer offers. Read-only: nothing here can be ticked or unticked,
|
|
115
|
+
and saving keeps them exactly as stored.
|
|
116
|
+
-->
|
|
117
|
+
<div v-if="hasNotOffered" class="role-perm__not-offered mt-4">
|
|
118
|
+
<div class="role-perm__row-title mb-1">
|
|
119
|
+
Granted — not offered to this client
|
|
120
|
+
</div>
|
|
121
|
+
<div class="role-perm__row-sub mb-2">
|
|
122
|
+
This role still holds these. They are outside this client's
|
|
123
|
+
modules, so they cannot be changed here, and saving keeps them.
|
|
124
|
+
</div>
|
|
125
|
+
<div class="role-perm__list">
|
|
126
|
+
<template
|
|
127
|
+
v-for="(actions, resourceKey, resourceIndex) in props.notOfferedPermissions"
|
|
128
|
+
:key="resourceKey"
|
|
129
|
+
>
|
|
130
|
+
<v-divider v-if="resourceIndex > 0" />
|
|
131
|
+
<v-list-item density="compact" :ripple="false">
|
|
132
|
+
<v-list-item-title class="text-capitalize role-perm__row-title">
|
|
133
|
+
{{ formatResourceLabel(String(resourceKey)) }}
|
|
134
|
+
</v-list-item-title>
|
|
135
|
+
<v-list-item-subtitle class="role-perm__row-sub">
|
|
136
|
+
{{
|
|
137
|
+
Object.keys(actions || {})
|
|
138
|
+
.map((action) => formatActionLabel(action))
|
|
139
|
+
.join(", ")
|
|
140
|
+
}}
|
|
141
|
+
</v-list-item-subtitle>
|
|
142
|
+
</v-list-item>
|
|
143
|
+
</template>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
111
146
|
<div v-if="errorMessages" class="role-perm__error mt-2">
|
|
112
147
|
{{ errorMessages }}
|
|
113
148
|
</div>
|
|
@@ -175,6 +210,12 @@ const props = defineProps({
|
|
|
175
210
|
type: Object,
|
|
176
211
|
default: () => ({}),
|
|
177
212
|
},
|
|
213
|
+
// F5: held grants outside the client's offer, `{ resource: { action } }`.
|
|
214
|
+
// Display only -- never part of the tree the toggles act on.
|
|
215
|
+
notOfferedPermissions: {
|
|
216
|
+
type: Object,
|
|
217
|
+
default: () => ({}),
|
|
218
|
+
},
|
|
178
219
|
// "Update role". This dialog had no permission prop at all, so it showed Edit
|
|
179
220
|
// to everyone -- including on the seeded platform-owner role -- and the
|
|
180
221
|
// `canUpdateRole` the apps have been passing to `RolePermissionMain` in good
|
|
@@ -294,6 +335,10 @@ const visiblePermissions = computed(() => {
|
|
|
294
335
|
return matches;
|
|
295
336
|
});
|
|
296
337
|
|
|
338
|
+
const hasNotOffered = computed(
|
|
339
|
+
() => Object.keys(props.notOfferedPermissions || {}).length > 0
|
|
340
|
+
);
|
|
341
|
+
|
|
297
342
|
const hasVisiblePermissions = computed(
|
|
298
343
|
() => Object.keys(visiblePermissions.value).length > 0
|
|
299
344
|
);
|
|
@@ -112,6 +112,7 @@
|
|
|
112
112
|
@success="successfulUpdate()"
|
|
113
113
|
:permissions="Permissions"
|
|
114
114
|
:original-permissions="originalPermissions"
|
|
115
|
+
:not-offered-permissions="heldNotOffered"
|
|
115
116
|
v-model="selectedPermissions"
|
|
116
117
|
v-model:edit="edit"
|
|
117
118
|
:name="name"
|
|
@@ -572,6 +573,25 @@ const Permissions = computed(() => {
|
|
|
572
573
|
: filterPermissions(offeredPermissions.value, originalPermissions.value);
|
|
573
574
|
});
|
|
574
575
|
|
|
576
|
+
/*
|
|
577
|
+
* F5: WHAT THE ROLE HOLDS THAT THIS CLIENT IS NO LONGER OFFERED.
|
|
578
|
+
*
|
|
579
|
+
* The tree above is the narrowed catalogue, so a grant outside the client's
|
|
580
|
+
* module list simply vanished from it and the role LOOKED as if it lacked a
|
|
581
|
+
* module it still holds. The dialog lists these separately, read-only. Saving
|
|
582
|
+
* keeps them: the dialog's model is the full stored array and every toggle only
|
|
583
|
+
* touches keys in the tree. Empty (the same object) whenever nothing is narrowed.
|
|
584
|
+
*/
|
|
585
|
+
const heldNotOffered = computed(() => {
|
|
586
|
+
const all = (props.permissions ?? {}) as TPermissions;
|
|
587
|
+
const offered = offeredPermissions.value as TPermissions;
|
|
588
|
+
if (offered === all) return {};
|
|
589
|
+
const outside = Object.fromEntries(
|
|
590
|
+
Object.entries(all).filter(([resource]) => !(resource in offered))
|
|
591
|
+
) as TPermissions;
|
|
592
|
+
return filterPermissions(outside, originalPermissions.value);
|
|
593
|
+
});
|
|
594
|
+
|
|
575
595
|
function successfulUpdate() {
|
|
576
596
|
const savedPermissions = [...selectedPermissions.value];
|
|
577
597
|
|
|
@@ -21,6 +21,46 @@ export default function useCleaningPermission() {
|
|
|
21
21
|
invitations: invitationPermissions,
|
|
22
22
|
"bulletin-board": bulletinBoardPermissions,
|
|
23
23
|
|
|
24
|
+
// Owner decision 3A, 2026-09-11: Emergency Contacts is offered in the
|
|
25
|
+
// Cleaning role editor. Exactly the seven actions `constants/permissions.ts`
|
|
26
|
+
// defines; descriptions from `usePropertyPermission`. The long spelling
|
|
27
|
+
// `see-all-emergency-contacts` is deliberately NOT added -- the hygiene app
|
|
28
|
+
// already accepts `see-all`, and a second "see all" row would only confuse.
|
|
29
|
+
"emergency-contact": {
|
|
30
|
+
"see-all": {
|
|
31
|
+
check: true,
|
|
32
|
+
description: "Allows the user to view the list of all emergency contacts.",
|
|
33
|
+
},
|
|
34
|
+
"see-details": {
|
|
35
|
+
check: true,
|
|
36
|
+
description:
|
|
37
|
+
"Allows the user to view the details of a specific emergency contact.",
|
|
38
|
+
},
|
|
39
|
+
"add-emergency-contact": {
|
|
40
|
+
check: true,
|
|
41
|
+
description: "Allows the user to add a new emergency contact to the system.",
|
|
42
|
+
},
|
|
43
|
+
"update-emergency-contact": {
|
|
44
|
+
check: true,
|
|
45
|
+
description: "Allows the user to update emergency contact details.",
|
|
46
|
+
},
|
|
47
|
+
"delete-emergency-contact": {
|
|
48
|
+
check: true,
|
|
49
|
+
description:
|
|
50
|
+
"Allows the user to remove an emergency contact from the system permanently.",
|
|
51
|
+
},
|
|
52
|
+
"add-emergency-contact-category": {
|
|
53
|
+
check: true,
|
|
54
|
+
description:
|
|
55
|
+
"Allows the user to add a new emergency contact category to the system.",
|
|
56
|
+
},
|
|
57
|
+
"delete-emergency-contact-category": {
|
|
58
|
+
check: true,
|
|
59
|
+
description:
|
|
60
|
+
"Allows the user to delete an emergency contact category from the system.",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
|
|
24
64
|
// `hasPermission` looks an action up as `catalogue[resource][action]`, so a
|
|
25
65
|
// resource with no key here can never answer anything but `false` -- the
|
|
26
66
|
// gate is then reachable only through the `"*"` short-circuit. These two
|
|
@@ -39,6 +39,41 @@ export default function useLandscapingPermission() {
|
|
|
39
39
|
work_orders: workOrderPermissions,
|
|
40
40
|
"bulletin-board": bulletinBoardPermissions,
|
|
41
41
|
"service-provider-mgmt": serviceProviderPermissions,
|
|
42
|
+
// Owner decision 3A, 2026-09-11: Emergency Contacts is offered in the
|
|
43
|
+
// Landscape role editor. Exactly the seven actions `constants/permissions.ts`
|
|
44
|
+
// defines; descriptions from `usePropertyPermission`. The long spelling
|
|
45
|
+
// `see-all-emergency-contacts` is deliberately NOT added -- the landscape app
|
|
46
|
+
// already accepts `see-all`, and a second "see all" row would only confuse.
|
|
47
|
+
"emergency-contact": {
|
|
48
|
+
"see-all": {
|
|
49
|
+
check: true,
|
|
50
|
+
description: "Allows the user to view the list of all emergency contacts.",
|
|
51
|
+
},
|
|
52
|
+
"see-details": {
|
|
53
|
+
check: true,
|
|
54
|
+
description: "Allows the user to view the details of a specific emergency contact.",
|
|
55
|
+
},
|
|
56
|
+
"add-emergency-contact": {
|
|
57
|
+
check: true,
|
|
58
|
+
description: "Allows the user to add a new emergency contact to the system.",
|
|
59
|
+
},
|
|
60
|
+
"update-emergency-contact": {
|
|
61
|
+
check: true,
|
|
62
|
+
description: "Allows the user to update emergency contact details.",
|
|
63
|
+
},
|
|
64
|
+
"delete-emergency-contact": {
|
|
65
|
+
check: true,
|
|
66
|
+
description: "Allows the user to remove an emergency contact from the system permanently.",
|
|
67
|
+
},
|
|
68
|
+
"add-emergency-contact-category": {
|
|
69
|
+
check: true,
|
|
70
|
+
description: "Allows the user to add a new emergency contact category to the system.",
|
|
71
|
+
},
|
|
72
|
+
"delete-emergency-contact-category": {
|
|
73
|
+
check: true,
|
|
74
|
+
description: "Allows the user to delete an emergency contact category from the system.",
|
|
75
|
+
},
|
|
76
|
+
},
|
|
42
77
|
inventory: {
|
|
43
78
|
"view-inventory": {
|
|
44
79
|
check: true,
|
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.1-staging.
|
|
5
|
+
"version": "4.5.1-staging.303",
|
|
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.",
|
package/utils/org-modules.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* The client half of `core src/utils/org-modules.util.ts`, and deliberately a
|
|
5
5
|
* COPY rather than an import: this package cannot depend on `@7365admin1/core`
|
|
6
6
|
* (it is the frontend layer, and `core` is a server package). The copy is
|
|
7
|
-
*
|
|
7
|
+
* short and fails open, and `test/org-module-catalogue.test.mjs` pins it
|
|
8
8
|
* against the same cases the server's tests use.
|
|
9
9
|
*
|
|
10
10
|
* ## What this is for
|
|
@@ -29,7 +29,75 @@
|
|
|
29
29
|
* would empty the role editor for every client the moment it deployed. It fails
|
|
30
30
|
* open on every uncertainty — a missing list, a non-array, an unreadable key,
|
|
31
31
|
* and a list that matches nothing at all.
|
|
32
|
+
*
|
|
33
|
+
* ## Spelling groups and the always-allowed set (plan S2, 2026-09-11)
|
|
34
|
+
*
|
|
35
|
+
* Both only WIDEN. A module is offered if the list names it under ANY spelling
|
|
36
|
+
* of the same module, and the modules every client needs to run its own
|
|
37
|
+
* organisation are offered whatever the list says.
|
|
32
38
|
*/
|
|
39
|
+
import { LEGACY_PERMISSION_ALIASES } from "../constants/permissions.ts";
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Offered to every client whatever its module list says: without them a client
|
|
43
|
+
* cannot manage its own people, roles, sites or billing. Same set as core's
|
|
44
|
+
* `ALWAYS_ALLOWED` (defined in `org-modules.util.ts`, re-exported from
|
|
45
|
+
* `module-gate.util.ts`).
|
|
46
|
+
*/
|
|
47
|
+
export const ALWAYS_ALLOWED_MODULES: readonly string[] = Object.freeze([
|
|
48
|
+
"sites",
|
|
49
|
+
"subscriptions",
|
|
50
|
+
"customers",
|
|
51
|
+
"payment-methods",
|
|
52
|
+
"members",
|
|
53
|
+
"invitations",
|
|
54
|
+
"roles",
|
|
55
|
+
"roles-and-permissions",
|
|
56
|
+
"site-settings",
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The one pair the alias map does not carry. iMA365 gates Online Forms on
|
|
61
|
+
* `online-forms` while roles hold `online-form-configuration` (production,
|
|
62
|
+
* 2026-09-10: 33 roles against 1), and the app already treats the two as one
|
|
63
|
+
* module (`permission.utils.ts` RESOURCE_ALIASES). Both keys exist in the
|
|
64
|
+
* catalogues; grouping them only widens. core `SPELLING_GROUPS` (defined in
|
|
65
|
+
* `org-modules.util.ts`, re-exported from `module-gate.util.ts`) carries the
|
|
66
|
+
* same pair.
|
|
67
|
+
*/
|
|
68
|
+
const EXTRA_SPELLING_GROUPS: readonly (readonly [string, ...string[]])[] = [
|
|
69
|
+
["online-form-configuration", "online-forms"],
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Resource keys that are the SAME module under different spellings — e.g.
|
|
74
|
+
* `workOrder` / `work_order` / `work-orders` / `work_orders`.
|
|
75
|
+
*
|
|
76
|
+
* DERIVED from `LEGACY_PERMISSION_ALIASES` (every alias whose resource differs
|
|
77
|
+
* from its canonical resource), never hand-written, so a spelling cannot be
|
|
78
|
+
* invented here and a new alias is picked up without touching this file.
|
|
79
|
+
*/
|
|
80
|
+
export const MODULE_SPELLING_GROUPS: readonly (readonly string[])[] = (() => {
|
|
81
|
+
const groups = new Map<string, Set<string>>();
|
|
82
|
+
for (const [legacy, canonical] of Object.entries(LEGACY_PERMISSION_ALIASES)) {
|
|
83
|
+
const from = legacy.split(":")[0];
|
|
84
|
+
const to = canonical.split(":")[0];
|
|
85
|
+
if (from === to) continue;
|
|
86
|
+
const group = groups.get(to) ?? new Set([to]);
|
|
87
|
+
group.add(from);
|
|
88
|
+
groups.set(to, group);
|
|
89
|
+
}
|
|
90
|
+
for (const [canonical, ...others] of EXTRA_SPELLING_GROUPS) {
|
|
91
|
+
const group = groups.get(canonical) ?? new Set([canonical]);
|
|
92
|
+
others.forEach((key) => group.add(key));
|
|
93
|
+
groups.set(canonical, group);
|
|
94
|
+
}
|
|
95
|
+
return Object.freeze([...groups.values()].map((group) => Object.freeze([...group])));
|
|
96
|
+
})();
|
|
97
|
+
|
|
98
|
+
function spellingsOf(key: string): readonly string[] {
|
|
99
|
+
return MODULE_SPELLING_GROUPS.find((group) => group.includes(key)) ?? [key];
|
|
100
|
+
}
|
|
33
101
|
|
|
34
102
|
/** May this client's role editor OFFER this module? Fails open. */
|
|
35
103
|
export function orgAllowsModule(
|
|
@@ -40,8 +108,9 @@ export function orgAllowsModule(
|
|
|
40
108
|
|
|
41
109
|
const key = typeof resource === "string" ? resource.trim() : "";
|
|
42
110
|
if (!key) return true;
|
|
111
|
+
if (ALWAYS_ALLOWED_MODULES.includes(key)) return true;
|
|
43
112
|
|
|
44
|
-
return modules.includes(
|
|
113
|
+
return spellingsOf(key).some((spelling) => modules.includes(spelling));
|
|
45
114
|
}
|
|
46
115
|
|
|
47
116
|
/**
|
|
@@ -58,19 +127,28 @@ export function catalogueForOrg<T extends Record<string, unknown>>(
|
|
|
58
127
|
if (!Array.isArray(modules) || modules.length === 0) return catalogue;
|
|
59
128
|
if (!catalogue || typeof catalogue !== "object") return catalogue;
|
|
60
129
|
|
|
61
|
-
const narrowed: Record<string, unknown> = {};
|
|
62
|
-
for (const [resource, actions] of Object.entries(catalogue)) {
|
|
63
|
-
if (orgAllowsModule(modules, resource)) narrowed[resource] = actions;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
130
|
/*
|
|
67
131
|
* A list that matched NOTHING shows the whole catalogue rather than an empty
|
|
68
132
|
* one. A blank role editor is indistinguishable from a broken screen, and the
|
|
69
133
|
* likeliest cause of matching nothing is a console typo or a catalogue whose
|
|
70
134
|
* resource keys were renamed — neither of which should take the editor away
|
|
71
135
|
* from the client.
|
|
136
|
+
*
|
|
137
|
+
* "Matched" is decided on the list AS TYPED — the rule from before the
|
|
138
|
+
* spelling groups and the always-allowed set existed. Deciding it on the
|
|
139
|
+
* widened rule would let `members` (in every catalogue) turn this fallback
|
|
140
|
+
* into a narrowed editor; this way both additions can only ADD.
|
|
72
141
|
*/
|
|
73
|
-
|
|
142
|
+
const matchedAsTyped = Object.keys(catalogue).some(
|
|
143
|
+
(resource) => !resource.trim() || modules.includes(resource.trim()),
|
|
144
|
+
);
|
|
145
|
+
if (!matchedAsTyped) return catalogue;
|
|
146
|
+
|
|
147
|
+
const narrowed: Record<string, unknown> = {};
|
|
148
|
+
for (const [resource, actions] of Object.entries(catalogue)) {
|
|
149
|
+
if (orgAllowsModule(modules, resource)) narrowed[resource] = actions;
|
|
150
|
+
}
|
|
151
|
+
return narrowed as T;
|
|
74
152
|
}
|
|
75
153
|
|
|
76
154
|
/**
|