@7365admin1/layer-common 4.17.0 → 4.17.1-staging.330
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 +4 -4
- package/components/DocumentForm.vue +407 -112
- package/components/DocumentManagement.vue +213 -12
- package/components/EntryPass/QrTemplatePreview.vue +21 -25
- package/components/EntryPassInformation.vue +119 -24
- package/components/Facility/BookingSetup.vue +63 -0
- package/components/HidAccessPermissions.vue +424 -0
- package/components/HidIntercomManagement.vue +193 -43
- package/components/HidProfileQrCode.vue +323 -0
- package/components/HidReaderManagement.vue +26 -0
- package/components/HidReaderUserRoster.vue +32 -2
- package/components/HidUserEnrollment.vue +779 -213
- package/components/InvitationClientForm.vue +19 -1
- package/components/Layout/Header.vue +26 -0
- package/components/NotificationBell.vue +321 -0
- package/components/VisitorManagement.vue +267 -5
- package/composables/useAccessManagement.ts +5 -0
- package/composables/useDocument.ts +7 -0
- package/composables/useFacility.ts +11 -0
- package/composables/useHidAmico.ts +97 -0
- package/composables/useHidNavigation.ts +25 -1
- package/composables/useNotification.ts +78 -0
- package/composables/usePeople.ts +19 -0
- package/composables/useSecurityPermission.ts +8 -7
- package/composables/useWebUsb.ts +14 -11
- 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-qr-code/index.vue +23 -0
- package/pages/[org]/[site]/access-mgmt/hid-readers/index.vue +1 -1
- package/types/document.d.ts +14 -0
- package/types/facility.d.ts +4 -0
- package/types/people.d.ts +4 -1
- package/utils/hid-permission-assignments.ts +190 -0
- package/utils/materialSymbols.ts +3 -0
|
@@ -388,9 +388,27 @@ watch(
|
|
|
388
388
|
const roles = ref<any[]>([])
|
|
389
389
|
const { getRoles } = useRole()
|
|
390
390
|
|
|
391
|
+
/*
|
|
392
|
+
* `type` is the ROLE type, not the service the client subscribes to, and the
|
|
393
|
+
* only caller (`ClientMain.vue` "Invite Client") passes no `app` prop -- so
|
|
394
|
+
* this sent `type: ""` and the endpoint applied no type filter at all. The
|
|
395
|
+
* dropdown therefore listed every org-less role of every type, which includes
|
|
396
|
+
* the platform's OWN staff roles (`type: "admin"` -- the two rows the console's
|
|
397
|
+
* `/super-admin/role-permissions` screen edits). Offering a Seven365 console
|
|
398
|
+
* staff role on a CLIENT invitation is the defect.
|
|
399
|
+
*
|
|
400
|
+
* A client admin's role is `type: "organization"`, which is what the client
|
|
401
|
+
* roles screen (`org/[organization]/roles-permissions.vue`) already lists. This
|
|
402
|
+
* narrows to exactly that. It is a narrowing of this one picker only: no role
|
|
403
|
+
* changes, no permission changes, and the org-less `organization` roles that
|
|
404
|
+
* were already being picked are all still offered.
|
|
405
|
+
*
|
|
406
|
+
* Keying off the selected service instead would empty the dropdown -- no
|
|
407
|
+
* org-less role carries a service type -- so `props.app` is not the filter.
|
|
408
|
+
*/
|
|
391
409
|
const { data: roleData, refresh: refreshRoles } = await useLazyAsyncData(
|
|
392
410
|
"roles",
|
|
393
|
-
() => getRoles({ org: org.value?._id, type:
|
|
411
|
+
() => getRoles({ org: org.value?._id, type: "organization", limit: 50 }),
|
|
394
412
|
{ watch: [() => props.app] }
|
|
395
413
|
)
|
|
396
414
|
|
|
@@ -41,6 +41,11 @@
|
|
|
41
41
|
@click="toggleTheme"
|
|
42
42
|
/>
|
|
43
43
|
|
|
44
|
+
<NotificationBell
|
|
45
|
+
v-if="props.showNotifications"
|
|
46
|
+
:site-id="routeSiteId"
|
|
47
|
+
/>
|
|
48
|
+
|
|
44
49
|
<v-menu offset="10px" :close-on-content-click="false">
|
|
45
50
|
<template #activator="{ props }">
|
|
46
51
|
<v-btn fab variant="text" icon v-bind="props" class="ms-2 me-1">
|
|
@@ -96,6 +101,18 @@ const props = defineProps({
|
|
|
96
101
|
type: Boolean,
|
|
97
102
|
default: false,
|
|
98
103
|
},
|
|
104
|
+
/**
|
|
105
|
+
* Whether to show the notification bell.
|
|
106
|
+
*
|
|
107
|
+
* Off by default, and opt-in per application rather than always on: this
|
|
108
|
+
* header is mounted by every app in the estate, and only the ones whose
|
|
109
|
+
* modules actually raise notifications should grow a bell that would
|
|
110
|
+
* otherwise sit there permanently empty.
|
|
111
|
+
*/
|
|
112
|
+
showNotifications: {
|
|
113
|
+
type: Boolean,
|
|
114
|
+
default: false,
|
|
115
|
+
},
|
|
99
116
|
});
|
|
100
117
|
|
|
101
118
|
const menu = defineModel("menu", { type: Boolean });
|
|
@@ -128,6 +145,15 @@ const { currentUser } = useLocalAuth();
|
|
|
128
145
|
*/
|
|
129
146
|
const { site } = useSite();
|
|
130
147
|
|
|
148
|
+
/**
|
|
149
|
+
* The site the user is currently inside, straight off the route. Empty outside
|
|
150
|
+
* a site, where the feed falls back to everything addressed to this user.
|
|
151
|
+
*/
|
|
152
|
+
const routeSiteId = computed(() => {
|
|
153
|
+
const param = useRoute().params.site;
|
|
154
|
+
return typeof param === "string" ? param : "";
|
|
155
|
+
});
|
|
156
|
+
|
|
131
157
|
/**
|
|
132
158
|
* The shared `site` state is only populated by the screens that load a site
|
|
133
159
|
* document, so on most screens - the dashboard included - the bar had no name
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<v-menu
|
|
3
|
+
v-model="open"
|
|
4
|
+
offset="10px"
|
|
5
|
+
:close-on-content-click="false"
|
|
6
|
+
location="bottom end"
|
|
7
|
+
>
|
|
8
|
+
<template #activator="{ props: activator }">
|
|
9
|
+
<v-btn
|
|
10
|
+
v-bind="activator"
|
|
11
|
+
variant="text"
|
|
12
|
+
size="36"
|
|
13
|
+
class="app-topbar-shell__icon-btn ms-2"
|
|
14
|
+
:aria-label="
|
|
15
|
+
unread > 0 ? `Notifications, ${unread} unread` : 'Notifications'
|
|
16
|
+
"
|
|
17
|
+
>
|
|
18
|
+
<v-badge
|
|
19
|
+
:model-value="unread > 0"
|
|
20
|
+
:content="badgeLabel"
|
|
21
|
+
color="error"
|
|
22
|
+
offset-x="-2"
|
|
23
|
+
offset-y="-2"
|
|
24
|
+
>
|
|
25
|
+
<v-icon icon="mdi-bell-outline" size="20" />
|
|
26
|
+
</v-badge>
|
|
27
|
+
</v-btn>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<v-card :width="440" elevation="0" class="notif-panel">
|
|
31
|
+
<div class="notif-panel__head">Notification</div>
|
|
32
|
+
|
|
33
|
+
<div class="notif-panel__body">
|
|
34
|
+
<div v-if="loading" class="notif-panel__state">
|
|
35
|
+
<v-progress-circular indeterminate size="22" />
|
|
36
|
+
</div>
|
|
37
|
+
|
|
38
|
+
<p v-else-if="error" class="notif-panel__state text-error">
|
|
39
|
+
Notifications could not be loaded.
|
|
40
|
+
</p>
|
|
41
|
+
|
|
42
|
+
<p v-else-if="!items.length" class="notif-panel__state">
|
|
43
|
+
You have no notifications.
|
|
44
|
+
</p>
|
|
45
|
+
|
|
46
|
+
<template v-else>
|
|
47
|
+
<button
|
|
48
|
+
v-for="item in items"
|
|
49
|
+
:key="item._id"
|
|
50
|
+
type="button"
|
|
51
|
+
class="notif-card"
|
|
52
|
+
:class="{ 'notif-card--unread': !item.hasRead }"
|
|
53
|
+
@click="openNotification(item)"
|
|
54
|
+
>
|
|
55
|
+
<div class="notif-card__top">
|
|
56
|
+
<span class="notif-card__title" :class="titleClass(item)">
|
|
57
|
+
{{ item.title }}
|
|
58
|
+
</span>
|
|
59
|
+
<span class="notif-card__age">{{ relativeAge(item.createdAt) }}</span>
|
|
60
|
+
</div>
|
|
61
|
+
|
|
62
|
+
<div class="notif-card__bottom">
|
|
63
|
+
<v-icon size="18" class="notif-card__icon">
|
|
64
|
+
mdi-file-document-outline
|
|
65
|
+
</v-icon>
|
|
66
|
+
<span class="notif-card__body">{{ item.body }}</span>
|
|
67
|
+
<span
|
|
68
|
+
class="notif-card__dot"
|
|
69
|
+
:class="{ 'notif-card__dot--read': item.hasRead }"
|
|
70
|
+
/>
|
|
71
|
+
</div>
|
|
72
|
+
</button>
|
|
73
|
+
</template>
|
|
74
|
+
</div>
|
|
75
|
+
</v-card>
|
|
76
|
+
</v-menu>
|
|
77
|
+
</template>
|
|
78
|
+
|
|
79
|
+
<script setup lang="ts">
|
|
80
|
+
/**
|
|
81
|
+
* The top-bar notification feed for the web.
|
|
82
|
+
*
|
|
83
|
+
* Opt-in from `Layout/Header.vue` rather than always on: the header is shared by
|
|
84
|
+
* every app in the estate, and only the ones whose modules actually raise a
|
|
85
|
+
* notification should grow a bell that is permanently empty.
|
|
86
|
+
*/
|
|
87
|
+
const PAGE_SIZE = 10;
|
|
88
|
+
|
|
89
|
+
const props = defineProps({
|
|
90
|
+
/** Scopes the feed to one site. Empty shows everything addressed to the user. */
|
|
91
|
+
siteId: {
|
|
92
|
+
type: String,
|
|
93
|
+
default: "",
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const { getAll, getUnreadCount, markAsRead } = useNotification();
|
|
98
|
+
const { currentUser } = useLocalAuth();
|
|
99
|
+
|
|
100
|
+
const open = ref(false);
|
|
101
|
+
const loading = ref(false);
|
|
102
|
+
const error = ref(false);
|
|
103
|
+
const items = ref<Array<Record<string, any>>>([]);
|
|
104
|
+
const unread = ref(0);
|
|
105
|
+
|
|
106
|
+
const userId = computed(() => String(currentUser.value?._id ?? ""));
|
|
107
|
+
|
|
108
|
+
/** Three digits of badge is a smudge; past 99 the exact number changes nothing. */
|
|
109
|
+
const badgeLabel = computed(() => (unread.value > 99 ? "99+" : String(unread.value)));
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Red for a document that has already lapsed, amber for one approaching it.
|
|
113
|
+
*
|
|
114
|
+
* Matched on the title because the stored feed row carries no structured stage:
|
|
115
|
+
* `send()` persists title, body, module, screen and params, and drops the rest
|
|
116
|
+
* of its `data`. The two titles come from one tested function in
|
|
117
|
+
* `document-expiry-reminder.util.ts`, and "expiring" does not contain
|
|
118
|
+
* "expired", so the test is narrower than it looks.
|
|
119
|
+
*/
|
|
120
|
+
function titleClass(item: Record<string, any>) {
|
|
121
|
+
return /expired/i.test(String(item?.title ?? ""))
|
|
122
|
+
? "notif-card__title--urgent"
|
|
123
|
+
: "notif-card__title--warn";
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/** "24 mins ago", the form the design prints. */
|
|
127
|
+
function relativeAge(value?: string | Date | null) {
|
|
128
|
+
if (!value) return "";
|
|
129
|
+
|
|
130
|
+
const then = new Date(value).getTime();
|
|
131
|
+
if (Number.isNaN(then)) return "";
|
|
132
|
+
|
|
133
|
+
const seconds = Math.max(0, Math.floor((Date.now() - then) / 1000));
|
|
134
|
+
if (seconds < 60) return "just now";
|
|
135
|
+
|
|
136
|
+
const minutes = Math.floor(seconds / 60);
|
|
137
|
+
if (minutes < 60) return `${minutes} min${minutes === 1 ? "" : "s"} ago`;
|
|
138
|
+
|
|
139
|
+
const hours = Math.floor(minutes / 60);
|
|
140
|
+
if (hours < 24) return `${hours} hour${hours === 1 ? "" : "s"} ago`;
|
|
141
|
+
|
|
142
|
+
const days = Math.floor(hours / 24);
|
|
143
|
+
return `${days} day${days === 1 ? "" : "s"} ago`;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/** Tolerates the reply being paginated, wrapped once, or a bare array. */
|
|
147
|
+
function readRows(response: any): Array<Record<string, any>> {
|
|
148
|
+
const payload = response?.data ?? response;
|
|
149
|
+
const rows = payload?.items ?? payload?.data ?? payload;
|
|
150
|
+
return Array.isArray(rows) ? rows : [];
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function readCount(response: any): number {
|
|
154
|
+
const payload = response?.data ?? response;
|
|
155
|
+
const value = payload?.unread ?? payload?.count ?? payload;
|
|
156
|
+
return Number.isFinite(Number(value)) ? Number(value) : 0;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async function refreshUnread() {
|
|
160
|
+
if (!userId.value) return;
|
|
161
|
+
|
|
162
|
+
try {
|
|
163
|
+
unread.value = readCount(await getUnreadCount(userId.value));
|
|
164
|
+
} catch {
|
|
165
|
+
// A badge that cannot be counted is not worth an error in the top bar of
|
|
166
|
+
// every screen; the panel itself reports a failure when it is opened.
|
|
167
|
+
unread.value = 0;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
async function refreshList() {
|
|
172
|
+
if (!userId.value) return;
|
|
173
|
+
|
|
174
|
+
loading.value = true;
|
|
175
|
+
error.value = false;
|
|
176
|
+
|
|
177
|
+
try {
|
|
178
|
+
items.value = readRows(
|
|
179
|
+
await getAll({
|
|
180
|
+
page: 1,
|
|
181
|
+
limit: PAGE_SIZE,
|
|
182
|
+
siteId: props.siteId,
|
|
183
|
+
user: userId.value,
|
|
184
|
+
}),
|
|
185
|
+
);
|
|
186
|
+
} catch {
|
|
187
|
+
error.value = true;
|
|
188
|
+
items.value = [];
|
|
189
|
+
} finally {
|
|
190
|
+
loading.value = false;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
async function openNotification(item: Record<string, any>) {
|
|
195
|
+
if (item.hasRead) return;
|
|
196
|
+
|
|
197
|
+
// Marked locally first. The count and the dot are the whole feedback for the
|
|
198
|
+
// click, and waiting on a round trip to move them reads as a dead control.
|
|
199
|
+
item.hasRead = true;
|
|
200
|
+
unread.value = Math.max(0, unread.value - 1);
|
|
201
|
+
|
|
202
|
+
try {
|
|
203
|
+
await markAsRead(String(item._id), userId.value);
|
|
204
|
+
} catch {
|
|
205
|
+
item.hasRead = false;
|
|
206
|
+
await refreshUnread();
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Fetched when the panel is opened rather than on a timer: a poll in a shared
|
|
211
|
+
// header would run on every screen of every app that mounts it.
|
|
212
|
+
watch(open, (isOpen) => {
|
|
213
|
+
if (isOpen) {
|
|
214
|
+
refreshList();
|
|
215
|
+
refreshUnread();
|
|
216
|
+
}
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
onMounted(refreshUnread);
|
|
220
|
+
</script>
|
|
221
|
+
|
|
222
|
+
<style scoped>
|
|
223
|
+
.notif-panel {
|
|
224
|
+
border-radius: var(--r-menu);
|
|
225
|
+
background: var(--card);
|
|
226
|
+
overflow: hidden;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
.notif-panel__head {
|
|
230
|
+
padding: 14px 16px;
|
|
231
|
+
font-weight: 600;
|
|
232
|
+
border-bottom: 1px solid var(--border);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.notif-panel__body {
|
|
236
|
+
max-height: 420px;
|
|
237
|
+
overflow-y: auto;
|
|
238
|
+
padding: 12px;
|
|
239
|
+
display: flex;
|
|
240
|
+
flex-direction: column;
|
|
241
|
+
gap: 10px;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.notif-panel__state {
|
|
245
|
+
padding: 24px 8px;
|
|
246
|
+
text-align: center;
|
|
247
|
+
color: var(--muted);
|
|
248
|
+
margin: 0;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.notif-card {
|
|
252
|
+
width: 100%;
|
|
253
|
+
text-align: left;
|
|
254
|
+
padding: 12px 14px;
|
|
255
|
+
border: 1px solid var(--border);
|
|
256
|
+
border-radius: var(--r-inner);
|
|
257
|
+
background: transparent;
|
|
258
|
+
cursor: pointer;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.notif-card:hover {
|
|
262
|
+
background: var(--hover);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.notif-card__top {
|
|
266
|
+
display: flex;
|
|
267
|
+
align-items: baseline;
|
|
268
|
+
justify-content: space-between;
|
|
269
|
+
gap: 12px;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
.notif-card__title {
|
|
273
|
+
font-size: var(--fs-cell);
|
|
274
|
+
font-weight: 500;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
.notif-card__title--warn {
|
|
278
|
+
color: var(--warn);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.notif-card__title--urgent {
|
|
282
|
+
color: var(--err);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.notif-card__age {
|
|
286
|
+
flex: 0 0 auto;
|
|
287
|
+
font-size: 12px;
|
|
288
|
+
color: var(--muted);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.notif-card__bottom {
|
|
292
|
+
display: flex;
|
|
293
|
+
align-items: center;
|
|
294
|
+
gap: 8px;
|
|
295
|
+
margin-top: 6px;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
.notif-card__icon {
|
|
299
|
+
flex: 0 0 auto;
|
|
300
|
+
color: var(--text);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.notif-card__body {
|
|
304
|
+
flex: 1 1 auto;
|
|
305
|
+
font-size: var(--fs-cell);
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/* Filled while unread, hollow grey once read - the design's two states. */
|
|
309
|
+
.notif-card__dot {
|
|
310
|
+
flex: 0 0 auto;
|
|
311
|
+
width: 10px;
|
|
312
|
+
height: 10px;
|
|
313
|
+
border-radius: 50%;
|
|
314
|
+
background: var(--info);
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
.notif-card__dot--read {
|
|
318
|
+
background: var(--muted);
|
|
319
|
+
opacity: 0.45;
|
|
320
|
+
}
|
|
321
|
+
</style>
|
|
@@ -742,11 +742,35 @@
|
|
|
742
742
|
class="visitor-preview__row"
|
|
743
743
|
>
|
|
744
744
|
<div class="visitor-preview__label">{{ label }}</div>
|
|
745
|
-
<div
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
745
|
+
<div>
|
|
746
|
+
<!-- Was a hover tooltip on the value: the full NRIC only
|
|
747
|
+
reachable by hovering, which says nothing is there to
|
|
748
|
+
reach and cannot be reached at all on a touch screen.
|
|
749
|
+
The eye alone, at the 14px the Incident Report screens
|
|
750
|
+
draw it, is a 14px target - the floor is 24px. So the
|
|
751
|
+
NUMBER is the control and the eye is its affordance:
|
|
752
|
+
the whole masked value is pressable, which makes the
|
|
753
|
+
target the width of the digits rather than of a glyph,
|
|
754
|
+
and being a real `button` it also takes a tab stop,
|
|
755
|
+
which a `v-icon` with a click handler never did. -->
|
|
756
|
+
<button
|
|
757
|
+
type="button"
|
|
758
|
+
class="visitor-preview__reveal"
|
|
759
|
+
:aria-label="showVisitorNric ? 'Hide NRIC' : 'Show NRIC'"
|
|
760
|
+
:aria-pressed="showVisitorNric"
|
|
761
|
+
@click="showVisitorNric = !showVisitorNric"
|
|
762
|
+
>
|
|
763
|
+
<span class="visitor-preview__value">
|
|
764
|
+
{{
|
|
765
|
+
showVisitorNric
|
|
766
|
+
? selectedVisitorObject[key]
|
|
767
|
+
: maskNRIC(selectedVisitorObject[key])
|
|
768
|
+
}}
|
|
769
|
+
</span>
|
|
770
|
+
<v-icon size="16" class="visitor-preview__eye">
|
|
771
|
+
{{ showVisitorNric ? "mdi-eye-off-outline" : "mdi-eye-outline" }}
|
|
772
|
+
</v-icon>
|
|
773
|
+
</button>
|
|
750
774
|
</div>
|
|
751
775
|
</div>
|
|
752
776
|
|
|
@@ -796,6 +820,84 @@
|
|
|
796
820
|
</div>
|
|
797
821
|
</div>
|
|
798
822
|
|
|
823
|
+
<!--
|
|
824
|
+
THE CONTRACTOR'S PARTY.
|
|
825
|
+
|
|
826
|
+
The list row has always said `( +2 members)` beside the name
|
|
827
|
+
and then had nowhere to send you for the names themselves. The
|
|
828
|
+
block spans both columns rather than sitting in the 116px
|
|
829
|
+
value track: a member is a record, not a value, and several of
|
|
830
|
+
them in a 250px column is unreadable.
|
|
831
|
+
|
|
832
|
+
Read off `selectedVisitorDataObject` (the raw row) and not
|
|
833
|
+
`selectedVisitorObject`, which filters itself down to
|
|
834
|
+
`typeFieldMap` plus five fixed keys - `members` is on neither
|
|
835
|
+
list, and widening that computed would change what four other
|
|
836
|
+
dialogs on this screen see.
|
|
837
|
+
-->
|
|
838
|
+
<div
|
|
839
|
+
v-else-if="key === 'members' && selectedVisitorMembers.length"
|
|
840
|
+
class="visitor-preview__row visitor-preview__row--block"
|
|
841
|
+
>
|
|
842
|
+
<div class="visitor-preview__label">
|
|
843
|
+
{{ label }} ({{ selectedVisitorMembers.length }})
|
|
844
|
+
</div>
|
|
845
|
+
<div class="visitor-preview__members">
|
|
846
|
+
<div
|
|
847
|
+
v-for="(member, index) in selectedVisitorMembers"
|
|
848
|
+
:key="member?.nric || member?.name || index"
|
|
849
|
+
class="visitor-preview__member"
|
|
850
|
+
>
|
|
851
|
+
<div class="visitor-preview__value">
|
|
852
|
+
{{ member?.name || "N/A" }}
|
|
853
|
+
</div>
|
|
854
|
+
<template v-for="field in memberDetailFields" :key="field.key">
|
|
855
|
+
<div
|
|
856
|
+
v-if="member?.[field.key]"
|
|
857
|
+
class="visitor-preview__member-line"
|
|
858
|
+
>
|
|
859
|
+
<span class="visitor-preview__member-key">
|
|
860
|
+
{{ field.label }}
|
|
861
|
+
</span>
|
|
862
|
+
<!-- A member's NRIC is the same class of data as the
|
|
863
|
+
visitor's, so it gets the same control. Each
|
|
864
|
+
member reveals separately - one toggle for the
|
|
865
|
+
whole card would show three people's NRICs to
|
|
866
|
+
read one. -->
|
|
867
|
+
<button
|
|
868
|
+
v-if="field.key === 'nric'"
|
|
869
|
+
type="button"
|
|
870
|
+
class="visitor-preview__reveal"
|
|
871
|
+
:aria-label="
|
|
872
|
+
isMemberNricShown(index)
|
|
873
|
+
? `Hide NRIC for ${member?.name || 'this member'}`
|
|
874
|
+
: `Show NRIC for ${member?.name || 'this member'}`
|
|
875
|
+
"
|
|
876
|
+
:aria-pressed="isMemberNricShown(index)"
|
|
877
|
+
@click="toggleMemberNric(index)"
|
|
878
|
+
>
|
|
879
|
+
<span>
|
|
880
|
+
{{
|
|
881
|
+
isMemberNricShown(index)
|
|
882
|
+
? member.nric
|
|
883
|
+
: maskNRIC(member.nric)
|
|
884
|
+
}}
|
|
885
|
+
</span>
|
|
886
|
+
<v-icon size="16" class="visitor-preview__eye">
|
|
887
|
+
{{
|
|
888
|
+
isMemberNricShown(index)
|
|
889
|
+
? "mdi-eye-off-outline"
|
|
890
|
+
: "mdi-eye-outline"
|
|
891
|
+
}}
|
|
892
|
+
</v-icon>
|
|
893
|
+
</button>
|
|
894
|
+
<span v-else>{{ member[field.key] }}</span>
|
|
895
|
+
</div>
|
|
896
|
+
</template>
|
|
897
|
+
</div>
|
|
898
|
+
</div>
|
|
899
|
+
</div>
|
|
900
|
+
|
|
799
901
|
<div
|
|
800
902
|
v-else-if="selectedVisitorObject[key]"
|
|
801
903
|
class="visitor-preview__row"
|
|
@@ -1898,6 +2000,71 @@ const isSelectedVisitorPendingApproval = computed(
|
|
|
1898
2000
|
() => selectedVisitorStatus.value === "pending"
|
|
1899
2001
|
);
|
|
1900
2002
|
|
|
2003
|
+
/**
|
|
2004
|
+
* The members a contractor brought with them. Not gated on the Guests tab: the
|
|
2005
|
+
* list row's own `( +N members)` count is not either, and a contractor with a
|
|
2006
|
+
* party has one wherever the screen shows it.
|
|
2007
|
+
*
|
|
2008
|
+
* Blank entries are dropped rather than drawn as an empty card - the payload
|
|
2009
|
+
* carries `""` for every detail nobody filled in, so a member with no name and
|
|
2010
|
+
* no details would otherwise render as a bare inset box.
|
|
2011
|
+
*/
|
|
2012
|
+
const selectedVisitorMembers = computed<Record<string, any>[]>(() => {
|
|
2013
|
+
const members = selectedVisitorDataObject.value?.members;
|
|
2014
|
+
if (!Array.isArray(members)) return [];
|
|
2015
|
+
|
|
2016
|
+
return members.filter(
|
|
2017
|
+
(member: Record<string, any>) =>
|
|
2018
|
+
member?.name || member?.nric || member?.contact || member?.plateNumber
|
|
2019
|
+
);
|
|
2020
|
+
});
|
|
2021
|
+
|
|
2022
|
+
/**
|
|
2023
|
+
* WHICH NRICs ARE UNCOVERED RIGHT NOW.
|
|
2024
|
+
*
|
|
2025
|
+
* Per member and not per card, so revealing one person's number does not
|
|
2026
|
+
* uncover the rest of the party's. Both are cleared when the dialog closes -
|
|
2027
|
+
* a preview must not open on the next visitor with the last one's NRIC
|
|
2028
|
+
* already showing, and it is the same `selectedVisitorId` that would carry it
|
|
2029
|
+
* across if the same row were reopened.
|
|
2030
|
+
*/
|
|
2031
|
+
const showVisitorNric = ref(false);
|
|
2032
|
+
const shownMemberNrics = ref<number[]>([]);
|
|
2033
|
+
|
|
2034
|
+
function isMemberNricShown(index: number) {
|
|
2035
|
+
return shownMemberNrics.value.includes(index);
|
|
2036
|
+
}
|
|
2037
|
+
|
|
2038
|
+
function toggleMemberNric(index: number) {
|
|
2039
|
+
shownMemberNrics.value = isMemberNricShown(index)
|
|
2040
|
+
? shownMemberNrics.value.filter((x) => x !== index)
|
|
2041
|
+
: [...shownMemberNrics.value, index];
|
|
2042
|
+
}
|
|
2043
|
+
|
|
2044
|
+
watch(
|
|
2045
|
+
() => dialog.viewVisitor,
|
|
2046
|
+
(open) => {
|
|
2047
|
+
if (open) return;
|
|
2048
|
+
showVisitorNric.value = false;
|
|
2049
|
+
shownMemberNrics.value = [];
|
|
2050
|
+
}
|
|
2051
|
+
);
|
|
2052
|
+
|
|
2053
|
+
/**
|
|
2054
|
+
* What a member row prints under the name, in order. `plateNumber` is in here
|
|
2055
|
+
* because the API returns it on `members[]` even though neither
|
|
2056
|
+
* `TMemberInfo` (this package) nor `TContractorMembers` (API-core's visitor
|
|
2057
|
+
* model, name and nric only) declares it - the two types have drifted from the
|
|
2058
|
+
* document and from each other. Reading the key defensively costs nothing and
|
|
2059
|
+
* shows the vehicle a member actually arrived in; the types are somebody's to
|
|
2060
|
+
* reconcile separately.
|
|
2061
|
+
*/
|
|
2062
|
+
const memberDetailFields = [
|
|
2063
|
+
{ key: "nric", label: "NRIC" },
|
|
2064
|
+
{ key: "contact", label: "Contact" },
|
|
2065
|
+
{ key: "plateNumber", label: "Vehicle" },
|
|
2066
|
+
] as const;
|
|
2067
|
+
|
|
1901
2068
|
const formatType = (item: any) =>
|
|
1902
2069
|
(item.deliveryType ? item.deliveryType + "-" : "") + item.type;
|
|
1903
2070
|
|
|
@@ -1911,6 +2078,7 @@ const formattedFields = {
|
|
|
1911
2078
|
level: "Level",
|
|
1912
2079
|
unit: "Unit",
|
|
1913
2080
|
purpose: "Purpose",
|
|
2081
|
+
members: "Members",
|
|
1914
2082
|
checkIn: "Check In",
|
|
1915
2083
|
snapshotEntryImage: "Entry Image",
|
|
1916
2084
|
checkOut: "Check Out",
|
|
@@ -2889,6 +3057,100 @@ watchEffect(async () => {
|
|
|
2889
3057
|
word-break: break-word;
|
|
2890
3058
|
}
|
|
2891
3059
|
|
|
3060
|
+
/* A row whose value is a set of records rather than a value - it drops the
|
|
3061
|
+
two-column grid and runs the full width of the card body. */
|
|
3062
|
+
.visitor-preview__row--block {
|
|
3063
|
+
display: block;
|
|
3064
|
+
}
|
|
3065
|
+
|
|
3066
|
+
.visitor-preview__members {
|
|
3067
|
+
display: flex;
|
|
3068
|
+
flex-direction: column;
|
|
3069
|
+
gap: 8px;
|
|
3070
|
+
margin-top: 8px;
|
|
3071
|
+
}
|
|
3072
|
+
|
|
3073
|
+
/*
|
|
3074
|
+
* An added member reads as an inset on the card it sits in - `--hover` on
|
|
3075
|
+
* `--border` at the inner radius. Those are `Card/MemberInfoSummary`'s three
|
|
3076
|
+
* decisions, unchanged, so a member looks the same in the preview as it does
|
|
3077
|
+
* in the form that created it. Only the TYPE differs: that card still prints
|
|
3078
|
+
* `<strong>Label:</strong> value`, which is the pattern this dialog just moved
|
|
3079
|
+
* off, so the lines below are set on the scale rather than inherited.
|
|
3080
|
+
*/
|
|
3081
|
+
.visitor-preview__member {
|
|
3082
|
+
padding: 9px 12px;
|
|
3083
|
+
border: 1px solid var(--border);
|
|
3084
|
+
border-radius: var(--r-inner);
|
|
3085
|
+
background: var(--hover);
|
|
3086
|
+
}
|
|
3087
|
+
|
|
3088
|
+
.visitor-preview__member-line {
|
|
3089
|
+
display: flex;
|
|
3090
|
+
gap: 8px;
|
|
3091
|
+
margin-top: 3px;
|
|
3092
|
+
font-size: var(--fs-breadcrumb);
|
|
3093
|
+
color: var(--text2);
|
|
3094
|
+
word-break: break-word;
|
|
3095
|
+
}
|
|
3096
|
+
|
|
3097
|
+
.visitor-preview__member-key {
|
|
3098
|
+
flex: 0 0 52px;
|
|
3099
|
+
color: var(--muted);
|
|
3100
|
+
}
|
|
3101
|
+
|
|
3102
|
+
/*
|
|
3103
|
+
* THE NRIC REVEAL.
|
|
3104
|
+
*
|
|
3105
|
+
* The pressable thing is the masked number, not the glyph beside it: an eye on
|
|
3106
|
+
* its own is a 14-16px target where 24px is the floor, and on a 12.5px member
|
|
3107
|
+
* line an `AppButton variant="icon"` - the layer's 32px icon square - would
|
|
3108
|
+
* make the NRIC line half again the height of the Contact line under it.
|
|
3109
|
+
* Pressing the digits gives a target the width of the value at no cost to the
|
|
3110
|
+
* rhythm, and reads the right way round: the number is what changes.
|
|
3111
|
+
*
|
|
3112
|
+
* It inherits its type rather than setting any, so the visitor's NRIC stays on
|
|
3113
|
+
* `--fs-cell` and a member's on the `--fs-breadcrumb` of the line it sits in.
|
|
3114
|
+
* The negative margin pays back the padding, so a revealed value starts on the
|
|
3115
|
+
* same left edge as every other value in the card.
|
|
3116
|
+
*/
|
|
3117
|
+
.visitor-preview__reveal {
|
|
3118
|
+
display: inline-flex;
|
|
3119
|
+
align-items: center;
|
|
3120
|
+
gap: 6px;
|
|
3121
|
+
margin: -3px -7px;
|
|
3122
|
+
padding: 3px 7px;
|
|
3123
|
+
border: none;
|
|
3124
|
+
border-radius: var(--r-inner-sm);
|
|
3125
|
+
background: transparent;
|
|
3126
|
+
font: inherit;
|
|
3127
|
+
color: inherit;
|
|
3128
|
+
text-align: left;
|
|
3129
|
+
cursor: pointer;
|
|
3130
|
+
transition: background var(--motion) ease;
|
|
3131
|
+
}
|
|
3132
|
+
|
|
3133
|
+
.visitor-preview__reveal:hover {
|
|
3134
|
+
background: var(--hover);
|
|
3135
|
+
}
|
|
3136
|
+
|
|
3137
|
+
.visitor-preview__reveal:focus-visible {
|
|
3138
|
+
outline: 2px solid var(--accent);
|
|
3139
|
+
outline-offset: 1px;
|
|
3140
|
+
}
|
|
3141
|
+
|
|
3142
|
+
/* The design's interactive ink - not Vuetify's fixed blue, which is one colour
|
|
3143
|
+
on both themes. `affectedEntities` gives its NRIC eye the same value. */
|
|
3144
|
+
.visitor-preview__eye {
|
|
3145
|
+
color: var(--accent-text);
|
|
3146
|
+
}
|
|
3147
|
+
|
|
3148
|
+
@media (prefers-reduced-motion: reduce) {
|
|
3149
|
+
.visitor-preview__reveal {
|
|
3150
|
+
transition: none;
|
|
3151
|
+
}
|
|
3152
|
+
}
|
|
3153
|
+
|
|
2892
3154
|
/* The width the type filter carried as `max-width="200"` on the v-select. */
|
|
2893
3155
|
.visitor-type-filter {
|
|
2894
3156
|
max-width: 200px;
|