@7365admin1/layer-common 4.90.2-staging.491 → 4.90.2
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 +10 -4
- package/assets/css/primitives.css +0 -57
- package/assets/css/screens.css +4 -8
- package/components/AccessCardDetailsDialog.vue +6 -59
- package/components/AccessCardPreviewDialog.vue +53 -371
- package/components/AppSelect.vue +4 -143
- package/components/BuildingUnitFormEdit.vue +0 -6
- package/components/Dialog/UpdateMoreAction.vue +1 -11
- package/components/DocumentForm.vue +112 -407
- package/components/DocumentManagement.vue +12 -213
- package/components/Facility/BookingSetup.vue +0 -63
- package/components/HidAccessLogDashboard.vue +17 -74
- package/components/HidIntercomManagement.vue +14 -183
- package/components/HidQrCodeConfiguration.vue +195 -17
- package/components/HidReaderManagement.vue +0 -398
- package/components/HidReaderUserRoster.vue +3 -44
- package/components/HidUserEnrollment.vue +292 -2255
- package/components/InventoryItemDetail.vue +1 -2
- package/components/InventoryLinesDialog.vue +13 -91
- package/components/InventoryPhotoInput.vue +6 -44
- package/components/InventoryReportsTab.vue +3 -23
- package/components/InventoryRequestsTab.vue +4 -27
- package/components/InventoryStockTab.vue +0 -3
- package/components/InvitationClientForm.vue +1 -19
- package/components/InvitationForm.vue +4 -31
- package/components/InvitationMain.vue +22 -124
- package/components/MemberInformation.vue +4 -4
- package/components/PassInformation.vue +2 -2
- package/components/SiteSettings.vue +0 -48
- package/components/TableMain.vue +7 -22
- package/components/VehicleManagement.vue +5 -80
- package/components/VisitorForm.vue +19 -65
- package/components/VisitorManagement.vue +5 -267
- package/composables/useAccessManagement.ts +1 -17
- package/composables/useDocument.ts +0 -7
- package/composables/useFacility.ts +0 -11
- package/composables/useHidAmico.ts +0 -165
- package/composables/useHidNavigation.ts +1 -25
- package/composables/useInventory.ts +1 -4
- package/composables/useMember.ts +0 -12
- package/composables/useNFCPatrolReportFilters.ts +3 -21
- package/composables/useNFCPatrolRoute.ts +1 -8
- package/composables/usePeople.ts +0 -19
- package/composables/useServiceProvider.ts +2 -45
- package/composables/useSettingsPermission.ts +0 -14
- package/composables/useUser.ts +2 -6
- package/composables/useVehicle.ts +1 -40
- package/composables/useVerification.ts +0 -3
- package/middleware/01.auth.ts +7 -3
- package/package.json +1 -1
- package/pages/[org]/[site]/access-mgmt/administrator/index.vue +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-cards/index.vue +1 -1
- package/pages/[org]/[site]/access-mgmt/hid-readers/index.vue +1 -1
- package/types/document.d.ts +0 -14
- package/types/facility.d.ts +0 -4
- package/types/inventory.d.ts +0 -27
- package/types/member.d.ts +0 -4
- package/types/people.d.ts +1 -28
- package/types/service-provider.d.ts +0 -5
- package/types/site.d.ts +1 -7
- package/components/BuildingUnitManagement.vue +0 -298
- package/components/HidAccessPermissions.vue +0 -424
- package/components/HidProfileQrCode.vue +0 -332
- package/components/InventoryPoDialog.vue +0 -111
- package/components/VehicleQrStickerDialog.vue +0 -249
- package/composables/useHidReaderSelection.ts +0 -50
- package/composables/useSiteCategory.ts +0 -45
- package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +0 -23
- package/utils/hid-enrolment-subject.ts +0 -344
- package/utils/hid-permission-assignments.ts +0 -198
- package/utils/hid-reader-selection.ts +0 -52
- package/utils/inventory-receiving.ts +0 -90
- package/utils/invite-group.ts +0 -61
- package/utils/invite-sites.ts +0 -25
- package/utils/occupancy-role.ts +0 -109
- package/utils/service-type.ts +0 -30
- package/utils/vehicle-qr-sticker.ts +0 -184
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
:org="orgId"
|
|
6
6
|
message="Enable HID as a service for this site before managing physical HID cards."
|
|
7
7
|
>
|
|
8
|
-
<HidUserEnrollment :site="siteId"
|
|
8
|
+
<HidUserEnrollment :site="siteId" card-management />
|
|
9
9
|
</HidEnabledGate>
|
|
10
10
|
</v-container>
|
|
11
11
|
</template>
|
package/types/document.d.ts
CHANGED
|
@@ -3,18 +3,4 @@ declare type TDocument = {
|
|
|
3
3
|
name: string;
|
|
4
4
|
attachment: string;
|
|
5
5
|
type: string;
|
|
6
|
-
/**
|
|
7
|
-
* Set at upload or renewal, absent when the document never expires.
|
|
8
|
-
*
|
|
9
|
-
* An ISO instant on the way out of the API and a `YYYY-MM-DD` string on the
|
|
10
|
-
* way back in, which is what `InputDatePicker` binds to - hence the loose
|
|
11
|
-
* type rather than `string`.
|
|
12
|
-
*/
|
|
13
|
-
expiryDate?: string | Date | null;
|
|
14
|
-
remarks?: string;
|
|
15
|
-
size?: number;
|
|
16
|
-
parentId?: string | null;
|
|
17
|
-
createdAt?: string | Date;
|
|
18
|
-
updatedAt?: string | Date;
|
|
19
|
-
status?: string;
|
|
20
6
|
};
|
package/types/facility.d.ts
CHANGED
|
@@ -73,10 +73,6 @@ declare type TFacility = {
|
|
|
73
73
|
hourInterval?: number;
|
|
74
74
|
isBookingFeeEnabled: boolean;
|
|
75
75
|
isGuestEnabled: boolean;
|
|
76
|
-
/** Residents may complete this facility's checklist themselves. */
|
|
77
|
-
isResidentChecklistEnabled?: boolean;
|
|
78
|
-
/** Security may complete it. Mutually exclusive with the above. */
|
|
79
|
-
isSecurityChecklistEnabled?: boolean;
|
|
80
76
|
bookingAmount: number | null;
|
|
81
77
|
peakBookingFeeAmount?: number | null;
|
|
82
78
|
bookingFeeGuestAmount?: number | null;
|
package/types/inventory.d.ts
CHANGED
|
@@ -105,12 +105,6 @@ declare type TInventoryTransaction = {
|
|
|
105
105
|
location?: { type: "common_area" | "tenant_unit"; area?: string; unit?: string; unitName?: string; tenantName?: string };
|
|
106
106
|
reference?: string;
|
|
107
107
|
supplier?: string;
|
|
108
|
-
/** Receiving (2026-10): missing on older rows = PO. */
|
|
109
|
-
receivingType?: "PO" | "DO" | "CASH";
|
|
110
|
-
doNumber?: string;
|
|
111
|
-
doDate?: string | null;
|
|
112
|
-
receiptNumber?: string;
|
|
113
|
-
poOrderedQty?: number | null;
|
|
114
108
|
unitCost: number;
|
|
115
109
|
totalCost: number;
|
|
116
110
|
photos?: { before: string[]; after: string[]; other: string[] };
|
|
@@ -170,24 +164,3 @@ declare type TInventoryHandover = {
|
|
|
170
164
|
createdAt: string;
|
|
171
165
|
decidedAt?: string;
|
|
172
166
|
};
|
|
173
|
-
|
|
174
|
-
/** GET /stores/:id/reports/purchase-order: one item of a PO, ordered (null = not recorded) vs received. */
|
|
175
|
-
declare type TInventoryPoLine = {
|
|
176
|
-
item: string;
|
|
177
|
-
itemName: string;
|
|
178
|
-
unit: string;
|
|
179
|
-
ordered: number | null;
|
|
180
|
-
received: number;
|
|
181
|
-
outstanding: number | null;
|
|
182
|
-
deliveries: {
|
|
183
|
-
_id: string;
|
|
184
|
-
date: string;
|
|
185
|
-
qty: number;
|
|
186
|
-
receivingType: "PO" | "DO" | "CASH";
|
|
187
|
-
doNumber: string;
|
|
188
|
-
doDate: string | null;
|
|
189
|
-
receiptNumber: string;
|
|
190
|
-
supplier: string;
|
|
191
|
-
receivedBy: string;
|
|
192
|
-
}[];
|
|
193
|
-
};
|
package/types/member.d.ts
CHANGED
|
@@ -10,10 +10,6 @@ declare type TMember = {
|
|
|
10
10
|
customerOrgId?: string;
|
|
11
11
|
customerSiteId?: string;
|
|
12
12
|
status?: string;
|
|
13
|
-
email?: string;
|
|
14
|
-
/** The building unit this member manages (a unit's Management tab). */
|
|
15
|
-
unit?: string | null;
|
|
16
|
-
unitName?: string;
|
|
17
13
|
createdAt?: string;
|
|
18
14
|
updatedAt?: string;
|
|
19
15
|
deletedAt?: string;
|
package/types/people.d.ts
CHANGED
|
@@ -22,38 +22,11 @@ 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;
|
|
32
|
-
// Link to this person's `users` row. Empty for the person types that carry
|
|
33
|
-
// no login, and empty for a resident whose account was never written.
|
|
34
|
-
user?: string;
|
|
35
|
-
};
|
|
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
25
|
};
|
|
50
26
|
|
|
51
27
|
declare type TPlateNumber = { plateNumber: string, recNo?: string, _id?: string, status: TVehicleStatus, type: TVehicleType, anprCameras?: TVehicleAnprCamera[] };
|
|
52
28
|
|
|
53
29
|
|
|
54
|
-
|
|
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 | "" }
|
|
30
|
+
declare type TPeoplePayload = Pick<TGuest, "name" | "block" | "level" | "unit" | "unitName" | "contact" | "plateNumber" | "nric" | "contact" | "remarks" | "org" | "site" | "start" | "end" | "type" | "isOwner"> & { status?: string }
|
|
58
31
|
|
|
59
32
|
declare type TPeopleType = "guest" | "resident" | "tenant"
|
|
@@ -7,11 +7,6 @@ declare type TServiceProvider = {
|
|
|
7
7
|
serviceProviderOrgId: string;
|
|
8
8
|
type: string;
|
|
9
9
|
nature: string;
|
|
10
|
-
status?: string;
|
|
11
|
-
email?: string;
|
|
12
|
-
/** The building unit this provider serves (a unit's Management tab). */
|
|
13
|
-
unit?: string | null;
|
|
14
|
-
unitName?: string;
|
|
15
10
|
};
|
|
16
11
|
|
|
17
12
|
declare type TServiceProviderName = {
|
package/types/site.d.ts
CHANGED
|
@@ -5,10 +5,7 @@ declare type THidQrCodeFormat = "0" | "1" | "2";
|
|
|
5
5
|
declare type THidPermissionCategory =
|
|
6
6
|
| "resident"
|
|
7
7
|
| "property_management"
|
|
8
|
-
|
|
9
|
-
| "service_provider"
|
|
10
|
-
/** ONE PERSON from a provider company, by their membership at this site. */
|
|
11
|
-
| "service_provider_member";
|
|
8
|
+
| "service_provider";
|
|
12
9
|
|
|
13
10
|
declare type THidPermissionAssignment = {
|
|
14
11
|
subjectId: string;
|
|
@@ -30,10 +27,7 @@ declare type THidSitePermissions = {
|
|
|
30
27
|
counts: {
|
|
31
28
|
resident: number;
|
|
32
29
|
propertyManagement: number;
|
|
33
|
-
/** Provider COMPANIES granted. */
|
|
34
30
|
serviceProvider: number;
|
|
35
|
-
/** Named provider people granted. Counted apart from the companies. */
|
|
36
|
-
serviceProviderMember: number;
|
|
37
31
|
intercom: number;
|
|
38
32
|
};
|
|
39
33
|
};
|
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<v-card width="100%">
|
|
3
|
-
<v-expansion-panels v-model="panels" variant="accordion" multiple>
|
|
4
|
-
<v-expansion-panel v-for="section in sections" :key="section.key" :value="section.key">
|
|
5
|
-
<v-expansion-panel-title class="bg-primary">
|
|
6
|
-
<span>{{ section.title }} ({{ section.items.length }})</span>
|
|
7
|
-
<v-spacer />
|
|
8
|
-
<!-- @click.stop: the button sits in the panel header, so a click must
|
|
9
|
-
not also open or close the panel. -->
|
|
10
|
-
<v-btn v-if="canUpdate" size="small" variant="tonal" class="text-none mr-4" prepend-icon="mdi-plus"
|
|
11
|
-
@click.stop="openAdd(section.key)">
|
|
12
|
-
Add
|
|
13
|
-
</v-btn>
|
|
14
|
-
</v-expansion-panel-title>
|
|
15
|
-
|
|
16
|
-
<v-expansion-panel-text>
|
|
17
|
-
<v-progress-linear v-if="section.loading" indeterminate color="primary" />
|
|
18
|
-
<v-list v-if="section.items.length" density="compact" class="bg-transparent">
|
|
19
|
-
<v-list-item v-for="item in section.items" :key="item._id" :title="item.name"
|
|
20
|
-
:subtitle="section.subtitle(item)">
|
|
21
|
-
<template v-if="canUpdate" #append>
|
|
22
|
-
<v-btn icon="mdi-close" size="small" variant="text" :loading="removing === item._id"
|
|
23
|
-
:aria-label="`Remove ${item.name} from this unit`" @click="confirmRemove(section.key, item)" />
|
|
24
|
-
</template>
|
|
25
|
-
</v-list-item>
|
|
26
|
-
</v-list>
|
|
27
|
-
<p v-else-if="!section.loading" class="font-weight-semibold text-caption ml-2 mt-5">
|
|
28
|
-
**No {{ section.empty }} to display**
|
|
29
|
-
</p>
|
|
30
|
-
</v-expansion-panel-text>
|
|
31
|
-
</v-expansion-panel>
|
|
32
|
-
</v-expansion-panels>
|
|
33
|
-
|
|
34
|
-
<p v-if="message" class="text-center text-subtitle-2 font-weight-medium text-error mt-4">
|
|
35
|
-
{{ message }}
|
|
36
|
-
</p>
|
|
37
|
-
|
|
38
|
-
<v-dialog v-model="removeDialog" width="450" persistent>
|
|
39
|
-
<v-card width="100%">
|
|
40
|
-
<v-toolbar density="compact" class="pl-4">
|
|
41
|
-
<span class="font-weight-medium text-h5">
|
|
42
|
-
Remove {{ pendingRemove?.section === "members" ? "Management" : "Service Provider" }}
|
|
43
|
-
</span>
|
|
44
|
-
</v-toolbar>
|
|
45
|
-
|
|
46
|
-
<v-card-text>
|
|
47
|
-
<p class="text-subtitle-2 text-center">
|
|
48
|
-
Are you sure you want to remove <strong>{{ pendingRemove?.name }}</strong> from this unit?
|
|
49
|
-
</p>
|
|
50
|
-
</v-card-text>
|
|
51
|
-
|
|
52
|
-
<v-toolbar density="compact">
|
|
53
|
-
<v-row no-gutters>
|
|
54
|
-
<v-col cols="6">
|
|
55
|
-
<v-btn tile block size="48" variant="text" class="text-none" :disabled="!!removing"
|
|
56
|
-
@click="removeDialog = false">
|
|
57
|
-
Cancel
|
|
58
|
-
</v-btn>
|
|
59
|
-
</v-col>
|
|
60
|
-
<v-col cols="6">
|
|
61
|
-
<v-btn tile block size="48" color="primary-button" variant="flat" class="text-none"
|
|
62
|
-
:loading="!!removing" @click="remove">
|
|
63
|
-
Remove
|
|
64
|
-
</v-btn>
|
|
65
|
-
</v-col>
|
|
66
|
-
</v-row>
|
|
67
|
-
</v-toolbar>
|
|
68
|
-
</v-card>
|
|
69
|
-
</v-dialog>
|
|
70
|
-
|
|
71
|
-
<v-dialog v-model="addDialog" width="520" persistent>
|
|
72
|
-
<v-card>
|
|
73
|
-
<v-toolbar density="compact" class="pl-4">
|
|
74
|
-
<span class="font-weight-medium text-h6">Add {{ adding === "members" ? "Management" : "Service Providers" }}</span>
|
|
75
|
-
</v-toolbar>
|
|
76
|
-
<v-card-text>
|
|
77
|
-
<p class="text-caption mb-3">
|
|
78
|
-
Only active {{ adding === "members" ? "members" : "service provider people" }} that are not assigned to a
|
|
79
|
-
unit yet are listed.
|
|
80
|
-
</p>
|
|
81
|
-
<v-autocomplete v-model="selected" v-model:search="candidateSearch" :items="candidates"
|
|
82
|
-
:loading="candidatesLoading" item-title="name" item-value="_id" multiple chips closable-chips
|
|
83
|
-
no-filter density="comfortable" placeholder="Search by name"
|
|
84
|
-
:no-data-text="candidatesLoading ? 'Loading...' : 'No one available'">
|
|
85
|
-
<template #item="{ props: itemProps, item }">
|
|
86
|
-
<v-list-item v-bind="itemProps" :subtitle="subtitleOf(item.raw)" />
|
|
87
|
-
</template>
|
|
88
|
-
</v-autocomplete>
|
|
89
|
-
</v-card-text>
|
|
90
|
-
<v-card-actions>
|
|
91
|
-
<v-spacer />
|
|
92
|
-
<v-btn class="text-none" :disabled="saving" @click="addDialog = false">Cancel</v-btn>
|
|
93
|
-
<v-btn class="text-none" color="primary" variant="flat" :loading="saving" :disabled="!selected.length"
|
|
94
|
-
@click="add">
|
|
95
|
-
Add
|
|
96
|
-
</v-btn>
|
|
97
|
-
</v-card-actions>
|
|
98
|
-
</v-card>
|
|
99
|
-
</v-dialog>
|
|
100
|
-
</v-card>
|
|
101
|
-
</template>
|
|
102
|
-
|
|
103
|
-
<script setup lang="ts">
|
|
104
|
-
/**
|
|
105
|
-
* A building unit's Management tab: the management members and the service
|
|
106
|
-
* provider people (Members > Service Providers, not the provider companies)
|
|
107
|
-
* attached to this unit. Each can be on one unit at a time, and only while
|
|
108
|
-
* active - the server detaches them the moment they are suspended or deleted,
|
|
109
|
-
* so they simply drop off this list.
|
|
110
|
-
*/
|
|
111
|
-
type TSection = "members" | "providers";
|
|
112
|
-
type TRow = {
|
|
113
|
-
_id: string;
|
|
114
|
-
name: string;
|
|
115
|
-
email?: string;
|
|
116
|
-
roleName?: string;
|
|
117
|
-
type?: string;
|
|
118
|
-
company?: string;
|
|
119
|
-
role?: string;
|
|
120
|
-
status?: string;
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
const props = defineProps({
|
|
124
|
-
unitId: {
|
|
125
|
-
type: String,
|
|
126
|
-
required: true,
|
|
127
|
-
},
|
|
128
|
-
/** The unit's site. The route's `site` is used when this is empty. */
|
|
129
|
-
siteId: {
|
|
130
|
-
type: String,
|
|
131
|
-
default: "",
|
|
132
|
-
},
|
|
133
|
-
/** The membership type whose members manage the site. */
|
|
134
|
-
managementType: {
|
|
135
|
-
type: String,
|
|
136
|
-
default: "property_management_agency",
|
|
137
|
-
},
|
|
138
|
-
canUpdate: {
|
|
139
|
-
type: Boolean,
|
|
140
|
-
default: false,
|
|
141
|
-
},
|
|
142
|
-
});
|
|
143
|
-
|
|
144
|
-
const route = useRoute();
|
|
145
|
-
const org = computed(() => (route.params.org as string) ?? "");
|
|
146
|
-
const site = computed(() => props.siteId || ((route.params.site as string) ?? ""));
|
|
147
|
-
|
|
148
|
-
const { getAll: getMembers, updateMemberUnit } = useMember();
|
|
149
|
-
const { getSiteMembers: getProviderPeople, updateSiteMemberUnit: updateProviderUnit } = useServiceProvider();
|
|
150
|
-
const { debounce } = useUtils();
|
|
151
|
-
|
|
152
|
-
const panels = ref<TSection[]>(["members", "providers"]);
|
|
153
|
-
const message = ref("");
|
|
154
|
-
const removing = ref("");
|
|
155
|
-
|
|
156
|
-
function membersQuery(unit: string, search = "") {
|
|
157
|
-
return getMembers({ org: org.value, siteId: site.value, type: props.managementType, status: "active", unit, search, limit: 50 });
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* The site's provider people on `unit`, active only. The endpoint returns the
|
|
162
|
-
* whole list (no paging or search), so `search` is matched here.
|
|
163
|
-
*/
|
|
164
|
-
async function providersQuery(unit: string, search = "") {
|
|
165
|
-
const res = await getProviderPeople(site.value, unit);
|
|
166
|
-
const q = search.toLowerCase();
|
|
167
|
-
const items = (res?.items ?? []).filter(
|
|
168
|
-
(p) => p.status === "active" && (!q || [p.name, p.email, p.company].some((v) => v?.toLowerCase().includes(q))),
|
|
169
|
-
);
|
|
170
|
-
return { items };
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
const { data: memberRes, pending: membersLoading, refresh: refreshMembers } = useLazyAsyncData(
|
|
174
|
-
`unit-management-members-${props.unitId}`,
|
|
175
|
-
() => membersQuery(props.unitId),
|
|
176
|
-
);
|
|
177
|
-
const { data: providerRes, pending: providersLoading, refresh: refreshProviders } = useLazyAsyncData(
|
|
178
|
-
`unit-management-providers-${props.unitId}`,
|
|
179
|
-
() => providersQuery(props.unitId),
|
|
180
|
-
);
|
|
181
|
-
|
|
182
|
-
function subtitleOf(row: TRow) {
|
|
183
|
-
return [row.company, row.roleName || row.role || row.type?.replace(/_/g, " "), row.email]
|
|
184
|
-
.filter(Boolean)
|
|
185
|
-
.join(" · ");
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const sections = computed(() => [
|
|
189
|
-
{
|
|
190
|
-
key: "members" as TSection,
|
|
191
|
-
title: "Management",
|
|
192
|
-
empty: "management",
|
|
193
|
-
items: (memberRes.value?.items ?? []) as TRow[],
|
|
194
|
-
loading: membersLoading.value,
|
|
195
|
-
subtitle: subtitleOf,
|
|
196
|
-
},
|
|
197
|
-
{
|
|
198
|
-
key: "providers" as TSection,
|
|
199
|
-
title: "Service Providers",
|
|
200
|
-
empty: "service providers",
|
|
201
|
-
items: (providerRes.value?.items ?? []) as TRow[],
|
|
202
|
-
loading: providersLoading.value,
|
|
203
|
-
subtitle: subtitleOf,
|
|
204
|
-
},
|
|
205
|
-
]);
|
|
206
|
-
|
|
207
|
-
function refresh(section: TSection) {
|
|
208
|
-
return section === "members" ? refreshMembers() : refreshProviders();
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
function assign(section: TSection, id: string, unit: string) {
|
|
212
|
-
return section === "members" ? updateMemberUnit(id, unit) : updateProviderUnit(id, unit);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
function errorOf(error: any, fallback: string) {
|
|
216
|
-
return error?.response?._data?.message || error?.data?.message || fallback;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
// --- Remove: confirmed first ---
|
|
220
|
-
const removeDialog = ref(false);
|
|
221
|
-
const pendingRemove = ref<{ section: TSection; id: string; name: string } | null>(null);
|
|
222
|
-
|
|
223
|
-
function confirmRemove(section: TSection, row: TRow) {
|
|
224
|
-
message.value = "";
|
|
225
|
-
pendingRemove.value = { section, id: row._id, name: row.name };
|
|
226
|
-
removeDialog.value = true;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
async function remove() {
|
|
230
|
-
if (!pendingRemove.value) return;
|
|
231
|
-
const { section, id } = pendingRemove.value;
|
|
232
|
-
removing.value = id;
|
|
233
|
-
try {
|
|
234
|
-
await assign(section, id, "");
|
|
235
|
-
await refresh(section);
|
|
236
|
-
} catch (error: any) {
|
|
237
|
-
message.value = errorOf(error, "Failed to remove from unit.");
|
|
238
|
-
} finally {
|
|
239
|
-
removing.value = "";
|
|
240
|
-
removeDialog.value = false;
|
|
241
|
-
pendingRemove.value = null;
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
// --- Add dialog: active rows on no unit yet ---
|
|
246
|
-
const addDialog = ref(false);
|
|
247
|
-
const adding = ref<TSection>("members");
|
|
248
|
-
const selected = ref<string[]>([]);
|
|
249
|
-
const candidates = ref<TRow[]>([]);
|
|
250
|
-
const candidateSearch = ref("");
|
|
251
|
-
const candidatesLoading = ref(false);
|
|
252
|
-
const saving = ref(false);
|
|
253
|
-
|
|
254
|
-
async function loadCandidates() {
|
|
255
|
-
candidatesLoading.value = true;
|
|
256
|
-
try {
|
|
257
|
-
const search = candidateSearch.value?.trim() ?? "";
|
|
258
|
-
const res = adding.value === "members" ? await membersQuery("none", search) : await providersQuery("none", search);
|
|
259
|
-
// Keep what is already picked, so a new search does not drop the chips.
|
|
260
|
-
const picked = candidates.value.filter((c) => selected.value.includes(c._id));
|
|
261
|
-
const found = ((res?.items ?? []) as TRow[]).filter((c) => !selected.value.includes(c._id));
|
|
262
|
-
candidates.value = [...picked, ...found];
|
|
263
|
-
} catch (error: any) {
|
|
264
|
-
message.value = errorOf(error, "Failed to load the list.");
|
|
265
|
-
} finally {
|
|
266
|
-
candidatesLoading.value = false;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
const debouncedLoad = debounce(loadCandidates, 400);
|
|
271
|
-
watch(candidateSearch, () => {
|
|
272
|
-
if (addDialog.value) debouncedLoad();
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
function openAdd(section: TSection) {
|
|
276
|
-
message.value = "";
|
|
277
|
-
adding.value = section;
|
|
278
|
-
selected.value = [];
|
|
279
|
-
candidates.value = [];
|
|
280
|
-
candidateSearch.value = "";
|
|
281
|
-
addDialog.value = true;
|
|
282
|
-
loadCandidates();
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
async function add() {
|
|
286
|
-
saving.value = true;
|
|
287
|
-
message.value = "";
|
|
288
|
-
const section = adding.value;
|
|
289
|
-
const results = await Promise.allSettled(selected.value.map((id) => assign(section, id, props.unitId)));
|
|
290
|
-
const failed = results.filter((r): r is PromiseRejectedResult => r.status === "rejected");
|
|
291
|
-
if (failed.length) {
|
|
292
|
-
message.value = errorOf(failed[0].reason, `${failed.length} could not be added.`);
|
|
293
|
-
}
|
|
294
|
-
await refresh(section);
|
|
295
|
-
saving.value = false;
|
|
296
|
-
addDialog.value = false;
|
|
297
|
-
}
|
|
298
|
-
</script>
|