@7365admin1/layer-common 4.35.1-staging.430 → 4.35.1-staging.432
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/components/InvitationMain.vue +24 -1
- package/components/MemberMain.vue +50 -7
- package/components/RolePermissionMain.vue +5 -1
- package/components/VisitorManagement.vue +47 -10
- package/package.json +1 -1
- package/utils/invitations-empty-text.ts +14 -0
- package/utils/role.ts +21 -0
- package/utils/visitor-search.ts +23 -0
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
hide-default-footer
|
|
51
51
|
style="max-height: calc(100vh - (126px))"
|
|
52
52
|
:loading="loading"
|
|
53
|
+
:no-data-text="emptyText"
|
|
53
54
|
>
|
|
54
55
|
<template #item.permissions="{ value }">
|
|
55
56
|
<span class="text-caption font-weight-bold text-capitalize">
|
|
@@ -137,6 +138,9 @@
|
|
|
137
138
|
</template>
|
|
138
139
|
|
|
139
140
|
<script setup lang="ts">
|
|
141
|
+
// Relative import: this layer's `utils/` is not auto-imported into consumers.
|
|
142
|
+
import { invitationsEmptyText } from "../utils/invitations-empty-text";
|
|
143
|
+
|
|
140
144
|
/** The same two tabs, same labels, same routes. */
|
|
141
145
|
const invitationTabs = [
|
|
142
146
|
{ status: "pending", label: "Pending" },
|
|
@@ -260,7 +264,10 @@ const {
|
|
|
260
264
|
type: "member-invite",
|
|
261
265
|
app: props.app,
|
|
262
266
|
orgId: props.org,
|
|
263
|
-
//
|
|
267
|
+
// A site app lists only THIS site's invitations; the server checks the
|
|
268
|
+
// caller reaches it (owner report 2026-09-28: LakeGarden's invitations
|
|
269
|
+
// showed on every Wing Tai site). The org console passes no site.
|
|
270
|
+
siteId: props.siteId,
|
|
264
271
|
}),
|
|
265
272
|
{
|
|
266
273
|
watch: [() => props.status]
|
|
@@ -269,6 +276,22 @@ const {
|
|
|
269
276
|
|
|
270
277
|
const loading = computed(() => getVerificationsStatus.value === "pending");
|
|
271
278
|
|
|
279
|
+
// A plain empty state instead of "No data available" (QA sweep 2026-09-28).
|
|
280
|
+
const siteName = ref("");
|
|
281
|
+
if (props.siteId) {
|
|
282
|
+
useSite()
|
|
283
|
+
.getSiteById(props.siteId)
|
|
284
|
+
.then((site) => (siteName.value = site?.name ?? ""))
|
|
285
|
+
.catch(() => {});
|
|
286
|
+
}
|
|
287
|
+
const emptyText = computed(() =>
|
|
288
|
+
invitationsEmptyText({
|
|
289
|
+
status: props.status,
|
|
290
|
+
siteName: props.siteId ? siteName.value || "this site" : "",
|
|
291
|
+
canInvite: props.inviteMember,
|
|
292
|
+
}),
|
|
293
|
+
);
|
|
294
|
+
|
|
272
295
|
watchEffect(() => {
|
|
273
296
|
if (getVerificationsReq.value) {
|
|
274
297
|
items.value = getVerificationsReq.value.items;
|
|
@@ -250,7 +250,11 @@
|
|
|
250
250
|
<v-col cols="12">
|
|
251
251
|
<v-row no-gutters>
|
|
252
252
|
<InputLabel class="text-capitalize" title="Name" required />
|
|
253
|
-
<v-col cols="12">
|
|
253
|
+
<v-col v-if="noSiteRoles" cols="12" class="py-2" data-test="assign-role-empty">
|
|
254
|
+
<p class="text-body-2 mb-2">{{ noSiteRolesText }}</p>
|
|
255
|
+
<NuxtLink v-if="rolesPageLink" :to="rolesPageLink">Go to Roles & Permissions</NuxtLink>
|
|
256
|
+
</v-col>
|
|
257
|
+
<v-col v-else cols="12">
|
|
254
258
|
<v-select
|
|
255
259
|
v-model="selectedRole"
|
|
256
260
|
:items="pickerRoles"
|
|
@@ -287,7 +291,7 @@
|
|
|
287
291
|
<v-btn
|
|
288
292
|
class="screen-btn-primary"
|
|
289
293
|
variant="flat"
|
|
290
|
-
:disabled="!memberRoleForm"
|
|
294
|
+
:disabled="!memberRoleForm || noSiteRoles"
|
|
291
295
|
type="submit"
|
|
292
296
|
>
|
|
293
297
|
Submit
|
|
@@ -300,7 +304,14 @@
|
|
|
300
304
|
</template>
|
|
301
305
|
|
|
302
306
|
<script setup lang="ts">
|
|
303
|
-
import {
|
|
307
|
+
import {
|
|
308
|
+
memberRoleChip,
|
|
309
|
+
noRolesForSiteText,
|
|
310
|
+
otherSiteBannerText,
|
|
311
|
+
roleUsableHere,
|
|
312
|
+
safeReturnTo,
|
|
313
|
+
withCurrentRole,
|
|
314
|
+
} from "../utils/role";
|
|
304
315
|
|
|
305
316
|
const props = defineProps({
|
|
306
317
|
/** The design's page title. Every app that mounts this screen calls it
|
|
@@ -547,9 +558,14 @@ function setMember({
|
|
|
547
558
|
}
|
|
548
559
|
|
|
549
560
|
selectedMemberId.value = role._id;
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
561
|
+
// A role the member cannot use HERE (another site's, another organisation's,
|
|
562
|
+
// deleted, none) is neither pre-filled nor offered (owner report 2026-09-28,
|
|
563
|
+
// One Pearl Bank: The Loft's "Security" appeared as if created for this site).
|
|
564
|
+
const usable = roleUsableHere(role);
|
|
565
|
+
selectedRole.value = usable ? role.role : null;
|
|
566
|
+
selectedMemberRole.value = usable ? role.role : "";
|
|
567
|
+
selectedMemberRoleName.value = usable ? role.roleName ?? "" : "";
|
|
568
|
+
if (dialog) refreshRoles();
|
|
553
569
|
}
|
|
554
570
|
|
|
555
571
|
const roles = ref<Array<Record<string, any>>>([]);
|
|
@@ -593,7 +609,7 @@ const pickerRoles = computed(() =>
|
|
|
593
609
|
* filter would be decorative -- the same trap the server's own Redis key had.
|
|
594
610
|
*/
|
|
595
611
|
const { getRoles } = useRole();
|
|
596
|
-
const { data: getAllRoleReq } = useLazyAsyncData(
|
|
612
|
+
const { data: getAllRoleReq, refresh: refreshRoles } = useLazyAsyncData(
|
|
597
613
|
`get-roles-${props.type}-${props.orgId}-${props.siteId}`,
|
|
598
614
|
() =>
|
|
599
615
|
getRoles({
|
|
@@ -610,6 +626,33 @@ watchEffect(() => {
|
|
|
610
626
|
}
|
|
611
627
|
});
|
|
612
628
|
|
|
629
|
+
/* No role exists for this site yet: say so and point at Roles & Permissions,
|
|
630
|
+
which sends the user back here after creating one (`returnTo`). */
|
|
631
|
+
const noSiteRoles = computed(
|
|
632
|
+
() => !!props.siteId && !!getAllRoleReq.value && pickerRoles.value.length === 0
|
|
633
|
+
);
|
|
634
|
+
const assignSiteName = ref("");
|
|
635
|
+
if (props.siteId) {
|
|
636
|
+
useSite()
|
|
637
|
+
.getSiteById(props.siteId)
|
|
638
|
+
.then((site) => (assignSiteName.value = site?.name ?? ""))
|
|
639
|
+
.catch(() => {});
|
|
640
|
+
}
|
|
641
|
+
const noSiteRolesText = computed(() => noRolesForSiteText(assignSiteName.value));
|
|
642
|
+
const memberRoute = useRoute();
|
|
643
|
+
const rolesPageLink = computed(() => {
|
|
644
|
+
const here = memberRoute.path;
|
|
645
|
+
const path = here.replace(/\/members(\/.*)?$/, "/roles-permissions");
|
|
646
|
+
if (path === here) return "";
|
|
647
|
+
try {
|
|
648
|
+
return useRouter().resolve(path).matched.length
|
|
649
|
+
? `${path}?returnTo=${encodeURIComponent(here)}`
|
|
650
|
+
: "";
|
|
651
|
+
} catch {
|
|
652
|
+
return "";
|
|
653
|
+
}
|
|
654
|
+
});
|
|
655
|
+
|
|
613
656
|
watchEffect(() => {
|
|
614
657
|
if (selectedRole.value) {
|
|
615
658
|
message.value = "";
|
|
@@ -204,7 +204,7 @@
|
|
|
204
204
|
|
|
205
205
|
<script setup lang="ts">
|
|
206
206
|
// Relative import: this layer's `utils/` is not auto-imported into consumers.
|
|
207
|
-
import { showSiteField } from "../utils/role";
|
|
207
|
+
import { safeReturnTo, showSiteField } from "../utils/role";
|
|
208
208
|
import { holdsPermission } from "../utils/permission-spellings";
|
|
209
209
|
import {
|
|
210
210
|
catalogueForOrg,
|
|
@@ -509,6 +509,10 @@ const siteFieldShown = computed(() =>
|
|
|
509
509
|
function success() {
|
|
510
510
|
createDialog.value = false;
|
|
511
511
|
getRoles();
|
|
512
|
+
// Came here from Members -> Assign Role with no role for the site: go back to
|
|
513
|
+
// finish assigning (same-app path only).
|
|
514
|
+
const back = safeReturnTo(useRoute().query.returnTo);
|
|
515
|
+
if (back) navigateTo(back);
|
|
512
516
|
}
|
|
513
517
|
|
|
514
518
|
const previewDialog = ref(false);
|
|
@@ -85,7 +85,8 @@
|
|
|
85
85
|
<v-text-field
|
|
86
86
|
v-model="searchInput"
|
|
87
87
|
density="compact"
|
|
88
|
-
placeholder="
|
|
88
|
+
placeholder="Name, plate, phone, unit..."
|
|
89
|
+
aria-label="Search visitors"
|
|
89
90
|
clearable
|
|
90
91
|
max-width="300"
|
|
91
92
|
append-inner-icon="mdi-magnify"
|
|
@@ -592,6 +593,12 @@
|
|
|
592
593
|
>
|
|
593
594
|
</span>
|
|
594
595
|
</template>
|
|
596
|
+
<template #no-data>
|
|
597
|
+
<div class="table-card__empty">
|
|
598
|
+
<v-icon icon="mdi-magnify-close" size="32" />
|
|
599
|
+
<span>{{ visitorSearchEmptyText(searchQuery) }}</span>
|
|
600
|
+
</div>
|
|
601
|
+
</template>
|
|
595
602
|
</TableMain>
|
|
596
603
|
|
|
597
604
|
<v-dialog v-model="dialog.showSelection" width="450" persistent>
|
|
@@ -1557,6 +1564,11 @@
|
|
|
1557
1564
|
<script setup lang="ts">
|
|
1558
1565
|
import moment from "moment-timezone";
|
|
1559
1566
|
import QRCode from "qrcode";
|
|
1567
|
+
import {
|
|
1568
|
+
VISITOR_SEARCH_DEBOUNCE_MS,
|
|
1569
|
+
visitorSearchEmptyText,
|
|
1570
|
+
visitorSearchQuery,
|
|
1571
|
+
} from "../utils/visitor-search";
|
|
1560
1572
|
|
|
1561
1573
|
|
|
1562
1574
|
const { downloadPDF } = usePDFDownload();
|
|
@@ -1750,6 +1762,20 @@ watch(hidQrDialog, (open) => {
|
|
|
1750
1762
|
|
|
1751
1763
|
//filter states
|
|
1752
1764
|
const searchInput = ref("");
|
|
1765
|
+
// What is actually searched: the box, trimmed, from 2 characters, sent
|
|
1766
|
+
// VISITOR_SEARCH_DEBOUNCE_MS after the last keystroke (cleared at once). The
|
|
1767
|
+
// list used to refetch on every keystroke, and a burst of typing (or a paste,
|
|
1768
|
+
// or a scanner) could leave the table showing the FIRST letter's results.
|
|
1769
|
+
const searchQuery = ref("");
|
|
1770
|
+
// Reads the box when it fires, so a clear that lands inside the wait is not
|
|
1771
|
+
// overwritten by the text that was there before it.
|
|
1772
|
+
const applySearch = debounce(() => {
|
|
1773
|
+
searchQuery.value = visitorSearchQuery(searchInput.value);
|
|
1774
|
+
}, VISITOR_SEARCH_DEBOUNCE_MS);
|
|
1775
|
+
watch(searchInput, (value) => {
|
|
1776
|
+
if (!visitorSearchQuery(value)) searchQuery.value = "";
|
|
1777
|
+
else applySearch();
|
|
1778
|
+
});
|
|
1753
1779
|
|
|
1754
1780
|
const today = new Date();
|
|
1755
1781
|
const oneMonthAgo = new Date();
|
|
@@ -2322,7 +2348,7 @@ const {
|
|
|
2322
2348
|
const params: any = {
|
|
2323
2349
|
page: page.value,
|
|
2324
2350
|
site: siteId,
|
|
2325
|
-
search:
|
|
2351
|
+
search: searchQuery.value,
|
|
2326
2352
|
dateTo: dateTo.value
|
|
2327
2353
|
? moment(dateTo.value).endOf("day").toISOString()
|
|
2328
2354
|
: undefined,
|
|
@@ -2363,7 +2389,9 @@ const {
|
|
|
2363
2389
|
// }
|
|
2364
2390
|
|
|
2365
2391
|
try {
|
|
2366
|
-
|
|
2392
|
+
const res = await getVisitors(params);
|
|
2393
|
+
// Remember which search this answers, so a late reply is not shown.
|
|
2394
|
+
return res ? { ...res, _search: params.search } : res;
|
|
2367
2395
|
} catch (error: any) {
|
|
2368
2396
|
// Refused by the server: say so with its own message, hide the tab and
|
|
2369
2397
|
// go back to Registered - no empty "No data available" table.
|
|
@@ -2380,7 +2408,7 @@ const {
|
|
|
2380
2408
|
{
|
|
2381
2409
|
watch: [
|
|
2382
2410
|
page,
|
|
2383
|
-
|
|
2411
|
+
searchQuery,
|
|
2384
2412
|
dateFrom,
|
|
2385
2413
|
dateTo,
|
|
2386
2414
|
filterTypes,
|
|
@@ -2392,6 +2420,11 @@ const {
|
|
|
2392
2420
|
);
|
|
2393
2421
|
|
|
2394
2422
|
watch(getVisitorReq, (newData: any) => {
|
|
2423
|
+
// An answer for an older search: ask again for the current one.
|
|
2424
|
+
if (newData && newData._search !== searchQuery.value) {
|
|
2425
|
+
getVisitorRefresh();
|
|
2426
|
+
return;
|
|
2427
|
+
}
|
|
2395
2428
|
if (newData) {
|
|
2396
2429
|
items.value = newData.items ?? [];
|
|
2397
2430
|
pages.value = newData.pages ?? 0;
|
|
@@ -2890,7 +2923,7 @@ async function handleNfcCheckout() {
|
|
|
2890
2923
|
function buildReportParams(): any {
|
|
2891
2924
|
const params: any = {
|
|
2892
2925
|
site: siteId,
|
|
2893
|
-
search:
|
|
2926
|
+
search: searchQuery.value,
|
|
2894
2927
|
dateTo: dateTo.value
|
|
2895
2928
|
? moment(dateTo.value).endOf("day").toISOString()
|
|
2896
2929
|
: undefined,
|
|
@@ -2934,7 +2967,7 @@ async function handleDownloadPDFReport() {
|
|
|
2934
2967
|
|
|
2935
2968
|
// Build URL with query parameters
|
|
2936
2969
|
const queryParams = new URLSearchParams();
|
|
2937
|
-
if (
|
|
2970
|
+
if (searchQuery.value) queryParams.append("search", searchQuery.value);
|
|
2938
2971
|
if (dateFrom.value) queryParams.append("dateFrom", dateFrom.value);
|
|
2939
2972
|
if (dateTo.value) queryParams.append("dateTo", dateTo.value);
|
|
2940
2973
|
if (filterTypes.value.length > 0)
|
|
@@ -3083,7 +3116,7 @@ const updateRouteQuery = debounce(
|
|
|
3083
3116
|
);
|
|
3084
3117
|
|
|
3085
3118
|
watch(
|
|
3086
|
-
[
|
|
3119
|
+
[searchQuery, dateFrom, dateTo, filterTypes, activeTab, displayNotCheckedOut],
|
|
3087
3120
|
([search, from, to, types, tab, checkedOut]) => {
|
|
3088
3121
|
const normalizedFrom = normalizeDateOnly(from);
|
|
3089
3122
|
const normalizedTo = normalizeDateOnly(to);
|
|
@@ -3103,7 +3136,7 @@ watch(
|
|
|
3103
3136
|
},
|
|
3104
3137
|
{ deep: true }
|
|
3105
3138
|
);
|
|
3106
|
-
watch([
|
|
3139
|
+
watch([searchQuery, dateFrom, dateTo, filterTypes, activeTab], () => {
|
|
3107
3140
|
page.value = 1;
|
|
3108
3141
|
});
|
|
3109
3142
|
|
|
@@ -3123,9 +3156,13 @@ const syncVisitorFiltersFromRoute = () => {
|
|
|
3123
3156
|
activeTab.value = nextTab;
|
|
3124
3157
|
}
|
|
3125
3158
|
|
|
3126
|
-
|
|
3127
|
-
|
|
3159
|
+
// Compared with the SEARCHED text, not the box: the route only ever holds
|
|
3160
|
+
// what was searched, so comparing with the box put back an older value over
|
|
3161
|
+
// letters typed since. A different value is an outside link (e.g. ?search=).
|
|
3162
|
+
const nextSearch = visitorSearchQuery(route.query.search);
|
|
3163
|
+
if (searchQuery.value !== nextSearch) {
|
|
3128
3164
|
searchInput.value = nextSearch;
|
|
3165
|
+
searchQuery.value = nextSearch;
|
|
3129
3166
|
}
|
|
3130
3167
|
|
|
3131
3168
|
if (route.query.dateFrom) {
|
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.432",
|
|
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,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Invitations table's empty state (QA sweep 2026-09-28), e.g.
|
|
3
|
+
* "No pending invitations for The LakeGarden Residences. Use Invite member to
|
|
4
|
+
* add someone." / "No expired invitations."
|
|
5
|
+
*/
|
|
6
|
+
export function invitationsEmptyText({
|
|
7
|
+
status = "pending",
|
|
8
|
+
siteName = "",
|
|
9
|
+
canInvite = true,
|
|
10
|
+
}: { status?: string; siteName?: string; canInvite?: boolean } = {}): string {
|
|
11
|
+
if (status === "expired") return "No expired invitations.";
|
|
12
|
+
const where = siteName ? ` for ${siteName}` : "";
|
|
13
|
+
return `No pending invitations${where}.${canInvite ? " Use Invite member to add someone." : ""}`;
|
|
14
|
+
}
|
package/utils/role.ts
CHANGED
|
@@ -73,3 +73,24 @@ export function otherSiteBannerText(count: unknown): string | null {
|
|
|
73
73
|
? "1 member here has a role from another site. Assign them a role for this site."
|
|
74
74
|
: `${n} members here have a role from another site. Assign each one a role for this site.`;
|
|
75
75
|
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Can this member's CURRENT role be used on the screen's site? The server's
|
|
79
|
+
* `roleState` is empty for a usable role and names the problem otherwise
|
|
80
|
+
* ("other-site", "other-org", "deleted", "missing"). An unusable role is never
|
|
81
|
+
* pre-filled in Assign Role nor offered in its list (owner report 2026-09-28).
|
|
82
|
+
*/
|
|
83
|
+
export function roleUsableHere(member: { role?: unknown; roleState?: unknown }): boolean {
|
|
84
|
+
return !!member?.role && !member?.roleState;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Assign Role's empty state when the site has no role of its own yet. */
|
|
88
|
+
export function noRolesForSiteText(siteName?: string | null): string {
|
|
89
|
+
return `No roles created for ${siteName || "this site"} yet. Create one in Roles & Permissions.`;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/** A same-app path to return to (`?returnTo=`), or "" - never another origin. */
|
|
93
|
+
export function safeReturnTo(value: unknown): string {
|
|
94
|
+
const path = Array.isArray(value) ? value[0] : value;
|
|
95
|
+
return typeof path === "string" && /^\/(?!\/)[^\s\\]*$/.test(path) ? path : "";
|
|
96
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Visitor Management search box rules (VisitorManagement.vue). The server does
|
|
3
|
+
* the matching (name, plate, phone, NRIC, company, purpose, block/unit - see
|
|
4
|
+
* @7365admin1/core visitor-search.util); this only decides WHEN to ask.
|
|
5
|
+
* Browser-safe: no Node globals. Tested by utils/visitor-search.test.ts.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** Characters needed before a search is sent; shorter means "no search". */
|
|
9
|
+
export const VISITOR_SEARCH_MIN_LENGTH = 2;
|
|
10
|
+
|
|
11
|
+
/** Wait after the last keystroke before searching. */
|
|
12
|
+
export const VISITOR_SEARCH_DEBOUNCE_MS = 350;
|
|
13
|
+
|
|
14
|
+
/** The text to send for what is in the box: trimmed, or "" when too short. */
|
|
15
|
+
export function visitorSearchQuery(raw: unknown): string {
|
|
16
|
+
const text = typeof raw === "string" ? raw.replace(/\s+/g, " ").trim() : "";
|
|
17
|
+
return text.length >= VISITOR_SEARCH_MIN_LENGTH ? text : "";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** The empty-table sentence: names the search when there is one. */
|
|
21
|
+
export function visitorSearchEmptyText(query: string): string {
|
|
22
|
+
return query ? `No visitors match '${query}'` : "No data available";
|
|
23
|
+
}
|