@7365admin1/layer-common 4.11.1-staging.313 → 4.11.1-staging.315
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.
|
@@ -99,10 +99,18 @@
|
|
|
99
99
|
<template v-if="passType === 'NFC'">
|
|
100
100
|
<div class="mt-3">
|
|
101
101
|
<InputLabel title="Select Cards" />
|
|
102
|
-
|
|
102
|
+
<!-- Was a `v-select` over the first 100 cards, which only lets the
|
|
103
|
+
operator scroll. Typing now goes to the endpoint as `search`
|
|
104
|
+
(debounced, page 1), and reaching the end of the list fetches
|
|
105
|
+
the next page. Vuetify's own client-side match on `cardNo` is
|
|
106
|
+
left on as well: API-core does not read `search` yet, so until
|
|
107
|
+
it does that is what makes typing narrow the list. -->
|
|
108
|
+
<v-autocomplete
|
|
103
109
|
v-model="selectedCards"
|
|
110
|
+
v-model:search="cardSearch"
|
|
104
111
|
:items="filteredCardItems"
|
|
105
112
|
:loading="cardsLoading"
|
|
113
|
+
:hide-no-data="false"
|
|
106
114
|
item-title="cardNo"
|
|
107
115
|
item-value="_id"
|
|
108
116
|
density="comfortable"
|
|
@@ -110,10 +118,30 @@
|
|
|
110
118
|
chips
|
|
111
119
|
closable-chips
|
|
112
120
|
hide-details
|
|
113
|
-
placeholder="
|
|
121
|
+
placeholder="Search or select cards..."
|
|
114
122
|
return-object
|
|
123
|
+
@update:model-value="cardSearch = ''"
|
|
115
124
|
>
|
|
116
|
-
|
|
125
|
+
<template #append-item>
|
|
126
|
+
<!-- Sentinel for infinite scroll. Keyed on the page so it
|
|
127
|
+
re-mounts after each append: an IntersectionObserver only
|
|
128
|
+
reports changes, so a sentinel that stays in view after a
|
|
129
|
+
short page would otherwise never fire again. -->
|
|
130
|
+
<div
|
|
131
|
+
v-if="cardHasMore"
|
|
132
|
+
:key="cardPage"
|
|
133
|
+
v-intersect="onCardListEndReached"
|
|
134
|
+
class="d-flex justify-center py-2"
|
|
135
|
+
>
|
|
136
|
+
<v-progress-circular
|
|
137
|
+
v-if="cardsLoadingMore"
|
|
138
|
+
indeterminate
|
|
139
|
+
size="20"
|
|
140
|
+
width="2"
|
|
141
|
+
/>
|
|
142
|
+
</div>
|
|
143
|
+
</template>
|
|
144
|
+
</v-autocomplete>
|
|
117
145
|
</div>
|
|
118
146
|
|
|
119
147
|
<div class="mt-3">
|
|
@@ -322,6 +350,7 @@ const props = defineProps({
|
|
|
322
350
|
const emit = defineEmits(["update:modelValue", "update:quantity", "update:cards", "update:availableQrCount"]);
|
|
323
351
|
|
|
324
352
|
const { getAvailableContractorCards, generateQrVms } = useAccessManagement();
|
|
353
|
+
const { debounce } = useUtils();
|
|
325
354
|
|
|
326
355
|
const nfcEnabled = computed(() => props.settings?.data?.settings?.nfcPass ?? false);
|
|
327
356
|
const hidQrCodeEnabled = computed(() => {
|
|
@@ -367,21 +396,53 @@ const filteredCardItems = computed(() =>
|
|
|
367
396
|
: cardItems.value
|
|
368
397
|
);
|
|
369
398
|
const cardsLoading = ref(false);
|
|
399
|
+
const cardsLoadingMore = ref(false);
|
|
400
|
+
// Typed text in the card picker. Reset after each pick so the next search
|
|
401
|
+
// starts from the full list instead of staying narrowed to the last term.
|
|
402
|
+
const cardSearch = ref("");
|
|
403
|
+
const CARD_PAGE_SIZE = 100;
|
|
404
|
+
const cardPage = ref(1);
|
|
405
|
+
const cardHasMore = ref(false);
|
|
406
|
+
// Bumped on every request. A response whose number is no longer current is
|
|
407
|
+
// dropped, so a slow page-1 search cannot overwrite a newer one and a
|
|
408
|
+
// load-more cannot append onto a list that has since been replaced.
|
|
409
|
+
let cardRequestSeq = 0;
|
|
370
410
|
const generating = ref(false);
|
|
371
411
|
const availableCount = ref<number | null>(null);
|
|
372
412
|
|
|
373
|
-
|
|
413
|
+
// The picker is NFC-only (see the template's `v-if`), so only NFC fetches
|
|
414
|
+
// carry the search term and only NFC reacts to typing. The QR path keeps
|
|
415
|
+
// its page-1, no-search fetch and its top-up generation untouched.
|
|
416
|
+
const cardFetchType = computed<"NFC" | "QRCODE" | null>(() =>
|
|
417
|
+
passType.value === "NFC" ? "NFC" : passType.value === "QR" ? "QRCODE" : null,
|
|
418
|
+
);
|
|
419
|
+
|
|
420
|
+
async function fetchCards(
|
|
421
|
+
type: "NFC" | "QRCODE" = "NFC",
|
|
422
|
+
opts: { page?: number; append?: boolean } = {},
|
|
423
|
+
) {
|
|
374
424
|
if (!props.siteId || !props.unitId) return;
|
|
375
|
-
|
|
425
|
+
const page = opts.page ?? 1;
|
|
426
|
+
const append = opts.append === true;
|
|
427
|
+
const seq = ++cardRequestSeq;
|
|
428
|
+
const query = {
|
|
429
|
+
type,
|
|
430
|
+
siteId: props.siteId,
|
|
431
|
+
unitId: props.unitId,
|
|
432
|
+
page,
|
|
433
|
+
limit: CARD_PAGE_SIZE,
|
|
434
|
+
// Vuetify writes null into the search model when it clears the field.
|
|
435
|
+
search: type === "NFC" ? cardSearch.value ?? "" : undefined,
|
|
436
|
+
};
|
|
437
|
+
|
|
438
|
+
if (append) cardsLoadingMore.value = true;
|
|
439
|
+
else cardsLoading.value = true;
|
|
376
440
|
if (type === "QRCODE") emit("update:availableQrCount", null);
|
|
377
441
|
try {
|
|
378
|
-
const res = await getAvailableContractorCards(
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
});
|
|
383
|
-
cardItems.value = res?.data?.[0]?.items ?? [];
|
|
384
|
-
availableCount.value = (res?.data?.[2] as any)?.count ?? cardItems.value.length;
|
|
442
|
+
const res = await getAvailableContractorCards(query);
|
|
443
|
+
if (seq !== cardRequestSeq) return;
|
|
444
|
+
let items: any[] = res?.data?.[0]?.items ?? [];
|
|
445
|
+
availableCount.value = (res?.data?.[2] as any)?.count ?? items.length;
|
|
385
446
|
|
|
386
447
|
if (type === "QRCODE" && props.settings?.data?._id && availableCount.value !== null && availableCount.value > 0 && availableCount.value < 50) {
|
|
387
448
|
cardsLoading.value = false;
|
|
@@ -392,30 +453,64 @@ async function fetchCards(type: "NFC" | "QRCODE" = "NFC") {
|
|
|
392
453
|
quantity: 50,
|
|
393
454
|
});
|
|
394
455
|
// Re-fetch to get the updated count after generation
|
|
395
|
-
const refreshed = await getAvailableContractorCards(
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
});
|
|
400
|
-
cardItems.value = refreshed?.data?.[0]?.items ?? [];
|
|
401
|
-
availableCount.value = (refreshed?.data?.[2] as any)?.count ?? cardItems.value.length;
|
|
456
|
+
const refreshed = await getAvailableContractorCards(query);
|
|
457
|
+
if (seq !== cardRequestSeq) return;
|
|
458
|
+
items = refreshed?.data?.[0]?.items ?? [];
|
|
459
|
+
availableCount.value = (refreshed?.data?.[2] as any)?.count ?? items.length;
|
|
402
460
|
generating.value = false;
|
|
403
461
|
}
|
|
404
462
|
|
|
463
|
+
cardItems.value = append ? [...cardItems.value, ...items] : items;
|
|
464
|
+
cardPage.value = page;
|
|
465
|
+
// A short page is the last one. An exact multiple of the page size costs
|
|
466
|
+
// one extra, empty fetch, which then turns this off.
|
|
467
|
+
cardHasMore.value = items.length === CARD_PAGE_SIZE;
|
|
468
|
+
|
|
405
469
|
if (type === "QRCODE") emit("update:availableQrCount", availableCount.value);
|
|
406
470
|
} catch (err: any) {
|
|
471
|
+
if (seq !== cardRequestSeq) return;
|
|
407
472
|
const msg = err?.data?.message ?? err?.message ?? String(err);
|
|
408
473
|
showSnackbar(`Entry pass service error: ${msg}`);
|
|
409
|
-
availableCount.value = null;
|
|
410
|
-
cardItems.value = [];
|
|
411
474
|
generating.value = false;
|
|
412
|
-
|
|
475
|
+
// A failed load-more keeps what is already listed; a failed first page
|
|
476
|
+
// clears the list as before.
|
|
477
|
+
if (!append) {
|
|
478
|
+
availableCount.value = null;
|
|
479
|
+
cardItems.value = [];
|
|
480
|
+
cardHasMore.value = false;
|
|
481
|
+
if (type === "QRCODE") emit("update:availableQrCount", null);
|
|
482
|
+
}
|
|
413
483
|
} finally {
|
|
414
|
-
|
|
415
|
-
|
|
484
|
+
// Only the request that is still current may clear the flags; a stale
|
|
485
|
+
// one finishing late must not switch off a newer request's spinner.
|
|
486
|
+
if (seq === cardRequestSeq) {
|
|
487
|
+
cardsLoading.value = false;
|
|
488
|
+
cardsLoadingMore.value = false;
|
|
489
|
+
generating.value = false;
|
|
490
|
+
}
|
|
416
491
|
}
|
|
417
492
|
}
|
|
418
493
|
|
|
494
|
+
function onCardListEndReached(isIntersecting: boolean) {
|
|
495
|
+
if (!isIntersecting || !cardHasMore.value) return;
|
|
496
|
+
if (cardsLoading.value || cardsLoadingMore.value) return;
|
|
497
|
+
const type = cardFetchType.value;
|
|
498
|
+
if (!type) return;
|
|
499
|
+
fetchCards(type, { page: cardPage.value + 1, append: true });
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
const searchCards = debounce(() => {
|
|
503
|
+
if (cardFetchType.value !== "NFC") return;
|
|
504
|
+
fetchCards("NFC");
|
|
505
|
+
}, 500);
|
|
506
|
+
|
|
507
|
+
// Vuetify hands back null when it clears the field, and re-sets "" on blur;
|
|
508
|
+
// only a real change of the trimmed term should cost a request.
|
|
509
|
+
watch(cardSearch, (val, old) => {
|
|
510
|
+
if ((val ?? "").trim() === (old ?? "").trim()) return;
|
|
511
|
+
searchCards();
|
|
512
|
+
});
|
|
513
|
+
|
|
419
514
|
function addCard(card: any) {
|
|
420
515
|
const already = selectedCards.value.some((c) => c._id === card._id);
|
|
421
516
|
if (!already) selectedCards.value = [...selectedCards.value, card];
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
:rules="[requiredRule, emailRule]"
|
|
17
17
|
:loading="loading.verifyingEmail"
|
|
18
18
|
/>
|
|
19
|
-
<div v-if="existingUserMessage" class="text-subtitle-2 text-
|
|
19
|
+
<div v-if="existingUserMessage" class="text-subtitle-2 text-medium-emphasis mt-n3 mb-2">
|
|
20
20
|
{{ existingUserMessage }}
|
|
21
21
|
</div>
|
|
22
22
|
</v-col>
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
|
|
61
61
|
<template #subtitle>
|
|
62
62
|
<span v-if="item.raw.disabled" class="text-error text-caption">
|
|
63
|
-
|
|
63
|
+
{{ APP_TAKEN_NOTE }}
|
|
64
64
|
</span>
|
|
65
65
|
</template>
|
|
66
66
|
</v-list-item>
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
|
|
71
71
|
<!-- ROLE -->
|
|
72
72
|
<v-col cols="12">
|
|
73
|
-
<InputLabel title="Role" />
|
|
73
|
+
<InputLabel title="Role" required />
|
|
74
74
|
<v-autocomplete
|
|
75
75
|
v-model="invite.role"
|
|
76
76
|
:items="roles"
|
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
|
|
85
85
|
<!-- SITE -->
|
|
86
86
|
<v-col v-if="hasSite" cols="12">
|
|
87
|
-
<InputLabel title="Site" />
|
|
87
|
+
<InputLabel title="Site" required />
|
|
88
88
|
<v-autocomplete
|
|
89
89
|
v-model="invite.site"
|
|
90
90
|
:items="sites"
|
|
@@ -206,6 +206,13 @@ watch(
|
|
|
206
206
|
{ immediate: true }
|
|
207
207
|
)
|
|
208
208
|
|
|
209
|
+
/*
|
|
210
|
+
* Why an app cannot be ticked. It used to say the person was already a member,
|
|
211
|
+
* which is not what is checked: the option is disabled when this e-mail holds a membership
|
|
212
|
+
* of that app type in ANY client (`getAllByUserId` below), not in this one.
|
|
213
|
+
*/
|
|
214
|
+
const APP_TAKEN_NOTE = "Already uses this app in another client"
|
|
215
|
+
|
|
209
216
|
const apps = computed(() => {
|
|
210
217
|
return APP_LIST.map(app => {
|
|
211
218
|
const disabled = userAccess.value.some(
|
|
@@ -218,8 +225,16 @@ const apps = computed(() => {
|
|
|
218
225
|
/* ================= SITE ================= */
|
|
219
226
|
const { natureOfBusiness } = useLocal()
|
|
220
227
|
|
|
228
|
+
/*
|
|
229
|
+
* A site can only be chosen for an organisation that exists. `invite.app` is an
|
|
230
|
+
* ARRAY, and this compared it to each nature's string, so the field could never
|
|
231
|
+
* show; and the site list was requested with no organisation at all. Inviting a
|
|
232
|
+
* brand-new client (the console's Invite Client) has no organisation and so no
|
|
233
|
+
* sites - the field stays hidden and nothing is requested.
|
|
234
|
+
*/
|
|
221
235
|
const hasSite = computed(() =>
|
|
222
|
-
|
|
236
|
+
!!org.value?._id &&
|
|
237
|
+
invite.value.app.some(app => natureOfBusiness.some(i => i.value === app))
|
|
223
238
|
)
|
|
224
239
|
|
|
225
240
|
const sites = ref<any[]>([])
|
|
@@ -227,7 +242,10 @@ const { getAll: getAllCustomerSite } = useCustomerSite()
|
|
|
227
242
|
|
|
228
243
|
const { data: siteData, refresh: refreshSiteData } = await useLazyAsyncData(
|
|
229
244
|
"sites",
|
|
230
|
-
() =>
|
|
245
|
+
() =>
|
|
246
|
+
org.value?._id
|
|
247
|
+
? getAllCustomerSite({ org: org.value._id, limit: 50 })
|
|
248
|
+
: Promise.resolve({ items: [] })
|
|
231
249
|
)
|
|
232
250
|
|
|
233
251
|
watchEffect(() => {
|
|
@@ -351,7 +369,10 @@ async function checkEmail(email: string) {
|
|
|
351
369
|
|
|
352
370
|
if (user?._id) {
|
|
353
371
|
existingUser.value = user
|
|
354
|
-
|
|
372
|
+
// Not an error: an existing account can be invited, and accepting adds
|
|
373
|
+
// the new client to it. The old wording read as a refusal.
|
|
374
|
+
existingUserMessage.value =
|
|
375
|
+
"This e-mail already has an iService365 account. Accepting the invitation adds this client to it."
|
|
355
376
|
|
|
356
377
|
const memberRes = await getAllByUserId(user._id)
|
|
357
378
|
|
|
@@ -228,7 +228,11 @@ export default function useAccessManagement() {
|
|
|
228
228
|
unitId: string;
|
|
229
229
|
page?: number;
|
|
230
230
|
limit?: number;
|
|
231
|
+
/** Card-number search. Sent only when non-empty; API-core does not read
|
|
232
|
+
* it yet, so until it does the list comes back unfiltered. */
|
|
233
|
+
search?: string;
|
|
231
234
|
}) {
|
|
235
|
+
const search = params.search?.trim();
|
|
232
236
|
return useNuxtApp().$api<Record<string, any>>(
|
|
233
237
|
`/api/access-management/available-card-contractor/${params.type}`,
|
|
234
238
|
{
|
|
@@ -238,6 +242,7 @@ export default function useAccessManagement() {
|
|
|
238
242
|
unitId: params.unitId,
|
|
239
243
|
page: params.page ?? 1,
|
|
240
244
|
limit: params.limit ?? 100,
|
|
245
|
+
...(search ? { search } : {}),
|
|
241
246
|
},
|
|
242
247
|
}
|
|
243
248
|
);
|
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.11.1-staging.
|
|
5
|
+
"version": "4.11.1-staging.315",
|
|
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.",
|