@7365admin1/layer-common 4.35.1-staging.387 → 4.35.1-staging.388
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.
|
@@ -46,9 +46,10 @@
|
|
|
46
46
|
<v-col cols="12">
|
|
47
47
|
<v-autocomplete
|
|
48
48
|
v-model="invite.role"
|
|
49
|
-
:items="
|
|
50
|
-
item-title="
|
|
49
|
+
:items="roleOptions"
|
|
50
|
+
item-title="title"
|
|
51
51
|
item-value="_id"
|
|
52
|
+
:item-props="(item: any) => ({ subtitle: item.subtitle })"
|
|
52
53
|
:rules="[requiredRule]"
|
|
53
54
|
class="filter-field"
|
|
54
55
|
density="comfortable"
|
|
@@ -61,7 +62,23 @@
|
|
|
61
62
|
<v-row no-gutters>
|
|
62
63
|
<InputLabel class="text-capitalize" title="Site" />
|
|
63
64
|
<v-col cols="12">
|
|
65
|
+
<!--
|
|
66
|
+
Inviting from inside a site invites INTO that site. The owner
|
|
67
|
+
(2026-09-25): other sites in this list were confusing, so the
|
|
68
|
+
site is shown, not chosen.
|
|
69
|
+
-->
|
|
70
|
+
<v-text-field
|
|
71
|
+
v-if="fixedSite"
|
|
72
|
+
:model-value="invite.siteName || 'This site'"
|
|
73
|
+
class="filter-field"
|
|
74
|
+
density="comfortable"
|
|
75
|
+
readonly
|
|
76
|
+
hint="Invitations from this site are for this site."
|
|
77
|
+
persistent-hint
|
|
78
|
+
data-test="invite-fixed-site"
|
|
79
|
+
></v-text-field>
|
|
64
80
|
<v-autocomplete
|
|
81
|
+
v-else
|
|
65
82
|
v-model="invite.site"
|
|
66
83
|
:items="sites"
|
|
67
84
|
class="filter-field"
|
|
@@ -133,6 +150,8 @@ import useCustomerSite from '../composables/useCustomerSite';
|
|
|
133
150
|
import useLocal from '../composables/useLocal';
|
|
134
151
|
import { useLocalSetup } from '../composables/useLocalSetup';
|
|
135
152
|
import useRole from '../composables/useRole';
|
|
153
|
+
import useSite from '../composables/useSite';
|
|
154
|
+
import { inviteRoleOptions } from '../utils/invite-role-options';
|
|
136
155
|
import useUser from '../composables/useUser';
|
|
137
156
|
import useUtils from '../composables/useUtils';
|
|
138
157
|
|
|
@@ -169,6 +188,16 @@ const props = defineProps({
|
|
|
169
188
|
* which is about the site created in step 4) had no way to say so. It is
|
|
170
189
|
* wired to `invite` below.
|
|
171
190
|
*/
|
|
191
|
+
/*
|
|
192
|
+
* The site the invitation is being made FROM (every site-level Invitations
|
|
193
|
+
* page passes it through InvitationMain). When set, the Site field is fixed
|
|
194
|
+
* to it and the Role list is that site's roles plus the organisation-wide
|
|
195
|
+
* ones.
|
|
196
|
+
*/
|
|
197
|
+
siteId: {
|
|
198
|
+
type: String,
|
|
199
|
+
default: "",
|
|
200
|
+
},
|
|
172
201
|
site: {
|
|
173
202
|
type: Object as PropType<TCustomerSite>,
|
|
174
203
|
default: () => ({
|
|
@@ -262,6 +291,18 @@ watch(
|
|
|
262
291
|
},
|
|
263
292
|
{ immediate: true, deep: true }
|
|
264
293
|
)
|
|
294
|
+
|
|
295
|
+
/* The site this form is fixed to, if any: the page's site, or onboarding's. */
|
|
296
|
+
const fixedSite = computed(() => props.siteId || props.site?.site || "")
|
|
297
|
+
|
|
298
|
+
watch(
|
|
299
|
+
() => props.siteId,
|
|
300
|
+
(siteId) => {
|
|
301
|
+
if (!siteId) return
|
|
302
|
+
invite.value.site = siteId
|
|
303
|
+
},
|
|
304
|
+
{ immediate: true }
|
|
305
|
+
)
|
|
265
306
|
// invite.value.app = props.app;
|
|
266
307
|
// invite.value.org = props.org ?? "";
|
|
267
308
|
|
|
@@ -357,6 +398,27 @@ watchEffect(() => {
|
|
|
357
398
|
}
|
|
358
399
|
});
|
|
359
400
|
|
|
401
|
+
/* Name the fixed site: from the organisation's site list, else read it. */
|
|
402
|
+
const { getSiteById } = useSite();
|
|
403
|
+
watch(
|
|
404
|
+
[fixedSite, sites],
|
|
405
|
+
async ([siteId]) => {
|
|
406
|
+
if (!siteId || invite.value.siteName) return
|
|
407
|
+
const listed = sites.value.find((x) => x?.value === siteId)
|
|
408
|
+
if (listed?.title) {
|
|
409
|
+
invite.value.siteName = listed.title
|
|
410
|
+
return
|
|
411
|
+
}
|
|
412
|
+
try {
|
|
413
|
+
const site: any = await getSiteById(siteId)
|
|
414
|
+
invite.value.siteName = site?.name || site?.data?.name || ""
|
|
415
|
+
} catch {
|
|
416
|
+
// The field still reads "This site"; the invitation carries the id.
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
{ immediate: true }
|
|
420
|
+
)
|
|
421
|
+
|
|
360
422
|
watchEffect(() => {
|
|
361
423
|
if (hasSite.value) {
|
|
362
424
|
refreshSiteData();
|
|
@@ -384,26 +446,47 @@ const roles = ref<Array<Record<string, any>>>([]);
|
|
|
384
446
|
*/
|
|
385
447
|
const { getInvitableRoles } = useRole();
|
|
386
448
|
|
|
449
|
+
/*
|
|
450
|
+
* 2026-09-25 (owner report, Wing Tai / Winsland House I): the list now asks for
|
|
451
|
+
* the app actually being invited into (`invite.app`, which the App field can
|
|
452
|
+
* change - it used to keep asking for `props.app`) and for the chosen site, so
|
|
453
|
+
* it holds only this organisation's roles for this app and site. The org-less
|
|
454
|
+
* templates are gone from any invitation that names an organisation - the
|
|
455
|
+
* server refuses them there (`core roleInvitable`).
|
|
456
|
+
*/
|
|
387
457
|
const { data: RolesData, refresh: refreshRoles } = await useLazyAsyncData(
|
|
388
|
-
"get-roles-by-type-" + props.org + "-" + props.app,
|
|
458
|
+
"get-roles-by-type-" + props.org + "-" + props.app + "-" + fixedSite.value,
|
|
389
459
|
() =>
|
|
390
460
|
getInvitableRoles({
|
|
391
461
|
org: props.org,
|
|
392
|
-
type: props.app,
|
|
393
|
-
|
|
462
|
+
type: invite.value.app || props.app,
|
|
463
|
+
site: invite.value.site,
|
|
464
|
+
limit: 100,
|
|
394
465
|
}),
|
|
395
|
-
{ watch: [() => props.app] }
|
|
466
|
+
{ watch: [() => props.app, () => invite.value.app, () => invite.value.site] }
|
|
396
467
|
);
|
|
397
468
|
|
|
398
469
|
watchEffect(() => {
|
|
399
470
|
if (RolesData.value) {
|
|
400
471
|
roles.value = RolesData.value.items;
|
|
472
|
+
// A role picked for a different site is not valid for this one.
|
|
473
|
+
if (
|
|
474
|
+
invite.value.role &&
|
|
475
|
+
!roles.value.some((r: any) => String(r._id) === String(invite.value.role))
|
|
476
|
+
) {
|
|
477
|
+
invite.value.role = "";
|
|
478
|
+
}
|
|
401
479
|
}
|
|
402
480
|
});
|
|
403
481
|
|
|
482
|
+
const roleOptions = computed(() => inviteRoleOptions(roles.value));
|
|
483
|
+
|
|
404
484
|
async function handleUpdateApp(value: string) {
|
|
405
485
|
invite.value.role = "";
|
|
406
|
-
|
|
486
|
+
if (!fixedSite.value) {
|
|
487
|
+
invite.value.site = "";
|
|
488
|
+
invite.value.siteName = "";
|
|
489
|
+
}
|
|
407
490
|
await refreshRoles()
|
|
408
491
|
}
|
|
409
492
|
|
package/composables/useRole.ts
CHANGED
|
@@ -73,17 +73,34 @@ export default function useRole() {
|
|
|
73
73
|
limit?: number;
|
|
74
74
|
}
|
|
75
75
|
) {
|
|
76
|
+
/*
|
|
77
|
+
* An invitation INTO an organisation offers that organisation's own roles
|
|
78
|
+
* only (owner, 2026-09-25: the org-less templates "Org Owner", "Org - Admin
|
|
79
|
+
* Doan623"... in a site's Invite member list were never this client's).
|
|
80
|
+
* The server refuses a template on such an invitation (`core
|
|
81
|
+
* roleInvitable`). Templates are still what an invitation naming NO
|
|
82
|
+
* organisation offers, e.g. the console's new-client flows.
|
|
83
|
+
*
|
|
84
|
+
* A role pinned to a site is offered only for THAT site: the server's site
|
|
85
|
+
* filter returns this site's roles plus the org-wide ones, and with no site
|
|
86
|
+
* chosen yet only the org-wide ones are valid.
|
|
87
|
+
*/
|
|
76
88
|
const [tenant, templates] = await Promise.all([
|
|
77
89
|
org
|
|
78
90
|
? getRoles({ search, org, site, type, limit })
|
|
79
91
|
: Promise.resolve({ items: [] } as Record<string, any>),
|
|
80
|
-
|
|
92
|
+
org
|
|
93
|
+
? Promise.resolve({ items: [] } as Record<string, any>)
|
|
94
|
+
: getRoles({ search, type: "organization", limit }),
|
|
81
95
|
]);
|
|
82
96
|
|
|
83
97
|
const seen = new Set<string>();
|
|
84
98
|
const items = [...(tenant?.items ?? []), ...(templates?.items ?? [])].filter(
|
|
85
99
|
(role: Record<string, any>) => {
|
|
86
100
|
if (role?.type === "admin") return false;
|
|
101
|
+
if (role?.status && role.status !== "active") return false;
|
|
102
|
+
const roleSite = String(role?.site ?? "");
|
|
103
|
+
if (roleSite && roleSite !== String(site ?? "")) return false;
|
|
87
104
|
const id = String(role?._id ?? "");
|
|
88
105
|
if (!id || seen.has(id)) return false;
|
|
89
106
|
seen.add(id);
|
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.35.1-staging.
|
|
5
|
+
"version": "4.35.1-staging.388",
|
|
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.",
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Invite member Role list, labelled so an inviter can tell a role made for
|
|
3
|
+
* this site from one that applies across the organisation (owner report
|
|
4
|
+
* 2026-09-25). The roles themselves are already scoped by
|
|
5
|
+
* `useRole.getInvitableRoles`.
|
|
6
|
+
*/
|
|
7
|
+
export type TInviteRoleOption = { _id: string; title: string; subtitle: string };
|
|
8
|
+
|
|
9
|
+
export const SITE_ROLE_LABEL = "Site role";
|
|
10
|
+
export const ORG_ROLE_LABEL = "Organisation role";
|
|
11
|
+
|
|
12
|
+
export function inviteRoleOptions(
|
|
13
|
+
roles: Array<Record<string, any>> | null | undefined,
|
|
14
|
+
): TInviteRoleOption[] {
|
|
15
|
+
return (roles ?? [])
|
|
16
|
+
.filter((role) => role && role._id)
|
|
17
|
+
.map((role) => ({
|
|
18
|
+
_id: String(role._id),
|
|
19
|
+
title: String(role.name ?? ""),
|
|
20
|
+
subtitle: role.site ? SITE_ROLE_LABEL : ORG_ROLE_LABEL,
|
|
21
|
+
}));
|
|
22
|
+
}
|