@7365admin1/layer-common 4.10.1 → 4.10.3
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 +18 -4
- package/components/RolePermissionMain.vue +7 -2
- package/components/SwitchContext.vue +16 -4
- package/composables/useAreaPermission.ts +25 -1
- package/composables/useAttendancePermission.ts +24 -1
- package/composables/useBulletinBoardPermission.ts +23 -1
- package/composables/useEquipmentItemPermission.ts +25 -1
- package/composables/useEquipmentManagementPermission.ts +25 -1
- package/composables/useScheduleTaskPermission.ts +24 -1
- package/composables/useServiceProviderPermission.ts +21 -1
- package/composables/useUnitPermission.ts +25 -1
- package/package.json +1 -1
- package/utils/org-modules.ts +26 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @iservice365/layer-common
|
|
2
2
|
|
|
3
|
+
## 4.10.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- ab4fb5a: The client's module list now governs the permission gates this package spreads into the staff apps. `useAreaPermission`, `useUnitPermission`, `useAttendancePermission`, `useBulletinBoardPermission`, `useScheduleTaskPermission`, `useServiceProviderPermission`, `useEquipmentItemPermission` and `useEquipmentManagementPermission` — 43 gates — now ask the deny list immediately before their `*` short-circuit, the order `DashboardMain` already uses. The apps closed the same hole in their own gates, but these are re-exported from here and an app PR could not reach them (40 of hygiene's 47 spread-in gates, 43 of landscape's 43, 38 of M&E's 45).
|
|
8
|
+
|
|
9
|
+
Inert and fails open: no client has an enforced list, so an absent, empty or unreadable list denies nothing. `useSettingsPermission` is deliberately untouched (`site-settings` is always allowed and can never be denied), as are the schedule gates that match any `*-schedule-mgmt` string.
|
|
10
|
+
|
|
11
|
+
## 4.10.2
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- d0b5995: Role editor: a service provider editing its roles on a client's site is no longer narrowed by the client's site module list. The site tier applies only when the site belongs to the organisation whose roles are being edited; otherwise the organisation's own list applies, as before.
|
|
16
|
+
|
|
3
17
|
## 4.10.1
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
|
@@ -1053,11 +1067,11 @@
|
|
|
1053
1067
|
`utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
|
|
1054
1068
|
own rule from two endpoints the console already calls, unprojected:
|
|
1055
1069
|
|
|
1056
|
-
|
|
1057
|
-
|
|
1070
|
+
GET /api/members/user/:user/app/admin the Seven365 staff membership
|
|
1071
|
+
GET /api/roles/id/:role that membership's role document
|
|
1058
1072
|
|
|
1059
|
-
|
|
1060
|
-
|
|
1073
|
+
owner = member.type === "admin" && role.type === "admin" && role.default === true
|
|
1074
|
+
staff = member.type === "admin" && role.type === "admin"
|
|
1061
1075
|
|
|
1062
1076
|
`role.default` is the marker because it is the only property of a platform
|
|
1063
1077
|
staff role no API caller can set - `role.controller.ts` validates create and
|
|
@@ -203,7 +203,11 @@
|
|
|
203
203
|
// Relative import: this layer's `utils/` is not auto-imported into consumers.
|
|
204
204
|
import { showSiteField } from "../utils/role";
|
|
205
205
|
import { holdsPermission } from "../utils/permission-spellings";
|
|
206
|
-
import {
|
|
206
|
+
import {
|
|
207
|
+
catalogueForOrg,
|
|
208
|
+
effectiveModules,
|
|
209
|
+
siteModulesForOrg,
|
|
210
|
+
} from "../utils/org-modules";
|
|
207
211
|
|
|
208
212
|
const props = defineProps({
|
|
209
213
|
orgId: {
|
|
@@ -362,7 +366,8 @@ const offeredPermissions = computed(() =>
|
|
|
362
366
|
props.permissions ?? {},
|
|
363
367
|
effectiveModules(
|
|
364
368
|
(orgForModules.value as any)?.modules,
|
|
365
|
-
(
|
|
369
|
+
// Only the site's OWN organisation is narrowed by it (owner Q1).
|
|
370
|
+
siteModulesForOrg(siteForModules.value as any, props.orgId)
|
|
366
371
|
)
|
|
367
372
|
)
|
|
368
373
|
);
|
|
@@ -181,10 +181,22 @@ const emit = defineEmits(["search", "select", "manage", "add"]);
|
|
|
181
181
|
* are its problem to reject. It also means a duplicate arriving from any other
|
|
182
182
|
* caller is handled without waiting for that caller to notice.
|
|
183
183
|
*
|
|
184
|
-
* FIRST OCCURRENCE WINS,
|
|
185
|
-
*
|
|
186
|
-
* the
|
|
187
|
-
*
|
|
184
|
+
* FIRST OCCURRENCE WINS. This is a SAFETY NET, not the place the name is
|
|
185
|
+
* decided — and the original reasoning here was wrong, so it is worth stating
|
|
186
|
+
* plainly. I assumed the newer engagement row carried the current name; the
|
|
187
|
+
* owner corrected it. Site `6923d666…` is named "Seventh Condominium", and it is
|
|
188
|
+
* the NEWER row that still says "NCC" from an earlier name. RECENCY IS NO GUIDE
|
|
189
|
+
* to which snapshot is current.
|
|
190
|
+
*
|
|
191
|
+
* The name is now resolved SERVER-SIDE from the site record itself
|
|
192
|
+
* (`core customer-site.repo.ts getAll` looks the site up and projects its live
|
|
193
|
+
* name over the snapshot), and the same query returns one row per site. So by
|
|
194
|
+
* the time a list reaches this component the duplicate should already be gone
|
|
195
|
+
* and the label should already be right.
|
|
196
|
+
*
|
|
197
|
+
* This filter stays because a switcher must never offer the same destination
|
|
198
|
+
* twice whatever a caller hands it — a stale cache, an older API, or a caller
|
|
199
|
+
* that builds its list some other way.
|
|
188
200
|
*
|
|
189
201
|
* An item with no `value` is left alone: it cannot collide, and silently
|
|
190
202
|
* dropping it would hide a malformed row instead of showing it.
|
|
@@ -1,41 +1,65 @@
|
|
|
1
|
+
import { permissionsDenied } from "../utils/module-routes";
|
|
2
|
+
|
|
1
3
|
export function useAreaPermission() {
|
|
2
4
|
const { hasPermission } = usePermission();
|
|
3
5
|
const { permissions } = useCleaningPermission();
|
|
4
6
|
|
|
5
|
-
const { userAppRole } = useLocalSetup();
|
|
7
|
+
const { userAppRole, userAppModulesDenied } = useLocalSetup();
|
|
8
|
+
|
|
9
|
+
// THE CLIENT'S MODULE LIST (RP-5). A gate whose every module Seven365 did not
|
|
10
|
+
// give this client is closed. It is asked BEFORE the `*` short-circuit below,
|
|
11
|
+
// because a wildcard role is exactly the role a module list exists to narrow --
|
|
12
|
+
// the order `DashboardMain` already uses. Wrapping `hasPermission` instead
|
|
13
|
+
// would have missed every wildcard role, which is why the check is per gate.
|
|
14
|
+
//
|
|
15
|
+
// Inert today: no client has an enforced list, so the list is `[]` for
|
|
16
|
+
// everyone and this closes nothing. An absent, empty or unreadable list denies
|
|
17
|
+
// nothing -- it never reads as "hide everything".
|
|
18
|
+
//
|
|
19
|
+
// `?.` on purpose: an app pinned to an older layer-common, or any caller that
|
|
20
|
+
// stubs `useLocalSetup` without this field, hands back `undefined` here. That
|
|
21
|
+
// must mean "nothing denied", not a TypeError inside every gate.
|
|
22
|
+
const moduleDenied = (...modules: string[]) =>
|
|
23
|
+
permissionsDenied(modules, userAppModulesDenied?.value);
|
|
6
24
|
|
|
7
25
|
const canViewAreas = computed(() => {
|
|
8
26
|
if (!userAppRole.value) return false;
|
|
27
|
+
if (moduleDenied("area-mgmt")) return false;
|
|
9
28
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
10
29
|
return hasPermission(userAppRole.value, permissions, "area-mgmt", "see-all-areas");
|
|
11
30
|
});
|
|
12
31
|
|
|
13
32
|
const canCreateArea = computed(() => {
|
|
14
33
|
if (!userAppRole.value) return false;
|
|
34
|
+
if (moduleDenied("area-mgmt")) return false;
|
|
15
35
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
16
36
|
return hasPermission(userAppRole.value, permissions, "area-mgmt", "add-area");
|
|
17
37
|
});
|
|
18
38
|
|
|
19
39
|
const canUpdateArea = computed(() => {
|
|
20
40
|
if (!userAppRole.value) return false;
|
|
41
|
+
if (moduleDenied("area-mgmt")) return false;
|
|
21
42
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
22
43
|
return hasPermission(userAppRole.value, permissions, "area-mgmt", "update-area");
|
|
23
44
|
});
|
|
24
45
|
|
|
25
46
|
const canViewAreaDetails = computed(() => {
|
|
26
47
|
if (!userAppRole.value) return false;
|
|
48
|
+
if (moduleDenied("area-mgmt")) return false;
|
|
27
49
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
28
50
|
return hasPermission(userAppRole.value, permissions, "area-mgmt", "see-area-details");
|
|
29
51
|
});
|
|
30
52
|
|
|
31
53
|
const canImportArea = computed(() => {
|
|
32
54
|
if (!userAppRole.value) return false;
|
|
55
|
+
if (moduleDenied("area-mgmt")) return false;
|
|
33
56
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
34
57
|
return hasPermission(userAppRole.value, permissions, "area-mgmt", "import-areas");
|
|
35
58
|
});
|
|
36
59
|
|
|
37
60
|
const canDeleteArea = computed(() => {
|
|
38
61
|
if (!userAppRole.value) return false;
|
|
62
|
+
if (moduleDenied("area-mgmt")) return false;
|
|
39
63
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
40
64
|
return hasPermission(userAppRole.value, permissions, "area-mgmt", "delete-area");
|
|
41
65
|
});
|
|
@@ -1,10 +1,29 @@
|
|
|
1
|
+
import { permissionsDenied } from "../utils/module-routes";
|
|
2
|
+
|
|
1
3
|
export function useAttendancePermission() {
|
|
2
4
|
const { hasPermission } = usePermission();
|
|
3
5
|
const { permissions } = useCleaningPermission();
|
|
4
|
-
const { userAppRole } = useLocalSetup();
|
|
6
|
+
const { userAppRole, userAppModulesDenied } = useLocalSetup();
|
|
7
|
+
|
|
8
|
+
// THE CLIENT'S MODULE LIST (RP-5). A gate whose every module Seven365 did not
|
|
9
|
+
// give this client is closed. It is asked BEFORE the `*` short-circuit below,
|
|
10
|
+
// because a wildcard role is exactly the role a module list exists to narrow --
|
|
11
|
+
// the order `DashboardMain` already uses. Wrapping `hasPermission` instead
|
|
12
|
+
// would have missed every wildcard role, which is why the check is per gate.
|
|
13
|
+
//
|
|
14
|
+
// Inert today: no client has an enforced list, so the list is `[]` for
|
|
15
|
+
// everyone and this closes nothing. An absent, empty or unreadable list denies
|
|
16
|
+
// nothing -- it never reads as "hide everything".
|
|
17
|
+
//
|
|
18
|
+
// `?.` on purpose: an app pinned to an older layer-common, or any caller that
|
|
19
|
+
// stubs `useLocalSetup` without this field, hands back `undefined` here. That
|
|
20
|
+
// must mean "nothing denied", not a TypeError inside every gate.
|
|
21
|
+
const moduleDenied = (...modules: string[]) =>
|
|
22
|
+
permissionsDenied(modules, userAppModulesDenied?.value);
|
|
5
23
|
|
|
6
24
|
const canViewAllAttendance = computed(() => {
|
|
7
25
|
if (!userAppRole.value) return false;
|
|
26
|
+
if (moduleDenied("attendance-mgmt")) return false;
|
|
8
27
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
9
28
|
return hasPermission(
|
|
10
29
|
userAppRole.value,
|
|
@@ -16,6 +35,7 @@ export function useAttendancePermission() {
|
|
|
16
35
|
|
|
17
36
|
const canViewAttendanceDetails = computed(() => {
|
|
18
37
|
if (!userAppRole.value) return false;
|
|
38
|
+
if (moduleDenied("attendance-mgmt")) return false;
|
|
19
39
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
20
40
|
return hasPermission(
|
|
21
41
|
userAppRole.value,
|
|
@@ -27,6 +47,7 @@ export function useAttendancePermission() {
|
|
|
27
47
|
|
|
28
48
|
const canManageAttendanceSettings = computed(() => {
|
|
29
49
|
if (!userAppRole.value) return false;
|
|
50
|
+
if (moduleDenied("attendance-mgmt")) return false;
|
|
30
51
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
31
52
|
return hasPermission(
|
|
32
53
|
userAppRole.value,
|
|
@@ -38,6 +59,7 @@ export function useAttendancePermission() {
|
|
|
38
59
|
|
|
39
60
|
const canViewOwnAttendance = computed(() => {
|
|
40
61
|
if (!userAppRole.value) return false;
|
|
62
|
+
if (moduleDenied("my-attendance")) return false;
|
|
41
63
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
42
64
|
return hasPermission(
|
|
43
65
|
userAppRole.value,
|
|
@@ -49,6 +71,7 @@ export function useAttendancePermission() {
|
|
|
49
71
|
|
|
50
72
|
const canCheckInOut = computed(() => {
|
|
51
73
|
if (!userAppRole.value) return false;
|
|
74
|
+
if (moduleDenied("my-attendance")) return false;
|
|
52
75
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
53
76
|
return hasPermission(
|
|
54
77
|
userAppRole.value,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useCommonPermissions } from "./useCommonPermission";
|
|
2
|
+
import { permissionsDenied } from "../utils/module-routes";
|
|
2
3
|
|
|
3
4
|
export function useBulletinBoardPermission() {
|
|
4
5
|
const { hasPermission } = usePermission();
|
|
@@ -41,12 +42,29 @@ export function useBulletinBoardPermission() {
|
|
|
41
42
|
},
|
|
42
43
|
};
|
|
43
44
|
|
|
44
|
-
const { userAppRole } = useLocalSetup();
|
|
45
|
+
const { userAppRole, userAppModulesDenied } = useLocalSetup();
|
|
46
|
+
|
|
47
|
+
// THE CLIENT'S MODULE LIST (RP-5). A gate whose every module Seven365 did not
|
|
48
|
+
// give this client is closed. It is asked BEFORE the `*` short-circuit below,
|
|
49
|
+
// because a wildcard role is exactly the role a module list exists to narrow --
|
|
50
|
+
// the order `DashboardMain` already uses. Wrapping `hasPermission` instead
|
|
51
|
+
// would have missed every wildcard role, which is why the check is per gate.
|
|
52
|
+
//
|
|
53
|
+
// Inert today: no client has an enforced list, so the list is `[]` for
|
|
54
|
+
// everyone and this closes nothing. An absent, empty or unreadable list denies
|
|
55
|
+
// nothing -- it never reads as "hide everything".
|
|
56
|
+
//
|
|
57
|
+
// `?.` on purpose: an app pinned to an older layer-common, or any caller that
|
|
58
|
+
// stubs `useLocalSetup` without this field, hands back `undefined` here. That
|
|
59
|
+
// must mean "nothing denied", not a TypeError inside every gate.
|
|
60
|
+
const moduleDenied = (...modules: string[]) =>
|
|
61
|
+
permissionsDenied(modules, userAppModulesDenied?.value);
|
|
45
62
|
|
|
46
63
|
// Every gate fails closed while the role is still resolving: `userAppRole` is
|
|
47
64
|
// null on the first tick and a null role must never read as "allowed".
|
|
48
65
|
const canViewBulletinBoard = computed(() => {
|
|
49
66
|
if (!userAppRole.value) return false;
|
|
67
|
+
if (moduleDenied("bulletin-board", "bulletin-board-mgmt")) return false;
|
|
50
68
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
51
69
|
return (
|
|
52
70
|
hasPermission(userAppRole.value, permissions, "bulletin-board", "see-all-bulletin-boards") ||
|
|
@@ -57,6 +75,7 @@ export function useBulletinBoardPermission() {
|
|
|
57
75
|
|
|
58
76
|
const canCreateBulletinBoard = computed(() => {
|
|
59
77
|
if (!userAppRole.value) return false;
|
|
78
|
+
if (moduleDenied("bulletin-board", "bulletin-board-mgmt")) return false;
|
|
60
79
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
61
80
|
return (
|
|
62
81
|
hasPermission(userAppRole.value, permissions, "bulletin-board", "add-bulletin-board") ||
|
|
@@ -66,6 +85,7 @@ export function useBulletinBoardPermission() {
|
|
|
66
85
|
|
|
67
86
|
const canUpdateBulletinBoard = computed(() => {
|
|
68
87
|
if (!userAppRole.value) return false;
|
|
88
|
+
if (moduleDenied("bulletin-board", "bulletin-board-mgmt")) return false;
|
|
69
89
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
70
90
|
return (
|
|
71
91
|
hasPermission(userAppRole.value, permissions, "bulletin-board", "update-bulletin-board") ||
|
|
@@ -75,6 +95,7 @@ export function useBulletinBoardPermission() {
|
|
|
75
95
|
|
|
76
96
|
const canViewBulletinBoardDetails = computed(() => {
|
|
77
97
|
if (!userAppRole.value) return false;
|
|
98
|
+
if (moduleDenied("bulletin-board", "bulletin-board-mgmt")) return false;
|
|
78
99
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
79
100
|
return (
|
|
80
101
|
hasPermission(userAppRole.value, permissions, "bulletin-board", "see-bulletin-board-details") ||
|
|
@@ -84,6 +105,7 @@ export function useBulletinBoardPermission() {
|
|
|
84
105
|
|
|
85
106
|
const canDeleteBulletinBoard = computed(() => {
|
|
86
107
|
if (!userAppRole.value) return false;
|
|
108
|
+
if (moduleDenied("bulletin-board", "bulletin-board-mgmt")) return false;
|
|
87
109
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
88
110
|
return (
|
|
89
111
|
hasPermission(userAppRole.value, permissions, "bulletin-board", "delete-bulletin-board") ||
|
|
@@ -1,10 +1,29 @@
|
|
|
1
|
+
import { permissionsDenied } from "../utils/module-routes";
|
|
2
|
+
|
|
1
3
|
export function useEquipmentItemPermission() {
|
|
2
4
|
const { hasPermission } = usePermission();
|
|
3
5
|
const { permissions } = useCleaningPermission();
|
|
4
|
-
const { userAppRole } = useLocalSetup();
|
|
6
|
+
const { userAppRole, userAppModulesDenied } = useLocalSetup();
|
|
7
|
+
|
|
8
|
+
// THE CLIENT'S MODULE LIST (RP-5). A gate whose every module Seven365 did not
|
|
9
|
+
// give this client is closed. It is asked BEFORE the `*` short-circuit below,
|
|
10
|
+
// because a wildcard role is exactly the role a module list exists to narrow --
|
|
11
|
+
// the order `DashboardMain` already uses. Wrapping `hasPermission` instead
|
|
12
|
+
// would have missed every wildcard role, which is why the check is per gate.
|
|
13
|
+
//
|
|
14
|
+
// Inert today: no client has an enforced list, so the list is `[]` for
|
|
15
|
+
// everyone and this closes nothing. An absent, empty or unreadable list denies
|
|
16
|
+
// nothing -- it never reads as "hide everything".
|
|
17
|
+
//
|
|
18
|
+
// `?.` on purpose: an app pinned to an older layer-common, or any caller that
|
|
19
|
+
// stubs `useLocalSetup` without this field, hands back `undefined` here. That
|
|
20
|
+
// must mean "nothing denied", not a TypeError inside every gate.
|
|
21
|
+
const moduleDenied = (...modules: string[]) =>
|
|
22
|
+
permissionsDenied(modules, userAppModulesDenied?.value);
|
|
5
23
|
|
|
6
24
|
const canViewAllEquipmentItems = computed(() => {
|
|
7
25
|
if (!userAppRole.value) return false;
|
|
26
|
+
if (moduleDenied("checkout-item-mgmt")) return false;
|
|
8
27
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
9
28
|
return hasPermission(
|
|
10
29
|
userAppRole.value,
|
|
@@ -16,6 +35,7 @@ export function useEquipmentItemPermission() {
|
|
|
16
35
|
|
|
17
36
|
const canCreateEquipmentItem = computed(() => {
|
|
18
37
|
if (!userAppRole.value) return false;
|
|
38
|
+
if (moduleDenied("checkout-item-mgmt")) return false;
|
|
19
39
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
20
40
|
return hasPermission(
|
|
21
41
|
userAppRole.value,
|
|
@@ -27,6 +47,7 @@ export function useEquipmentItemPermission() {
|
|
|
27
47
|
|
|
28
48
|
const canUpdateEquipmentItem = computed(() => {
|
|
29
49
|
if (!userAppRole.value) return false;
|
|
50
|
+
if (moduleDenied("checkout-item-mgmt")) return false;
|
|
30
51
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
31
52
|
return hasPermission(
|
|
32
53
|
userAppRole.value,
|
|
@@ -38,6 +59,7 @@ export function useEquipmentItemPermission() {
|
|
|
38
59
|
|
|
39
60
|
const canApproveEquipmentItem = computed(() => {
|
|
40
61
|
if (!userAppRole.value) return false;
|
|
62
|
+
if (moduleDenied("checkout-item-mgmt")) return false;
|
|
41
63
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
42
64
|
return hasPermission(
|
|
43
65
|
userAppRole.value,
|
|
@@ -49,6 +71,7 @@ export function useEquipmentItemPermission() {
|
|
|
49
71
|
|
|
50
72
|
const canDisapproveEquipmentItem = computed(() => {
|
|
51
73
|
if (!userAppRole.value) return false;
|
|
74
|
+
if (moduleDenied("checkout-item-mgmt")) return false;
|
|
52
75
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
53
76
|
return hasPermission(
|
|
54
77
|
userAppRole.value,
|
|
@@ -60,6 +83,7 @@ export function useEquipmentItemPermission() {
|
|
|
60
83
|
|
|
61
84
|
const canViewEquipmentItemDetails = computed(() => {
|
|
62
85
|
if (!userAppRole.value) return false;
|
|
86
|
+
if (moduleDenied("checkout-item-mgmt")) return false;
|
|
63
87
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
64
88
|
return hasPermission(
|
|
65
89
|
userAppRole.value,
|
|
@@ -1,14 +1,32 @@
|
|
|
1
1
|
import useCleaningPermission from "./useCleaningPermission";
|
|
2
2
|
import { useLocalSetup } from "./useLocalSetup";
|
|
3
3
|
import usePermission from "./usePermission";
|
|
4
|
+
import { permissionsDenied } from "../utils/module-routes";
|
|
4
5
|
|
|
5
6
|
export function useEquipmentManagementPermission() {
|
|
6
7
|
const { hasPermission } = usePermission();
|
|
7
8
|
const { permissions } = useCleaningPermission();
|
|
8
|
-
const { userAppRole } = useLocalSetup();
|
|
9
|
+
const { userAppRole, userAppModulesDenied } = useLocalSetup();
|
|
10
|
+
|
|
11
|
+
// THE CLIENT'S MODULE LIST (RP-5). A gate whose every module Seven365 did not
|
|
12
|
+
// give this client is closed. It is asked BEFORE the `*` short-circuit below,
|
|
13
|
+
// because a wildcard role is exactly the role a module list exists to narrow --
|
|
14
|
+
// the order `DashboardMain` already uses. Wrapping `hasPermission` instead
|
|
15
|
+
// would have missed every wildcard role, which is why the check is per gate.
|
|
16
|
+
//
|
|
17
|
+
// Inert today: no client has an enforced list, so the list is `[]` for
|
|
18
|
+
// everyone and this closes nothing. An absent, empty or unreadable list denies
|
|
19
|
+
// nothing -- it never reads as "hide everything".
|
|
20
|
+
//
|
|
21
|
+
// `?.` on purpose: an app pinned to an older layer-common, or any caller that
|
|
22
|
+
// stubs `useLocalSetup` without this field, hands back `undefined` here. That
|
|
23
|
+
// must mean "nothing denied", not a TypeError inside every gate.
|
|
24
|
+
const moduleDenied = (...modules: string[]) =>
|
|
25
|
+
permissionsDenied(modules, userAppModulesDenied?.value);
|
|
9
26
|
|
|
10
27
|
const canViewEquipments = computed(() => {
|
|
11
28
|
if (!userAppRole.value) return false;
|
|
29
|
+
if (moduleDenied("supply-mgmt")) return false;
|
|
12
30
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
13
31
|
return hasPermission(
|
|
14
32
|
userAppRole.value,
|
|
@@ -20,6 +38,7 @@ export function useEquipmentManagementPermission() {
|
|
|
20
38
|
|
|
21
39
|
const canAddEquipment = computed(() => {
|
|
22
40
|
if (!userAppRole.value) return false;
|
|
41
|
+
if (moduleDenied("supply-mgmt")) return false;
|
|
23
42
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
24
43
|
return hasPermission(
|
|
25
44
|
userAppRole.value,
|
|
@@ -31,6 +50,7 @@ export function useEquipmentManagementPermission() {
|
|
|
31
50
|
|
|
32
51
|
const canUpdateEquipment = computed(() => {
|
|
33
52
|
if (!userAppRole.value) return false;
|
|
53
|
+
if (moduleDenied("supply-mgmt")) return false;
|
|
34
54
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
35
55
|
return hasPermission(
|
|
36
56
|
userAppRole.value,
|
|
@@ -42,6 +62,7 @@ export function useEquipmentManagementPermission() {
|
|
|
42
62
|
|
|
43
63
|
const canDeleteEquipment = computed(() => {
|
|
44
64
|
if (!userAppRole.value) return false;
|
|
65
|
+
if (moduleDenied("supply-mgmt")) return false;
|
|
45
66
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
46
67
|
return hasPermission(
|
|
47
68
|
userAppRole.value,
|
|
@@ -53,6 +74,7 @@ export function useEquipmentManagementPermission() {
|
|
|
53
74
|
|
|
54
75
|
const canAddStock = computed(() => {
|
|
55
76
|
if (!userAppRole.value) return false;
|
|
77
|
+
if (moduleDenied("supply-mgmt")) return false;
|
|
56
78
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
57
79
|
return hasPermission(
|
|
58
80
|
userAppRole.value,
|
|
@@ -64,6 +86,7 @@ export function useEquipmentManagementPermission() {
|
|
|
64
86
|
|
|
65
87
|
const canViewStock = computed(() => {
|
|
66
88
|
if (!userAppRole.value) return false;
|
|
89
|
+
if (moduleDenied("supply-mgmt")) return false;
|
|
67
90
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
68
91
|
return hasPermission(
|
|
69
92
|
userAppRole.value,
|
|
@@ -75,6 +98,7 @@ export function useEquipmentManagementPermission() {
|
|
|
75
98
|
|
|
76
99
|
const canRequestItem = computed(() => {
|
|
77
100
|
if (!userAppRole.value) return false;
|
|
101
|
+
if (moduleDenied("supply-mgmt")) return false;
|
|
78
102
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
79
103
|
return hasPermission(
|
|
80
104
|
userAppRole.value,
|
|
@@ -1,10 +1,29 @@
|
|
|
1
|
+
import { permissionsDenied } from "../utils/module-routes";
|
|
2
|
+
|
|
1
3
|
export default function useScheduleTaskPermission() {
|
|
2
4
|
const { hasPermission } = usePermission();
|
|
3
5
|
const { permissions } = useCleaningPermission();
|
|
4
|
-
const { userAppRole } = useLocalSetup();
|
|
6
|
+
const { userAppRole, userAppModulesDenied } = useLocalSetup();
|
|
7
|
+
|
|
8
|
+
// THE CLIENT'S MODULE LIST (RP-5). A gate whose every module Seven365 did not
|
|
9
|
+
// give this client is closed. It is asked BEFORE the `*` short-circuit below,
|
|
10
|
+
// because a wildcard role is exactly the role a module list exists to narrow --
|
|
11
|
+
// the order `DashboardMain` already uses. Wrapping `hasPermission` instead
|
|
12
|
+
// would have missed every wildcard role, which is why the check is per gate.
|
|
13
|
+
//
|
|
14
|
+
// Inert today: no client has an enforced list, so the list is `[]` for
|
|
15
|
+
// everyone and this closes nothing. An absent, empty or unreadable list denies
|
|
16
|
+
// nothing -- it never reads as "hide everything".
|
|
17
|
+
//
|
|
18
|
+
// `?.` on purpose: an app pinned to an older layer-common, or any caller that
|
|
19
|
+
// stubs `useLocalSetup` without this field, hands back `undefined` here. That
|
|
20
|
+
// must mean "nothing denied", not a TypeError inside every gate.
|
|
21
|
+
const moduleDenied = (...modules: string[]) =>
|
|
22
|
+
permissionsDenied(modules, userAppModulesDenied?.value);
|
|
5
23
|
|
|
6
24
|
const canViewScheduleTasks = computed(() => {
|
|
7
25
|
if (!userAppRole.value) return false;
|
|
26
|
+
if (moduleDenied("schedule-task-mgmt")) return false;
|
|
8
27
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
9
28
|
return hasPermission(
|
|
10
29
|
userAppRole.value,
|
|
@@ -16,6 +35,7 @@ export default function useScheduleTaskPermission() {
|
|
|
16
35
|
|
|
17
36
|
const canCreateScheduleTask = computed(() => {
|
|
18
37
|
if (!userAppRole.value) return false;
|
|
38
|
+
if (moduleDenied("schedule-task-mgmt")) return false;
|
|
19
39
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
20
40
|
return hasPermission(
|
|
21
41
|
userAppRole.value,
|
|
@@ -27,6 +47,7 @@ export default function useScheduleTaskPermission() {
|
|
|
27
47
|
|
|
28
48
|
const canUpdateScheduleTask = computed(() => {
|
|
29
49
|
if (!userAppRole.value) return false;
|
|
50
|
+
if (moduleDenied("schedule-task-mgmt")) return false;
|
|
30
51
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
31
52
|
return hasPermission(
|
|
32
53
|
userAppRole.value,
|
|
@@ -38,6 +59,7 @@ export default function useScheduleTaskPermission() {
|
|
|
38
59
|
|
|
39
60
|
const canDeleteScheduleTask = computed(() => {
|
|
40
61
|
if (!userAppRole.value) return false;
|
|
62
|
+
if (moduleDenied("schedule-task-mgmt")) return false;
|
|
41
63
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
42
64
|
return hasPermission(
|
|
43
65
|
userAppRole.value,
|
|
@@ -49,6 +71,7 @@ export default function useScheduleTaskPermission() {
|
|
|
49
71
|
|
|
50
72
|
const canViewScheduleTaskDetails = computed(() => {
|
|
51
73
|
if (!userAppRole.value) return false;
|
|
74
|
+
if (moduleDenied("schedule-task-mgmt")) return false;
|
|
52
75
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
53
76
|
return hasPermission(
|
|
54
77
|
userAppRole.value,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useCommonPermissions } from "./useCommonPermission";
|
|
2
|
+
import { permissionsDenied } from "../utils/module-routes";
|
|
2
3
|
|
|
3
4
|
export function useServiceProviderPermission() {
|
|
4
5
|
const { hasPermission } = usePermission();
|
|
@@ -26,24 +27,43 @@ export function useServiceProviderPermission() {
|
|
|
26
27
|
},
|
|
27
28
|
};
|
|
28
29
|
|
|
29
|
-
const { userAppRole } = useLocalSetup();
|
|
30
|
+
const { userAppRole, userAppModulesDenied } = useLocalSetup();
|
|
31
|
+
|
|
32
|
+
// THE CLIENT'S MODULE LIST (RP-5). A gate whose every module Seven365 did not
|
|
33
|
+
// give this client is closed. It is asked BEFORE the `*` short-circuit below,
|
|
34
|
+
// because a wildcard role is exactly the role a module list exists to narrow --
|
|
35
|
+
// the order `DashboardMain` already uses. Wrapping `hasPermission` instead
|
|
36
|
+
// would have missed every wildcard role, which is why the check is per gate.
|
|
37
|
+
//
|
|
38
|
+
// Inert today: no client has an enforced list, so the list is `[]` for
|
|
39
|
+
// everyone and this closes nothing. An absent, empty or unreadable list denies
|
|
40
|
+
// nothing -- it never reads as "hide everything".
|
|
41
|
+
//
|
|
42
|
+
// `?.` on purpose: an app pinned to an older layer-common, or any caller that
|
|
43
|
+
// stubs `useLocalSetup` without this field, hands back `undefined` here. That
|
|
44
|
+
// must mean "nothing denied", not a TypeError inside every gate.
|
|
45
|
+
const moduleDenied = (...modules: string[]) =>
|
|
46
|
+
permissionsDenied(modules, userAppModulesDenied?.value);
|
|
30
47
|
|
|
31
48
|
// Every gate fails closed while the role is still resolving: `userAppRole` is
|
|
32
49
|
// null on the first tick and a null role must never read as "allowed".
|
|
33
50
|
const canAddServiceProvider = computed(() => {
|
|
34
51
|
if (!userAppRole.value) return false;
|
|
52
|
+
if (moduleDenied("service-provider-mgmt", "service-provider")) return false;
|
|
35
53
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
36
54
|
return hasPermission(userAppRole.value, permissions, "service-provider-mgmt", "add-service-provider");
|
|
37
55
|
});
|
|
38
56
|
|
|
39
57
|
const canInviteServiceProvider = computed(() => {
|
|
40
58
|
if (!userAppRole.value) return false;
|
|
59
|
+
if (moduleDenied("service-provider-mgmt", "service-provider")) return false;
|
|
41
60
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
42
61
|
return hasPermission(userAppRole.value, permissions, "service-provider-mgmt", "invite-service-provider");
|
|
43
62
|
});
|
|
44
63
|
|
|
45
64
|
const canViewServiceProviders = computed(() => {
|
|
46
65
|
if (!userAppRole.value) return false;
|
|
66
|
+
if (moduleDenied("service-provider-mgmt", "service-provider")) return false;
|
|
47
67
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
48
68
|
return (
|
|
49
69
|
hasPermission(userAppRole.value, permissions, "service-provider-mgmt", "see-all-service-providers") ||
|
|
@@ -1,41 +1,65 @@
|
|
|
1
|
+
import { permissionsDenied } from "../utils/module-routes";
|
|
2
|
+
|
|
1
3
|
export function useUnitPermission() {
|
|
2
4
|
const { hasPermission } = usePermission();
|
|
3
5
|
const { permissions } = useCleaningPermission();
|
|
4
6
|
|
|
5
|
-
const { userAppRole } = useLocalSetup();
|
|
7
|
+
const { userAppRole, userAppModulesDenied } = useLocalSetup();
|
|
8
|
+
|
|
9
|
+
// THE CLIENT'S MODULE LIST (RP-5). A gate whose every module Seven365 did not
|
|
10
|
+
// give this client is closed. It is asked BEFORE the `*` short-circuit below,
|
|
11
|
+
// because a wildcard role is exactly the role a module list exists to narrow --
|
|
12
|
+
// the order `DashboardMain` already uses. Wrapping `hasPermission` instead
|
|
13
|
+
// would have missed every wildcard role, which is why the check is per gate.
|
|
14
|
+
//
|
|
15
|
+
// Inert today: no client has an enforced list, so the list is `[]` for
|
|
16
|
+
// everyone and this closes nothing. An absent, empty or unreadable list denies
|
|
17
|
+
// nothing -- it never reads as "hide everything".
|
|
18
|
+
//
|
|
19
|
+
// `?.` on purpose: an app pinned to an older layer-common, or any caller that
|
|
20
|
+
// stubs `useLocalSetup` without this field, hands back `undefined` here. That
|
|
21
|
+
// must mean "nothing denied", not a TypeError inside every gate.
|
|
22
|
+
const moduleDenied = (...modules: string[]) =>
|
|
23
|
+
permissionsDenied(modules, userAppModulesDenied?.value);
|
|
6
24
|
|
|
7
25
|
const canViewUnits = computed(() => {
|
|
8
26
|
if (!userAppRole.value) return false;
|
|
27
|
+
if (moduleDenied("unit-mgmt")) return false;
|
|
9
28
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
10
29
|
return hasPermission(userAppRole.value, permissions, "unit-mgmt", "see-all-units");
|
|
11
30
|
});
|
|
12
31
|
|
|
13
32
|
const canCreateUnit = computed(() => {
|
|
14
33
|
if (!userAppRole.value) return false;
|
|
34
|
+
if (moduleDenied("unit-mgmt")) return false;
|
|
15
35
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
16
36
|
return hasPermission(userAppRole.value, permissions, "unit-mgmt", "add-unit");
|
|
17
37
|
});
|
|
18
38
|
|
|
19
39
|
const canUpdateUnit = computed(() => {
|
|
20
40
|
if (!userAppRole.value) return false;
|
|
41
|
+
if (moduleDenied("unit-mgmt")) return false;
|
|
21
42
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
22
43
|
return hasPermission(userAppRole.value, permissions, "unit-mgmt", "update-unit");
|
|
23
44
|
});
|
|
24
45
|
|
|
25
46
|
const canViewUnitDetails = computed(() => {
|
|
26
47
|
if (!userAppRole.value) return false;
|
|
48
|
+
if (moduleDenied("unit-mgmt")) return false;
|
|
27
49
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
28
50
|
return hasPermission(userAppRole.value, permissions, "unit-mgmt", "see-unit-details");
|
|
29
51
|
});
|
|
30
52
|
|
|
31
53
|
const canDeleteUnit = computed(() => {
|
|
32
54
|
if (!userAppRole.value) return false;
|
|
55
|
+
if (moduleDenied("unit-mgmt")) return false;
|
|
33
56
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
34
57
|
return hasPermission(userAppRole.value, permissions, "unit-mgmt", "delete-unit");
|
|
35
58
|
});
|
|
36
59
|
|
|
37
60
|
const canImportUnit = computed(() => {
|
|
38
61
|
if (!userAppRole.value) return false;
|
|
62
|
+
if (moduleDenied("unit-mgmt")) return false;
|
|
39
63
|
if (userAppRole.value.permissions.includes("*")) return true;
|
|
40
64
|
return hasPermission(userAppRole.value, permissions, "unit-mgmt", "import-units");
|
|
41
65
|
});
|
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.10.
|
|
5
|
+
"version": "4.10.3",
|
|
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
|
@@ -187,6 +187,32 @@ export function effectiveModules(
|
|
|
187
187
|
return allowed.length ? allowed : org;
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
/**
|
|
191
|
+
* The site tier, but only for the organisation that OWNS the site.
|
|
192
|
+
*
|
|
193
|
+
* Owner Q1, 2026-09-11: a service provider's role editor follows the
|
|
194
|
+
* PROVIDER's own company modules, never the client's. A provider editing
|
|
195
|
+
* roles while working on a client's site passes that site's id, and the site
|
|
196
|
+
* list there is what the CLIENT chose for its own staff - so it must not
|
|
197
|
+
* narrow the provider. Only when the site belongs to the organisation whose
|
|
198
|
+
* roles are being edited does the site tier apply.
|
|
199
|
+
*
|
|
200
|
+
* Fails open: no site, no `orgId` on it, or no org to compare with all mean
|
|
201
|
+
* "no site tier", which leaves the organisation's own list in charge.
|
|
202
|
+
*/
|
|
203
|
+
export function siteModulesForOrg(
|
|
204
|
+
site: { orgId?: unknown; org?: unknown; metadata?: { modules?: unknown } } | null | undefined,
|
|
205
|
+
orgId: unknown,
|
|
206
|
+
): readonly string[] | undefined {
|
|
207
|
+
// `org` is the legacy field name; core reads `orgId ?? org` the same way.
|
|
208
|
+
const siteOrg = String(site?.orgId ?? site?.org ?? "");
|
|
209
|
+
const org = String(orgId ?? "");
|
|
210
|
+
if (!siteOrg || !org || siteOrg !== org) return undefined;
|
|
211
|
+
|
|
212
|
+
const modules = site?.metadata?.modules;
|
|
213
|
+
return Array.isArray(modules) ? modules : undefined;
|
|
214
|
+
}
|
|
215
|
+
|
|
190
216
|
function isKey(value: unknown): value is string {
|
|
191
217
|
return typeof value === "string" && value.trim().length > 0;
|
|
192
218
|
}
|