@7365admin1/layer-common 4.21.4-staging.351 → 4.22.1-staging.352
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 +6 -0
- package/components/Dialog/UpdateMoreAction.vue +11 -1
- package/composables/useSiteCategory.ts +45 -0
- package/package.json +1 -1
- package/types/people.d.ts +25 -1
- package/utils/occupancy-role.ts +109 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @iservice365/layer-common
|
|
2
2
|
|
|
3
|
+
## 4.22.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- a0d5977: Vehicle Mgmt: three tabs - Residents, Season Passes and Block Listed - each showing every status (Temporary, Blocked, Unblocked and the rest). Adding a Whitelist vehicle files it as resident, a Season Pass as season_pass, and a Blocklist vehicle as Visitor or Contractor from a new Category dropdown. Adding a plate the site already holds shows which tab and status it is under, with Cancel or Update - Update saves the entered details on that record and moves it to the form's tab. Block and Unblock call the blocklist endpoints; a History button on each plate shows its last 20 changes (who, when, which fields). Visitor Mgmt: a Block button beside a Registered visitor's vehicle number (new `canBlockVehicle` prop) opens the Block Listed form with the plate, name, NRIC and phone filled in and the category taken from the visitor type (guest as Visitor; contractor, delivery, pick-up, drop-off as they are).
|
|
8
|
+
|
|
3
9
|
## 4.21.3
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
Close
|
|
24
24
|
</v-btn>
|
|
25
25
|
|
|
26
|
-
<v-menu v-if="canUpdate || canDelete" contained>
|
|
26
|
+
<v-menu v-if="canUpdate || canDelete || $slots.actions" contained>
|
|
27
27
|
<template #activator="{ props }">
|
|
28
28
|
<v-btn
|
|
29
29
|
variant="flat"
|
|
@@ -42,6 +42,16 @@
|
|
|
42
42
|
render-verified either. Only the row type and the destructive ink
|
|
43
43
|
change. -->
|
|
44
44
|
<v-list class="pa-0 update-more__list">
|
|
45
|
+
<!--
|
|
46
|
+
Screen-specific rows, above Edit and the destructive one.
|
|
47
|
+
|
|
48
|
+
Additive: a screen that passes nothing gets the menu it always
|
|
49
|
+
had, and `$slots.actions` is undefined unless a caller actually
|
|
50
|
+
defines the slot - so the button does not appear over an empty
|
|
51
|
+
list when a screen has neither permission nor extra rows.
|
|
52
|
+
-->
|
|
53
|
+
<slot name="actions" />
|
|
54
|
+
|
|
45
55
|
<v-list-item v-if="canUpdate" @click="emit('edit')">
|
|
46
56
|
<v-list-item-title>
|
|
47
57
|
{{ editButtonLabel }}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE CATEGORY OF THE SITE THE USER IS CURRENTLY IN.
|
|
3
|
+
*
|
|
4
|
+
* One shared answer, published once by the application's layout from the site
|
|
5
|
+
* it already loaded for the switcher, and read by anything that has to behave
|
|
6
|
+
* differently on a commercial or industrial site - the business Add Tenant
|
|
7
|
+
* form, the tenant list. Publishing it rather than re-fetching it per
|
|
8
|
+
* component means no two screens can disagree about which site this is.
|
|
9
|
+
*
|
|
10
|
+
* READ FROM THE CUSTOMER-SITE RECORD, NOT THE SITE RECORD. Both carry a
|
|
11
|
+
* `category` and `customer-site.service` keeps them equal (it writes the site
|
|
12
|
+
* on create and on update), but `siteSchema` DEFAULTS the site's own copy to
|
|
13
|
+
* `commercial` - so a site created without an explicit category reads back as
|
|
14
|
+
* commercial there even when it is a residential estate. The customer-site
|
|
15
|
+
* copy has no default: it is either the category somebody chose or nothing.
|
|
16
|
+
*
|
|
17
|
+
* An empty category means "not published yet" or "never set", and every
|
|
18
|
+
* caller must behave as it did before this existed - never assume commercial
|
|
19
|
+
* from silence.
|
|
20
|
+
*/
|
|
21
|
+
const BUSINESS_SITE_CATEGORIES: string[] = ["commercial", "industrial"];
|
|
22
|
+
|
|
23
|
+
export default function useSiteCategory() {
|
|
24
|
+
const siteCategory = useState<string>("current-site-category", () => "");
|
|
25
|
+
|
|
26
|
+
function setSiteCategory(value?: string | null) {
|
|
27
|
+
siteCategory.value = typeof value === "string" ? value : "";
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The categories whose units are LET TO A BUSINESS rather than lived in.
|
|
32
|
+
*
|
|
33
|
+
* These are the sites where a unit has an owner, an occupier and often a
|
|
34
|
+
* person in charge who is neither, so they are the sites that ask for a
|
|
35
|
+
* tenant's standing and print it back (see `OCCUPANCY_ROLE_OPTIONS`).
|
|
36
|
+
*
|
|
37
|
+
* The category never changes what the APPLICATION is called: the rail says
|
|
38
|
+
* Property Management on every site it serves.
|
|
39
|
+
*/
|
|
40
|
+
const isBusinessSite = computed(() =>
|
|
41
|
+
BUSINESS_SITE_CATEGORIES.includes(siteCategory.value),
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
return { siteCategory, isBusinessSite, setSiteCategory };
|
|
45
|
+
}
|
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.22.1-staging.352",
|
|
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.",
|
package/types/people.d.ts
CHANGED
|
@@ -22,14 +22,38 @@ declare type TPeople = {
|
|
|
22
22
|
email?: string;
|
|
23
23
|
files?: { name: string, id: string }[];
|
|
24
24
|
isOwner?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Owner / occupant / person-in-charge, as the BUSINESS people form asks it.
|
|
27
|
+
* Absent on everyone else - `isOwner` is still the flag that decides unit
|
|
28
|
+
* ownership, and the server derives it from this when it is sent. See
|
|
29
|
+
* `OccupancyRoles` in core's `person.model.ts`.
|
|
30
|
+
*/
|
|
31
|
+
occupancyRole?: TOccupancyRole;
|
|
25
32
|
// Link to this person's `users` row. Empty for the person types that carry
|
|
26
33
|
// no login, and empty for a resident whose account was never written.
|
|
27
34
|
user?: string;
|
|
28
35
|
};
|
|
29
36
|
|
|
37
|
+
declare type TOccupancyRole = "owner" | "occupant" | "person-in-charge";
|
|
38
|
+
|
|
39
|
+
/** One standing and everything the product says about it. See `utils/occupancy-role.ts`. */
|
|
40
|
+
declare type TOccupancyRoleOption = {
|
|
41
|
+
value: TOccupancyRole;
|
|
42
|
+
/** The label a stored role is printed with. */
|
|
43
|
+
title: string;
|
|
44
|
+
/** The row menu's wording. */
|
|
45
|
+
action: string;
|
|
46
|
+
/** The confirmation's heading and its sentence. */
|
|
47
|
+
prompt: string;
|
|
48
|
+
description: string;
|
|
49
|
+
};
|
|
50
|
+
|
|
30
51
|
declare type TPlateNumber = { plateNumber: string, recNo?: string, _id?: string, status: TVehicleStatus, type: TVehicleType, anprCameras?: TVehicleAnprCamera[] };
|
|
31
52
|
|
|
32
53
|
|
|
33
|
-
|
|
54
|
+
// `""` is the FORM's "nothing picked yet" - it is stripped from the payload
|
|
55
|
+
// before it is sent, because absence is what the server reads as "never
|
|
56
|
+
// asked". See `PeopleFormMgmt.vue`.
|
|
57
|
+
declare type TPeoplePayload = Pick<TGuest, "name" | "block" | "level" | "unit" | "unitName" | "contact" | "plateNumber" | "nric" | "contact" | "remarks" | "org" | "site" | "start" | "end" | "type" | "isOwner"> & { status?: string; user?: string; occupancyRole?: TOccupancyRole | "" }
|
|
34
58
|
|
|
35
59
|
declare type TPeopleType = "guest" | "resident" | "tenant"
|
|
@@ -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
|
+
}
|