@7365admin1/layer-common 4.26.1-staging.355 → 4.28.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 +16 -4
- package/components/AccessCardAddForm.vue +4 -5
- package/components/AccessCardAssignToUnitForm.vue +2 -3
- package/components/AccessCardPreviewDialog.vue +3 -4
- package/components/Dialog/UpdateMoreAction.vue +1 -11
- package/components/DocumentForm.vue +112 -407
- package/components/DocumentManagement.vue +12 -213
- package/components/EntryPass/QrTemplatePreview.vue +25 -21
- package/components/EntryPassInformation.vue +24 -119
- package/components/Facility/BookingSetup.vue +0 -63
- package/components/HidAccessLogDashboard.vue +5 -29
- package/components/HidIntercomManagement.vue +14 -148
- package/components/HidReaderManagement.vue +0 -26
- package/components/HidReaderUserRoster.vue +2 -32
- package/components/HidUserEnrollment.vue +152 -833
- package/components/InvitationClientForm.vue +1 -19
- package/components/RolePermissionFormCreate.vue +19 -163
- package/components/RolePermissionFormPreviewUpdate.vue +19 -230
- package/components/RolePermissionMain.vue +0 -19
- package/components/VisitorManagement.vue +5 -267
- package/composables/useAccessManagement.ts +0 -5
- package/composables/useDocument.ts +0 -7
- package/composables/useFacility.ts +0 -11
- package/composables/useHidAmico.ts +0 -117
- package/composables/useHidNavigation.ts +1 -25
- package/composables/usePeople.ts +0 -19
- package/composables/useSiteEntryPassSettings.ts +0 -26
- package/composables/useWebUsb.ts +11 -14
- 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-readers/index.vue +1 -1
- package/types/document.d.ts +0 -14
- package/types/facility.d.ts +0 -4
- package/types/people.d.ts +1 -28
- package/utils/permission-labels.ts +0 -30
- package/components/HidAccessPermissions.vue +0 -424
- package/components/HidProfileQrCode.vue +0 -323
- package/composables/useSiteCategory.ts +0 -45
- package/pages/[org]/[site]/access-mgmt/hid-qr-code/index.vue +0 -23
- package/utils/hid-permission-assignments.ts +0 -190
- package/utils/occupancy-role.ts +0 -109
|
@@ -388,27 +388,9 @@ 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
|
-
*/
|
|
409
391
|
const { data: roleData, refresh: refreshRoles } = await useLazyAsyncData(
|
|
410
392
|
"roles",
|
|
411
|
-
() => getRoles({ org: org.value?._id, type:
|
|
393
|
+
() => getRoles({ org: org.value?._id, type: props.app, limit: 50 }),
|
|
412
394
|
{ watch: [() => props.app] }
|
|
413
395
|
)
|
|
414
396
|
|
|
@@ -1,21 +1,8 @@
|
|
|
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
|
-
-->
|
|
10
3
|
<div class="role-create__head">
|
|
11
4
|
<v-card-title>Create Role</v-card-title>
|
|
12
|
-
<
|
|
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>
|
|
5
|
+
<AppButton variant="icon" icon="mdi-close" aria-label="Close" @click="cancel" />
|
|
19
6
|
</div>
|
|
20
7
|
|
|
21
8
|
<div class="screen-modal__body role-create__body filter-field">
|
|
@@ -95,27 +82,14 @@
|
|
|
95
82
|
>
|
|
96
83
|
<v-divider v-if="resourceIndex > 0" />
|
|
97
84
|
|
|
98
|
-
<!--
|
|
99
|
-
|
|
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
|
-
>
|
|
85
|
+
<!-- Category row -->
|
|
86
|
+
<v-list-item density="compact" :ripple="false">
|
|
113
87
|
<template #prepend>
|
|
114
88
|
<StatusChip
|
|
115
89
|
class="mr-3"
|
|
116
90
|
:dot="false"
|
|
117
91
|
tone="info"
|
|
118
|
-
:label="
|
|
92
|
+
:label="String(selectedActionCount(String(resourceKey)))"
|
|
119
93
|
/>
|
|
120
94
|
</template>
|
|
121
95
|
<v-list-item-title>
|
|
@@ -124,38 +98,25 @@
|
|
|
124
98
|
</span>
|
|
125
99
|
</v-list-item-title>
|
|
126
100
|
<template #append>
|
|
127
|
-
<
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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>
|
|
101
|
+
<v-switch
|
|
102
|
+
:model-value="isCategoryEnabled(String(resourceKey))"
|
|
103
|
+
@update:model-value="
|
|
104
|
+
toggleCategory(String(resourceKey), $event)
|
|
105
|
+
"
|
|
106
|
+
class="app-switch"
|
|
107
|
+
density="compact"
|
|
108
|
+
hide-details
|
|
109
|
+
/>
|
|
150
110
|
</template>
|
|
151
111
|
</v-list-item>
|
|
152
112
|
|
|
153
|
-
<!-- Expanded checkboxes
|
|
154
|
-
<template v-if="
|
|
113
|
+
<!-- Expanded checkboxes when toggled on -->
|
|
114
|
+
<template v-if="isCategoryEnabled(String(resourceKey))">
|
|
155
115
|
<template
|
|
156
116
|
v-for="[actionKey, action] in Object.entries(actions || {})"
|
|
157
117
|
:key="actionKey"
|
|
158
118
|
>
|
|
119
|
+
<v-divider />
|
|
159
120
|
<v-list-item density="compact" :ripple="false">
|
|
160
121
|
<template #prepend>
|
|
161
122
|
<v-checkbox-btn
|
|
@@ -214,7 +175,6 @@
|
|
|
214
175
|
import {
|
|
215
176
|
formatActionLabel,
|
|
216
177
|
formatResourceLabel,
|
|
217
|
-
sortResourcesByLabel,
|
|
218
178
|
} from "../utils/permission-labels";
|
|
219
179
|
import useRole from "../composables/useRole";
|
|
220
180
|
import useUtils from "../composables/useUtils";
|
|
@@ -270,91 +230,22 @@ function isCategoryEnabled(resource: string) {
|
|
|
270
230
|
return permState.value.enabled.includes(resource);
|
|
271
231
|
}
|
|
272
232
|
|
|
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
|
-
|
|
294
233
|
function selectedActionCount(resource: string) {
|
|
295
234
|
return permState.value.selected.filter((p) => p.startsWith(`${resource}:`))
|
|
296
235
|
.length;
|
|
297
236
|
}
|
|
298
237
|
|
|
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
|
-
|
|
344
238
|
function toggleCategory(resource: string, value: boolean | null) {
|
|
345
239
|
const { selected, enabled } = permState.value;
|
|
346
240
|
if (value) {
|
|
347
241
|
if (!enabled.includes(resource)) {
|
|
348
242
|
permState.value = { selected, enabled: [...enabled, resource] };
|
|
349
243
|
}
|
|
350
|
-
// Switching a module on opens it, which closes whichever was open.
|
|
351
|
-
expandedResource.value = resource;
|
|
352
244
|
} else {
|
|
353
245
|
permState.value = {
|
|
354
246
|
selected: selected.filter((p) => !p.startsWith(`${resource}:`)),
|
|
355
247
|
enabled: enabled.filter((r) => r !== resource),
|
|
356
248
|
};
|
|
357
|
-
if (expandedResource.value === resource) expandedResource.value = null;
|
|
358
249
|
}
|
|
359
250
|
}
|
|
360
251
|
|
|
@@ -402,12 +293,6 @@ function toggleSelectAll(value: boolean) {
|
|
|
402
293
|
selected: selected.filter((key) => !visibleKeys.includes(key)),
|
|
403
294
|
enabled: enabled.filter((resource) => !visibleResources.includes(resource)),
|
|
404
295
|
};
|
|
405
|
-
if (
|
|
406
|
-
expandedResource.value &&
|
|
407
|
-
visibleResources.includes(expandedResource.value)
|
|
408
|
-
) {
|
|
409
|
-
expandedResource.value = null;
|
|
410
|
-
}
|
|
411
296
|
return;
|
|
412
297
|
}
|
|
413
298
|
|
|
@@ -467,7 +352,6 @@ async function submit() {
|
|
|
467
352
|
function cancel() {
|
|
468
353
|
name.value = "";
|
|
469
354
|
permState.value = { selected: [], enabled: [] };
|
|
470
|
-
expandedResource.value = null;
|
|
471
355
|
// A query left behind would greet the next person with a filtered list and
|
|
472
356
|
// no obvious reason for it.
|
|
473
357
|
moduleSearch.value = "";
|
|
@@ -493,18 +377,12 @@ function cancel() {
|
|
|
493
377
|
* view is still ticked and still saved — losing a tick because somebody typed in
|
|
494
378
|
* a box would be far worse than the scrolling this replaces.
|
|
495
379
|
*/
|
|
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>("");
|
|
380
|
+
const moduleSearch = ref("");
|
|
503
381
|
|
|
504
382
|
/** `safePermissions`, narrowed to what the search box matches. */
|
|
505
383
|
const visiblePermissions = computed(() => {
|
|
506
|
-
const query =
|
|
507
|
-
const all =
|
|
384
|
+
const query = moduleSearch.value.trim().toLowerCase();
|
|
385
|
+
const all = safePermissions.value;
|
|
508
386
|
if (!query) return all;
|
|
509
387
|
|
|
510
388
|
const matches: Record<string, any> = {};
|
|
@@ -571,14 +449,6 @@ const isAllSelected = computed(() => {
|
|
|
571
449
|
padding-right: 12px;
|
|
572
450
|
}
|
|
573
451
|
|
|
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
|
-
|
|
582
452
|
.role-create__body {
|
|
583
453
|
padding: 0 20px;
|
|
584
454
|
max-height: calc(100vh - 160px);
|
|
@@ -593,20 +463,6 @@ const isAllSelected = computed(() => {
|
|
|
593
463
|
overflow: hidden;
|
|
594
464
|
}
|
|
595
465
|
|
|
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
|
-
|
|
610
466
|
.role-create__row-title {
|
|
611
467
|
font-size: var(--fs-cell);
|
|
612
468
|
font-weight: var(--fw-cell);
|
|
@@ -1,21 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<v-card width="100%" class="screen-modal role-perm">
|
|
3
|
-
<!--
|
|
4
|
-
THE RUNNING TOTAL sits on the title row. The same `held / offered` the
|
|
5
|
-
role's row in the list shows, so the number a person clicked in on is the
|
|
6
|
-
number they see here -- and in edit it moves as they tick, which is the
|
|
7
|
-
only place the effect of a change is visible without counting chips down
|
|
8
|
-
a 47-module list. On the header because a row of its own cost a band of
|
|
9
|
-
empty space above a list that is already fighting for height.
|
|
10
|
-
-->
|
|
11
3
|
<div class="role-perm__head">
|
|
12
4
|
<v-card-title>{{ props.name }}</v-card-title>
|
|
13
|
-
<div class="role-perm__head-total">
|
|
14
|
-
<span class="role-perm__row-sub">Modules</span>
|
|
15
|
-
<StatusChip :dot="false" tone="neutral" :label="moduleTotalLabel" />
|
|
16
|
-
<span class="role-perm__row-sub">Permissions</span>
|
|
17
|
-
<StatusChip :dot="false" tone="info" :label="totalLabel" />
|
|
18
|
-
</div>
|
|
19
5
|
</div>
|
|
20
6
|
<div class="screen-modal__body role-perm__body">
|
|
21
7
|
<v-form v-model="validForm" :disabled="disable">
|
|
@@ -58,65 +44,37 @@
|
|
|
58
44
|
:key="resourceKey"
|
|
59
45
|
>
|
|
60
46
|
<v-divider v-if="resourceIndex > 0" />
|
|
61
|
-
|
|
62
|
-
The whole row is the accordion header: one module is open at
|
|
63
|
-
a time, so clicking this one closes whichever was open. The
|
|
64
|
-
switch stops the click, so granting a module is never
|
|
65
|
-
confused with looking at it -- and reading a role in view
|
|
66
|
-
mode works the same way, without the switch being live.
|
|
67
|
-
-->
|
|
68
|
-
<v-list-item
|
|
69
|
-
density="compact"
|
|
70
|
-
:ripple="false"
|
|
71
|
-
:class="[
|
|
72
|
-
'role-perm__cat',
|
|
73
|
-
{ 'role-perm__cat--open': isCategoryOpen(String(resourceKey)) },
|
|
74
|
-
]"
|
|
75
|
-
@click="onCategoryRowClick(String(resourceKey))"
|
|
76
|
-
>
|
|
47
|
+
<v-list-item density="compact" :ripple="false">
|
|
77
48
|
<template #prepend>
|
|
78
49
|
<StatusChip
|
|
79
50
|
class="mr-3"
|
|
80
51
|
:dot="false"
|
|
81
52
|
tone="info"
|
|
82
|
-
:label="
|
|
53
|
+
:label="String(selectedActionCount(String(resourceKey)))"
|
|
83
54
|
/>
|
|
84
55
|
</template>
|
|
85
56
|
<v-list-item-title class="text-capitalize role-perm__row-title">
|
|
86
57
|
{{ formatResourceLabel(String(resourceKey)) }}
|
|
87
58
|
</v-list-item-title>
|
|
88
59
|
<template #append>
|
|
89
|
-
<
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
/>
|
|
100
|
-
<div @click.stop>
|
|
101
|
-
<v-switch
|
|
102
|
-
:model-value="isCategoryEnabled(String(resourceKey))"
|
|
103
|
-
:disabled="!edit"
|
|
104
|
-
class="app-switch"
|
|
105
|
-
density="compact"
|
|
106
|
-
hide-details
|
|
107
|
-
@update:model-value="
|
|
108
|
-
toggleCategory(String(resourceKey), $event)
|
|
109
|
-
"
|
|
110
|
-
/>
|
|
111
|
-
</div>
|
|
112
|
-
</div>
|
|
60
|
+
<v-switch
|
|
61
|
+
:model-value="isCategoryEnabled(String(resourceKey))"
|
|
62
|
+
:disabled="!edit"
|
|
63
|
+
class="app-switch"
|
|
64
|
+
density="compact"
|
|
65
|
+
hide-details
|
|
66
|
+
@update:model-value="
|
|
67
|
+
toggleCategory(String(resourceKey), $event)
|
|
68
|
+
"
|
|
69
|
+
/>
|
|
113
70
|
</template>
|
|
114
71
|
</v-list-item>
|
|
115
|
-
<template v-if="
|
|
72
|
+
<template v-if="isCategoryEnabled(String(resourceKey))">
|
|
116
73
|
<template
|
|
117
74
|
v-for="[actionKey, action] in Object.entries(actions || {})"
|
|
118
75
|
:key="actionKey"
|
|
119
76
|
>
|
|
77
|
+
<v-divider />
|
|
120
78
|
<v-list-item density="compact" :ripple="false">
|
|
121
79
|
<template #prepend>
|
|
122
80
|
<v-checkbox-btn
|
|
@@ -166,7 +124,7 @@
|
|
|
166
124
|
</div>
|
|
167
125
|
<div class="role-perm__list">
|
|
168
126
|
<template
|
|
169
|
-
v-for="(actions, resourceKey, resourceIndex) in
|
|
127
|
+
v-for="(actions, resourceKey, resourceIndex) in props.notOfferedPermissions"
|
|
170
128
|
:key="resourceKey"
|
|
171
129
|
>
|
|
172
130
|
<v-divider v-if="resourceIndex > 0" />
|
|
@@ -208,7 +166,7 @@
|
|
|
208
166
|
|
|
209
167
|
<div class="role-perm__footer">
|
|
210
168
|
<AppButton v-if="!edit" variant="ghost" @click="emit('cancel')">Close</AppButton>
|
|
211
|
-
<AppButton v-else variant="ghost" @click="
|
|
169
|
+
<AppButton v-else variant="ghost" @click="edit = false">Cancel</AppButton>
|
|
212
170
|
|
|
213
171
|
<AppButton v-if="!edit && canUpdateRole" :disabled="disable" @click="edit = true">Edit</AppButton>
|
|
214
172
|
<AppButton v-else :disabled="Boolean(errorMessages) || disable" @click="submit()">
|
|
@@ -223,7 +181,6 @@
|
|
|
223
181
|
import {
|
|
224
182
|
formatActionLabel,
|
|
225
183
|
formatResourceLabel,
|
|
226
|
-
sortResourcesByLabel,
|
|
227
184
|
} from "../utils/permission-labels";
|
|
228
185
|
import useRole from "../composables/useRole";
|
|
229
186
|
import useUtils from "../composables/useUtils";
|
|
@@ -268,56 +225,6 @@ const props = defineProps({
|
|
|
268
225
|
type: Boolean,
|
|
269
226
|
default: false,
|
|
270
227
|
},
|
|
271
|
-
// Size of the catalogue this client was offered -- the denominators of the
|
|
272
|
-
// two running totals. The dialog cannot derive either: in view it is handed
|
|
273
|
-
// the tree already narrowed to what the role holds.
|
|
274
|
-
catalogueSize: {
|
|
275
|
-
type: Number,
|
|
276
|
-
default: 0,
|
|
277
|
-
},
|
|
278
|
-
moduleCount: {
|
|
279
|
-
type: Number,
|
|
280
|
-
default: 0,
|
|
281
|
-
},
|
|
282
|
-
});
|
|
283
|
-
|
|
284
|
-
/** A role holding the wildcard has ONE stored entry and reaches everything. */
|
|
285
|
-
const holdsWildcard = computed(() => (definedModel.value ?? []).includes("*"));
|
|
286
|
-
|
|
287
|
-
/**
|
|
288
|
-
* `held / offered`, or "All" for the wildcard.
|
|
289
|
-
*
|
|
290
|
-
* Counts the STORED array, not the tree, so grants this client is no longer
|
|
291
|
-
* offered are still counted -- they are still held, and saving keeps them.
|
|
292
|
-
* A role holding `*` has one entry, so counting it would print "1 / 146" for
|
|
293
|
-
* the role that can do everything.
|
|
294
|
-
*/
|
|
295
|
-
const totalLabel = computed(() => {
|
|
296
|
-
const held = definedModel.value ?? [];
|
|
297
|
-
if (holdsWildcard.value) return "All";
|
|
298
|
-
return props.catalogueSize > 0
|
|
299
|
-
? `${held.length} / ${props.catalogueSize}`
|
|
300
|
-
: String(held.length);
|
|
301
|
-
});
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* HOW MANY MODULES THIS ROLE REACHES, out of the modules the client was
|
|
305
|
-
* offered. 146 permissions means little on its own; "4 of 31 modules" is the
|
|
306
|
-
* shape of the role, and it is the sentence a person actually wants when they
|
|
307
|
-
* open a role they did not build.
|
|
308
|
-
*
|
|
309
|
-
* Counted the same way in both modes: a module counts when at least one of its
|
|
310
|
-
* actions is ticked. The read-only tree is already narrowed to what the role
|
|
311
|
-
* holds, so that is every module in it.
|
|
312
|
-
*/
|
|
313
|
-
const moduleTotalLabel = computed(() => {
|
|
314
|
-
if (holdsWildcard.value) return "All";
|
|
315
|
-
const reached = Object.keys(safePermissions.value).filter(
|
|
316
|
-
(resource) => selectedActionCount(resource) > 0
|
|
317
|
-
).length;
|
|
318
|
-
return props.moduleCount > 0
|
|
319
|
-
? `${reached} / ${props.moduleCount}`
|
|
320
|
-
: String(reached);
|
|
321
228
|
});
|
|
322
229
|
|
|
323
230
|
const validForm = ref(false);
|
|
@@ -352,21 +259,6 @@ function selectedActionCount(resource: string) {
|
|
|
352
259
|
).length;
|
|
353
260
|
}
|
|
354
261
|
|
|
355
|
-
/**
|
|
356
|
-
* The module chip: `ticked / offered` while editing, a bare count while reading.
|
|
357
|
-
*
|
|
358
|
-
* Only edit needs the denominator. The read-only tree is ALREADY narrowed to
|
|
359
|
-
* what the role holds, so every module there would read `6 / 6` -- a
|
|
360
|
-
* denominator that says nothing and invites the reader to think the module has
|
|
361
|
-
* six actions in total when it may have twelve.
|
|
362
|
-
*/
|
|
363
|
-
function moduleCountLabel(resource: string) {
|
|
364
|
-
const selected = selectedActionCount(resource);
|
|
365
|
-
if (!edit.value) return String(selected);
|
|
366
|
-
const offered = Object.keys(safePermissions.value[resource] ?? {}).length;
|
|
367
|
-
return offered > 0 ? `${selected} / ${offered}` : String(selected);
|
|
368
|
-
}
|
|
369
|
-
|
|
370
262
|
function isCategoryEnabled(resource: string) {
|
|
371
263
|
return (
|
|
372
264
|
expandedResources.value.includes(resource) ||
|
|
@@ -374,41 +266,16 @@ function isCategoryEnabled(resource: string) {
|
|
|
374
266
|
);
|
|
375
267
|
}
|
|
376
268
|
|
|
377
|
-
/*
|
|
378
|
-
* ACCORDION -- one module open at a time.
|
|
379
|
-
*
|
|
380
|
-
* `isCategoryEnabled` stays the switch, i.e. what the role grants.
|
|
381
|
-
* `expandedResource` is purely what is on screen. Keeping them apart means
|
|
382
|
-
* opening a module never grants anything and closing one never takes a grant
|
|
383
|
-
* away -- which matters here more than in the create dialog, because this is a
|
|
384
|
-
* role somebody already relies on.
|
|
385
|
-
*/
|
|
386
|
-
const expandedResource = ref<string | null>(null);
|
|
387
|
-
|
|
388
|
-
function isCategoryOpen(resource: string) {
|
|
389
|
-
return isCategoryEnabled(resource) && expandedResource.value === resource;
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
function onCategoryRowClick(resource: string) {
|
|
393
|
-
// A module that is off has nothing to show; its switch is the way in.
|
|
394
|
-
if (!isCategoryEnabled(resource)) return;
|
|
395
|
-
expandedResource.value =
|
|
396
|
-
expandedResource.value === resource ? null : resource;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
269
|
function toggleCategory(resource: string, value: boolean | null) {
|
|
400
270
|
if (!edit.value || value === null) return;
|
|
401
271
|
if (value) {
|
|
402
272
|
if (!expandedResources.value.includes(resource))
|
|
403
273
|
expandedResources.value.push(resource);
|
|
404
|
-
// Switching a module on opens it, which closes whichever was open.
|
|
405
|
-
expandedResource.value = resource;
|
|
406
274
|
return;
|
|
407
275
|
}
|
|
408
276
|
expandedResources.value = expandedResources.value.filter(
|
|
409
277
|
(item) => item !== resource
|
|
410
278
|
);
|
|
411
|
-
if (expandedResource.value === resource) expandedResource.value = null;
|
|
412
279
|
const actions = Object.keys(safePermissions.value[resource] ?? {});
|
|
413
280
|
definedModel.value = actions.reduce(
|
|
414
281
|
(kept, action) => withoutPermission(kept, `${resource}:${action}`),
|
|
@@ -444,17 +311,11 @@ const safePermissions = computed(() => props.permissions || {});
|
|
|
444
311
|
* ticked and still saved. That matters more here than in the create dialog:
|
|
445
312
|
* this one is editing a role somebody already relies on.
|
|
446
313
|
*/
|
|
447
|
-
|
|
448
|
-
* `clearable` writes NULL, not "". The query below used to call `.trim()` on
|
|
449
|
-
* it, which threw inside the computed the moment the X was pressed: the render
|
|
450
|
-
* aborted, the list stayed on the last filtered result, and the button looked
|
|
451
|
-
* dead. The ref admits null and the read below absorbs it.
|
|
452
|
-
*/
|
|
453
|
-
const moduleSearch = ref<string | null>("");
|
|
314
|
+
const moduleSearch = ref("");
|
|
454
315
|
|
|
455
316
|
const visiblePermissions = computed(() => {
|
|
456
|
-
const query =
|
|
457
|
-
const all =
|
|
317
|
+
const query = moduleSearch.value.trim().toLowerCase();
|
|
318
|
+
const all = safePermissions.value;
|
|
458
319
|
if (!query) return all;
|
|
459
320
|
|
|
460
321
|
const matches: Record<string, any> = {};
|
|
@@ -474,12 +335,6 @@ const visiblePermissions = computed(() => {
|
|
|
474
335
|
return matches;
|
|
475
336
|
});
|
|
476
337
|
|
|
477
|
-
// Same A-Z as the tree above it; a second list in a second order reads as a
|
|
478
|
-
// different kind of thing.
|
|
479
|
-
const sortedNotOffered = computed(() =>
|
|
480
|
-
sortResourcesByLabel(props.notOfferedPermissions as Record<string, any>)
|
|
481
|
-
);
|
|
482
|
-
|
|
483
338
|
const hasNotOffered = computed(
|
|
484
339
|
() => Object.keys(props.notOfferedPermissions || {}).length > 0
|
|
485
340
|
);
|
|
@@ -525,9 +380,6 @@ function toggleSelectAll(value: boolean) {
|
|
|
525
380
|
expandedResources.value = expandedResources.value.filter(
|
|
526
381
|
(resource) => !resources.includes(resource)
|
|
527
382
|
);
|
|
528
|
-
if (expandedResource.value && resources.includes(expandedResource.value)) {
|
|
529
|
-
expandedResource.value = null;
|
|
530
|
-
}
|
|
531
383
|
return;
|
|
532
384
|
}
|
|
533
385
|
|
|
@@ -543,39 +395,6 @@ const edit = defineModel<boolean>("edit", {
|
|
|
543
395
|
default: false,
|
|
544
396
|
});
|
|
545
397
|
|
|
546
|
-
/**
|
|
547
|
-
* CANCEL THROWS THE DRAFT AWAY.
|
|
548
|
-
*
|
|
549
|
-
* It used to do `edit = false` and nothing else, so every tick made during the
|
|
550
|
-
* edit stayed in the model. The read-only view filters by
|
|
551
|
-
* `originalPermissions`, so the dialog LOOKED unchanged -- and then the next
|
|
552
|
-
* Edit re-opened the abandoned draft with modules enabled that the role does
|
|
553
|
-
* not hold. One Submit from there would have saved them.
|
|
554
|
-
*/
|
|
555
|
-
function cancelEdit() {
|
|
556
|
-
definedModel.value = Array.isArray(props.originalPermissions)
|
|
557
|
-
? [...props.originalPermissions]
|
|
558
|
-
: [];
|
|
559
|
-
resetExpansion();
|
|
560
|
-
message.value = "";
|
|
561
|
-
edit.value = false;
|
|
562
|
-
}
|
|
563
|
-
|
|
564
|
-
function resetExpansion() {
|
|
565
|
-
expandedResources.value = [];
|
|
566
|
-
expandedResource.value = null;
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
// Reopening the dialog on another role must not inherit the last one's open
|
|
570
|
-
// panel or its switched-on-but-empty modules.
|
|
571
|
-
watch(
|
|
572
|
-
() => props.id,
|
|
573
|
-
() => {
|
|
574
|
-
resetExpansion();
|
|
575
|
-
message.value = "";
|
|
576
|
-
}
|
|
577
|
-
);
|
|
578
|
-
|
|
579
398
|
function equalListValue() {
|
|
580
399
|
return JSON.stringify(definedModel.value) ===
|
|
581
400
|
JSON.stringify(props.originalPermissions)
|
|
@@ -641,36 +460,6 @@ async function submit() {
|
|
|
641
460
|
overflow: hidden;
|
|
642
461
|
}
|
|
643
462
|
|
|
644
|
-
.role-perm__head-total {
|
|
645
|
-
display: flex;
|
|
646
|
-
align-items: center;
|
|
647
|
-
gap: 6px;
|
|
648
|
-
white-space: nowrap;
|
|
649
|
-
flex: 0 0 auto;
|
|
650
|
-
}
|
|
651
|
-
|
|
652
|
-
/* The name yields first: a long role name must not push the counts off the
|
|
653
|
-
edge of a 500px dialog. */
|
|
654
|
-
.role-perm__head .v-card-title {
|
|
655
|
-
min-width: 0;
|
|
656
|
-
overflow: hidden;
|
|
657
|
-
text-overflow: ellipsis;
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
.role-perm__cat {
|
|
661
|
-
cursor: pointer;
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
.role-perm__cat-actions {
|
|
665
|
-
display: flex;
|
|
666
|
-
align-items: center;
|
|
667
|
-
gap: 4px;
|
|
668
|
-
}
|
|
669
|
-
|
|
670
|
-
.role-perm__chevron {
|
|
671
|
-
color: var(--text2);
|
|
672
|
-
}
|
|
673
|
-
|
|
674
463
|
.role-perm__row-title {
|
|
675
464
|
font-size: var(--fs-cell) !important;
|
|
676
465
|
font-weight: var(--fw-cell) !important;
|