@7365admin1/layer-common 4.5.1-staging.300 → 4.6.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.
Files changed (36) hide show
  1. package/CHANGELOG.md +20 -4
  2. package/components/AreaChecklistHistoryLogs.vue +0 -81
  3. package/components/Chat/Bubbles.vue +30 -94
  4. package/components/Chat/Message.vue +67 -281
  5. package/components/Facility/BookingSetup.vue +0 -63
  6. package/components/FeedbackDetail.vue +1 -1
  7. package/components/HidIntercomManagement.vue +42 -145
  8. package/components/HidReaderUserRoster.vue +2 -32
  9. package/components/HidUserEnrollment.vue +212 -771
  10. package/components/InvitationClientForm.vue +1 -19
  11. package/components/ManageChecklistMain.vue +2 -34
  12. package/components/SwitchContext.vue +2 -46
  13. package/components/VisitorManagement.vue +5 -267
  14. package/components/WorkOrder/Detail.vue +1 -1
  15. package/composables/useCleaningPermission.ts +0 -5
  16. package/composables/useComment.ts +1 -9
  17. package/composables/useFacility.ts +0 -11
  18. package/composables/useHidAmico.ts +0 -73
  19. package/composables/useHidNavigation.ts +1 -25
  20. package/composables/useLandscapingPermission.ts +0 -5
  21. package/composables/useMechanicalElectricalPermission.ts +0 -6
  22. package/composables/usePeople.ts +0 -19
  23. package/composables/usePestControlPermission.ts +0 -5
  24. package/composables/usePoolMaintenancePermission.ts +0 -5
  25. package/composables/usePropertyPermission.ts +0 -5
  26. package/composables/useSecurityPermission.ts +0 -5
  27. package/package.json +1 -1
  28. package/types/cleaner-schedule.d.ts +0 -2
  29. package/types/comment.d.ts +0 -2
  30. package/types/facility.d.ts +0 -4
  31. package/types/people.d.ts +1 -4
  32. package/utils/materialSymbols.ts +0 -3
  33. package/components/HidProfileQrCode.vue +0 -323
  34. package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +0 -23
  35. package/utils/chat-sender.ts +0 -47
  36. package/utils/module-applications.ts +0 -146
@@ -11,127 +11,57 @@
11
11
  </div>
12
12
 
13
13
  <v-sheet
14
- ref="threadEl"
15
14
  class="chat-panel__thread overflow-y-auto flex-grow-1 pa-3"
16
15
  :style="{ height: 'calc(100vh - 300px)', overflowX: 'hidden' }"
17
16
  >
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"
17
+ <v-row
18
+ v-for="(msg, i) in messages"
19
+ :key="i"
20
+ no-gutters
21
+ :justify="msg.isCurrentUser ? 'end' : 'start'"
22
+ class="mb-2"
25
23
  >
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>
24
+ <v-col cols="auto">
25
+ <ChatBubbles
26
+ :isCurrentUser="msg.isCurrentUser"
27
+ :message="msg.message"
28
+ :timestamp="msg.timestamp"
29
+ :seenLabel="msg.seenLabel"
30
+ :senderName="msg.senderName"
31
+ :role="msg.role"
32
+ />
33
+ </v-col>
34
+ </v-row>
60
35
  </v-sheet>
61
36
 
62
37
  <v-card class="screen-card mx-4 mb-4 mt-2 pa-3" elevation="0">
63
38
  <v-row no-gutters align="end">
64
39
  <v-col cols="10">
65
40
  <v-textarea
66
- v-model="draft"
67
41
  class="filter-field"
68
42
  label="Message"
69
43
  auto-grow
70
44
  hide-details
71
45
  rows="1"
72
46
  variant="outlined"
73
- :disabled="sending"
74
- @keydown.enter.exact.prevent="send"
75
47
  />
76
48
  </v-col>
77
49
  <v-col cols="2" class="pl-2">
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>
50
+ <v-btn class="screen-btn-primary" variant="flat" block>Send</v-btn>
88
51
  </v-col>
89
52
  </v-row>
90
53
 
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
-
114
54
  <v-divider class="my-2" />
115
55
 
116
56
  <v-row justify="start" no-gutters align="center">
117
57
  <v-col cols="auto">
118
- <v-btn
119
- icon
120
- density="compact"
121
- variant="text"
122
- :loading="uploading"
123
- @click="fileInput?.click()"
58
+ <v-icon size="20" class="chat-panel__tool mr-3">mdi-paperclip</v-icon>
59
+ </v-col>
60
+
61
+ <v-col cols="auto">
62
+ <v-icon size="20" class="chat-panel__tool mr-3"
63
+ >mdi-emoticon-happy-outline</v-icon
124
64
  >
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
- />
135
65
  </v-col>
136
66
 
137
67
  <v-col cols="auto">
@@ -164,185 +94,57 @@
164
94
  </v-col>
165
95
  </v-row>
166
96
  </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" />
185
97
  </v-sheet>
186
98
  </template>
187
99
 
188
100
  <script setup lang="ts">
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({
101
+ defineProps({
201
102
  type: {
202
103
  type: String,
203
104
  default: "feedback",
204
105
  },
205
- /** The feedback or work order this thread hangs off. */
206
- recordId: {
207
- type: String,
208
- default: "",
209
- },
210
106
  });
211
107
 
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
- };
108
+ const messages = [
109
+ {
110
+ isCurrentUser: true,
111
+ message: "Hello we would like to transfer this task...",
112
+ timestamp: "06/28/2024 08:40",
113
+ seenLabel: "Seen",
114
+ senderName: "You",
115
+ role: "Site Personnel",
116
+ },
117
+ {
118
+ isCurrentUser: false,
119
+ message: "Sure. Let me take care of that.",
120
+ timestamp: "06/28/2024 08:42",
121
+ senderName: "Tan Wei",
122
+ role: "Manager",
123
+ },
124
+ {
125
+ isCurrentUser: true,
126
+ message: "Thanks!",
127
+ timestamp: "06/28/2024 08:43",
128
+ seenLabel: "Seen",
129
+ senderName: "You",
130
+ role: "Site Personnel",
131
+ },
132
+ {
133
+ isCurrentUser: false,
134
+ message: "No worries!",
135
+ timestamp: "06/28/2024 08:44",
136
+ senderName: "Tan Wei",
137
+ role: "Manager",
138
+ },
139
+ {
140
+ isCurrentUser: true,
141
+ message: "Let me know if you need anything else.",
142
+ timestamp: "06/28/2024 08:45",
143
+ seenLabel: "Seen",
144
+ senderName: "You",
145
+ role: "Site Personnel",
146
+ },
147
+ ];
346
148
 
347
149
  const quickChatOptions = [
348
150
  "This is all noted, thank you!",
@@ -352,8 +154,9 @@ const quickChatOptions = [
352
154
  "We are here to help.",
353
155
  ];
354
156
 
157
+ // Placeholder: choosing a quick-chat option is not wired to anything yet.
355
158
  const selectQuickChat = (msg: string) => {
356
- draft.value = draft.value ? `${draft.value} ${msg}` : msg;
159
+ void msg;
357
160
  };
358
161
  </script>
359
162
 
@@ -374,23 +177,6 @@ const selectQuickChat = (msg: string) => {
374
177
  background: var(--bg);
375
178
  }
376
179
 
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
-
394
180
  /* Was a bare icon and one `color="gray"` - not a token, and not the same tone
395
181
  as the icon beside it. */
396
182
  .chat-panel__tool {
@@ -482,55 +482,6 @@
482
482
  </draggable>
483
483
  </section>
484
484
 
485
- <!-- RESIDENT CHECKLISTS -->
486
- <v-col cols="12" class="mt-4 border-t">
487
- <v-row align="center" no-gutters class="pt-5">
488
- <v-col cols="9" class="d-flex align-center text-body-2">
489
- <v-row no-gutters>
490
- <v-col cols="12" class="header-style">
491
- Resident Checklists
492
- </v-col>
493
- <v-col cols="12" class="text-body-2 text-medium-emphasis">
494
- Allow residents to view and complete assigned checklists. Each
495
- checklist requires a photo upload before submission.
496
- </v-col>
497
- </v-row>
498
- </v-col>
499
- <v-col cols="3" class="d-flex align-center justify-end">
500
- <v-switch
501
- v-model="facility.isResidentChecklistEnabled"
502
- class="d-flex align-center"
503
- color="accent"
504
- hide-details
505
- @update:model-value="onToggleResidentChecklist"
506
- />
507
- </v-col>
508
- </v-row>
509
-
510
- <!-- SECURITY CHECKLISTS -->
511
- <v-row align="center" no-gutters class="border-t pt-5 mt-5">
512
- <v-col cols="9" class="d-flex align-center text-body-2">
513
- <v-row no-gutters>
514
- <v-col cols="12" class="header-style">
515
- Security Checklists
516
- </v-col>
517
- <v-col cols="12" class="text-body-2 text-medium-emphasis">
518
- Allow Security to view and complete assigned checklists
519
- </v-col>
520
- </v-row>
521
- </v-col>
522
- <v-col cols="3" class="d-flex align-center justify-end">
523
- <v-switch
524
- v-model="facility.isSecurityChecklistEnabled"
525
- class="d-flex align-center"
526
- color="accent"
527
- hide-details
528
- @update:model-value="onToggleSecurityChecklist"
529
- />
530
- </v-col>
531
- </v-row>
532
- </v-col>
533
-
534
485
  <v-col cols="12" class="mt-10">
535
486
  <p class="header-style font-weight-bold mb-5 mt-md-0 ml-md-4">
536
487
  Other Settings
@@ -1069,20 +1020,6 @@ watchEffect(() => {
1069
1020
  }
1070
1021
  });
1071
1022
 
1072
- /**
1073
- * One checklist, one owner, and always one. A facility is completed either by
1074
- * its residents or by Security, so the two switches are each other's inverse:
1075
- * turning either off turns the other on. There is no state where a facility
1076
- * has no checklist owner.
1077
- */
1078
- function onToggleResidentChecklist(enabled: boolean | null) {
1079
- facility.value.isSecurityChecklistEnabled = !enabled;
1080
- }
1081
-
1082
- function onToggleSecurityChecklist(enabled: boolean | null) {
1083
- facility.value.isResidentChecklistEnabled = !enabled;
1084
- }
1085
-
1086
1023
  function onToggleBookingUnitLimit(val: any) {
1087
1024
  if (val) {
1088
1025
  isBookingUnitLimitEnabled.value = true;
@@ -4,7 +4,7 @@
4
4
 
5
5
  <v-col cols="12" xl="7" lg="7" md="7" class="fill-height">
6
6
  <div class="panel-container border-e">
7
- <ChatMessage :type="'feedback'" :record-id="String(feedback?._id || '')" />
7
+ <ChatMessage :type="'feedback'" />
8
8
  </div>
9
9
  </v-col>
10
10