@7365admin1/layer-common 4.185.0 → 4.185.1
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
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @iservice365/layer-common
|
|
2
2
|
|
|
3
|
+
## 4.185.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b5d02c0: Visitor form: look saved people up by phone only once the number is complete for its country (visitor and contractor member).
|
|
8
|
+
|
|
3
9
|
## 4.185.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
|
@@ -4028,11 +4034,11 @@ Monthly report: a month that had patrols opens the list of that month's patrol r
|
|
|
4028
4034
|
`utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
|
|
4029
4035
|
own rule from two endpoints the console already calls, unprojected:
|
|
4030
4036
|
|
|
4031
|
-
|
|
4032
|
-
|
|
4037
|
+
GET /api/members/user/:user/app/admin the Seven365 staff membership
|
|
4038
|
+
GET /api/roles/id/:role that membership's role document
|
|
4033
4039
|
|
|
4034
|
-
|
|
4035
|
-
|
|
4040
|
+
owner = member.type === "admin" && role.type === "admin" && role.default === true
|
|
4041
|
+
staff = member.type === "admin" && role.type === "admin"
|
|
4036
4042
|
|
|
4037
4043
|
`role.default` is the marker because it is the only property of a platform
|
|
4038
4044
|
staff role no API caller can set - `role.controller.ts` validates create and
|
|
@@ -202,6 +202,7 @@ import usePassKey from "../composables/usePassKey";
|
|
|
202
202
|
import useUtils from "../composables/useUtils";
|
|
203
203
|
import usePeople from "../composables/usePeople";
|
|
204
204
|
import { errorConverter } from "../utils/data";
|
|
205
|
+
import { isCompletePhoneNumber } from "../utils/phone-complete";
|
|
205
206
|
import {
|
|
206
207
|
DELETE_PERSON_TITLE,
|
|
207
208
|
PERSON_DELETED_MESSAGE,
|
|
@@ -502,13 +503,16 @@ const memberSelectedContactOptions = computed(() => {
|
|
|
502
503
|
: [];
|
|
503
504
|
});
|
|
504
505
|
|
|
505
|
-
// Member NRIC / phone lookups (isecure365 `scheduleMemberLookup`): 4
|
|
506
|
-
// characters or more, 500 ms after the last
|
|
506
|
+
// Member NRIC / phone lookups (isecure365 `scheduleMemberLookup`): NRIC 4
|
|
507
|
+
// characters or more, the phone only once complete, 500 ms after the last
|
|
508
|
+
// keystroke, across every visitor
|
|
507
509
|
// type. One person is filled in straight away (or the chooser opens).
|
|
508
510
|
const lookupTimers: Record<string, ReturnType<typeof setTimeout> | undefined> = {};
|
|
509
511
|
|
|
510
512
|
function memberTerm(by: "nric" | "contact") {
|
|
511
|
-
|
|
513
|
+
if (by === "nric") return memberForm.nric?.trim() || "";
|
|
514
|
+
// The phone only once the whole number is typed (see isCompletePhoneNumber).
|
|
515
|
+
return isCompletePhoneNumber(memberForm.contact) ? memberForm.contact.trim() : "";
|
|
512
516
|
}
|
|
513
517
|
|
|
514
518
|
function scheduleMemberLookup(by: "nric" | "contact") {
|
|
@@ -846,6 +846,7 @@ import useHidAmico from "../composables/useHidAmico";
|
|
|
846
846
|
import useFile from "../composables/useFile";
|
|
847
847
|
import usePassKey from "../composables/usePassKey";
|
|
848
848
|
import { defaultGateForSite } from "../utils/visitor-camera";
|
|
849
|
+
import { isCompletePhoneNumber } from "../utils/phone-complete";
|
|
849
850
|
import { barrierCameraOf, barrierOf, type TBarrierOutcome } from "../utils/visitor-barrier";
|
|
850
851
|
import VisitorPassKeyQRScanner from "./VisitorPassKeyQRScanner.vue";
|
|
851
852
|
import {
|
|
@@ -1392,8 +1393,9 @@ const companyCombo = ref(null);
|
|
|
1392
1393
|
/*
|
|
1393
1394
|
* People lookup and autofill, as the security mobile app (isecure365 `add.tsx`
|
|
1394
1395
|
* lookup / choosePerson / applyPerson):
|
|
1395
|
-
* - typing 4 characters or more of the NRIC
|
|
1396
|
-
*
|
|
1396
|
+
* - typing 4 characters or more of the NRIC or plate, or a COMPLETE phone
|
|
1397
|
+
* number (isCompletePhoneNumber), looks the person up, 500 ms after the
|
|
1398
|
+
* last keystroke, across EVERY
|
|
1397
1399
|
* visitor type (the type being registered first); not for pick-up /
|
|
1398
1400
|
* drop-off, which carry no person;
|
|
1399
1401
|
* - exactly one person is filled in straight away (or, with several phone
|
|
@@ -1416,7 +1418,8 @@ const lookupTimers: Partial<Record<LookupField, ReturnType<typeof setTimeout>>>
|
|
|
1416
1418
|
|
|
1417
1419
|
function lookupTerm(by: LookupField) {
|
|
1418
1420
|
if (by === "nric") return visitor.nric?.trim() || "";
|
|
1419
|
-
|
|
1421
|
+
// The phone only once the whole number is typed (see isCompletePhoneNumber).
|
|
1422
|
+
if (by === "contact") return isCompletePhoneNumber(visitor.contact) ? visitor.contact.trim() : "";
|
|
1420
1423
|
return visitor.plateNumber?.trim()?.toUpperCase() || "";
|
|
1421
1424
|
}
|
|
1422
1425
|
|
|
@@ -1526,7 +1529,7 @@ watch(
|
|
|
1526
1529
|
watch(
|
|
1527
1530
|
() => visitor.contact,
|
|
1528
1531
|
(value) => {
|
|
1529
|
-
if (!value
|
|
1532
|
+
if (!isCompletePhoneNumber(value)) {
|
|
1530
1533
|
phoneSearchMenu.value = false;
|
|
1531
1534
|
phoneSearchResults.value = [];
|
|
1532
1535
|
}
|
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.185.
|
|
5
|
+
"version": "4.185.1",
|
|
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,19 @@
|
|
|
1
|
+
import phoneMasks from "./phoneMasks";
|
|
2
|
+
|
|
3
|
+
type TPhoneMask = { dial_code: string; regex: string };
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* True only for a WHOLE phone number in the stored E.164 shape (`+6591234567`):
|
|
7
|
+
* it matches the pattern of a country whose dial code it starts with (the same
|
|
8
|
+
* patterns InputPhoneNumberV2 validates with). A part-typed number is not
|
|
9
|
+
* complete. The visitor form looks saved people up by phone only once this is
|
|
10
|
+
* true: the people search matches numbers that CONTAIN the term, so a partial
|
|
11
|
+
* number found unrelated people and a single match was filled in straight away.
|
|
12
|
+
*/
|
|
13
|
+
export function isCompletePhoneNumber(value: string | null | undefined): boolean {
|
|
14
|
+
const phone = String(value ?? "").trim();
|
|
15
|
+
if (!phone.startsWith("+")) return false;
|
|
16
|
+
return (phoneMasks as TPhoneMask[]).some(
|
|
17
|
+
(country) => phone.startsWith(country.dial_code) && new RegExp(country.regex).test(phone)
|
|
18
|
+
);
|
|
19
|
+
}
|