@7365admin1/layer-common 4.35.1-staging.443 → 4.35.1-staging.445
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/components/BuildingUnitFormEdit.vue +6 -0
- package/components/BuildingUnitManagement.vue +277 -0
- package/components/RolePermissionFormCreate.vue +24 -11
- package/components/RolePermissionFormPreviewUpdate.vue +31 -15
- package/composables/useMember.ts +12 -0
- package/composables/useServiceProvider.ts +15 -0
- package/package.json +1 -1
- package/types/member.d.ts +4 -0
- package/types/service-provider.d.ts +5 -0
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
<v-tab value="general">General</v-tab>
|
|
11
11
|
<v-tab value="residents">Residents/Tenants</v-tab>
|
|
12
12
|
<v-tab value="vehicles">Vehicles</v-tab>
|
|
13
|
+
<v-tab value="management">Management</v-tab>
|
|
13
14
|
<v-tab value="others">Others</v-tab>
|
|
14
15
|
</v-tabs>
|
|
15
16
|
</v-toolbar>
|
|
@@ -170,6 +171,11 @@
|
|
|
170
171
|
</TableMain>
|
|
171
172
|
</template>
|
|
172
173
|
|
|
174
|
+
<template v-else-if="tab === 'management'">
|
|
175
|
+
<BuildingUnitManagement :unit-id="buildingUnit._id" :site-id="buildingUnit?.site?._id"
|
|
176
|
+
:can-update="canUpdateUnit" />
|
|
177
|
+
</template>
|
|
178
|
+
|
|
173
179
|
<template v-else-if="tab === 'others'">
|
|
174
180
|
<v-row>
|
|
175
181
|
<!-- <v-col cols="12" md="6" class="mt-2">
|
|
@@ -0,0 +1,277 @@
|
|
|
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 providers" }} that are not assigned to a unit
|
|
79
|
+
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
|
+
* providers attached to this unit. Each can be on one unit at a time, and
|
|
107
|
+
* only while active - the server detaches them the moment they are suspended,
|
|
108
|
+
* set inactive or deleted, so they simply drop off this list.
|
|
109
|
+
*/
|
|
110
|
+
type TSection = "members" | "providers";
|
|
111
|
+
type TRow = { _id: string; name: string; email?: string; roleName?: string; type?: string };
|
|
112
|
+
|
|
113
|
+
const props = defineProps({
|
|
114
|
+
unitId: {
|
|
115
|
+
type: String,
|
|
116
|
+
required: true,
|
|
117
|
+
},
|
|
118
|
+
/** The unit's site. The route's `site` is used when this is empty. */
|
|
119
|
+
siteId: {
|
|
120
|
+
type: String,
|
|
121
|
+
default: "",
|
|
122
|
+
},
|
|
123
|
+
/** The membership type whose members manage the site. */
|
|
124
|
+
managementType: {
|
|
125
|
+
type: String,
|
|
126
|
+
default: "property_management_agency",
|
|
127
|
+
},
|
|
128
|
+
canUpdate: {
|
|
129
|
+
type: Boolean,
|
|
130
|
+
default: false,
|
|
131
|
+
},
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
const route = useRoute();
|
|
135
|
+
const org = computed(() => (route.params.org as string) ?? "");
|
|
136
|
+
const site = computed(() => props.siteId || ((route.params.site as string) ?? ""));
|
|
137
|
+
|
|
138
|
+
const { getAll: getMembers, updateMemberUnit } = useMember();
|
|
139
|
+
const { getAll: getProviders, updateUnit: updateProviderUnit } = useServiceProvider();
|
|
140
|
+
const { debounce } = useUtils();
|
|
141
|
+
|
|
142
|
+
const panels = ref<TSection[]>(["members", "providers"]);
|
|
143
|
+
const message = ref("");
|
|
144
|
+
const removing = ref("");
|
|
145
|
+
|
|
146
|
+
function membersQuery(unit: string, search = "") {
|
|
147
|
+
return getMembers({ org: org.value, siteId: site.value, type: props.managementType, status: "active", unit, search, limit: 50 });
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function providersQuery(unit: string, search = "") {
|
|
151
|
+
return getProviders({ siteId: site.value, status: "active", unit, search, limit: 50 });
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
const { data: memberRes, pending: membersLoading, refresh: refreshMembers } = useLazyAsyncData(
|
|
155
|
+
`unit-management-members-${props.unitId}`,
|
|
156
|
+
() => membersQuery(props.unitId),
|
|
157
|
+
);
|
|
158
|
+
const { data: providerRes, pending: providersLoading, refresh: refreshProviders } = useLazyAsyncData(
|
|
159
|
+
`unit-management-providers-${props.unitId}`,
|
|
160
|
+
() => providersQuery(props.unitId),
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
function subtitleOf(row: TRow) {
|
|
164
|
+
return [row.roleName || row.type?.replace(/_/g, " "), row.email].filter(Boolean).join(" · ");
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
const sections = computed(() => [
|
|
168
|
+
{
|
|
169
|
+
key: "members" as TSection,
|
|
170
|
+
title: "Management",
|
|
171
|
+
empty: "management",
|
|
172
|
+
items: (memberRes.value?.items ?? []) as TRow[],
|
|
173
|
+
loading: membersLoading.value,
|
|
174
|
+
subtitle: subtitleOf,
|
|
175
|
+
},
|
|
176
|
+
{
|
|
177
|
+
key: "providers" as TSection,
|
|
178
|
+
title: "Service Providers",
|
|
179
|
+
empty: "service providers",
|
|
180
|
+
items: (providerRes.value?.items ?? []) as TRow[],
|
|
181
|
+
loading: providersLoading.value,
|
|
182
|
+
subtitle: subtitleOf,
|
|
183
|
+
},
|
|
184
|
+
]);
|
|
185
|
+
|
|
186
|
+
function refresh(section: TSection) {
|
|
187
|
+
return section === "members" ? refreshMembers() : refreshProviders();
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function assign(section: TSection, id: string, unit: string) {
|
|
191
|
+
return section === "members" ? updateMemberUnit(id, unit) : updateProviderUnit(id, unit);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function errorOf(error: any, fallback: string) {
|
|
195
|
+
return error?.response?._data?.message || error?.data?.message || fallback;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
// --- Remove: confirmed first ---
|
|
199
|
+
const removeDialog = ref(false);
|
|
200
|
+
const pendingRemove = ref<{ section: TSection; id: string; name: string } | null>(null);
|
|
201
|
+
|
|
202
|
+
function confirmRemove(section: TSection, row: TRow) {
|
|
203
|
+
message.value = "";
|
|
204
|
+
pendingRemove.value = { section, id: row._id, name: row.name };
|
|
205
|
+
removeDialog.value = true;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
async function remove() {
|
|
209
|
+
if (!pendingRemove.value) return;
|
|
210
|
+
const { section, id } = pendingRemove.value;
|
|
211
|
+
removing.value = id;
|
|
212
|
+
try {
|
|
213
|
+
await assign(section, id, "");
|
|
214
|
+
await refresh(section);
|
|
215
|
+
} catch (error: any) {
|
|
216
|
+
message.value = errorOf(error, "Failed to remove from unit.");
|
|
217
|
+
} finally {
|
|
218
|
+
removing.value = "";
|
|
219
|
+
removeDialog.value = false;
|
|
220
|
+
pendingRemove.value = null;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// --- Add dialog: active rows on no unit yet ---
|
|
225
|
+
const addDialog = ref(false);
|
|
226
|
+
const adding = ref<TSection>("members");
|
|
227
|
+
const selected = ref<string[]>([]);
|
|
228
|
+
const candidates = ref<TRow[]>([]);
|
|
229
|
+
const candidateSearch = ref("");
|
|
230
|
+
const candidatesLoading = ref(false);
|
|
231
|
+
const saving = ref(false);
|
|
232
|
+
|
|
233
|
+
async function loadCandidates() {
|
|
234
|
+
candidatesLoading.value = true;
|
|
235
|
+
try {
|
|
236
|
+
const search = candidateSearch.value?.trim() ?? "";
|
|
237
|
+
const res = adding.value === "members" ? await membersQuery("none", search) : await providersQuery("none", search);
|
|
238
|
+
// Keep what is already picked, so a new search does not drop the chips.
|
|
239
|
+
const picked = candidates.value.filter((c) => selected.value.includes(c._id));
|
|
240
|
+
const found = ((res?.items ?? []) as TRow[]).filter((c) => !selected.value.includes(c._id));
|
|
241
|
+
candidates.value = [...picked, ...found];
|
|
242
|
+
} catch (error: any) {
|
|
243
|
+
message.value = errorOf(error, "Failed to load the list.");
|
|
244
|
+
} finally {
|
|
245
|
+
candidatesLoading.value = false;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
const debouncedLoad = debounce(loadCandidates, 400);
|
|
250
|
+
watch(candidateSearch, () => {
|
|
251
|
+
if (addDialog.value) debouncedLoad();
|
|
252
|
+
});
|
|
253
|
+
|
|
254
|
+
function openAdd(section: TSection) {
|
|
255
|
+
message.value = "";
|
|
256
|
+
adding.value = section;
|
|
257
|
+
selected.value = [];
|
|
258
|
+
candidates.value = [];
|
|
259
|
+
candidateSearch.value = "";
|
|
260
|
+
addDialog.value = true;
|
|
261
|
+
loadCandidates();
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
async function add() {
|
|
265
|
+
saving.value = true;
|
|
266
|
+
message.value = "";
|
|
267
|
+
const section = adding.value;
|
|
268
|
+
const results = await Promise.allSettled(selected.value.map((id) => assign(section, id, props.unitId)));
|
|
269
|
+
const failed = results.filter((r): r is PromiseRejectedResult => r.status === "rejected");
|
|
270
|
+
if (failed.length) {
|
|
271
|
+
message.value = errorOf(failed[0].reason, `${failed.length} could not be added.`);
|
|
272
|
+
}
|
|
273
|
+
await refresh(section);
|
|
274
|
+
saving.value = false;
|
|
275
|
+
addDialog.value = false;
|
|
276
|
+
}
|
|
277
|
+
</script>
|
|
@@ -216,17 +216,21 @@
|
|
|
216
216
|
</div>
|
|
217
217
|
</v-col>
|
|
218
218
|
|
|
219
|
-
<v-col cols="12" class="my-2">
|
|
220
|
-
<v-row no-gutters>
|
|
221
|
-
<v-col cols="12" class="text-center">
|
|
222
|
-
<span class="role-create__error">{{ message }}</span>
|
|
223
|
-
</v-col>
|
|
224
|
-
</v-row>
|
|
225
|
-
</v-col>
|
|
226
219
|
</v-row>
|
|
227
220
|
</v-form>
|
|
228
221
|
</div>
|
|
229
222
|
|
|
223
|
+
<!--
|
|
224
|
+
WHY A SAVE FAILED, where it can be seen (owner, 2026-09-29: Wing Tai pressed
|
|
225
|
+
Submit on a 35-module role and "nothing happened"). The server's answer
|
|
226
|
+
used to be printed at the END of the scrolling list, below every module,
|
|
227
|
+
so a refused save looked like an ignored click. It now sits above the
|
|
228
|
+
buttons, outside the scroll, and is read out by screen readers.
|
|
229
|
+
-->
|
|
230
|
+
<div v-if="message" class="role-create__save-error" role="alert">
|
|
231
|
+
Couldn't save: {{ message }}
|
|
232
|
+
</div>
|
|
233
|
+
|
|
230
234
|
<div class="role-create__footer">
|
|
231
235
|
<AppButton
|
|
232
236
|
v-if="disabledModuleCount > 0 || !showDisabledModules"
|
|
@@ -257,6 +261,11 @@ import {
|
|
|
257
261
|
import useRole from "../composables/useRole";
|
|
258
262
|
import useUtils from "../composables/useUtils";
|
|
259
263
|
import useSite from "../composables/useSite";
|
|
264
|
+
import { readApiError } from "../utils/subscription-form";
|
|
265
|
+
|
|
266
|
+
/** Shown after "Couldn't save:" when the server gave no reason (network, timeout). */
|
|
267
|
+
const SAVE_FALLBACK =
|
|
268
|
+
"the server could not be reached. Please check your connection and try again.";
|
|
260
269
|
|
|
261
270
|
const props = defineProps({
|
|
262
271
|
permissions: {
|
|
@@ -487,6 +496,7 @@ watch(
|
|
|
487
496
|
|
|
488
497
|
async function submit() {
|
|
489
498
|
disable.value = true;
|
|
499
|
+
message.value = "";
|
|
490
500
|
try {
|
|
491
501
|
await createRole({
|
|
492
502
|
name: name.value,
|
|
@@ -500,9 +510,7 @@ async function submit() {
|
|
|
500
510
|
// Same unguarded chain as the preview dialog had: on a network or timeout
|
|
501
511
|
// failure `error.response` is undefined and the catch threw inside itself,
|
|
502
512
|
// leaving the user with no message at all.
|
|
503
|
-
message.value =
|
|
504
|
-
error?.response?._data?.message ??
|
|
505
|
-
"Could not create this role. Please check your connection and try again.";
|
|
513
|
+
message.value = readApiError(error, SAVE_FALLBACK);
|
|
506
514
|
} finally {
|
|
507
515
|
disable.value = false;
|
|
508
516
|
}
|
|
@@ -703,10 +711,15 @@ const isAllSelected = computed(() => {
|
|
|
703
711
|
color: var(--text2);
|
|
704
712
|
}
|
|
705
713
|
|
|
706
|
-
.role-
|
|
714
|
+
.role-create__save-error {
|
|
715
|
+
margin: 0 16px;
|
|
716
|
+
padding: 8px 12px;
|
|
717
|
+
border-radius: 6px;
|
|
707
718
|
font-size: var(--fs-cell);
|
|
708
719
|
font-weight: 600;
|
|
709
720
|
color: var(--err);
|
|
721
|
+
background: var(--err-bg);
|
|
722
|
+
border: 1px solid var(--err-border, transparent);
|
|
710
723
|
}
|
|
711
724
|
|
|
712
725
|
/* The design's dialog footer. Deliberately not the shared
|
|
@@ -216,22 +216,23 @@
|
|
|
216
216
|
</div>
|
|
217
217
|
</v-col>
|
|
218
218
|
|
|
219
|
-
<!--
|
|
220
|
-
One message, once. This block used to appear twice -- inside
|
|
221
|
-
`v-if="edit"` and again unconditionally -- so a refused save printed
|
|
222
|
-
the server's sentence back to back.
|
|
223
|
-
-->
|
|
224
|
-
<v-col v-if="message" cols="12" class="my-2">
|
|
225
|
-
<v-row no-gutters>
|
|
226
|
-
<v-col cols="12" class="text-center">
|
|
227
|
-
<span class="role-perm__error">{{ message }}</span>
|
|
228
|
-
</v-col>
|
|
229
|
-
</v-row>
|
|
230
|
-
</v-col>
|
|
231
219
|
</v-row>
|
|
232
220
|
</v-form>
|
|
233
221
|
</div>
|
|
234
222
|
|
|
223
|
+
<!--
|
|
224
|
+
WHY A SAVE FAILED - or why Submit is switched off - where it can be seen:
|
|
225
|
+
above the buttons, outside the scrolling list (owner, 2026-09-29: a refused
|
|
226
|
+
save printed below 35 modules looked like an ignored click). One message,
|
|
227
|
+
once; read out by screen readers.
|
|
228
|
+
-->
|
|
229
|
+
<div v-if="message" class="role-perm__save-error" role="alert">
|
|
230
|
+
Couldn't save: {{ message }}
|
|
231
|
+
</div>
|
|
232
|
+
<div v-else-if="edit && errorMessages" class="role-perm__save-error" role="alert">
|
|
233
|
+
{{ errorMessages }}
|
|
234
|
+
</div>
|
|
235
|
+
|
|
235
236
|
<div class="role-perm__footer">
|
|
236
237
|
<AppButton
|
|
237
238
|
v-if="disabledModuleCount > 0 || showDisabledModules"
|
|
@@ -266,6 +267,7 @@ import {
|
|
|
266
267
|
} from "../utils/permission-labels";
|
|
267
268
|
import useRole from "../composables/useRole";
|
|
268
269
|
import useUtils from "../composables/useUtils";
|
|
270
|
+
import { readApiError } from "../utils/subscription-form";
|
|
269
271
|
import {
|
|
270
272
|
holdsPermission,
|
|
271
273
|
withoutPermission,
|
|
@@ -692,8 +694,13 @@ const errorMessages = computed(() => {
|
|
|
692
694
|
|
|
693
695
|
const { updatePermissionById } = useRole();
|
|
694
696
|
|
|
697
|
+
/** Shown after "Couldn't save:" when the server gave no reason (network, timeout). */
|
|
698
|
+
const SAVE_FALLBACK =
|
|
699
|
+
"the server could not be reached. Please check your connection and try again.";
|
|
700
|
+
|
|
695
701
|
async function submit() {
|
|
696
702
|
disable.value = true;
|
|
703
|
+
message.value = "";
|
|
697
704
|
try {
|
|
698
705
|
await updatePermissionById(props.id, definedModel.value);
|
|
699
706
|
emit("success");
|
|
@@ -701,9 +708,7 @@ async function submit() {
|
|
|
701
708
|
// `error.response` is undefined on a network or timeout failure, so the old
|
|
702
709
|
// unguarded chain threw inside its own catch: nothing was shown, the button
|
|
703
710
|
// came back enabled, and the save looked like it had simply been ignored.
|
|
704
|
-
message.value =
|
|
705
|
-
error?.response?._data?.message ??
|
|
706
|
-
"Could not save this role. Please check your connection and try again.";
|
|
711
|
+
message.value = readApiError(error, SAVE_FALLBACK);
|
|
707
712
|
} finally {
|
|
708
713
|
disable.value = false;
|
|
709
714
|
}
|
|
@@ -779,6 +784,17 @@ async function submit() {
|
|
|
779
784
|
color: var(--err);
|
|
780
785
|
}
|
|
781
786
|
|
|
787
|
+
.role-perm__save-error {
|
|
788
|
+
margin: 0 16px;
|
|
789
|
+
padding: 8px 12px;
|
|
790
|
+
border-radius: 6px;
|
|
791
|
+
font-size: var(--fs-cell);
|
|
792
|
+
font-weight: 600;
|
|
793
|
+
color: var(--err);
|
|
794
|
+
background: var(--err-bg);
|
|
795
|
+
border: 1px solid var(--err-border, transparent);
|
|
796
|
+
}
|
|
797
|
+
|
|
782
798
|
/* The design's dialog footer. Deliberately not the shared
|
|
783
799
|
`.screen-modal__footer` - that class is on the batch-D branch (#1150), not
|
|
784
800
|
on this base, and a second copy in `screens.css` would collide with it. */
|
package/composables/useMember.ts
CHANGED
|
@@ -70,6 +70,8 @@ export default function useMember() {
|
|
|
70
70
|
status = "active",
|
|
71
71
|
siteId = "",
|
|
72
72
|
roleState = "",
|
|
73
|
+
/** A building unit id, or "none": members on no unit yet. */
|
|
74
|
+
unit = "",
|
|
73
75
|
} = {}) {
|
|
74
76
|
const query: Record<string, any> = { page, limit, type, status };
|
|
75
77
|
|
|
@@ -79,6 +81,7 @@ export default function useMember() {
|
|
|
79
81
|
if (user) query.user = user;
|
|
80
82
|
if (org) query.org = org;
|
|
81
83
|
if (siteId) query.siteId = siteId;
|
|
84
|
+
if (unit) query.unit = unit;
|
|
82
85
|
return useNuxtApp().$api<Record<string, any>>("/api/members", {
|
|
83
86
|
method: "GET",
|
|
84
87
|
query,
|
|
@@ -154,6 +157,14 @@ export default function useMember() {
|
|
|
154
157
|
});
|
|
155
158
|
}
|
|
156
159
|
|
|
160
|
+
/** Attach a member to a building unit, or detach them (`unit` ""). */
|
|
161
|
+
function updateMemberUnit(id: string, unit: string) {
|
|
162
|
+
return useNuxtApp().$api<Record<string, any>>("/api/members/unit", {
|
|
163
|
+
method: "PUT",
|
|
164
|
+
body: { id, unit },
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
157
168
|
function getByUserTypeOrg(user: string, type: string, org: string) {
|
|
158
169
|
return useNuxtApp().$api<TMember>(
|
|
159
170
|
`/api/members/user/${user}/app/${type}/org`,
|
|
@@ -197,6 +208,7 @@ export default function useMember() {
|
|
|
197
208
|
return {
|
|
198
209
|
getSiteAccess,
|
|
199
210
|
saveSiteAccess,
|
|
211
|
+
updateMemberUnit,
|
|
200
212
|
members,
|
|
201
213
|
member,
|
|
202
214
|
page,
|
|
@@ -90,6 +90,8 @@ export default function useServiceProvider() {
|
|
|
90
90
|
status = "",
|
|
91
91
|
/** "engagements": also providers engaged through an accepted invitation. */
|
|
92
92
|
include = "",
|
|
93
|
+
/** A building unit id, or "none": providers on no unit yet. */
|
|
94
|
+
unit = "",
|
|
93
95
|
} = {}) {
|
|
94
96
|
return useNuxtApp().$api<Record<string, any>>("/api/service-providers", {
|
|
95
97
|
method: "GET",
|
|
@@ -102,6 +104,7 @@ export default function useServiceProvider() {
|
|
|
102
104
|
siteId,
|
|
103
105
|
...(status ? { status } : {}),
|
|
104
106
|
...(include ? { include } : {}),
|
|
107
|
+
...(unit ? { unit } : {}),
|
|
105
108
|
},
|
|
106
109
|
});
|
|
107
110
|
}
|
|
@@ -269,6 +272,17 @@ export default function useServiceProvider() {
|
|
|
269
272
|
);
|
|
270
273
|
}
|
|
271
274
|
|
|
275
|
+
/** Attach a provider to a building unit, or detach it (`unit` ""). */
|
|
276
|
+
async function updateUnit(id: string, unit: string) {
|
|
277
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
278
|
+
`/api/service-providers/${id}/unit`,
|
|
279
|
+
{
|
|
280
|
+
method: "PATCH",
|
|
281
|
+
body: { unit },
|
|
282
|
+
}
|
|
283
|
+
);
|
|
284
|
+
}
|
|
285
|
+
|
|
272
286
|
async function getByEmail({
|
|
273
287
|
email = "",
|
|
274
288
|
orgId = "",
|
|
@@ -338,6 +352,7 @@ export default function useServiceProvider() {
|
|
|
338
352
|
add,
|
|
339
353
|
addViaInvite,
|
|
340
354
|
updateStatus,
|
|
355
|
+
updateUnit,
|
|
341
356
|
getByEmail,
|
|
342
357
|
};
|
|
343
358
|
}
|
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.35.1-staging.
|
|
5
|
+
"version": "4.35.1-staging.445",
|
|
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/member.d.ts
CHANGED
|
@@ -10,6 +10,10 @@ 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;
|
|
13
17
|
createdAt?: string;
|
|
14
18
|
updatedAt?: string;
|
|
15
19
|
deletedAt?: string;
|
|
@@ -7,6 +7,11 @@ 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;
|
|
10
15
|
};
|
|
11
16
|
|
|
12
17
|
declare type TServiceProviderName = {
|