@7365admin1/layer-common 4.25.0 → 4.26.1-staging.354
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 +18 -4
- 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/Robot/Fleet.vue +182 -2
- package/components/Robot/Form.vue +37 -12
- package/components/Robot/Map3D.vue +803 -40
- package/components/Robot/Plans.vue +63 -0
- package/components/Robot/SpotClean.vue +174 -0
- 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/useRobots.ts +111 -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/building-map.ts +179 -8
- package/utils/hid-permission-assignments.ts +190 -0
- package/utils/occupancy-role.ts +109 -0
- package/utils/permission-labels.ts +30 -0
- package/utils/robot-display.ts +89 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="pa-4">
|
|
3
|
+
<div v-if="loading" class="py-6 text-center">
|
|
4
|
+
<v-progress-circular indeterminate size="28" />
|
|
5
|
+
</div>
|
|
6
|
+
<v-alert v-else-if="error" type="error" variant="tonal" :text="error" />
|
|
7
|
+
<div v-else-if="!plans.length" class="py-6 text-center text-body-2 text-medium-emphasis">
|
|
8
|
+
This robot has no cleaning schedule.
|
|
9
|
+
</div>
|
|
10
|
+
<v-list v-else density="compact" class="pa-0">
|
|
11
|
+
<v-list-item v-for="(plan, i) in plans" :key="plan.planId ?? i" class="px-0">
|
|
12
|
+
<v-list-item-title class="font-weight-medium">
|
|
13
|
+
{{ plan.summary.days }} · {{ plan.summary.time }}
|
|
14
|
+
<v-chip
|
|
15
|
+
size="x-small"
|
|
16
|
+
label
|
|
17
|
+
variant="tonal"
|
|
18
|
+
class="ml-2"
|
|
19
|
+
:color="plan.summary.enabled ? 'success' : 'default'"
|
|
20
|
+
>
|
|
21
|
+
{{ plan.summary.enabled ? "On" : "Off" }}
|
|
22
|
+
</v-chip>
|
|
23
|
+
</v-list-item-title>
|
|
24
|
+
<v-list-item-subtitle>
|
|
25
|
+
{{ plan.summary.jobs.join(" · ") || "No jobs in this plan" }}
|
|
26
|
+
</v-list-item-subtitle>
|
|
27
|
+
</v-list-item>
|
|
28
|
+
</v-list>
|
|
29
|
+
<!--
|
|
30
|
+
Read-only on purpose: the schedule lives in the robot maker's cloud, and no
|
|
31
|
+
brand's adapter offers editing it through this platform yet.
|
|
32
|
+
-->
|
|
33
|
+
<p class="text-caption text-medium-emphasis mt-3 mb-0">
|
|
34
|
+
Schedules are set in the robot maker's own app and shown here as they are.
|
|
35
|
+
</p>
|
|
36
|
+
</div>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<script lang="ts" setup>
|
|
40
|
+
/** The cleaning schedule a robot's cloud holds, shown read-only. */
|
|
41
|
+
import { planSummary, robotErrorMessage } from "../../utils/robot-display";
|
|
42
|
+
|
|
43
|
+
const props = defineProps<{ robotId: string }>();
|
|
44
|
+
const { getRobotPlans } = useRobots();
|
|
45
|
+
|
|
46
|
+
const plans = ref<Array<Record<string, any>>>([]);
|
|
47
|
+
const loading = ref(true);
|
|
48
|
+
const error = ref("");
|
|
49
|
+
|
|
50
|
+
onMounted(async () => {
|
|
51
|
+
try {
|
|
52
|
+
const res = await getRobotPlans(props.robotId);
|
|
53
|
+
plans.value = (res?.items ?? []).map((p: Record<string, any>) => ({
|
|
54
|
+
...p,
|
|
55
|
+
summary: planSummary(p),
|
|
56
|
+
}));
|
|
57
|
+
} catch (e) {
|
|
58
|
+
error.value = robotErrorMessage(e, "Could not load this robot's schedule.");
|
|
59
|
+
} finally {
|
|
60
|
+
loading.value = false;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
</script>
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="pa-4">
|
|
3
|
+
<AppSelect
|
|
4
|
+
v-if="maps.length > 1"
|
|
5
|
+
v-model="floorNo"
|
|
6
|
+
:items="floorOptions"
|
|
7
|
+
item-title="title"
|
|
8
|
+
item-value="value"
|
|
9
|
+
label="Level"
|
|
10
|
+
density="compact"
|
|
11
|
+
hide-details
|
|
12
|
+
class="mb-3"
|
|
13
|
+
style="max-width: 220px"
|
|
14
|
+
/>
|
|
15
|
+
<div v-if="loading" class="py-6 text-center">
|
|
16
|
+
<v-progress-circular indeterminate size="28" />
|
|
17
|
+
</div>
|
|
18
|
+
<v-alert v-else-if="error" type="error" variant="tonal" :text="error" />
|
|
19
|
+
<template v-else>
|
|
20
|
+
<p class="text-body-2 text-medium-emphasis mb-2">
|
|
21
|
+
Click the spot on the floor plan you want cleaned.
|
|
22
|
+
</p>
|
|
23
|
+
<div class="spot-plan">
|
|
24
|
+
<img
|
|
25
|
+
ref="img"
|
|
26
|
+
:src="imageUrl"
|
|
27
|
+
alt="Floor plan"
|
|
28
|
+
class="spot-plan__img"
|
|
29
|
+
@click="pick"
|
|
30
|
+
/>
|
|
31
|
+
<div
|
|
32
|
+
v-if="picked"
|
|
33
|
+
class="spot-plan__marker"
|
|
34
|
+
:style="{ left: `${picked.left}%`, top: `${picked.top}%` }"
|
|
35
|
+
/>
|
|
36
|
+
</div>
|
|
37
|
+
</template>
|
|
38
|
+
<div class="d-flex justify-end ga-2 mt-3">
|
|
39
|
+
<AppButton variant="text" :disabled="sending" @click="$emit('close')">Close</AppButton>
|
|
40
|
+
<AppButton :loading="sending" :disabled="!picked" @click="send">Clean this spot</AppButton>
|
|
41
|
+
</div>
|
|
42
|
+
</div>
|
|
43
|
+
</template>
|
|
44
|
+
|
|
45
|
+
<script lang="ts" setup>
|
|
46
|
+
/**
|
|
47
|
+
* Spot cleaning by clicking the robot's own floor plan.
|
|
48
|
+
*
|
|
49
|
+
* The click is taken in the plan's PIXELS - the frame the spot command uses -
|
|
50
|
+
* so no metre conversion happens here. Offered only for brands declaring
|
|
51
|
+
* `spotClean`; the server refuses the rest by name as well.
|
|
52
|
+
*/
|
|
53
|
+
import { robotErrorMessage, spotPolygon } from "../../utils/robot-display";
|
|
54
|
+
|
|
55
|
+
const props = defineProps<{ robotId: string; robotName?: string }>();
|
|
56
|
+
const emit = defineEmits<{ close: []; sent: [message: string] }>();
|
|
57
|
+
|
|
58
|
+
const { getRobotMaps, getRobotMapImages, sendRobotCommand } = useRobots();
|
|
59
|
+
|
|
60
|
+
const maps = ref<Array<Record<string, any>>>([]);
|
|
61
|
+
const floorNo = ref<number | null>(null);
|
|
62
|
+
const imageUrl = ref("");
|
|
63
|
+
const img = ref<HTMLImageElement | null>(null);
|
|
64
|
+
const picked = ref<{ x: number; y: number; left: number; top: number } | null>(null);
|
|
65
|
+
const loading = ref(true);
|
|
66
|
+
const sending = ref(false);
|
|
67
|
+
const error = ref("");
|
|
68
|
+
|
|
69
|
+
const floorOptions = computed(() =>
|
|
70
|
+
maps.value.map((m) => ({ title: m.mapName?.trim() || `Floor ${m.floorNo}`, value: m.floorNo })),
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
async function loadImage() {
|
|
74
|
+
const map = maps.value.find((m) => m.floorNo === floorNo.value);
|
|
75
|
+
picked.value = null;
|
|
76
|
+
imageUrl.value = "";
|
|
77
|
+
if (!map?.backgroundFileKey) {
|
|
78
|
+
error.value = "This floor has no plan image.";
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const files = await getRobotMapImages(props.robotId, [map.backgroundFileKey]);
|
|
82
|
+
imageUrl.value = files?.items?.find((f: any) => f.fileKey === map.backgroundFileKey)?.url ?? "";
|
|
83
|
+
if (!imageUrl.value) error.value = "The floor plan image could not be fetched.";
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
onMounted(async () => {
|
|
87
|
+
try {
|
|
88
|
+
const res = await getRobotMaps(props.robotId);
|
|
89
|
+
maps.value = res?.items ?? [];
|
|
90
|
+
if (!maps.value.length) {
|
|
91
|
+
error.value = "This robot has no floor maps yet.";
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
floorNo.value = maps.value[0].floorNo;
|
|
95
|
+
await loadImage();
|
|
96
|
+
} catch (e) {
|
|
97
|
+
error.value = robotErrorMessage(e, "Could not load this robot's floor plan.");
|
|
98
|
+
} finally {
|
|
99
|
+
loading.value = false;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
watch(floorNo, async (next, prev) => {
|
|
104
|
+
if (prev === null || next === prev) return;
|
|
105
|
+
loading.value = true;
|
|
106
|
+
error.value = "";
|
|
107
|
+
try {
|
|
108
|
+
await loadImage();
|
|
109
|
+
} catch (e) {
|
|
110
|
+
error.value = robotErrorMessage(e, "Could not load this floor.");
|
|
111
|
+
} finally {
|
|
112
|
+
loading.value = false;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
/** Screen point to plan pixel: the image is scaled to fit, its pixels are not. */
|
|
117
|
+
function pick(event: MouseEvent) {
|
|
118
|
+
const el = img.value;
|
|
119
|
+
if (!el || !el.naturalWidth) return;
|
|
120
|
+
const rect = el.getBoundingClientRect();
|
|
121
|
+
const fx = (event.clientX - rect.left) / rect.width;
|
|
122
|
+
const fy = (event.clientY - rect.top) / rect.height;
|
|
123
|
+
picked.value = {
|
|
124
|
+
x: fx * el.naturalWidth,
|
|
125
|
+
y: fy * el.naturalHeight,
|
|
126
|
+
left: fx * 100,
|
|
127
|
+
top: fy * 100,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
async function send() {
|
|
132
|
+
const el = img.value;
|
|
133
|
+
if (!picked.value || !el) return;
|
|
134
|
+
sending.value = true;
|
|
135
|
+
try {
|
|
136
|
+
await sendRobotCommand(props.robotId, {
|
|
137
|
+
kind: "spot",
|
|
138
|
+
points: spotPolygon(picked.value.x, picked.value.y, {
|
|
139
|
+
width: el.naturalWidth,
|
|
140
|
+
height: el.naturalHeight,
|
|
141
|
+
}),
|
|
142
|
+
});
|
|
143
|
+
emit("sent", `${props.robotName ?? "The robot"} has been sent to clean that spot.`);
|
|
144
|
+
} catch (e) {
|
|
145
|
+
error.value = robotErrorMessage(e);
|
|
146
|
+
} finally {
|
|
147
|
+
sending.value = false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
</script>
|
|
151
|
+
|
|
152
|
+
<style scoped>
|
|
153
|
+
.spot-plan {
|
|
154
|
+
position: relative;
|
|
155
|
+
width: 100%;
|
|
156
|
+
}
|
|
157
|
+
.spot-plan__img {
|
|
158
|
+
display: block;
|
|
159
|
+
width: 100%;
|
|
160
|
+
cursor: crosshair;
|
|
161
|
+
image-rendering: pixelated;
|
|
162
|
+
border: 1px solid rgba(0, 0, 0, 0.12);
|
|
163
|
+
}
|
|
164
|
+
.spot-plan__marker {
|
|
165
|
+
position: absolute;
|
|
166
|
+
width: 14px;
|
|
167
|
+
height: 14px;
|
|
168
|
+
margin: -7px 0 0 -7px;
|
|
169
|
+
border-radius: 50%;
|
|
170
|
+
background: #ff5a1f;
|
|
171
|
+
box-shadow: 0 0 0 3px rgba(255, 90, 31, 0.3);
|
|
172
|
+
pointer-events: none;
|
|
173
|
+
}
|
|
174
|
+
</style>
|
|
@@ -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);
|