@7365admin1/layer-common 4.28.0 → 4.28.1-staging.357
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 -16
- package/components/AccessCardAddForm.vue +5 -4
- package/components/AccessCardAssignToUnitForm.vue +3 -2
- package/components/AccessCardPreviewDialog.vue +4 -3
- package/components/Dialog/UpdateMoreAction.vue +11 -1
- 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/HidAccessLogDashboard.vue +29 -5
- package/components/HidAccessPermissions.vue +424 -0
- package/components/HidIntercomManagement.vue +148 -14
- package/components/HidProfileQrCode.vue +323 -0
- package/components/HidReaderManagement.vue +26 -0
- package/components/HidReaderUserRoster.vue +32 -2
- package/components/HidUserEnrollment.vue +833 -152
- package/components/InvitationClientForm.vue +19 -1
- package/components/NotificationBell.vue +39 -3
- package/components/RolePermissionFormCreate.vue +163 -19
- package/components/RolePermissionFormPreviewUpdate.vue +230 -19
- package/components/RolePermissionMain.vue +19 -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 +117 -0
- package/composables/useHidNavigation.ts +25 -1
- package/composables/usePeople.ts +19 -0
- package/composables/useSiteCategory.ts +45 -0
- package/composables/useSiteEntryPassSettings.ts +26 -0
- 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 +28 -1
- package/utils/hid-permission-assignments.ts +190 -0
- package/utils/notification-target.ts +75 -0
- package/utils/occupancy-role.ts +109 -0
- package/utils/permission-labels.ts +30 -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
|
|
|
@@ -134,6 +134,7 @@ import {
|
|
|
134
134
|
timeAgo,
|
|
135
135
|
type TInboxItem,
|
|
136
136
|
} from "../utils/notification-inbox";
|
|
137
|
+
import { notificationTarget } from "../utils/notification-target";
|
|
137
138
|
|
|
138
139
|
/**
|
|
139
140
|
* The top-bar notification feed for the web, in every signed-in app.
|
|
@@ -165,6 +166,8 @@ defineProps({
|
|
|
165
166
|
|
|
166
167
|
const { getAll, getUnreadCount, markAsRead, markAllAsRead } = useNotification();
|
|
167
168
|
const { currentUser } = useLocalAuth();
|
|
169
|
+
const route = useRoute();
|
|
170
|
+
const router = useRouter();
|
|
168
171
|
|
|
169
172
|
const open = ref(false);
|
|
170
173
|
const loading = ref(false);
|
|
@@ -269,16 +272,49 @@ function announce(fresh: TInboxItem[]) {
|
|
|
269
272
|
}
|
|
270
273
|
}
|
|
271
274
|
|
|
275
|
+
/**
|
|
276
|
+
* Clicking a row does two separate things, and the second one is why the row is
|
|
277
|
+
* a button at all: mark it read, and go to what it is about.
|
|
278
|
+
*
|
|
279
|
+
* They are kept apart deliberately. Marking read is best-effort and reverts on
|
|
280
|
+
* failure; navigation must not wait on that round trip, and must still happen
|
|
281
|
+
* for a row that was ALREADY read — a person re-opening the bell to find the
|
|
282
|
+
* order they were told about is the ordinary case, and the old early-return on
|
|
283
|
+
* `hasRead` would have sent them nowhere.
|
|
284
|
+
*/
|
|
272
285
|
async function openNotification(item: Record<string, any>) {
|
|
286
|
+
markRead(item);
|
|
287
|
+
await goToSubject(item);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function markRead(item: Record<string, any>) {
|
|
273
291
|
if (item.hasRead) return;
|
|
274
292
|
// Marked locally first: waiting on a round trip to move the dot reads as a dead control.
|
|
275
293
|
item.hasRead = true;
|
|
276
294
|
unread.value = Math.max(0, unread.value - 1);
|
|
277
|
-
|
|
278
|
-
await markAsRead(String(item._id), userId.value);
|
|
279
|
-
} catch {
|
|
295
|
+
markAsRead(String(item._id), userId.value).catch(() => {
|
|
280
296
|
item.hasRead = false;
|
|
281
297
|
unread.value += 1;
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
/**
|
|
302
|
+
* `hasRoute` is the whole reason an org-app route name may live in the shared
|
|
303
|
+
* layer: the ten apps that have no order queue simply do not match it, and the
|
|
304
|
+
* click there stays what it always was.
|
|
305
|
+
*/
|
|
306
|
+
async function goToSubject(item: Record<string, any>) {
|
|
307
|
+
const target = notificationTarget(item as any, {
|
|
308
|
+
organization: String(route.params?.organization ?? ""),
|
|
309
|
+
});
|
|
310
|
+
if (!target) return;
|
|
311
|
+
if (typeof router.hasRoute !== "function" || !router.hasRoute(target.name)) return;
|
|
312
|
+
|
|
313
|
+
open.value = false;
|
|
314
|
+
try {
|
|
315
|
+
await router.push(target);
|
|
316
|
+
} catch {
|
|
317
|
+
// A cancelled or duplicate navigation is not worth an error in the top bar.
|
|
282
318
|
}
|
|
283
319
|
}
|
|
284
320
|
|
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<v-card width="100%" class="screen-modal role-create">
|
|
3
|
+
<!--
|
|
4
|
+
THE RUNNING TOTALS, the same pair the update dialog carries. The two
|
|
5
|
+
dialogs render the same tree and a client who learns one must not find the
|
|
6
|
+
other behaving differently -- and while BUILDING a role the counts matter
|
|
7
|
+
more than while reading one: they are the only way to see what has been
|
|
8
|
+
ticked without scrolling back up a 31-module list.
|
|
9
|
+
-->
|
|
3
10
|
<div class="role-create__head">
|
|
4
11
|
<v-card-title>Create Role</v-card-title>
|
|
5
|
-
<
|
|
12
|
+
<div class="role-create__head-right">
|
|
13
|
+
<span class="role-create__row-sub">Modules</span>
|
|
14
|
+
<StatusChip :dot="false" tone="neutral" :label="moduleTotalLabel" />
|
|
15
|
+
<span class="role-create__row-sub">Permissions</span>
|
|
16
|
+
<StatusChip :dot="false" tone="info" :label="totalLabel" />
|
|
17
|
+
<AppButton variant="icon" icon="mdi-close" aria-label="Close" @click="cancel" />
|
|
18
|
+
</div>
|
|
6
19
|
</div>
|
|
7
20
|
|
|
8
21
|
<div class="screen-modal__body role-create__body filter-field">
|
|
@@ -82,14 +95,27 @@
|
|
|
82
95
|
>
|
|
83
96
|
<v-divider v-if="resourceIndex > 0" />
|
|
84
97
|
|
|
85
|
-
<!--
|
|
86
|
-
|
|
98
|
+
<!--
|
|
99
|
+
Category row. The whole row is the accordion header: one
|
|
100
|
+
module is open at a time, so clicking this one closes
|
|
101
|
+
whichever was open. The switch inside stops the click, so
|
|
102
|
+
granting a module is never confused with looking at it.
|
|
103
|
+
-->
|
|
104
|
+
<v-list-item
|
|
105
|
+
density="compact"
|
|
106
|
+
:ripple="false"
|
|
107
|
+
:class="[
|
|
108
|
+
'role-create__cat',
|
|
109
|
+
{ 'role-create__cat--open': isCategoryOpen(String(resourceKey)) },
|
|
110
|
+
]"
|
|
111
|
+
@click="onCategoryRowClick(String(resourceKey))"
|
|
112
|
+
>
|
|
87
113
|
<template #prepend>
|
|
88
114
|
<StatusChip
|
|
89
115
|
class="mr-3"
|
|
90
116
|
:dot="false"
|
|
91
117
|
tone="info"
|
|
92
|
-
:label="
|
|
118
|
+
:label="moduleCountLabel(String(resourceKey))"
|
|
93
119
|
/>
|
|
94
120
|
</template>
|
|
95
121
|
<v-list-item-title>
|
|
@@ -98,25 +124,38 @@
|
|
|
98
124
|
</span>
|
|
99
125
|
</v-list-item-title>
|
|
100
126
|
<template #append>
|
|
101
|
-
<
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
127
|
+
<div class="role-create__cat-actions">
|
|
128
|
+
<v-icon
|
|
129
|
+
v-if="isCategoryEnabled(String(resourceKey))"
|
|
130
|
+
class="role-create__chevron"
|
|
131
|
+
size="small"
|
|
132
|
+
:icon="
|
|
133
|
+
isCategoryOpen(String(resourceKey))
|
|
134
|
+
? 'mdi-chevron-up'
|
|
135
|
+
: 'mdi-chevron-down'
|
|
136
|
+
"
|
|
137
|
+
/>
|
|
138
|
+
<div @click.stop>
|
|
139
|
+
<v-switch
|
|
140
|
+
:model-value="isCategoryEnabled(String(resourceKey))"
|
|
141
|
+
@update:model-value="
|
|
142
|
+
toggleCategory(String(resourceKey), $event)
|
|
143
|
+
"
|
|
144
|
+
class="app-switch"
|
|
145
|
+
density="compact"
|
|
146
|
+
hide-details
|
|
147
|
+
/>
|
|
148
|
+
</div>
|
|
149
|
+
</div>
|
|
110
150
|
</template>
|
|
111
151
|
</v-list-item>
|
|
112
152
|
|
|
113
|
-
<!-- Expanded checkboxes
|
|
114
|
-
<template v-if="
|
|
153
|
+
<!-- Expanded checkboxes for the one open module -->
|
|
154
|
+
<template v-if="isCategoryOpen(String(resourceKey))">
|
|
115
155
|
<template
|
|
116
156
|
v-for="[actionKey, action] in Object.entries(actions || {})"
|
|
117
157
|
:key="actionKey"
|
|
118
158
|
>
|
|
119
|
-
<v-divider />
|
|
120
159
|
<v-list-item density="compact" :ripple="false">
|
|
121
160
|
<template #prepend>
|
|
122
161
|
<v-checkbox-btn
|
|
@@ -175,6 +214,7 @@
|
|
|
175
214
|
import {
|
|
176
215
|
formatActionLabel,
|
|
177
216
|
formatResourceLabel,
|
|
217
|
+
sortResourcesByLabel,
|
|
178
218
|
} from "../utils/permission-labels";
|
|
179
219
|
import useRole from "../composables/useRole";
|
|
180
220
|
import useUtils from "../composables/useUtils";
|
|
@@ -230,22 +270,91 @@ function isCategoryEnabled(resource: string) {
|
|
|
230
270
|
return permState.value.enabled.includes(resource);
|
|
231
271
|
}
|
|
232
272
|
|
|
273
|
+
/*
|
|
274
|
+
* ACCORDION -- one module open at a time.
|
|
275
|
+
*
|
|
276
|
+
* `enabled` stays what it always was: the switch, i.e. what the role grants.
|
|
277
|
+
* `expandedResource` is purely what is on screen. Keeping them apart means
|
|
278
|
+
* opening a module never grants anything and closing one never takes a tick
|
|
279
|
+
* away -- with 47 modules the list was otherwise unreadable once a few were on.
|
|
280
|
+
*/
|
|
281
|
+
const expandedResource = ref<string | null>(null);
|
|
282
|
+
|
|
283
|
+
function isCategoryOpen(resource: string) {
|
|
284
|
+
return isCategoryEnabled(resource) && expandedResource.value === resource;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function onCategoryRowClick(resource: string) {
|
|
288
|
+
// A module that is off has nothing to show; its switch is the way in.
|
|
289
|
+
if (!isCategoryEnabled(resource)) return;
|
|
290
|
+
expandedResource.value =
|
|
291
|
+
expandedResource.value === resource ? null : resource;
|
|
292
|
+
}
|
|
293
|
+
|
|
233
294
|
function selectedActionCount(resource: string) {
|
|
234
295
|
return permState.value.selected.filter((p) => p.startsWith(`${resource}:`))
|
|
235
296
|
.length;
|
|
236
297
|
}
|
|
237
298
|
|
|
299
|
+
/*
|
|
300
|
+
* THE HEADER TOTALS.
|
|
301
|
+
*
|
|
302
|
+
* Both denominators come from the WHOLE offered catalogue, never from
|
|
303
|
+
* `visiblePermissions` -- a search must not make the role look smaller than it
|
|
304
|
+
* is by shrinking the number it is measured against.
|
|
305
|
+
*/
|
|
306
|
+
const catalogueSize = computed(() =>
|
|
307
|
+
Object.values(safePermissions.value).reduce(
|
|
308
|
+
(total: number, actions: any) => total + Object.keys(actions ?? {}).length,
|
|
309
|
+
0
|
|
310
|
+
)
|
|
311
|
+
);
|
|
312
|
+
|
|
313
|
+
const totalLabel = computed(() => {
|
|
314
|
+
const selected = permState.value.selected.length;
|
|
315
|
+
return catalogueSize.value > 0
|
|
316
|
+
? `${selected} / ${catalogueSize.value}`
|
|
317
|
+
: String(selected);
|
|
318
|
+
});
|
|
319
|
+
|
|
320
|
+
/** How many modules the role being built reaches, out of those offered. */
|
|
321
|
+
const moduleTotalLabel = computed(() => {
|
|
322
|
+
const resources = Object.keys(safePermissions.value);
|
|
323
|
+
const reached = resources.filter(
|
|
324
|
+
(resource) => selectedActionCount(resource) > 0
|
|
325
|
+
).length;
|
|
326
|
+
return resources.length > 0
|
|
327
|
+
? `${reached} / ${resources.length}`
|
|
328
|
+
: String(reached);
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* The module chip: `ticked / offered`.
|
|
333
|
+
*
|
|
334
|
+
* The same shape the update dialog shows while editing. The two dialogs render
|
|
335
|
+
* the same tree and a client who learns one must not find the other behaving
|
|
336
|
+
* differently.
|
|
337
|
+
*/
|
|
338
|
+
function moduleCountLabel(resource: string) {
|
|
339
|
+
const offered = Object.keys(visiblePermissions.value?.[resource] ?? {}).length;
|
|
340
|
+
const selected = selectedActionCount(resource);
|
|
341
|
+
return offered > 0 ? `${selected} / ${offered}` : String(selected);
|
|
342
|
+
}
|
|
343
|
+
|
|
238
344
|
function toggleCategory(resource: string, value: boolean | null) {
|
|
239
345
|
const { selected, enabled } = permState.value;
|
|
240
346
|
if (value) {
|
|
241
347
|
if (!enabled.includes(resource)) {
|
|
242
348
|
permState.value = { selected, enabled: [...enabled, resource] };
|
|
243
349
|
}
|
|
350
|
+
// Switching a module on opens it, which closes whichever was open.
|
|
351
|
+
expandedResource.value = resource;
|
|
244
352
|
} else {
|
|
245
353
|
permState.value = {
|
|
246
354
|
selected: selected.filter((p) => !p.startsWith(`${resource}:`)),
|
|
247
355
|
enabled: enabled.filter((r) => r !== resource),
|
|
248
356
|
};
|
|
357
|
+
if (expandedResource.value === resource) expandedResource.value = null;
|
|
249
358
|
}
|
|
250
359
|
}
|
|
251
360
|
|
|
@@ -293,6 +402,12 @@ function toggleSelectAll(value: boolean) {
|
|
|
293
402
|
selected: selected.filter((key) => !visibleKeys.includes(key)),
|
|
294
403
|
enabled: enabled.filter((resource) => !visibleResources.includes(resource)),
|
|
295
404
|
};
|
|
405
|
+
if (
|
|
406
|
+
expandedResource.value &&
|
|
407
|
+
visibleResources.includes(expandedResource.value)
|
|
408
|
+
) {
|
|
409
|
+
expandedResource.value = null;
|
|
410
|
+
}
|
|
296
411
|
return;
|
|
297
412
|
}
|
|
298
413
|
|
|
@@ -352,6 +467,7 @@ async function submit() {
|
|
|
352
467
|
function cancel() {
|
|
353
468
|
name.value = "";
|
|
354
469
|
permState.value = { selected: [], enabled: [] };
|
|
470
|
+
expandedResource.value = null;
|
|
355
471
|
// A query left behind would greet the next person with a filtered list and
|
|
356
472
|
// no obvious reason for it.
|
|
357
473
|
moduleSearch.value = "";
|
|
@@ -377,12 +493,18 @@ function cancel() {
|
|
|
377
493
|
* view is still ticked and still saved — losing a tick because somebody typed in
|
|
378
494
|
* a box would be far worse than the scrolling this replaces.
|
|
379
495
|
*/
|
|
380
|
-
|
|
496
|
+
/*
|
|
497
|
+
* `clearable` writes NULL, not "". The query below used to call `.trim()` on
|
|
498
|
+
* it, which threw inside the computed the moment the X was pressed: the render
|
|
499
|
+
* aborted, the list stayed on the last filtered result, and the button looked
|
|
500
|
+
* dead. The ref admits null and the read below absorbs it.
|
|
501
|
+
*/
|
|
502
|
+
const moduleSearch = ref<string | null>("");
|
|
381
503
|
|
|
382
504
|
/** `safePermissions`, narrowed to what the search box matches. */
|
|
383
505
|
const visiblePermissions = computed(() => {
|
|
384
|
-
const query = moduleSearch.value.trim().toLowerCase();
|
|
385
|
-
const all = safePermissions.value;
|
|
506
|
+
const query = (moduleSearch.value ?? "").trim().toLowerCase();
|
|
507
|
+
const all = sortResourcesByLabel(safePermissions.value);
|
|
386
508
|
if (!query) return all;
|
|
387
509
|
|
|
388
510
|
const matches: Record<string, any> = {};
|
|
@@ -449,6 +571,14 @@ const isAllSelected = computed(() => {
|
|
|
449
571
|
padding-right: 12px;
|
|
450
572
|
}
|
|
451
573
|
|
|
574
|
+
.role-create__head-right {
|
|
575
|
+
display: flex;
|
|
576
|
+
align-items: center;
|
|
577
|
+
gap: 6px;
|
|
578
|
+
white-space: nowrap;
|
|
579
|
+
flex: 0 0 auto;
|
|
580
|
+
}
|
|
581
|
+
|
|
452
582
|
.role-create__body {
|
|
453
583
|
padding: 0 20px;
|
|
454
584
|
max-height: calc(100vh - 160px);
|
|
@@ -463,6 +593,20 @@ const isAllSelected = computed(() => {
|
|
|
463
593
|
overflow: hidden;
|
|
464
594
|
}
|
|
465
595
|
|
|
596
|
+
.role-create__cat {
|
|
597
|
+
cursor: pointer;
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
.role-create__cat-actions {
|
|
601
|
+
display: flex;
|
|
602
|
+
align-items: center;
|
|
603
|
+
gap: 4px;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
.role-create__chevron {
|
|
607
|
+
color: var(--text2);
|
|
608
|
+
}
|
|
609
|
+
|
|
466
610
|
.role-create__row-title {
|
|
467
611
|
font-size: var(--fs-cell);
|
|
468
612
|
font-weight: var(--fw-cell);
|