@7365admin1/layer-common 4.7.2 → 4.8.0
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 +41 -4
- package/components/AreaChecklistHistoryLogs.vue +81 -0
- package/components/Chat/Bubbles.vue +94 -30
- package/components/Chat/Message.vue +281 -67
- package/components/FeedbackDetail.vue +1 -1
- package/components/RolePermissionFormPreviewUpdate.vue +45 -0
- package/components/RolePermissionMain.vue +20 -0
- package/components/WorkOrder/Detail.vue +1 -1
- package/composables/useCleaningPermission.ts +40 -0
- package/composables/useComment.ts +9 -1
- package/composables/useLandscapingPermission.ts +35 -0
- package/package.json +1 -1
- package/types/cleaner-schedule.d.ts +2 -0
- package/types/comment.d.ts +2 -0
- package/utils/chat-sender.ts +47 -0
- package/utils/org-modules.ts +86 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,42 @@
|
|
|
1
1
|
# @iservice365/layer-common
|
|
2
2
|
|
|
3
|
+
## 4.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8e50211: Offer Emergency Contacts in the Cleaning and Landscape role editors, and stop the
|
|
8
|
+
client module list from hiding what a client or a role already has.
|
|
9
|
+
|
|
10
|
+
- `useCleaningPermission` and `useLandscapingPermission` now offer
|
|
11
|
+
`emergency-contact` with the seven actions `constants/permissions.ts` defines
|
|
12
|
+
(`see-all`, `see-details`, `add-/update-/delete-emergency-contact`,
|
|
13
|
+
`add-/delete-emergency-contact-category`). The long `see-all-emergency-contacts`
|
|
14
|
+
spelling is not added.
|
|
15
|
+
- `orgAllowsModule` treats every spelling of one module as the same module
|
|
16
|
+
(`MODULE_SPELLING_GROUPS`, derived from `LEGACY_PERMISSION_ALIASES`) and always
|
|
17
|
+
offers `ALWAYS_ALLOWED_MODULES` (sites, subscriptions, customers,
|
|
18
|
+
payment-methods, members, invitations, roles, roles-and-permissions,
|
|
19
|
+
site-settings). Widening only: everything offered before is still offered, and
|
|
20
|
+
the whole-catalogue fallback is decided exactly as before.
|
|
21
|
+
- The role dialog lists grants a role holds outside the client's offer as
|
|
22
|
+
"Granted — not offered to this client", read-only. Saving keeps them.
|
|
23
|
+
|
|
24
|
+
## 4.7.3
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- 24367db: Connect the feedback and work-order Chat panel to the real comment thread. It
|
|
29
|
+
shipped as a mockup - five hardcoded messages from "Tan Wei" dated 06/28/2024, a
|
|
30
|
+
textarea with no model and a Send button wired to nothing - while a complete
|
|
31
|
+
`useComment` composable sat in the layer with no callers. The panel now loads,
|
|
32
|
+
groups by day, aligns by sender, sends, and attaches photos. The bubble matches
|
|
33
|
+
the mobile apps field for field, its avatar renders an actual profile picture,
|
|
34
|
+
and a load failure is reported rather than shown as an empty thread.
|
|
35
|
+
- a4737bd: Show the completion photos on the area checklist history screen. The API has
|
|
36
|
+
always returned the file ids of the photos a technician took when completing a
|
|
37
|
+
unit; nothing drew them, so the office had no way to see the proof of work.
|
|
38
|
+
Each unit now shows its photos as thumbnails that open full size.
|
|
39
|
+
|
|
3
40
|
## 4.7.2
|
|
4
41
|
|
|
5
42
|
### Patch Changes
|
|
@@ -963,11 +1000,11 @@
|
|
|
963
1000
|
`utils/console-tier.ts` + `composables/useConsoleTier.ts` mirror the server's
|
|
964
1001
|
own rule from two endpoints the console already calls, unprojected:
|
|
965
1002
|
|
|
966
|
-
|
|
967
|
-
|
|
1003
|
+
GET /api/members/user/:user/app/admin the Seven365 staff membership
|
|
1004
|
+
GET /api/roles/id/:role that membership's role document
|
|
968
1005
|
|
|
969
|
-
|
|
970
|
-
|
|
1006
|
+
owner = member.type === "admin" && role.type === "admin" && role.default === true
|
|
1007
|
+
staff = member.type === "admin" && role.type === "admin"
|
|
971
1008
|
|
|
972
1009
|
`role.default` is the marker because it is the only property of a platform
|
|
973
1010
|
staff role no API caller can set - `role.controller.ts` validates create and
|
|
@@ -170,6 +170,63 @@
|
|
|
170
170
|
/>
|
|
171
171
|
</v-col>
|
|
172
172
|
</v-row>
|
|
173
|
+
|
|
174
|
+
<!-- The photos the technician took to complete the
|
|
175
|
+
unit. The API has always returned these ids on the
|
|
176
|
+
history record; nothing drew them, so the office
|
|
177
|
+
had no way to see the proof of work. -->
|
|
178
|
+
<v-row
|
|
179
|
+
v-if="unit.attachment?.length"
|
|
180
|
+
no-gutters
|
|
181
|
+
class="pb-2"
|
|
182
|
+
>
|
|
183
|
+
<v-col cols="12">
|
|
184
|
+
<div class="text-body-2 text-medium-emphasis mb-1">
|
|
185
|
+
Attached Photos ({{ unit.attachment.length }})
|
|
186
|
+
</div>
|
|
187
|
+
<div class="d-flex flex-wrap ga-2">
|
|
188
|
+
<v-img
|
|
189
|
+
v-for="id in unit.attachment"
|
|
190
|
+
:key="id"
|
|
191
|
+
:src="getFileUrl(id)"
|
|
192
|
+
width="72"
|
|
193
|
+
height="72"
|
|
194
|
+
cover
|
|
195
|
+
rounded="lg"
|
|
196
|
+
class="border-thin"
|
|
197
|
+
style="cursor: zoom-in; flex: 0 0 auto"
|
|
198
|
+
@click="openFullImage(getFileUrl(id))"
|
|
199
|
+
>
|
|
200
|
+
<template v-slot:placeholder>
|
|
201
|
+
<v-row
|
|
202
|
+
class="fill-height ma-0"
|
|
203
|
+
align="center"
|
|
204
|
+
justify="center"
|
|
205
|
+
>
|
|
206
|
+
<v-progress-circular
|
|
207
|
+
indeterminate
|
|
208
|
+
size="20"
|
|
209
|
+
color="grey-lighten-4"
|
|
210
|
+
/>
|
|
211
|
+
</v-row>
|
|
212
|
+
</template>
|
|
213
|
+
<template v-slot:error>
|
|
214
|
+
<v-row
|
|
215
|
+
class="fill-height ma-0"
|
|
216
|
+
align="center"
|
|
217
|
+
justify="center"
|
|
218
|
+
>
|
|
219
|
+
<v-icon
|
|
220
|
+
icon="mdi-image-broken"
|
|
221
|
+
size="24"
|
|
222
|
+
color="grey"
|
|
223
|
+
/>
|
|
224
|
+
</v-row>
|
|
225
|
+
</template>
|
|
226
|
+
</v-img>
|
|
227
|
+
</div>
|
|
228
|
+
</v-col>
|
|
229
|
+
</v-row>
|
|
173
230
|
</v-list-item>
|
|
174
231
|
|
|
175
232
|
<v-divider
|
|
@@ -186,6 +243,22 @@
|
|
|
186
243
|
</AppCard>
|
|
187
244
|
</v-col>
|
|
188
245
|
</v-row>
|
|
246
|
+
|
|
247
|
+
<v-dialog v-model="showLightbox" max-width="900">
|
|
248
|
+
<v-card class="screen-modal">
|
|
249
|
+
<v-card-actions class="pa-2 justify-end">
|
|
250
|
+
<v-btn
|
|
251
|
+
icon="mdi-close"
|
|
252
|
+
variant="text"
|
|
253
|
+
class="screen-modal__close"
|
|
254
|
+
@click="showLightbox = false"
|
|
255
|
+
/>
|
|
256
|
+
</v-card-actions>
|
|
257
|
+
<v-card-text class="screen-modal__body pa-2 pt-0">
|
|
258
|
+
<v-img :src="lightboxSrc" contain max-height="80vh" />
|
|
259
|
+
</v-card-text>
|
|
260
|
+
</v-card>
|
|
261
|
+
</v-dialog>
|
|
189
262
|
</template>
|
|
190
263
|
|
|
191
264
|
<script setup lang="ts">
|
|
@@ -227,6 +300,14 @@ watchEffect(() => {
|
|
|
227
300
|
}
|
|
228
301
|
});
|
|
229
302
|
|
|
303
|
+
const showLightbox = ref(false);
|
|
304
|
+
const lightboxSrc = ref("");
|
|
305
|
+
|
|
306
|
+
const openFullImage = (src: string) => {
|
|
307
|
+
lightboxSrc.value = src;
|
|
308
|
+
showLightbox.value = true;
|
|
309
|
+
};
|
|
310
|
+
|
|
230
311
|
const createdAt = ref<string>("N/A");
|
|
231
312
|
const createdBy = ref<string>("N/A");
|
|
232
313
|
const timeOut = ref<string>("N/A");
|
|
@@ -1,62 +1,120 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<v-card
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
<v-card
|
|
3
|
+
class="chat-bubble screen-card pa-3"
|
|
4
|
+
:class="isCurrentUser ? 'chat-bubble--mine' : 'chat-bubble--theirs'"
|
|
5
|
+
elevation="0"
|
|
6
|
+
>
|
|
7
|
+
<v-row no-gutters align="start" class="flex-nowrap">
|
|
8
|
+
<v-col cols="auto" :class="isCurrentUser ? 'order-last ml-3' : 'mr-3'">
|
|
5
9
|
<v-avatar class="chat-bubble__avatar" size="35">
|
|
6
|
-
|
|
10
|
+
<!-- Was `<v-img width="15" height="15" />` with no `src` at all, so a
|
|
11
|
+
sender with a profile picture got a blank 15px box instead of a
|
|
12
|
+
photo - and never fell through to their initials either. -->
|
|
13
|
+
<v-img v-if="avatarUrl" :src="avatarUrl" cover />
|
|
7
14
|
<span v-else>{{ getNameInitials(senderName) }}</span>
|
|
8
15
|
</v-avatar>
|
|
9
16
|
</v-col>
|
|
10
17
|
|
|
11
|
-
<v-col class="
|
|
12
|
-
<
|
|
13
|
-
<
|
|
14
|
-
|
|
15
|
-
|
|
18
|
+
<v-col class="chat-bubble__body">
|
|
19
|
+
<div class="chat-bubble__sender">{{ senderName }}</div>
|
|
20
|
+
<div v-if="roleLabel" class="chat-bubble__sub">{{ roleLabel }}</div>
|
|
21
|
+
|
|
22
|
+
<div v-if="message" class="chat-bubble__text mt-2">{{ message }}</div>
|
|
23
|
+
|
|
24
|
+
<div v-if="attachments?.length" class="d-flex flex-wrap ga-2 mt-2">
|
|
25
|
+
<v-img
|
|
26
|
+
v-for="file in attachments"
|
|
27
|
+
:key="file.id"
|
|
28
|
+
:src="getFileUrl(file.id)"
|
|
29
|
+
width="110"
|
|
30
|
+
height="90"
|
|
31
|
+
cover
|
|
32
|
+
rounded="lg"
|
|
33
|
+
class="border-thin"
|
|
34
|
+
style="cursor: zoom-in; flex: 0 0 auto"
|
|
35
|
+
@click="emit('preview', getFileUrl(file.id))"
|
|
36
|
+
>
|
|
37
|
+
<template #placeholder>
|
|
38
|
+
<v-row class="fill-height ma-0" align="center" justify="center">
|
|
39
|
+
<v-progress-circular
|
|
40
|
+
indeterminate
|
|
41
|
+
size="20"
|
|
42
|
+
color="grey-lighten-4"
|
|
43
|
+
/>
|
|
44
|
+
</v-row>
|
|
45
|
+
</template>
|
|
46
|
+
<template #error>
|
|
47
|
+
<v-row class="fill-height ma-0" align="center" justify="center">
|
|
48
|
+
<v-icon icon="mdi-image-broken" size="24" color="grey" />
|
|
49
|
+
</v-row>
|
|
50
|
+
</template>
|
|
51
|
+
</v-img>
|
|
52
|
+
</div>
|
|
16
53
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<v-row no-gutters justify="space-between" align="center" class="mt-1">
|
|
22
|
-
<v-col cols="auto">
|
|
23
|
-
<span class="chat-bubble__sub">{{ timestamp }}</span>
|
|
24
|
-
</v-col>
|
|
25
|
-
<v-col v-if="isCurrentUser" cols="auto" class="d-flex align-center">
|
|
26
|
-
<v-icon size="16" class="chat-bubble__sub mr-1"
|
|
27
|
-
>mdi-eye-outline</v-icon
|
|
28
|
-
>
|
|
29
|
-
<span class="chat-bubble__sub">{{ seenLabel }}</span>
|
|
30
|
-
</v-col>
|
|
31
|
-
</v-row>
|
|
54
|
+
<div class="chat-bubble__sub chat-bubble__time mt-2">
|
|
55
|
+
{{ timestamp }}
|
|
56
|
+
</div>
|
|
32
57
|
</v-col>
|
|
33
58
|
</v-row>
|
|
34
59
|
</v-card>
|
|
35
60
|
</template>
|
|
36
61
|
|
|
37
62
|
<script setup lang="ts">
|
|
38
|
-
|
|
63
|
+
import { formatSenderRole } from "../../utils/chat-sender.ts";
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* One message bubble, drawn the same way for both people in the conversation
|
|
67
|
+
* and matching the mobile apps' bubble field for field: avatar, sender, role,
|
|
68
|
+
* message, photos, time.
|
|
69
|
+
*
|
|
70
|
+
* It used to be a fixed `width="400"` card with no left/right distinction, an
|
|
71
|
+
* avatar that could not render a photo, and a "Seen" line that only the current
|
|
72
|
+
* user's own messages carried.
|
|
73
|
+
*/
|
|
74
|
+
const props = defineProps<{
|
|
39
75
|
isCurrentUser: boolean;
|
|
40
76
|
message: string;
|
|
41
77
|
timestamp: string;
|
|
42
|
-
seenLabel?: string;
|
|
43
78
|
senderName: string;
|
|
44
79
|
role?: string;
|
|
80
|
+
attachments?: TAttachment[];
|
|
81
|
+
avatarId?: string;
|
|
45
82
|
}>();
|
|
46
83
|
|
|
47
|
-
const {
|
|
84
|
+
const emit = defineEmits<{ (event: "preview", src: string): void }>();
|
|
85
|
+
|
|
48
86
|
const { getNameInitials } = useUtils();
|
|
87
|
+
const { getFileUrl } = useFile();
|
|
88
|
+
|
|
89
|
+
const roleLabel = computed(() => formatSenderRole(props.role));
|
|
90
|
+
const avatarUrl = computed(() =>
|
|
91
|
+
props.avatarId ? getFileUrl(props.avatarId) : ""
|
|
92
|
+
);
|
|
49
93
|
</script>
|
|
50
94
|
|
|
51
95
|
<style scoped>
|
|
52
96
|
.chat-bubble {
|
|
53
97
|
font-family: var(--font-sans);
|
|
54
98
|
color: var(--text);
|
|
99
|
+
/* Was a fixed 400px, which is both too wide on a narrow panel and unable to
|
|
100
|
+
grow on a wide one. The thread caps the column instead. */
|
|
101
|
+
max-width: 100%;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/* Alignment alone is a weak signal on a panel this narrow, so the two sides
|
|
105
|
+
also differ in fill - the same distinction the mobile bubbles make. */
|
|
106
|
+
.chat-bubble--mine {
|
|
107
|
+
background: var(--hover);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.chat-bubble--theirs {
|
|
111
|
+
background: var(--card);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.chat-bubble__body {
|
|
115
|
+
min-width: 0;
|
|
55
116
|
}
|
|
56
117
|
|
|
57
|
-
/* Was `color="surface-variant"` with the initials at `text-h5`, i.e. a 24px
|
|
58
|
-
pair of letters in a 35px circle. The design's avatar is the tone wash with
|
|
59
|
-
the accent ink, and the initials fit inside it. */
|
|
60
118
|
.chat-bubble__avatar {
|
|
61
119
|
background: var(--hover);
|
|
62
120
|
color: var(--text2);
|
|
@@ -71,6 +129,8 @@ const { getNameInitials } = useUtils();
|
|
|
71
129
|
|
|
72
130
|
.chat-bubble__text {
|
|
73
131
|
font-size: var(--fs-cell);
|
|
132
|
+
white-space: pre-wrap;
|
|
133
|
+
overflow-wrap: anywhere;
|
|
74
134
|
}
|
|
75
135
|
|
|
76
136
|
/* The role, the timestamp and the seen label were `text-grey`, `text-caption`
|
|
@@ -79,4 +139,8 @@ const { getNameInitials } = useUtils();
|
|
|
79
139
|
font-size: var(--fs-chip);
|
|
80
140
|
color: var(--muted);
|
|
81
141
|
}
|
|
142
|
+
|
|
143
|
+
.chat-bubble__time {
|
|
144
|
+
text-align: right;
|
|
145
|
+
}
|
|
82
146
|
</style>
|
|
@@ -11,57 +11,127 @@
|
|
|
11
11
|
</div>
|
|
12
12
|
|
|
13
13
|
<v-sheet
|
|
14
|
+
ref="threadEl"
|
|
14
15
|
class="chat-panel__thread overflow-y-auto flex-grow-1 pa-3"
|
|
15
16
|
:style="{ height: 'calc(100vh - 300px)', overflowX: 'hidden' }"
|
|
16
17
|
>
|
|
17
|
-
<v-
|
|
18
|
-
v-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
18
|
+
<div v-if="isCommentsLoaded" class="d-flex justify-center py-6">
|
|
19
|
+
<v-progress-circular indeterminate size="28" color="primary" />
|
|
20
|
+
</div>
|
|
21
|
+
|
|
22
|
+
<div
|
|
23
|
+
v-else-if="!days.length"
|
|
24
|
+
class="text-center text-medium-emphasis py-6"
|
|
23
25
|
>
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
26
|
+
No messages yet
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
<template v-for="group in days" :key="group.day">
|
|
30
|
+
<div class="d-flex justify-center my-3">
|
|
31
|
+
<span class="chat-panel__day px-3 py-1">{{ group.day }}</span>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<v-row
|
|
35
|
+
v-for="msg in group.messages"
|
|
36
|
+
:key="msg._id"
|
|
37
|
+
no-gutters
|
|
38
|
+
:justify="isMine(msg) ? 'end' : 'start'"
|
|
39
|
+
class="mb-2"
|
|
40
|
+
>
|
|
41
|
+
<v-col cols="11" sm="10">
|
|
42
|
+
<div
|
|
43
|
+
class="d-flex"
|
|
44
|
+
:class="isMine(msg) ? 'justify-end' : 'justify-start'"
|
|
45
|
+
>
|
|
46
|
+
<ChatBubbles
|
|
47
|
+
:isCurrentUser="isMine(msg)"
|
|
48
|
+
:message="msg.comment"
|
|
49
|
+
:timestamp="formatTime(msg.createdAt)"
|
|
50
|
+
:senderName="isMine(msg) ? 'You' : msg.createdByName || 'User'"
|
|
51
|
+
:role="msg.createdByType"
|
|
52
|
+
:attachments="msg.attachments"
|
|
53
|
+
:avatarId="msg.createdByProfile"
|
|
54
|
+
@preview="openPreview"
|
|
55
|
+
/>
|
|
56
|
+
</div>
|
|
57
|
+
</v-col>
|
|
58
|
+
</v-row>
|
|
59
|
+
</template>
|
|
35
60
|
</v-sheet>
|
|
36
61
|
|
|
37
62
|
<v-card class="screen-card mx-4 mb-4 mt-2 pa-3" elevation="0">
|
|
38
63
|
<v-row no-gutters align="end">
|
|
39
64
|
<v-col cols="10">
|
|
40
65
|
<v-textarea
|
|
66
|
+
v-model="draft"
|
|
41
67
|
class="filter-field"
|
|
42
68
|
label="Message"
|
|
43
69
|
auto-grow
|
|
44
70
|
hide-details
|
|
45
71
|
rows="1"
|
|
46
72
|
variant="outlined"
|
|
73
|
+
:disabled="sending"
|
|
74
|
+
@keydown.enter.exact.prevent="send"
|
|
47
75
|
/>
|
|
48
76
|
</v-col>
|
|
49
77
|
<v-col cols="2" class="pl-2">
|
|
50
|
-
<v-btn
|
|
78
|
+
<v-btn
|
|
79
|
+
class="screen-btn-primary"
|
|
80
|
+
variant="flat"
|
|
81
|
+
block
|
|
82
|
+
:loading="sending"
|
|
83
|
+
:disabled="!canSend"
|
|
84
|
+
@click="send"
|
|
85
|
+
>
|
|
86
|
+
Send
|
|
87
|
+
</v-btn>
|
|
51
88
|
</v-col>
|
|
52
89
|
</v-row>
|
|
53
90
|
|
|
91
|
+
<div v-if="photos.length" class="d-flex flex-wrap ga-2 mt-3">
|
|
92
|
+
<div
|
|
93
|
+
v-for="(photo, index) in photos"
|
|
94
|
+
:key="photo.id"
|
|
95
|
+
class="chat-panel__pending"
|
|
96
|
+
>
|
|
97
|
+
<v-img
|
|
98
|
+
:src="getFileUrl(photo.id)"
|
|
99
|
+
width="64"
|
|
100
|
+
height="64"
|
|
101
|
+
cover
|
|
102
|
+
rounded="lg"
|
|
103
|
+
/>
|
|
104
|
+
<v-btn
|
|
105
|
+
icon="mdi-close"
|
|
106
|
+
size="x-small"
|
|
107
|
+
variant="flat"
|
|
108
|
+
class="chat-panel__pending-remove"
|
|
109
|
+
@click="photos.splice(index, 1)"
|
|
110
|
+
/>
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
|
|
54
114
|
<v-divider class="my-2" />
|
|
55
115
|
|
|
56
116
|
<v-row justify="start" no-gutters align="center">
|
|
57
117
|
<v-col cols="auto">
|
|
58
|
-
<v-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
118
|
+
<v-btn
|
|
119
|
+
icon
|
|
120
|
+
density="compact"
|
|
121
|
+
variant="text"
|
|
122
|
+
:loading="uploading"
|
|
123
|
+
@click="fileInput?.click()"
|
|
64
124
|
>
|
|
125
|
+
<v-icon size="20" class="chat-panel__tool">mdi-paperclip</v-icon>
|
|
126
|
+
</v-btn>
|
|
127
|
+
<input
|
|
128
|
+
ref="fileInput"
|
|
129
|
+
type="file"
|
|
130
|
+
accept="image/*"
|
|
131
|
+
multiple
|
|
132
|
+
hidden
|
|
133
|
+
@change="onFilesPicked"
|
|
134
|
+
/>
|
|
65
135
|
</v-col>
|
|
66
136
|
|
|
67
137
|
<v-col cols="auto">
|
|
@@ -94,57 +164,185 @@
|
|
|
94
164
|
</v-col>
|
|
95
165
|
</v-row>
|
|
96
166
|
</v-card>
|
|
167
|
+
|
|
168
|
+
<v-dialog v-model="showPreview" max-width="900">
|
|
169
|
+
<v-card class="screen-modal">
|
|
170
|
+
<v-card-actions class="pa-2 justify-end">
|
|
171
|
+
<v-btn
|
|
172
|
+
icon="mdi-close"
|
|
173
|
+
variant="text"
|
|
174
|
+
class="screen-modal__close"
|
|
175
|
+
@click="showPreview = false"
|
|
176
|
+
/>
|
|
177
|
+
</v-card-actions>
|
|
178
|
+
<v-card-text class="screen-modal__body pa-2 pt-0">
|
|
179
|
+
<v-img :src="previewSrc" contain max-height="80vh" />
|
|
180
|
+
</v-card-text>
|
|
181
|
+
</v-card>
|
|
182
|
+
</v-dialog>
|
|
183
|
+
|
|
184
|
+
<Snackbar v-model="showMessage" :text="message" :color="messageColor" />
|
|
97
185
|
</v-sheet>
|
|
98
186
|
</template>
|
|
99
187
|
|
|
100
188
|
<script setup lang="ts">
|
|
101
|
-
|
|
189
|
+
import { groupChatByDay } from "../../utils/chat-sender.ts";
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* The comment thread under a feedback or a work order.
|
|
193
|
+
*
|
|
194
|
+
* This panel used to be a mockup: five hardcoded messages from "Tan Wei" dated
|
|
195
|
+
* 06/28/2024, a textarea with no model, and a Send button wired to nothing. So
|
|
196
|
+
* on the web the chat showed the same fake conversation on every record, and
|
|
197
|
+
* nothing anyone typed was ever sent - while the mobile apps had been reading
|
|
198
|
+
* and writing the real thread through `/api/comments/v1` all along.
|
|
199
|
+
*/
|
|
200
|
+
const props = defineProps({
|
|
102
201
|
type: {
|
|
103
202
|
type: String,
|
|
104
203
|
default: "feedback",
|
|
105
204
|
},
|
|
205
|
+
/** The feedback or work order this thread hangs off. */
|
|
206
|
+
recordId: {
|
|
207
|
+
type: String,
|
|
208
|
+
default: "",
|
|
209
|
+
},
|
|
106
210
|
});
|
|
107
211
|
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
212
|
+
// `useComment` already existed with everything this panel needs - the fetch,
|
|
213
|
+
// the post, and the read receipts - and had not a single caller, because the
|
|
214
|
+
// panel it was written for was never wired up.
|
|
215
|
+
const { comments, isCommentsLoaded, setComments, addComment } = useComment();
|
|
216
|
+
const { currentUser } = useLocalAuth();
|
|
217
|
+
const { getFileUrl, addFile } = useFile();
|
|
218
|
+
|
|
219
|
+
const sending = ref(false);
|
|
220
|
+
const uploading = ref(false);
|
|
221
|
+
const draft = ref("");
|
|
222
|
+
const photos = ref<{ id: string; name?: string }[]>([]);
|
|
223
|
+
const fileInput = ref<HTMLInputElement | null>(null);
|
|
224
|
+
const threadEl = ref<any>(null);
|
|
225
|
+
|
|
226
|
+
const showPreview = ref(false);
|
|
227
|
+
const previewSrc = ref("");
|
|
228
|
+
const showMessage = ref(false);
|
|
229
|
+
const message = ref("");
|
|
230
|
+
const messageColor = ref("error");
|
|
231
|
+
|
|
232
|
+
const notify = (text: string, color = "error") => {
|
|
233
|
+
message.value = text;
|
|
234
|
+
messageColor.value = color;
|
|
235
|
+
showMessage.value = true;
|
|
236
|
+
};
|
|
237
|
+
|
|
238
|
+
const formatDay = (value: string | Date) =>
|
|
239
|
+
new Date(value).toLocaleDateString("en-US", {
|
|
240
|
+
year: "numeric",
|
|
241
|
+
month: "short",
|
|
242
|
+
day: "numeric",
|
|
243
|
+
});
|
|
244
|
+
|
|
245
|
+
const formatTime = (value?: string | Date) =>
|
|
246
|
+
value
|
|
247
|
+
? new Date(value).toLocaleTimeString("en-US", {
|
|
248
|
+
hour: "2-digit",
|
|
249
|
+
minute: "2-digit",
|
|
250
|
+
})
|
|
251
|
+
: "";
|
|
252
|
+
|
|
253
|
+
// `setComments` hands the thread back oldest first, which is already reading
|
|
254
|
+
// order for a top-to-bottom panel.
|
|
255
|
+
const days = computed(() => groupChatByDay(comments.value, formatDay));
|
|
256
|
+
|
|
257
|
+
// `createdBy` is the author's user id; the API returns it unpopulated.
|
|
258
|
+
const isMine = (msg: TCommentChat) =>
|
|
259
|
+
!!currentUser.value?._id &&
|
|
260
|
+
String(msg.createdBy) === String(currentUser.value._id);
|
|
261
|
+
|
|
262
|
+
const canSend = computed(
|
|
263
|
+
() => !sending.value && (!!draft.value.trim() || photos.value.length > 0)
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
const threadKind = computed(() =>
|
|
267
|
+
props.type === "workOrder" ? "workOrder" : "feedback"
|
|
268
|
+
);
|
|
269
|
+
|
|
270
|
+
const scrollToLatest = () => {
|
|
271
|
+
nextTick(() => {
|
|
272
|
+
const el = threadEl.value?.$el ?? threadEl.value;
|
|
273
|
+
if (el) el.scrollTop = el.scrollHeight;
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
const load = async () => {
|
|
278
|
+
if (!props.recordId) {
|
|
279
|
+
comments.value = [];
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
try {
|
|
283
|
+
await setComments(props.recordId, threadKind.value);
|
|
284
|
+
scrollToLatest();
|
|
285
|
+
} catch (error: any) {
|
|
286
|
+
notify(error?.data?.message || "The chat could not be loaded.");
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
watch(() => props.recordId, load, { immediate: true });
|
|
291
|
+
|
|
292
|
+
const onFilesPicked = async (event: Event) => {
|
|
293
|
+
const input = event.target as HTMLInputElement;
|
|
294
|
+
const files = Array.from(input.files ?? []);
|
|
295
|
+
input.value = "";
|
|
296
|
+
if (!files.length) return;
|
|
297
|
+
|
|
298
|
+
uploading.value = true;
|
|
299
|
+
try {
|
|
300
|
+
for (const file of files) {
|
|
301
|
+
const uploaded = await addFile(file);
|
|
302
|
+
const id = uploaded?.id;
|
|
303
|
+
// No id means nothing to reference; saying so beats attaching a broken
|
|
304
|
+
// image to the message.
|
|
305
|
+
if (!id) throw new Error("The photo upload did not return a file id.");
|
|
306
|
+
photos.value.push({ id, name: file.name });
|
|
307
|
+
}
|
|
308
|
+
} catch (error: any) {
|
|
309
|
+
notify(error?.message || "The photo could not be uploaded.");
|
|
310
|
+
} finally {
|
|
311
|
+
uploading.value = false;
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
const send = async () => {
|
|
316
|
+
if (!canSend.value) return;
|
|
317
|
+
if (!props.recordId) return notify("This record has no id to post against.");
|
|
318
|
+
if (!currentUser.value?._id) return notify("Please sign in again to reply.");
|
|
319
|
+
|
|
320
|
+
sending.value = true;
|
|
321
|
+
try {
|
|
322
|
+
await addComment({
|
|
323
|
+
comment: draft.value.trim(),
|
|
324
|
+
createdBy: String(currentUser.value._id),
|
|
325
|
+
workOrder: threadKind.value === "workOrder" ? props.recordId : "",
|
|
326
|
+
feedback: threadKind.value === "feedback" ? props.recordId : "",
|
|
327
|
+
attachments: photos.value as TAttachment[],
|
|
328
|
+
seenByNames: "",
|
|
329
|
+
} as unknown as TCommentChat);
|
|
330
|
+
// Nothing is cleared until the server has taken it, so a failed send does
|
|
331
|
+
// not silently swallow what was typed.
|
|
332
|
+
draft.value = "";
|
|
333
|
+
photos.value = [];
|
|
334
|
+
await load();
|
|
335
|
+
} catch (error: any) {
|
|
336
|
+
notify(error?.data?.message || "The message could not be sent.");
|
|
337
|
+
} finally {
|
|
338
|
+
sending.value = false;
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
const openPreview = (src: string) => {
|
|
343
|
+
previewSrc.value = src;
|
|
344
|
+
showPreview.value = true;
|
|
345
|
+
};
|
|
148
346
|
|
|
149
347
|
const quickChatOptions = [
|
|
150
348
|
"This is all noted, thank you!",
|
|
@@ -154,9 +352,8 @@ const quickChatOptions = [
|
|
|
154
352
|
"We are here to help.",
|
|
155
353
|
];
|
|
156
354
|
|
|
157
|
-
// Placeholder: choosing a quick-chat option is not wired to anything yet.
|
|
158
355
|
const selectQuickChat = (msg: string) => {
|
|
159
|
-
|
|
356
|
+
draft.value = draft.value ? `${draft.value} ${msg}` : msg;
|
|
160
357
|
};
|
|
161
358
|
</script>
|
|
162
359
|
|
|
@@ -177,6 +374,23 @@ const selectQuickChat = (msg: string) => {
|
|
|
177
374
|
background: var(--bg);
|
|
178
375
|
}
|
|
179
376
|
|
|
377
|
+
.chat-panel__day {
|
|
378
|
+
background: var(--hover);
|
|
379
|
+
color: var(--muted);
|
|
380
|
+
border-radius: 10px;
|
|
381
|
+
font-size: var(--fs-chip);
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
.chat-panel__pending {
|
|
385
|
+
position: relative;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
.chat-panel__pending-remove {
|
|
389
|
+
position: absolute;
|
|
390
|
+
top: -6px;
|
|
391
|
+
right: -6px;
|
|
392
|
+
}
|
|
393
|
+
|
|
180
394
|
/* Was a bare icon and one `color="gray"` - not a token, and not the same tone
|
|
181
395
|
as the icon beside it. */
|
|
182
396
|
.chat-panel__tool {
|
|
@@ -108,6 +108,41 @@
|
|
|
108
108
|
</template>
|
|
109
109
|
</template>
|
|
110
110
|
</div>
|
|
111
|
+
|
|
112
|
+
<!--
|
|
113
|
+
F5: grants the role HOLDS that this client's module list no
|
|
114
|
+
longer offers. Read-only: nothing here can be ticked or unticked,
|
|
115
|
+
and saving keeps them exactly as stored.
|
|
116
|
+
-->
|
|
117
|
+
<div v-if="hasNotOffered" class="role-perm__not-offered mt-4">
|
|
118
|
+
<div class="role-perm__row-title mb-1">
|
|
119
|
+
Granted — not offered to this client
|
|
120
|
+
</div>
|
|
121
|
+
<div class="role-perm__row-sub mb-2">
|
|
122
|
+
This role still holds these. They are outside this client's
|
|
123
|
+
modules, so they cannot be changed here, and saving keeps them.
|
|
124
|
+
</div>
|
|
125
|
+
<div class="role-perm__list">
|
|
126
|
+
<template
|
|
127
|
+
v-for="(actions, resourceKey, resourceIndex) in props.notOfferedPermissions"
|
|
128
|
+
:key="resourceKey"
|
|
129
|
+
>
|
|
130
|
+
<v-divider v-if="resourceIndex > 0" />
|
|
131
|
+
<v-list-item density="compact" :ripple="false">
|
|
132
|
+
<v-list-item-title class="text-capitalize role-perm__row-title">
|
|
133
|
+
{{ formatResourceLabel(String(resourceKey)) }}
|
|
134
|
+
</v-list-item-title>
|
|
135
|
+
<v-list-item-subtitle class="role-perm__row-sub">
|
|
136
|
+
{{
|
|
137
|
+
Object.keys(actions || {})
|
|
138
|
+
.map((action) => formatActionLabel(action))
|
|
139
|
+
.join(", ")
|
|
140
|
+
}}
|
|
141
|
+
</v-list-item-subtitle>
|
|
142
|
+
</v-list-item>
|
|
143
|
+
</template>
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
111
146
|
<div v-if="errorMessages" class="role-perm__error mt-2">
|
|
112
147
|
{{ errorMessages }}
|
|
113
148
|
</div>
|
|
@@ -175,6 +210,12 @@ const props = defineProps({
|
|
|
175
210
|
type: Object,
|
|
176
211
|
default: () => ({}),
|
|
177
212
|
},
|
|
213
|
+
// F5: held grants outside the client's offer, `{ resource: { action } }`.
|
|
214
|
+
// Display only -- never part of the tree the toggles act on.
|
|
215
|
+
notOfferedPermissions: {
|
|
216
|
+
type: Object,
|
|
217
|
+
default: () => ({}),
|
|
218
|
+
},
|
|
178
219
|
// "Update role". This dialog had no permission prop at all, so it showed Edit
|
|
179
220
|
// to everyone -- including on the seeded platform-owner role -- and the
|
|
180
221
|
// `canUpdateRole` the apps have been passing to `RolePermissionMain` in good
|
|
@@ -294,6 +335,10 @@ const visiblePermissions = computed(() => {
|
|
|
294
335
|
return matches;
|
|
295
336
|
});
|
|
296
337
|
|
|
338
|
+
const hasNotOffered = computed(
|
|
339
|
+
() => Object.keys(props.notOfferedPermissions || {}).length > 0
|
|
340
|
+
);
|
|
341
|
+
|
|
297
342
|
const hasVisiblePermissions = computed(
|
|
298
343
|
() => Object.keys(visiblePermissions.value).length > 0
|
|
299
344
|
);
|
|
@@ -112,6 +112,7 @@
|
|
|
112
112
|
@success="successfulUpdate()"
|
|
113
113
|
:permissions="Permissions"
|
|
114
114
|
:original-permissions="originalPermissions"
|
|
115
|
+
:not-offered-permissions="heldNotOffered"
|
|
115
116
|
v-model="selectedPermissions"
|
|
116
117
|
v-model:edit="edit"
|
|
117
118
|
:name="name"
|
|
@@ -572,6 +573,25 @@ const Permissions = computed(() => {
|
|
|
572
573
|
: filterPermissions(offeredPermissions.value, originalPermissions.value);
|
|
573
574
|
});
|
|
574
575
|
|
|
576
|
+
/*
|
|
577
|
+
* F5: WHAT THE ROLE HOLDS THAT THIS CLIENT IS NO LONGER OFFERED.
|
|
578
|
+
*
|
|
579
|
+
* The tree above is the narrowed catalogue, so a grant outside the client's
|
|
580
|
+
* module list simply vanished from it and the role LOOKED as if it lacked a
|
|
581
|
+
* module it still holds. The dialog lists these separately, read-only. Saving
|
|
582
|
+
* keeps them: the dialog's model is the full stored array and every toggle only
|
|
583
|
+
* touches keys in the tree. Empty (the same object) whenever nothing is narrowed.
|
|
584
|
+
*/
|
|
585
|
+
const heldNotOffered = computed(() => {
|
|
586
|
+
const all = (props.permissions ?? {}) as TPermissions;
|
|
587
|
+
const offered = offeredPermissions.value as TPermissions;
|
|
588
|
+
if (offered === all) return {};
|
|
589
|
+
const outside = Object.fromEntries(
|
|
590
|
+
Object.entries(all).filter(([resource]) => !(resource in offered))
|
|
591
|
+
) as TPermissions;
|
|
592
|
+
return filterPermissions(outside, originalPermissions.value);
|
|
593
|
+
});
|
|
594
|
+
|
|
575
595
|
function successfulUpdate() {
|
|
576
596
|
const savedPermissions = [...selectedPermissions.value];
|
|
577
597
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<v-row no-gutters class="fill-height">
|
|
4
4
|
<v-col cols="12" xl="7" lg="7" md="7" class="fill-height">
|
|
5
5
|
<div class="panel-container border-e">
|
|
6
|
-
<ChatMessage :type="'workOrder'" />
|
|
6
|
+
<ChatMessage :type="'workOrder'" :record-id="String(workOrder?._id || '')" />
|
|
7
7
|
</div>
|
|
8
8
|
</v-col>
|
|
9
9
|
<v-col cols="12" xl="5" lg="5" md="5" class="fill-height">
|
|
@@ -21,6 +21,46 @@ export default function useCleaningPermission() {
|
|
|
21
21
|
invitations: invitationPermissions,
|
|
22
22
|
"bulletin-board": bulletinBoardPermissions,
|
|
23
23
|
|
|
24
|
+
// Owner decision 3A, 2026-09-11: Emergency Contacts is offered in the
|
|
25
|
+
// Cleaning role editor. Exactly the seven actions `constants/permissions.ts`
|
|
26
|
+
// defines; descriptions from `usePropertyPermission`. The long spelling
|
|
27
|
+
// `see-all-emergency-contacts` is deliberately NOT added -- the hygiene app
|
|
28
|
+
// already accepts `see-all`, and a second "see all" row would only confuse.
|
|
29
|
+
"emergency-contact": {
|
|
30
|
+
"see-all": {
|
|
31
|
+
check: true,
|
|
32
|
+
description: "Allows the user to view the list of all emergency contacts.",
|
|
33
|
+
},
|
|
34
|
+
"see-details": {
|
|
35
|
+
check: true,
|
|
36
|
+
description:
|
|
37
|
+
"Allows the user to view the details of a specific emergency contact.",
|
|
38
|
+
},
|
|
39
|
+
"add-emergency-contact": {
|
|
40
|
+
check: true,
|
|
41
|
+
description: "Allows the user to add a new emergency contact to the system.",
|
|
42
|
+
},
|
|
43
|
+
"update-emergency-contact": {
|
|
44
|
+
check: true,
|
|
45
|
+
description: "Allows the user to update emergency contact details.",
|
|
46
|
+
},
|
|
47
|
+
"delete-emergency-contact": {
|
|
48
|
+
check: true,
|
|
49
|
+
description:
|
|
50
|
+
"Allows the user to remove an emergency contact from the system permanently.",
|
|
51
|
+
},
|
|
52
|
+
"add-emergency-contact-category": {
|
|
53
|
+
check: true,
|
|
54
|
+
description:
|
|
55
|
+
"Allows the user to add a new emergency contact category to the system.",
|
|
56
|
+
},
|
|
57
|
+
"delete-emergency-contact-category": {
|
|
58
|
+
check: true,
|
|
59
|
+
description:
|
|
60
|
+
"Allows the user to delete an emergency contact category from the system.",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
|
|
24
64
|
// `hasPermission` looks an action up as `catalogue[resource][action]`, so a
|
|
25
65
|
// resource with no key here can never answer anything but `false` -- the
|
|
26
66
|
// gate is then reachable only through the `"*"` short-circuit. These two
|
|
@@ -111,10 +111,18 @@ export default function useComment() {
|
|
|
111
111
|
);
|
|
112
112
|
|
|
113
113
|
if (Array.isArray(updateSeenIds) && updateSeenIds.length > 0) {
|
|
114
|
-
const seenBy = await updateSeenBy(
|
|
114
|
+
const seenBy = await updateSeenBy(
|
|
115
|
+
updateSeenIds,
|
|
116
|
+
currentUser.value?._id
|
|
117
|
+
);
|
|
115
118
|
}
|
|
116
119
|
} catch (error) {
|
|
120
|
+
// Was swallowed here, which is why a thread that failed to load was
|
|
121
|
+
// indistinguishable from a thread with no messages in it. The caller
|
|
122
|
+
// decides what to tell the user.
|
|
117
123
|
console.error("error :", error);
|
|
124
|
+
comments.value = [];
|
|
125
|
+
throw error;
|
|
118
126
|
} finally {
|
|
119
127
|
isCommentsLoaded.value = false;
|
|
120
128
|
}
|
|
@@ -39,6 +39,41 @@ export default function useLandscapingPermission() {
|
|
|
39
39
|
work_orders: workOrderPermissions,
|
|
40
40
|
"bulletin-board": bulletinBoardPermissions,
|
|
41
41
|
"service-provider-mgmt": serviceProviderPermissions,
|
|
42
|
+
// Owner decision 3A, 2026-09-11: Emergency Contacts is offered in the
|
|
43
|
+
// Landscape role editor. Exactly the seven actions `constants/permissions.ts`
|
|
44
|
+
// defines; descriptions from `usePropertyPermission`. The long spelling
|
|
45
|
+
// `see-all-emergency-contacts` is deliberately NOT added -- the landscape app
|
|
46
|
+
// already accepts `see-all`, and a second "see all" row would only confuse.
|
|
47
|
+
"emergency-contact": {
|
|
48
|
+
"see-all": {
|
|
49
|
+
check: true,
|
|
50
|
+
description: "Allows the user to view the list of all emergency contacts.",
|
|
51
|
+
},
|
|
52
|
+
"see-details": {
|
|
53
|
+
check: true,
|
|
54
|
+
description: "Allows the user to view the details of a specific emergency contact.",
|
|
55
|
+
},
|
|
56
|
+
"add-emergency-contact": {
|
|
57
|
+
check: true,
|
|
58
|
+
description: "Allows the user to add a new emergency contact to the system.",
|
|
59
|
+
},
|
|
60
|
+
"update-emergency-contact": {
|
|
61
|
+
check: true,
|
|
62
|
+
description: "Allows the user to update emergency contact details.",
|
|
63
|
+
},
|
|
64
|
+
"delete-emergency-contact": {
|
|
65
|
+
check: true,
|
|
66
|
+
description: "Allows the user to remove an emergency contact from the system permanently.",
|
|
67
|
+
},
|
|
68
|
+
"add-emergency-contact-category": {
|
|
69
|
+
check: true,
|
|
70
|
+
description: "Allows the user to add a new emergency contact category to the system.",
|
|
71
|
+
},
|
|
72
|
+
"delete-emergency-contact-category": {
|
|
73
|
+
check: true,
|
|
74
|
+
description: "Allows the user to delete an emergency contact category from the system.",
|
|
75
|
+
},
|
|
76
|
+
},
|
|
42
77
|
inventory: {
|
|
43
78
|
"view-inventory": {
|
|
44
79
|
check: true,
|
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.8.0",
|
|
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/comment.d.ts
CHANGED
|
@@ -9,6 +9,8 @@ declare type TCommentChat = {
|
|
|
9
9
|
updatedAt?: string;
|
|
10
10
|
createdByName?: string;
|
|
11
11
|
createdByType?: string;
|
|
12
|
+
/** The sender's avatar file id. The API has always returned it. */
|
|
13
|
+
createdByProfile?: string;
|
|
12
14
|
justify?: string;
|
|
13
15
|
feedback?: string;
|
|
14
16
|
seenByNames: Person;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a message's sender is described under their name in a chat thread.
|
|
3
|
+
*
|
|
4
|
+
* `createdByType` is the raw `user.type` from the API - lowercase, sometimes
|
|
5
|
+
* hyphenated, sometimes empty. The mobile chat used to print it as-is for
|
|
6
|
+
* everything except "site", so a resident read "provider" while a technician on
|
|
7
|
+
* the same thread read "Site Personnel". The web read nothing at all, because
|
|
8
|
+
* the whole panel was a mockup. Nothing here invents a job title: the one name
|
|
9
|
+
* the product already uses is kept, and anything else is simply made readable.
|
|
10
|
+
*
|
|
11
|
+
* Kept in step with `src/utils/chat-sender.ts` in the six mobile apps.
|
|
12
|
+
*/
|
|
13
|
+
export function formatSenderRole(
|
|
14
|
+
type: string | undefined | null,
|
|
15
|
+
sitePersonnelLabel = "Site Personnel"
|
|
16
|
+
): string {
|
|
17
|
+
const raw = (type ?? "").trim();
|
|
18
|
+
if (!raw) return "";
|
|
19
|
+
if (raw.toLowerCase() === "site") return sitePersonnelLabel;
|
|
20
|
+
|
|
21
|
+
return raw
|
|
22
|
+
.split(/[-_\s]+/)
|
|
23
|
+
.filter(Boolean)
|
|
24
|
+
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
25
|
+
.join(" ");
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A thread already in reading order (oldest first, as `useComment.setComments`
|
|
30
|
+
* sorts it), split into one group per day so the panel can draw a single day
|
|
31
|
+
* heading above each day's messages instead of a date on every bubble.
|
|
32
|
+
*/
|
|
33
|
+
export function groupChatByDay<T extends { createdAt?: string | Date }>(
|
|
34
|
+
comments: T[],
|
|
35
|
+
formatDay: (value: string | Date) => string
|
|
36
|
+
): { day: string; messages: T[] }[] {
|
|
37
|
+
const days: { day: string; messages: T[] }[] = [];
|
|
38
|
+
|
|
39
|
+
for (const message of comments) {
|
|
40
|
+
const day = message.createdAt ? formatDay(message.createdAt) : "";
|
|
41
|
+
const current = days[days.length - 1];
|
|
42
|
+
if (current && current.day === day) current.messages.push(message);
|
|
43
|
+
else days.push({ day, messages: [message] });
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return days;
|
|
47
|
+
}
|
package/utils/org-modules.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* The client half of `core src/utils/org-modules.util.ts`, and deliberately a
|
|
5
5
|
* COPY rather than an import: this package cannot depend on `@7365admin1/core`
|
|
6
6
|
* (it is the frontend layer, and `core` is a server package). The copy is
|
|
7
|
-
*
|
|
7
|
+
* short and fails open, and `test/org-module-catalogue.test.mjs` pins it
|
|
8
8
|
* against the same cases the server's tests use.
|
|
9
9
|
*
|
|
10
10
|
* ## What this is for
|
|
@@ -29,7 +29,75 @@
|
|
|
29
29
|
* would empty the role editor for every client the moment it deployed. It fails
|
|
30
30
|
* open on every uncertainty — a missing list, a non-array, an unreadable key,
|
|
31
31
|
* and a list that matches nothing at all.
|
|
32
|
+
*
|
|
33
|
+
* ## Spelling groups and the always-allowed set (plan S2, 2026-09-11)
|
|
34
|
+
*
|
|
35
|
+
* Both only WIDEN. A module is offered if the list names it under ANY spelling
|
|
36
|
+
* of the same module, and the modules every client needs to run its own
|
|
37
|
+
* organisation are offered whatever the list says.
|
|
32
38
|
*/
|
|
39
|
+
import { LEGACY_PERMISSION_ALIASES } from "../constants/permissions.ts";
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Offered to every client whatever its module list says: without them a client
|
|
43
|
+
* cannot manage its own people, roles, sites or billing. Same set as core's
|
|
44
|
+
* `ALWAYS_ALLOWED` (defined in `org-modules.util.ts`, re-exported from
|
|
45
|
+
* `module-gate.util.ts`).
|
|
46
|
+
*/
|
|
47
|
+
export const ALWAYS_ALLOWED_MODULES: readonly string[] = Object.freeze([
|
|
48
|
+
"sites",
|
|
49
|
+
"subscriptions",
|
|
50
|
+
"customers",
|
|
51
|
+
"payment-methods",
|
|
52
|
+
"members",
|
|
53
|
+
"invitations",
|
|
54
|
+
"roles",
|
|
55
|
+
"roles-and-permissions",
|
|
56
|
+
"site-settings",
|
|
57
|
+
]);
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The one pair the alias map does not carry. iMA365 gates Online Forms on
|
|
61
|
+
* `online-forms` while roles hold `online-form-configuration` (production,
|
|
62
|
+
* 2026-09-10: 33 roles against 1), and the app already treats the two as one
|
|
63
|
+
* module (`permission.utils.ts` RESOURCE_ALIASES). Both keys exist in the
|
|
64
|
+
* catalogues; grouping them only widens. core `SPELLING_GROUPS` (defined in
|
|
65
|
+
* `org-modules.util.ts`, re-exported from `module-gate.util.ts`) carries the
|
|
66
|
+
* same pair.
|
|
67
|
+
*/
|
|
68
|
+
const EXTRA_SPELLING_GROUPS: readonly (readonly [string, ...string[]])[] = [
|
|
69
|
+
["online-form-configuration", "online-forms"],
|
|
70
|
+
];
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Resource keys that are the SAME module under different spellings — e.g.
|
|
74
|
+
* `workOrder` / `work_order` / `work-orders` / `work_orders`.
|
|
75
|
+
*
|
|
76
|
+
* DERIVED from `LEGACY_PERMISSION_ALIASES` (every alias whose resource differs
|
|
77
|
+
* from its canonical resource), never hand-written, so a spelling cannot be
|
|
78
|
+
* invented here and a new alias is picked up without touching this file.
|
|
79
|
+
*/
|
|
80
|
+
export const MODULE_SPELLING_GROUPS: readonly (readonly string[])[] = (() => {
|
|
81
|
+
const groups = new Map<string, Set<string>>();
|
|
82
|
+
for (const [legacy, canonical] of Object.entries(LEGACY_PERMISSION_ALIASES)) {
|
|
83
|
+
const from = legacy.split(":")[0];
|
|
84
|
+
const to = canonical.split(":")[0];
|
|
85
|
+
if (from === to) continue;
|
|
86
|
+
const group = groups.get(to) ?? new Set([to]);
|
|
87
|
+
group.add(from);
|
|
88
|
+
groups.set(to, group);
|
|
89
|
+
}
|
|
90
|
+
for (const [canonical, ...others] of EXTRA_SPELLING_GROUPS) {
|
|
91
|
+
const group = groups.get(canonical) ?? new Set([canonical]);
|
|
92
|
+
others.forEach((key) => group.add(key));
|
|
93
|
+
groups.set(canonical, group);
|
|
94
|
+
}
|
|
95
|
+
return Object.freeze([...groups.values()].map((group) => Object.freeze([...group])));
|
|
96
|
+
})();
|
|
97
|
+
|
|
98
|
+
function spellingsOf(key: string): readonly string[] {
|
|
99
|
+
return MODULE_SPELLING_GROUPS.find((group) => group.includes(key)) ?? [key];
|
|
100
|
+
}
|
|
33
101
|
|
|
34
102
|
/** May this client's role editor OFFER this module? Fails open. */
|
|
35
103
|
export function orgAllowsModule(
|
|
@@ -40,8 +108,9 @@ export function orgAllowsModule(
|
|
|
40
108
|
|
|
41
109
|
const key = typeof resource === "string" ? resource.trim() : "";
|
|
42
110
|
if (!key) return true;
|
|
111
|
+
if (ALWAYS_ALLOWED_MODULES.includes(key)) return true;
|
|
43
112
|
|
|
44
|
-
return modules.includes(
|
|
113
|
+
return spellingsOf(key).some((spelling) => modules.includes(spelling));
|
|
45
114
|
}
|
|
46
115
|
|
|
47
116
|
/**
|
|
@@ -58,19 +127,28 @@ export function catalogueForOrg<T extends Record<string, unknown>>(
|
|
|
58
127
|
if (!Array.isArray(modules) || modules.length === 0) return catalogue;
|
|
59
128
|
if (!catalogue || typeof catalogue !== "object") return catalogue;
|
|
60
129
|
|
|
61
|
-
const narrowed: Record<string, unknown> = {};
|
|
62
|
-
for (const [resource, actions] of Object.entries(catalogue)) {
|
|
63
|
-
if (orgAllowsModule(modules, resource)) narrowed[resource] = actions;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
130
|
/*
|
|
67
131
|
* A list that matched NOTHING shows the whole catalogue rather than an empty
|
|
68
132
|
* one. A blank role editor is indistinguishable from a broken screen, and the
|
|
69
133
|
* likeliest cause of matching nothing is a console typo or a catalogue whose
|
|
70
134
|
* resource keys were renamed — neither of which should take the editor away
|
|
71
135
|
* from the client.
|
|
136
|
+
*
|
|
137
|
+
* "Matched" is decided on the list AS TYPED — the rule from before the
|
|
138
|
+
* spelling groups and the always-allowed set existed. Deciding it on the
|
|
139
|
+
* widened rule would let `members` (in every catalogue) turn this fallback
|
|
140
|
+
* into a narrowed editor; this way both additions can only ADD.
|
|
72
141
|
*/
|
|
73
|
-
|
|
142
|
+
const matchedAsTyped = Object.keys(catalogue).some(
|
|
143
|
+
(resource) => !resource.trim() || modules.includes(resource.trim()),
|
|
144
|
+
);
|
|
145
|
+
if (!matchedAsTyped) return catalogue;
|
|
146
|
+
|
|
147
|
+
const narrowed: Record<string, unknown> = {};
|
|
148
|
+
for (const [resource, actions] of Object.entries(catalogue)) {
|
|
149
|
+
if (orgAllowsModule(modules, resource)) narrowed[resource] = actions;
|
|
150
|
+
}
|
|
151
|
+
return narrowed as T;
|
|
74
152
|
}
|
|
75
153
|
|
|
76
154
|
/**
|