@7365admin1/layer-common 4.175.0 → 4.177.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 +24 -4
- package/components/ClientMain.vue +10 -0
- package/components/TableMain.vue +19 -10
- package/composables/usePropertyPermission.ts +13 -0
- package/constants/permissions.ts +2 -0
- package/middleware/terms-gate.global.ts +10 -0
- package/package.json +1 -1
- package/plugins/secure-member.client.ts +167 -10
- package/utils/client-invite-modules.ts +1 -0
- package/utils/module-routes.ts +1 -0
- package/utils/permission-labels.ts +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# @iservice365/layer-common
|
|
2
2
|
|
|
3
|
+
## 4.177.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- fdd8205: Super Admin Client List: "Change nature" row action (opens the client details change-nature dialog).
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- ea860be: Faster sign-in and page loads: the permission guard now asks for the staff view, the organisation, and (once the member is known) the role and the client's module list at the same time instead of one after another, and the terms gate lets those lookups start while it waits for its own answer. The first move from the sign-in landing page to a site no longer asks for the same member and role twice. Who can see what is unchanged.
|
|
12
|
+
|
|
13
|
+
## 4.176.0
|
|
14
|
+
|
|
15
|
+
### Minor Changes
|
|
16
|
+
|
|
17
|
+
- b81d864: Liza (resident chat assistant): new `chatbot-mgmt` permission family (`see-chatbot`, `manage-chatbot`) in `PERMISSIONS` and the property-management role catalogue, labelled "Liza (chat assistant)"; route `org-site-liza` gated by `chatbot-mgmt`; and the `chatbot` resident-app module in `RESIDENT_APP_MODULES`, so Super Admin can switch Liza on or off per client.
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- 1070e52: TableMain: the refresh button now shows a "Refresh: reload this list" hover tip and has the accessible name "Refresh". Nothing else about the table changes.
|
|
22
|
+
|
|
3
23
|
## 4.175.0
|
|
4
24
|
|
|
5
25
|
### Minor Changes
|
|
@@ -3927,11 +3947,11 @@ Monthly report: a month that had patrols opens the list of that month's patrol r
|
|
|
3927
3947
|
`utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
|
|
3928
3948
|
own rule from two endpoints the console already calls, unprojected:
|
|
3929
3949
|
|
|
3930
|
-
|
|
3931
|
-
|
|
3950
|
+
GET /api/members/user/:user/app/admin the Seven365 staff membership
|
|
3951
|
+
GET /api/roles/id/:role that membership's role document
|
|
3932
3952
|
|
|
3933
|
-
|
|
3934
|
-
|
|
3953
|
+
owner = member.type === "admin" && role.type === "admin" && role.default === true
|
|
3954
|
+
staff = member.type === "admin" && role.type === "admin"
|
|
3935
3955
|
|
|
3936
3956
|
`role.default` is the marker because it is the only property of a platform
|
|
3937
3957
|
staff role no API caller can set - `role.controller.ts` validates create and
|
|
@@ -347,6 +347,11 @@
|
|
|
347
347
|
<button class="dd-item" @click="viewClient(activeMenuItem)">
|
|
348
348
|
View Organization
|
|
349
349
|
</button>
|
|
350
|
+
<!-- Owner 12 Nov 2026: Super Admin can move a client to another nature.
|
|
351
|
+
The change is made (and previewed) on the client's details page. -->
|
|
352
|
+
<button class="dd-item" data-test="client-change-nature" @click="changeNature(activeMenuItem)">
|
|
353
|
+
Change nature
|
|
354
|
+
</button>
|
|
350
355
|
<button class="dd-item" @click="openSubscription(activeMenuItem)">
|
|
351
356
|
{{ activeMenuItem?.sub?.state === 'none' ? 'Set up subscription' : 'Edit subscription' }}
|
|
352
357
|
</button>
|
|
@@ -673,6 +678,11 @@ function viewClient(item: any) {
|
|
|
673
678
|
closeMenu()
|
|
674
679
|
}
|
|
675
680
|
|
|
681
|
+
function changeNature(item: any) {
|
|
682
|
+
closeMenu()
|
|
683
|
+
if (item?._id) navigateTo({ path: '/super-admin/client-details', query: { org: String(item._id), changeNature: '1' } })
|
|
684
|
+
}
|
|
685
|
+
|
|
676
686
|
function cancelView() {
|
|
677
687
|
selectedClient.value = null
|
|
678
688
|
viewMode.value = 'table'
|
package/components/TableMain.vue
CHANGED
|
@@ -161,17 +161,26 @@
|
|
|
161
161
|
|
|
162
162
|
A caller that passes no `loading` renders exactly what it renders
|
|
163
163
|
today (the prop defaults to false).
|
|
164
|
+
|
|
165
|
+
The icon alone didn't say what it does (DV-0958): a hover tip and
|
|
166
|
+
an accessible name now both say "Refresh".
|
|
164
167
|
-->
|
|
165
|
-
<v-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
168
|
+
<v-tooltip text="Refresh: reload this list" location="top" :open-delay="300">
|
|
169
|
+
<template #activator="{ props: tip }">
|
|
170
|
+
<v-btn
|
|
171
|
+
v-bind="tip"
|
|
172
|
+
fab
|
|
173
|
+
icon
|
|
174
|
+
density="comfortable"
|
|
175
|
+
variant="text"
|
|
176
|
+
aria-label="Refresh"
|
|
177
|
+
:disabled="loading"
|
|
178
|
+
@click="emits('refresh')"
|
|
179
|
+
>
|
|
180
|
+
<v-icon>mdi-refresh</v-icon>
|
|
181
|
+
</v-btn>
|
|
182
|
+
</template>
|
|
183
|
+
</v-tooltip>
|
|
175
184
|
<slot name="prepend-additional" />
|
|
176
185
|
</template>
|
|
177
186
|
|
|
@@ -212,6 +212,19 @@ export default function usePropertyPermission() {
|
|
|
212
212
|
"Allows the user to remove a bulletin-video from the system permanently.",
|
|
213
213
|
},
|
|
214
214
|
},
|
|
215
|
+
|
|
216
|
+
"chatbot-mgmt": {
|
|
217
|
+
"see-chatbot": {
|
|
218
|
+
check: true,
|
|
219
|
+
description:
|
|
220
|
+
"Allows the user to open the Liza page and read its Q&As, documents, suggested and unanswered questions.",
|
|
221
|
+
},
|
|
222
|
+
"manage-chatbot": {
|
|
223
|
+
check: true,
|
|
224
|
+
description:
|
|
225
|
+
"Allows the user to add, edit, import, publish and archive Liza's Q&As and documents, and edit her greeting.",
|
|
226
|
+
},
|
|
227
|
+
},
|
|
215
228
|
"document-mgmt": {
|
|
216
229
|
"see-all-documents": {
|
|
217
230
|
check: true,
|
package/constants/permissions.ts
CHANGED
|
@@ -134,6 +134,8 @@ export const PERMISSIONS = {
|
|
|
134
134
|
"update-bulletin-video",
|
|
135
135
|
"delete-bulletin-video",
|
|
136
136
|
],
|
|
137
|
+
// Liza, the resident chat assistant: see = read the page, manage = every write.
|
|
138
|
+
"chatbot-mgmt": ["see-chatbot", "manage-chatbot"],
|
|
137
139
|
|
|
138
140
|
// ---- site settings: the server reads five of these, so it decides ----
|
|
139
141
|
"site-settings": [
|
|
@@ -8,6 +8,16 @@ import { termsGateRedirect } from "../utils/terms-gate";
|
|
|
8
8
|
*/
|
|
9
9
|
export default defineNuxtRouteMiddleware(async (to) => {
|
|
10
10
|
const { cookieConfig } = useRuntimeConfig().public;
|
|
11
|
+
// This runs before the permission guard (plugins/secure-member.client.ts) and
|
|
12
|
+
// then waits for its own answer. Let that guard's independent lookups travel
|
|
13
|
+
// alongside it instead of starting only once this one is done.
|
|
14
|
+
if (import.meta.client) {
|
|
15
|
+
try {
|
|
16
|
+
(useNuxtApp() as any).$warmSession?.(to);
|
|
17
|
+
} catch {
|
|
18
|
+
// A head start only: the guard asks for everything itself.
|
|
19
|
+
}
|
|
20
|
+
}
|
|
11
21
|
const redirect = await termsGateRedirect({
|
|
12
22
|
client: import.meta.client,
|
|
13
23
|
sid: useCookie("sid", cookieConfig).value,
|
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.177.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.",
|
|
@@ -68,6 +68,39 @@ function idParam(value: unknown) {
|
|
|
68
68
|
return hexSchema.safeParse(value).success ? String(value) : "";
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
/*
|
|
72
|
+
* SIGN-IN SPEED (owner, 2026-11-12: "when I click login it is very slow").
|
|
73
|
+
*
|
|
74
|
+
* The guard below used to ask its questions one after another - staff view,
|
|
75
|
+
* member, role, module list, organisation - and the terms gate (a middleware
|
|
76
|
+
* that runs first) asked its own before any of them. On a hard page load that is
|
|
77
|
+
* five or six round trips in a row before the first screen can paint. Most of
|
|
78
|
+
* them do not depend on each other, so they now go out together:
|
|
79
|
+
*
|
|
80
|
+
* - `prefetch(key, start)` starts a lookup (or reuses one already started)
|
|
81
|
+
* and keeps the promise for a few seconds; `take(key, start)` is what the
|
|
82
|
+
* guard calls: it uses that promise if there is one, otherwise it starts the
|
|
83
|
+
* lookup right there, exactly as before. Each promise is used once, and an
|
|
84
|
+
* old one is ignored, so a later navigation always asks the server again.
|
|
85
|
+
* - `warmSession(to)` (provided as `$warmSession`) lets the terms middleware
|
|
86
|
+
* start these lookups while it waits for its own answer.
|
|
87
|
+
*
|
|
88
|
+
* Nothing is cached beyond that hand-over and every answer is read by the same
|
|
89
|
+
* code as before, so who may see what is unchanged.
|
|
90
|
+
*/
|
|
91
|
+
export const PREFETCH_TTL_MS = 10_000;
|
|
92
|
+
|
|
93
|
+
/*
|
|
94
|
+
* The first navigation after a sign-in lands on the app's "SIGN IN AS you" page
|
|
95
|
+
* (no site in the address) and then opens the site's dashboard moments later.
|
|
96
|
+
* While Q16 is held the member lookup sends no site, so asking it again for the
|
|
97
|
+
* site returns the very same answer. Within this window that second ask is
|
|
98
|
+
* skipped; a site switch later in the session still re-asks (Q16 is unchanged).
|
|
99
|
+
*/
|
|
100
|
+
export const LANDING_FRESH_MS = 60_000;
|
|
101
|
+
|
|
102
|
+
type Prefetched = { at: number; promise: Promise<any> };
|
|
103
|
+
|
|
71
104
|
export default defineNuxtPlugin(() => {
|
|
72
105
|
const router = useRouter();
|
|
73
106
|
const { getByUserType, getDeniedModules } = useMember();
|
|
@@ -80,7 +113,7 @@ export default defineNuxtPlugin(() => {
|
|
|
80
113
|
// "Open as Seven365 staff": the server holds the view against the session.
|
|
81
114
|
// While it covers the route's organisation, staff work there with full setup
|
|
82
115
|
// rights instead of their own (absent) membership. Nothing is written.
|
|
83
|
-
const { loadStaffView } = useStaffView();
|
|
116
|
+
const { loadStaffView, staffView, staffViewLoaded } = useStaffView();
|
|
84
117
|
let staffViewActive = false;
|
|
85
118
|
let lastStaffOrg = "";
|
|
86
119
|
|
|
@@ -94,6 +127,38 @@ export default defineNuxtPlugin(() => {
|
|
|
94
127
|
let inFlight: Promise<void> | null = null;
|
|
95
128
|
let inFlightKey: string | null = null;
|
|
96
129
|
let hasMemberDocument = false;
|
|
130
|
+
let resolvedAt = 0;
|
|
131
|
+
|
|
132
|
+
const prefetched = new Map<string, Prefetched>();
|
|
133
|
+
|
|
134
|
+
function prefetch<T>(key: string, start: () => Promise<T>): Promise<T> {
|
|
135
|
+
const hit = prefetched.get(key);
|
|
136
|
+
if (hit && Date.now() - hit.at < PREFETCH_TTL_MS) return hit.promise;
|
|
137
|
+
const promise = start();
|
|
138
|
+
// Nobody may be waiting for it (a navigation that never got this far); the
|
|
139
|
+
// caller that does wait still sees the failure.
|
|
140
|
+
promise.catch(() => {});
|
|
141
|
+
prefetched.set(key, { at: Date.now(), promise });
|
|
142
|
+
return promise;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Each started lookup is handed over once; an old or missing one is started afresh. */
|
|
146
|
+
function take<T>(key: string, start: () => Promise<T>): Promise<T> {
|
|
147
|
+
const hit = prefetched.get(key);
|
|
148
|
+
prefetched.delete(key);
|
|
149
|
+
return hit && Date.now() - hit.at < PREFETCH_TTL_MS ? hit.promise : start();
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const memberKey = (userId: string, site: string) => `member:${userId}|${site}`;
|
|
153
|
+
const startMember = (userId: string, site: string) => () =>
|
|
154
|
+
bounded(
|
|
155
|
+
getByUserType(
|
|
156
|
+
userId,
|
|
157
|
+
useRuntimeConfig().public.APP,
|
|
158
|
+
undefined,
|
|
159
|
+
roleFollowsSite() && site ? site : undefined,
|
|
160
|
+
),
|
|
161
|
+
);
|
|
97
162
|
|
|
98
163
|
// The client's module list is decided per org|site, so it has its own key.
|
|
99
164
|
// `deniedWanted` is the latest key asked for: an older answer that lands after
|
|
@@ -101,6 +166,25 @@ export default defineNuxtPlugin(() => {
|
|
|
101
166
|
let deniedFor: string | null = null;
|
|
102
167
|
let deniedWanted: string | null = null;
|
|
103
168
|
|
|
169
|
+
const deniedKey = (userId: string, org: string, site: string) => `denied:${userId}|${org}|${site}`;
|
|
170
|
+
const askDenied = (userId: string, org: string, site: string) => () =>
|
|
171
|
+
getDeniedModules(userId, useRuntimeConfig().public.APP, org || undefined, site || undefined);
|
|
172
|
+
/** Start the module-list lookup early; `resolveDenied` picks the answer up. */
|
|
173
|
+
const startDenied = (userId: string, org: string, site: string) =>
|
|
174
|
+
prefetch(deniedKey(userId, org, site), askDenied(userId, org, site));
|
|
175
|
+
|
|
176
|
+
// See LANDING_FRESH_MS. Only from "no site yet" to a site, only for the same
|
|
177
|
+
// person, only while the member lookup does not send the site.
|
|
178
|
+
function landingAnswerStillHolds(userId: string, site: string, staffOrg: string) {
|
|
179
|
+
return (
|
|
180
|
+
!!site &&
|
|
181
|
+
!staffOrg &&
|
|
182
|
+
!roleFollowsSite() &&
|
|
183
|
+
resolvedFor === `${userId}|` &&
|
|
184
|
+
Date.now() - resolvedAt < LANDING_FRESH_MS
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
104
188
|
// Deliberately never redirects and never throws.
|
|
105
189
|
//
|
|
106
190
|
// `GET /api/members/user/:id/app/:type` returns 404 for any account holding no
|
|
@@ -111,6 +195,10 @@ export default defineNuxtPlugin(() => {
|
|
|
111
195
|
async function resolveAppRole(userId: string, site: string, staffOrg = "") {
|
|
112
196
|
const key = `${userId}|${site}${staffOrg ? `|staff:${staffOrg}` : ""}`;
|
|
113
197
|
if (resolvedFor === key) return;
|
|
198
|
+
if (landingAnswerStillHolds(userId, site, staffOrg)) {
|
|
199
|
+
resolvedFor = key;
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
114
202
|
if (inFlight) {
|
|
115
203
|
// A lookup for the SAME key is the one we want: await it and stop, which
|
|
116
204
|
// is what this did before there was a key. One for another site is not,
|
|
@@ -133,14 +221,13 @@ export default defineNuxtPlugin(() => {
|
|
|
133
221
|
}
|
|
134
222
|
|
|
135
223
|
async function run(userId: string, site: string, staffOrg = "") {
|
|
136
|
-
const APP = useRuntimeConfig().public.APP;
|
|
137
|
-
|
|
138
224
|
staffViewActive = !!staffOrg;
|
|
139
225
|
if (staffOrg) {
|
|
140
226
|
hasMemberDocument = true;
|
|
141
227
|
id.value = staffOrg;
|
|
142
228
|
userAppRole.value = STAFF_VIEW_ROLE;
|
|
143
229
|
resolvedFor = `${userId}|${site}|staff:${staffOrg}`;
|
|
230
|
+
resolvedAt = Date.now();
|
|
144
231
|
userAppRoleStatus.value = "resolved";
|
|
145
232
|
return;
|
|
146
233
|
}
|
|
@@ -151,11 +238,12 @@ export default defineNuxtPlugin(() => {
|
|
|
151
238
|
// membership it has always answered with -- so the only behaviour this
|
|
152
239
|
// adds is Q16 itself. Sending `org` as well would change the fallback
|
|
153
240
|
// too, and that is a separate change.
|
|
154
|
-
const member = await
|
|
155
|
-
getByUserType(userId, APP, undefined, roleFollowsSite() && site ? site : undefined),
|
|
156
|
-
);
|
|
241
|
+
const member = await take(memberKey(userId, site), startMember(userId, site));
|
|
157
242
|
hasMemberDocument = true;
|
|
158
243
|
id.value = member.org ?? "";
|
|
244
|
+
// The client's module list is asked for this org and site and does not
|
|
245
|
+
// need the role, so it goes out while the role is being read.
|
|
246
|
+
startDenied(userId, id.value ?? "", site);
|
|
159
247
|
userAppRole.value = member.role ? await bounded(getRoleById(member.role)) : null;
|
|
160
248
|
} catch (error) {
|
|
161
249
|
// Anything that is not a 404 is transient. Stay unresolved so the next
|
|
@@ -178,6 +266,7 @@ export default defineNuxtPlugin(() => {
|
|
|
178
266
|
}
|
|
179
267
|
|
|
180
268
|
resolvedFor = `${userId}|${site}`;
|
|
269
|
+
resolvedAt = Date.now();
|
|
181
270
|
userAppRoleStatus.value = "resolved";
|
|
182
271
|
}
|
|
183
272
|
|
|
@@ -201,8 +290,7 @@ export default defineNuxtPlugin(() => {
|
|
|
201
290
|
|
|
202
291
|
let denied: string[] = [];
|
|
203
292
|
try {
|
|
204
|
-
const
|
|
205
|
-
const res = await getDeniedModules(userId, APP, org || undefined, site || undefined);
|
|
293
|
+
const res: any = await take(deniedKey(userId, org, site), askDenied(userId, org, site));
|
|
206
294
|
const list = (res as any)?.denied;
|
|
207
295
|
if (Array.isArray(list)) denied = list.filter((k): k is string => typeof k === "string");
|
|
208
296
|
} catch {
|
|
@@ -214,6 +302,64 @@ export default defineNuxtPlugin(() => {
|
|
|
214
302
|
userAppModulesDenied.value = denied;
|
|
215
303
|
}
|
|
216
304
|
|
|
305
|
+
// The staff view belongs to the session, not to an organisation, and is read
|
|
306
|
+
// once per page load (`loadStaffView` keeps its answer), so one key serves
|
|
307
|
+
// every route.
|
|
308
|
+
const viewKey = (userId: string) => `view:${userId}`;
|
|
309
|
+
const startView = () => bounded(loadStaffView());
|
|
310
|
+
/**
|
|
311
|
+
* May the member / module-list lookups start before the staff view is read?
|
|
312
|
+
* Staff working inside a client are given full setup rights and NO member
|
|
313
|
+
* document is looked up for them (test/staff-view-role.test.mjs), so on an
|
|
314
|
+
* organisation's page they wait for the view - unless it is already known not
|
|
315
|
+
* to cover this organisation. A page with no organisation is never opened as
|
|
316
|
+
* staff, so nothing there depends on the view.
|
|
317
|
+
*/
|
|
318
|
+
const viewSettled = (routeOrg: string) =>
|
|
319
|
+
!routeOrg || (staffViewLoaded.value && !staffViewCovers(staffView.value, routeOrg));
|
|
320
|
+
const orgKey = (org: string) => `org:${org}`;
|
|
321
|
+
const startOrg = (org: string) => () => bounded(getById(org));
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Start every lookup the guard is about to need that does not depend on
|
|
325
|
+
* another lookup's answer, so they travel together instead of in a row. Reads
|
|
326
|
+
* nothing and decides nothing: the guard still takes each answer in its
|
|
327
|
+
* original order and applies it exactly as before. Called by the terms-gate
|
|
328
|
+
* middleware (which runs first and then waits for its own answer) and by the
|
|
329
|
+
* guard itself.
|
|
330
|
+
*/
|
|
331
|
+
function warmSession(to: { params?: Record<string, any>; meta?: Record<string, any> }) {
|
|
332
|
+
const userId = useCookie("user").value ?? "";
|
|
333
|
+
if (!userId) return;
|
|
334
|
+
const site = idParam(to.params?.site);
|
|
335
|
+
const routeOrg = idParam(to.params?.org) || idParam(to.params?.organization);
|
|
336
|
+
|
|
337
|
+
// Read the staff view at the first page of a session, wherever it is: the
|
|
338
|
+
// organisation's pages that follow then find it already answered.
|
|
339
|
+
prefetch(viewKey(userId), startView);
|
|
340
|
+
|
|
341
|
+
// The membership, only when the guard is going to ask for it (and not for
|
|
342
|
+
// someone already working inside a client as Seven365 staff).
|
|
343
|
+
if (
|
|
344
|
+
viewSettled(routeOrg) &&
|
|
345
|
+
!staffViewActive &&
|
|
346
|
+
!inFlight &&
|
|
347
|
+
resolvedFor !== `${userId}|${site}` &&
|
|
348
|
+
!landingAnswerStillHolds(userId, site, "")
|
|
349
|
+
) {
|
|
350
|
+
prefetch(memberKey(userId, site), startMember(userId, site));
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
// The client's module list for a site of an organisation we already know.
|
|
354
|
+
const org = id.value ?? "";
|
|
355
|
+
if (viewSettled(routeOrg) && hasMemberDocument && !staffViewActive && org && deniedFor !== `${userId}|${org}|${site}`) {
|
|
356
|
+
startDenied(userId, org, site);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
// The organisation document is read for member pages and needs no role.
|
|
360
|
+
if (to.meta?.memberOnly && routeOrg) prefetch(orgKey(routeOrg), startOrg(routeOrg));
|
|
361
|
+
}
|
|
362
|
+
|
|
217
363
|
router.beforeEach(async (to) => {
|
|
218
364
|
const userId = useCookie("user").value ?? "";
|
|
219
365
|
|
|
@@ -225,8 +371,16 @@ export default defineNuxtPlugin(() => {
|
|
|
225
371
|
// Awaited, so no gate is ever evaluated against an unresolved role.
|
|
226
372
|
const site = idParam(to.params.site);
|
|
227
373
|
const routeOrg = idParam(to.params.org) || idParam(to.params.organization);
|
|
374
|
+
// The lookups below that do not depend on each other are started together
|
|
375
|
+
// (`warmSession`, or right here when nothing warmed them first) and read in
|
|
376
|
+
// the same order as before.
|
|
377
|
+
warmSession(to);
|
|
378
|
+
|
|
228
379
|
// Only an organisation's pages can be opened as staff, so only they ask.
|
|
229
|
-
const view =
|
|
380
|
+
const view =
|
|
381
|
+
userId && routeOrg
|
|
382
|
+
? await take(viewKey(userId), startView).catch(() => null)
|
|
383
|
+
: null;
|
|
230
384
|
const staffOrg = staffViewCovers(view, routeOrg) ? routeOrg : "";
|
|
231
385
|
lastStaffOrg = staffOrg;
|
|
232
386
|
|
|
@@ -271,7 +425,7 @@ export default defineNuxtPlugin(() => {
|
|
|
271
425
|
}
|
|
272
426
|
|
|
273
427
|
try {
|
|
274
|
-
const orgResult = await
|
|
428
|
+
const orgResult = await take(orgKey(org), startOrg(org));
|
|
275
429
|
if (orgResult) orgNature.value = orgResult.nature ?? "";
|
|
276
430
|
} catch (error) {
|
|
277
431
|
// Cosmetic only, and it never blocked navigation before either.
|
|
@@ -302,6 +456,8 @@ export default defineNuxtPlugin(() => {
|
|
|
302
456
|
return Promise.resolve();
|
|
303
457
|
}
|
|
304
458
|
lastRefreshAt = Date.now();
|
|
459
|
+
// The point of this refresh is a FRESH answer: nothing started earlier.
|
|
460
|
+
prefetched.clear();
|
|
305
461
|
const site = idParam(router.currentRoute.value.params.site);
|
|
306
462
|
|
|
307
463
|
refreshing = (async () => {
|
|
@@ -319,6 +475,7 @@ export default defineNuxtPlugin(() => {
|
|
|
319
475
|
return {
|
|
320
476
|
provide: {
|
|
321
477
|
refreshAppRole,
|
|
478
|
+
warmSession,
|
|
322
479
|
},
|
|
323
480
|
};
|
|
324
481
|
});
|
|
@@ -56,6 +56,7 @@ export const RESIDENT_APP_MODULES: readonly { value: string; label: string }[] =
|
|
|
56
56
|
{ value: "facilityBooking", label: "Facility booking" },
|
|
57
57
|
{ value: "onlineForm", label: "Online form" },
|
|
58
58
|
{ value: "emergencyContact", label: "Emergency contact" },
|
|
59
|
+
{ value: "chatbot", label: "Liza (chat assistant)" },
|
|
59
60
|
]);
|
|
60
61
|
|
|
61
62
|
/** Does a new client of this nature get the Service365 resident app? */
|
package/utils/module-routes.ts
CHANGED
|
@@ -32,6 +32,7 @@ export const MODULE_ROUTES: Readonly<Record<string, string>> = Object.freeze({
|
|
|
32
32
|
"org-site-incident-reports": "incident-reports",
|
|
33
33
|
"org-site-bulletin-board": "bulletin-board",
|
|
34
34
|
"org-site-bulletin-videos": "bulletin-videos-mgmt",
|
|
35
|
+
"org-site-liza": "chatbot-mgmt",
|
|
35
36
|
"org-site-visitor-mgmt": "visitor-mgmt",
|
|
36
37
|
"org-site-visitor-management": "visitor-mgmt",
|
|
37
38
|
"org-site-vehicle-management": "vehicle-mgmt",
|
|
@@ -48,6 +48,7 @@ export const RESOURCE_LABELS: Record<string, string> = {
|
|
|
48
48
|
"my-attendance": "My attendance",
|
|
49
49
|
"online-form-configuration": "Online forms",
|
|
50
50
|
"bulletin-videos-mgmt": "Bulletin videos",
|
|
51
|
+
"chatbot-mgmt": "Liza (chat assistant)",
|
|
51
52
|
"access-card-mgmt": "Access cards",
|
|
52
53
|
feedbacks: "Feedback",
|
|
53
54
|
// The legacy singular resource: its own permission, same module (see `feedbacks`).
|