@7365admin1/layer-common 4.97.0 → 4.97.1-staging.501

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.
Files changed (62) hide show
  1. package/CHANGELOG.md +4 -4
  2. package/assets/css/primitives.css +57 -0
  3. package/assets/css/screens.css +8 -4
  4. package/components/AccessCardDetailsDialog.vue +59 -6
  5. package/components/AccessCardPreviewDialog.vue +371 -53
  6. package/components/AppSelect.vue +143 -4
  7. package/components/BuildingUnitFormEdit.vue +6 -0
  8. package/components/BuildingUnitManagement.vue +298 -0
  9. package/components/Dialog/UpdateMoreAction.vue +11 -1
  10. package/components/DocumentForm.vue +407 -112
  11. package/components/DocumentManagement.vue +213 -12
  12. package/components/Facility/BookingSetup.vue +63 -0
  13. package/components/HidAccessLogDashboard.vue +74 -17
  14. package/components/HidAccessPermissions.vue +532 -0
  15. package/components/HidIntercomManagement.vue +183 -14
  16. package/components/HidProfileQrCode.vue +332 -0
  17. package/components/HidQrCodeConfiguration.vue +17 -195
  18. package/components/HidReaderManagement.vue +398 -0
  19. package/components/HidReaderUserRoster.vue +44 -3
  20. package/components/HidUserEnrollment.vue +2242 -279
  21. package/components/InvitationClientForm.vue +19 -1
  22. package/components/Nfc/NFCPatrolRouteForm.vue +109 -58
  23. package/components/Nfc/NFCPatrolRouteMain.vue +3 -18
  24. package/components/Nfc/PatrolReport/PatrolActivityTable.vue +0 -8
  25. package/components/Nfc/PatrolReport/PatrolRouteSummary.vue +1 -1
  26. package/components/ServiceProviderMain.vue +48 -0
  27. package/components/SiteProviderChange.vue +371 -0
  28. package/components/TableMain.vue +22 -7
  29. package/components/VisitorForm.vue +12 -0
  30. package/components/VisitorManagement.vue +267 -5
  31. package/composables/useAccessManagement.ts +17 -1
  32. package/composables/useCustomerSite.ts +29 -0
  33. package/composables/useDocument.ts +7 -0
  34. package/composables/useFacility.ts +11 -0
  35. package/composables/useHidAmico.ts +165 -0
  36. package/composables/useHidNavigation.ts +25 -1
  37. package/composables/useHidReaderSelection.ts +50 -0
  38. package/composables/useMember.ts +12 -0
  39. package/composables/useNFCPatrolReport.ts +36 -32
  40. package/composables/useNFCPatrolReportFilters.ts +21 -3
  41. package/composables/useNFCPatrolRoute.ts +10 -3
  42. package/composables/usePeople.ts +19 -0
  43. package/composables/useServiceProvider.ts +45 -2
  44. package/composables/useSiteCategory.ts +45 -0
  45. package/package.json +1 -1
  46. package/pages/[org]/[site]/access-mgmt/administrator/index.vue +1 -1
  47. package/pages/[org]/[site]/access-mgmt/hid-cards/index.vue +1 -1
  48. package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +23 -0
  49. package/pages/[org]/[site]/access-mgmt/hid-readers/index.vue +1 -1
  50. package/types/document.d.ts +14 -0
  51. package/types/facility.d.ts +4 -0
  52. package/types/member.d.ts +4 -0
  53. package/types/nfc-patrol-report.ts +0 -2
  54. package/types/people.d.ts +28 -1
  55. package/types/service-provider.d.ts +5 -0
  56. package/types/site.d.ts +7 -1
  57. package/utils/hid-enrolment-subject.ts +366 -0
  58. package/utils/hid-permission-assignments.ts +259 -0
  59. package/utils/hid-reader-selection.ts +52 -0
  60. package/utils/nfc-patrol-time.ts +99 -0
  61. package/utils/occupancy-role.ts +109 -0
  62. package/utils/service-type.ts +30 -0
@@ -0,0 +1,99 @@
1
+ /**
2
+ * Times on an NFC patrol log, read the way they were written.
3
+ *
4
+ * Logs created since core reads the patrol window on the site's clock carry
5
+ * `timezone`, and every time on them is a real instant: show it on that clock.
6
+ *
7
+ * Older logs have no `timezone`. Their SCHEDULED times - each checkpoint's
8
+ * window, and the end of one not scanned yet - are the site's wall clock
9
+ * written as UTC by the API container, so their UTC digits ARE the wall clock.
10
+ * Scan times were real instants on every log.
11
+ */
12
+
13
+ export const DEFAULT_PATROL_TIMEZONE = "Asia/Singapore";
14
+
15
+ type PatrolCheckpointTimes = {
16
+ status?: string;
17
+ startDateTime?: string | Date;
18
+ endDateTime?: string | Date;
19
+ };
20
+
21
+ type PatrolLogTimes = {
22
+ timezone?: string;
23
+ createdAt?: string | Date;
24
+ checkPoints?: PatrolCheckpointTimes[];
25
+ };
26
+
27
+ function toDate(value?: string | Date | null): Date | null {
28
+ if (!value) return null;
29
+ const date = new Date(value);
30
+ return Number.isNaN(date.getTime()) ? null : date;
31
+ }
32
+
33
+ function formatClock(date: Date, timezone: string) {
34
+ return new Intl.DateTimeFormat("en-GB", {
35
+ hour: "2-digit",
36
+ minute: "2-digit",
37
+ hourCycle: "h23",
38
+ timeZone: timezone,
39
+ }).format(date);
40
+ }
41
+
42
+ /** "HH:mm" of an instant on `timezone`'s clock, or "-". */
43
+ export function clockTime(value: string | Date | null | undefined, timezone: string) {
44
+ const date = toDate(value);
45
+ if (!date) return "-";
46
+ try {
47
+ return formatClock(date, timezone);
48
+ } catch {
49
+ // An unknown zone name throws; the site default is what the server assumes.
50
+ return formatClock(date, DEFAULT_PATROL_TIMEZONE);
51
+ }
52
+ }
53
+
54
+ /** "HH:mm" of a wall clock stored as UTC, or "-". */
55
+ function storedWallClock(value?: string | Date | null) {
56
+ const date = toDate(value);
57
+ return date ? date.toISOString().slice(11, 16) : "-";
58
+ }
59
+
60
+ function isFinished(checkpoint: PatrolCheckpointTimes) {
61
+ return checkpoint.status === "Completed" || checkpoint.status === "Skipped";
62
+ }
63
+
64
+ /** The "HH:mm" a report shows for a checkpoint's start and end. */
65
+ export function checkpointClock(
66
+ log: PatrolLogTimes,
67
+ checkpoint: PatrolCheckpointTimes,
68
+ siteTimezone?: string,
69
+ ) {
70
+ const timezone = log.timezone || siteTimezone || DEFAULT_PATROL_TIMEZONE;
71
+ const scheduled = (value?: string | Date) =>
72
+ log.timezone ? clockTime(value, timezone) : storedWallClock(value);
73
+
74
+ return {
75
+ start: scheduled(checkpoint.startDateTime),
76
+ end: isFinished(checkpoint)
77
+ ? clockTime(checkpoint.endDateTime, timezone)
78
+ : scheduled(checkpoint.endDateTime),
79
+ };
80
+ }
81
+
82
+ /**
83
+ * When the patrol really ran: from the guard pressing Start Patrolling (the
84
+ * log is created then, so its `createdAt`) to the last scan or skip. A guard
85
+ * who starts early in the site's early start allowance shows as early. Both
86
+ * are real instants on every log.
87
+ */
88
+ export function actualPatrolSpan(log: PatrolLogTimes): { start?: Date; end?: Date } {
89
+ const start = toDate(log.createdAt) ?? undefined;
90
+
91
+ let end: Date | undefined;
92
+ for (const checkpoint of log.checkPoints ?? []) {
93
+ if (!isFinished(checkpoint)) continue;
94
+ const at = toDate(checkpoint.endDateTime);
95
+ if (at && (!end || at > end)) end = at;
96
+ }
97
+
98
+ return { start, end };
99
+ }
@@ -0,0 +1,109 @@
1
+ /**
2
+ * OWNER / OCCUPANT / PERSON IN CHARGE - the three standings a business
3
+ * tenancy has, and everything the product says about them.
4
+ *
5
+ * One list, because three screens read it: the form that asks the question
6
+ * (`PeopleFormMgmt`), the list and preview that print the answer back, and
7
+ * the row menu that reassigns it (`people-mgmt`). The values are the ones the
8
+ * server stores and validates - `OccupancyRoles` in core's `person.model.ts`
9
+ * - so a value added on one side has to be added on the other.
10
+ */
11
+ export const OCCUPANCY_ROLE_OPTIONS: TOccupancyRoleOption[] = [
12
+ {
13
+ value: "owner",
14
+ title: "Owner",
15
+ action: "Assign Owner",
16
+ prompt: "Assign Owner",
17
+ description:
18
+ "The legal titleholder or primary deed owner of the property.",
19
+ },
20
+ {
21
+ value: "occupant",
22
+ title: "Occupant",
23
+ action: "Assign Occupant",
24
+ prompt: "Assign Occupant",
25
+ description:
26
+ "The person currently living in, renting, or utilizing the physical unit.",
27
+ },
28
+ {
29
+ value: "person-in-charge",
30
+ title: "Person in Charge",
31
+ action: "Assign Person in Charge",
32
+ prompt: "Assign Person in Charge (PIC)",
33
+ description:
34
+ "The designated manager responsible for maintenance, emergencies, and daily operations.",
35
+ },
36
+ ];
37
+
38
+ /**
39
+ * The same three, in the order the ROW MENU draws them, which is not the
40
+ * order the form's radio does. Derived rather than re-typed so the wording
41
+ * cannot drift between the two.
42
+ */
43
+ export const OCCUPANCY_ROLE_ACTIONS: TOccupancyRoleOption[] = (
44
+ ["person-in-charge", "owner", "occupant"] as TOccupancyRole[]
45
+ ).map(
46
+ (value) =>
47
+ OCCUPANCY_ROLE_OPTIONS.find(
48
+ (option) => option.value === value,
49
+ ) as TOccupancyRoleOption,
50
+ );
51
+
52
+ /**
53
+ * The label for a stored role, or "" for a person who was never asked - which
54
+ * is everyone on a residential site and everyone saved before the question
55
+ * existed. Callers decide what to print instead; nobody should print a raw
56
+ * `person-in-charge` at a user.
57
+ */
58
+ export function occupancyRoleLabel(role?: string | null): string {
59
+ return (
60
+ OCCUPANCY_ROLE_OPTIONS.find((option) => option.value === role)?.title ?? ""
61
+ );
62
+ }
63
+
64
+ /**
65
+ * Does this person hold OWNER at their unit?
66
+ *
67
+ * The role when there is one, `isOwner` when there is not - the same test the
68
+ * server applies (`holdsUnitOwner` in core's `unit-owner.util.ts`). A person
69
+ * recorded before the role existed carries only the flag, and the people list
70
+ * already prints them as "Owner".
71
+ */
72
+ export function holdsUnitOwner(person?: {
73
+ occupancyRole?: string | null;
74
+ isOwner?: boolean;
75
+ }): boolean {
76
+ if (!person) return false;
77
+
78
+ if (person.occupancyRole) return person.occupancyRole === "owner";
79
+
80
+ return person.isOwner === true;
81
+ }
82
+
83
+ /**
84
+ * MUST THIS PERSON HAND THE UNIT OVER BEFORE THEY CAN BE DEACTIVATED?
85
+ *
86
+ * The owner of a unit does not leave while they still own it - the standing
87
+ * moves to another tenant at the same block, level and unit first.
88
+ *
89
+ * Keyed to the ROLE and never to `isOwner`, exactly as the server keys it
90
+ * (`mustHandOverBeforeDeactivating` in core): the flag is on every resident in
91
+ * the estate, and no residential screen can change it, so a rule keyed to it
92
+ * would trap records that can never satisfy it.
93
+ */
94
+ export function mustHandOverBeforeDeactivating(person?: {
95
+ occupancyRole?: string | null;
96
+ }): boolean {
97
+ return person?.occupancyRole === "owner";
98
+ }
99
+
100
+ /**
101
+ * Why a deactivation was held back. The SERVER carries the enforcing copy of
102
+ * this rule and of these words (core `unit-owner.util.ts`); this one exists so
103
+ * the console can say it before the round trip rather than after.
104
+ */
105
+ export function ownerHandoverRequiredMessage(name?: string): string {
106
+ const who = name?.trim() ? `"${name.trim()}"` : "This person";
107
+
108
+ return `${who} is the owner of this unit. Assign the owner role to another tenant at the same block, level and unit before deactivating them.`;
109
+ }
@@ -0,0 +1,30 @@
1
+ /**
2
+ * A SERVICE PROVIDER'S LINE OF BUSINESS, AS PEOPLE NAME IT.
3
+ *
4
+ * `/api/service-providers` returns the service CODE (`mechanical_electrical_services`),
5
+ * which is a database value, not something to show an operator. This is the same
6
+ * mapping `API-core src/utils/converter.ts spmServiceNewToOld` applies — copied
7
+ * rather than imported, because that is a server package this layer does not
8
+ * depend on.
9
+ *
10
+ * NOT the same labels as `utils/module-applications.ts APPLICATIONS`. Those name
11
+ * the seven role-permission applications ("Mechanical & electrical", "Pest
12
+ * control") and are keyed `mechanical-electrical`, not `*_services`. These are
13
+ * the shorter names the service-provider screens use ("M&E", "Pest Control").
14
+ *
15
+ * An unknown code is returned untouched: a new service type shows as its raw
16
+ * code, which is visibly odd, rather than vanishing from the row.
17
+ */
18
+ const SERVICE_TYPE_LABELS: Readonly<Record<string, string>> = Object.freeze({
19
+ security_agency: "Security",
20
+ cleaning_services: "Cleaning",
21
+ pool_maintenance_services: "Pool Maintenance",
22
+ pest_control_services: "Pest Control",
23
+ landscaping_services: "Landscape",
24
+ mechanical_electrical_services: "Mechanical & Electrical",
25
+ });
26
+
27
+ export function serviceTypeLabel(service: string | null | undefined): string {
28
+ const code = String(service ?? "");
29
+ return SERVICE_TYPE_LABELS[code] ?? code;
30
+ }