@7365admin1/layer-common 4.29.0 → 4.31.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 +18 -4
- package/assets/css/robot-hero.css +410 -0
- package/components/Robot/AlertsTable.vue +72 -0
- package/components/Robot/Bell.vue +21 -0
- package/components/Robot/ClientDrill.vue +36 -0
- package/components/Robot/Detail.vue +445 -0
- package/components/Robot/Fleet.vue +3 -1
- package/components/Robot/FloorPlan.vue +43 -0
- package/components/Robot/LiveIndicator.vue +18 -0
- package/components/Robot/LivePlan.vue +59 -0
- package/components/Robot/Mark.vue +17 -0
- package/components/Robot/MiniMap.vue +120 -0
- package/components/Robot/NeedsAttention.vue +56 -0
- package/components/Robot/PatrolRoutes.vue +48 -0
- package/components/Robot/SiteFleet.vue +266 -0
- package/components/Robot/SiteHeader.vue +64 -0
- package/components/Robot/SiteScreen.vue +160 -0
- package/components/Robot/SummaryCell.vue +5 -3
- package/components/Robot/SummaryStrip.vue +1 -1
- package/components/Robot/Table.vue +4 -1
- package/components/RolePermissionFormCreate.vue +78 -1
- package/components/RolePermissionFormPreviewUpdate.vue +83 -2
- package/components/VehicleManagement.vue +150 -10
- package/composables/useRobotLive.ts +139 -0
- package/composables/useRobots.ts +52 -1
- package/package.json +1 -1
- package/plugins/API.ts +7 -2
- package/types/vehicle.d.ts +11 -0
- package/utils/permission-refusal.ts +40 -0
- package/utils/robot-display.ts +583 -6
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!--
|
|
3
|
+
One estate's robots in the HERO look: the shared shell header (hidden when
|
|
4
|
+
the host draws its own, e.g. the console's drill-down), then the site
|
|
5
|
+
fleet overview, or one robot's detail when `robotId` is set. Every app
|
|
6
|
+
passes only its scope (org, site, the robot types it presents) and what
|
|
7
|
+
this user's role may do; the API narrows again on its own side.
|
|
8
|
+
-->
|
|
9
|
+
<RobotHero class="hero-screen">
|
|
10
|
+
<RobotSiteHeader
|
|
11
|
+
v-if="!hideHeader"
|
|
12
|
+
:org-name="orgName || names.clientName"
|
|
13
|
+
:sites="sites"
|
|
14
|
+
:site="site"
|
|
15
|
+
:types="types"
|
|
16
|
+
:type="type"
|
|
17
|
+
:connected="connected"
|
|
18
|
+
:faults="faults"
|
|
19
|
+
:role="role"
|
|
20
|
+
@update:site="(id) => emit('update:site', id)"
|
|
21
|
+
@update:type="setType"
|
|
22
|
+
@bell="emit('bell')"
|
|
23
|
+
/>
|
|
24
|
+
<main class="hero-main">
|
|
25
|
+
<RobotDetail
|
|
26
|
+
v-if="robotId"
|
|
27
|
+
:key="robotId"
|
|
28
|
+
:robot-id="robotId"
|
|
29
|
+
:back-label="siteName || names.siteName ? `${siteName || names.siteName} fleet` : ''"
|
|
30
|
+
:can-edit="canEdit"
|
|
31
|
+
:can-command="canCommand"
|
|
32
|
+
:can-delete="canDelete"
|
|
33
|
+
@back="emit('back')"
|
|
34
|
+
@removed="onRemoved"
|
|
35
|
+
@status="(s) => (connected = s.connected)"
|
|
36
|
+
/>
|
|
37
|
+
<RobotSiteFleet
|
|
38
|
+
v-else
|
|
39
|
+
:organization="organization"
|
|
40
|
+
:site="site"
|
|
41
|
+
:site-name="siteName"
|
|
42
|
+
:client-name="clientName"
|
|
43
|
+
:type="type"
|
|
44
|
+
:can-setup="canSetup"
|
|
45
|
+
:back-to-network="backToNetwork"
|
|
46
|
+
:reload-key="reloadKey"
|
|
47
|
+
@open="(r) => emit('open', String(r._id))"
|
|
48
|
+
@add="addOpen = true"
|
|
49
|
+
@network="emit('network')"
|
|
50
|
+
@status="onFleetStatus"
|
|
51
|
+
/>
|
|
52
|
+
</main>
|
|
53
|
+
|
|
54
|
+
<v-dialog v-model="addOpen" width="460" persistent>
|
|
55
|
+
<RobotForm
|
|
56
|
+
v-if="addOpen"
|
|
57
|
+
:organization="organization"
|
|
58
|
+
:site="site"
|
|
59
|
+
:type="type"
|
|
60
|
+
@cancel="addOpen = false"
|
|
61
|
+
@created="onCreated"
|
|
62
|
+
/>
|
|
63
|
+
</v-dialog>
|
|
64
|
+
<RobotToast v-model="toast" />
|
|
65
|
+
</RobotHero>
|
|
66
|
+
</template>
|
|
67
|
+
|
|
68
|
+
<script setup lang="ts">
|
|
69
|
+
import { computed, ref, watch } from "vue";
|
|
70
|
+
import RobotHero from "./Hero.vue";
|
|
71
|
+
import RobotSiteHeader from "./SiteHeader.vue";
|
|
72
|
+
import RobotSiteFleet from "./SiteFleet.vue";
|
|
73
|
+
import RobotDetail from "./Detail.vue";
|
|
74
|
+
import RobotForm from "./Form.vue";
|
|
75
|
+
import RobotToast from "./Toast.vue";
|
|
76
|
+
import { roleLabel, type TRobotType } from "../../utils/robot-display";
|
|
77
|
+
|
|
78
|
+
const props = withDefaults(
|
|
79
|
+
defineProps<{
|
|
80
|
+
organization: string;
|
|
81
|
+
site: string;
|
|
82
|
+
siteName?: string;
|
|
83
|
+
clientName?: string;
|
|
84
|
+
/** The header's org line ("Marina Bay Residences · MCST 3821"). */
|
|
85
|
+
orgName?: string;
|
|
86
|
+
/** The sites this person may pick; the Site select shows only with more than one. */
|
|
87
|
+
sites?: Array<{ _id: string; name: string }>;
|
|
88
|
+
/** The robot types this app presents (scope isolation): both only for Property Management. */
|
|
89
|
+
types?: TRobotType[];
|
|
90
|
+
/** The type shown now (v-model:type); defaults to the first allowed. */
|
|
91
|
+
type?: TRobotType;
|
|
92
|
+
/** One robot open, or none (the fleet). */
|
|
93
|
+
robotId?: string;
|
|
94
|
+
canSetup?: boolean;
|
|
95
|
+
canEdit?: boolean;
|
|
96
|
+
canCommand?: boolean;
|
|
97
|
+
canDelete?: boolean;
|
|
98
|
+
superAdmin?: boolean;
|
|
99
|
+
hideHeader?: boolean;
|
|
100
|
+
backToNetwork?: boolean;
|
|
101
|
+
}>(),
|
|
102
|
+
{
|
|
103
|
+
siteName: "",
|
|
104
|
+
clientName: "",
|
|
105
|
+
orgName: "",
|
|
106
|
+
sites: () => [],
|
|
107
|
+
types: () => ["cleaning"],
|
|
108
|
+
type: undefined,
|
|
109
|
+
robotId: "",
|
|
110
|
+
canSetup: false,
|
|
111
|
+
canEdit: false,
|
|
112
|
+
canCommand: false,
|
|
113
|
+
canDelete: false,
|
|
114
|
+
superAdmin: false,
|
|
115
|
+
hideHeader: false,
|
|
116
|
+
backToNetwork: false,
|
|
117
|
+
},
|
|
118
|
+
);
|
|
119
|
+
const emit = defineEmits<{
|
|
120
|
+
"update:site": [id: string];
|
|
121
|
+
"update:type": [type: TRobotType];
|
|
122
|
+
open: [id: string];
|
|
123
|
+
back: [];
|
|
124
|
+
network: [];
|
|
125
|
+
bell: [];
|
|
126
|
+
/** Live feed health + open faults, for a host drawing its own header. */
|
|
127
|
+
status: [status: { connected: boolean; faults: number }];
|
|
128
|
+
}>();
|
|
129
|
+
|
|
130
|
+
/** Never a type this app does not present, whatever the URL asked for. */
|
|
131
|
+
const type = computed<TRobotType>(() => (props.type && props.types.includes(props.type) ? props.type : props.types[0] ?? "cleaning"));
|
|
132
|
+
function setType(t: TRobotType) {
|
|
133
|
+
if (props.types.includes(t)) emit("update:type", t);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const role = computed(() => roleLabel({ superAdmin: props.superAdmin, canCommand: props.canCommand, canSetup: props.canSetup }));
|
|
137
|
+
const connected = ref(true);
|
|
138
|
+
const faults = ref(0);
|
|
139
|
+
const names = ref({ siteName: "", clientName: "" });
|
|
140
|
+
function onFleetStatus(s: { connected: boolean; faults: number; siteName: string; clientName: string }) {
|
|
141
|
+
connected.value = s.connected;
|
|
142
|
+
faults.value = s.faults;
|
|
143
|
+
if (s.siteName) names.value = { siteName: s.siteName, clientName: s.clientName };
|
|
144
|
+
}
|
|
145
|
+
watch([connected, faults], ([c, f]) => emit("status", { connected: c, faults: f }));
|
|
146
|
+
|
|
147
|
+
const addOpen = ref(false);
|
|
148
|
+
const toast = ref("");
|
|
149
|
+
const reloadKey = ref(0);
|
|
150
|
+
function onCreated() {
|
|
151
|
+
addOpen.value = false;
|
|
152
|
+
toast.value = "Robot saved · credentials hidden";
|
|
153
|
+
reloadKey.value++;
|
|
154
|
+
}
|
|
155
|
+
function onRemoved(name: string) {
|
|
156
|
+
toast.value = `${name} removed`;
|
|
157
|
+
reloadKey.value++;
|
|
158
|
+
emit("back");
|
|
159
|
+
}
|
|
160
|
+
</script>
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<span class="hero-cell__corner hero-cell__corner--tl" aria-hidden="true" />
|
|
4
4
|
<span class="hero-cell__corner hero-cell__corner--br" aria-hidden="true" />
|
|
5
5
|
<div class="hero-cell__label"><span class="hero-cell__square" aria-hidden="true" />{{ label }}</div>
|
|
6
|
-
<div class="hero-cell__value" :aria-label="`${label}: ${value}`">{{ shown }}</div>
|
|
6
|
+
<div class="hero-cell__value" :aria-label="`${label}: ${unknown ? 'not known yet' : value}`">{{ unknown ? "—" : shown }}</div>
|
|
7
7
|
<div class="hero-cell__ticks" aria-hidden="true">
|
|
8
8
|
<span
|
|
9
9
|
v-for="i in 20"
|
|
@@ -24,7 +24,8 @@ import { countUpValue, summaryAlert, summaryTicks } from "../../utils/robot-disp
|
|
|
24
24
|
const props = withDefaults(
|
|
25
25
|
defineProps<{
|
|
26
26
|
label: string;
|
|
27
|
-
|
|
27
|
+
/** null = not known (e.g. live counts before the first sweep): shows "—", never 0. */
|
|
28
|
+
value: number | null;
|
|
28
29
|
/** What the tick bar is a ratio of. */
|
|
29
30
|
total?: number;
|
|
30
31
|
/** "faults" / "offline" turn accent when above zero. */
|
|
@@ -35,12 +36,13 @@ const props = withDefaults(
|
|
|
35
36
|
{ total: 0, kind: "", split: "", duration: 900 },
|
|
36
37
|
);
|
|
37
38
|
|
|
39
|
+
const unknown = computed(() => typeof props.value !== "number");
|
|
38
40
|
const filled = computed(() => summaryTicks(props.value, props.total));
|
|
39
41
|
const alert = computed(() => summaryAlert(props.kind, props.value));
|
|
40
42
|
|
|
41
43
|
// The count-up and the tick reveal share one clock.
|
|
42
44
|
const elapsed = ref(0);
|
|
43
|
-
const shown = computed(() => countUpValue(props.value, elapsed.value, props.duration));
|
|
45
|
+
const shown = computed(() => countUpValue(props.value ?? 0, elapsed.value, props.duration));
|
|
44
46
|
const progress = computed(() => Math.min(1, elapsed.value / props.duration));
|
|
45
47
|
|
|
46
48
|
let frame = 0;
|
|
@@ -11,7 +11,7 @@ import RobotSummaryCell from "./SummaryCell.vue";
|
|
|
11
11
|
|
|
12
12
|
withDefaults(
|
|
13
13
|
defineProps<{
|
|
14
|
-
cells?: Array<{ label: string; value: number; total?: number; kind?: string; split?: string }>;
|
|
14
|
+
cells?: Array<{ label: string; value: number | null; total?: number; kind?: string; split?: string }>;
|
|
15
15
|
label?: string;
|
|
16
16
|
}>(),
|
|
17
17
|
{ cells: () => [], label: "Fleet summary" },
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
</template>
|
|
50
50
|
</v-data-table-server>
|
|
51
51
|
|
|
52
|
-
<div v-if="!loading && range.total" class="hero-table__foot">
|
|
52
|
+
<div v-if="!loading && range.total && (!pagedFoot || range.pages > 1)" class="hero-table__foot">
|
|
53
53
|
<span>{{ range.text }}</span>
|
|
54
54
|
<div v-if="range.pages > 1" class="hero-table__pager">
|
|
55
55
|
<v-btn variant="outlined" :disabled="!range.hasPrev" @click="emit('update:page', range.page - 1)">Prev</v-btn>
|
|
@@ -82,6 +82,8 @@ const props = withDefaults(
|
|
|
82
82
|
skeletonRows?: number;
|
|
83
83
|
/** 12.5px rows, for the Network table. */
|
|
84
84
|
compact?: boolean;
|
|
85
|
+
/** Footer ("Showing 1–25 of 60" + pager) only when there is more than one page (the site fleet). */
|
|
86
|
+
pagedFoot?: boolean;
|
|
85
87
|
}>(),
|
|
86
88
|
{
|
|
87
89
|
page: 1,
|
|
@@ -93,6 +95,7 @@ const props = withDefaults(
|
|
|
93
95
|
emptyHint: "",
|
|
94
96
|
skeletonRows: 6,
|
|
95
97
|
compact: false,
|
|
98
|
+
pagedFoot: false,
|
|
96
99
|
},
|
|
97
100
|
);
|
|
98
101
|
const emit = defineEmits<{ "update:page": [page: number] }>();
|
|
@@ -89,11 +89,29 @@
|
|
|
89
89
|
have already ticked is still selected and will still be saved.
|
|
90
90
|
</div>
|
|
91
91
|
|
|
92
|
+
<!--
|
|
93
|
+
Matched, but every match is switched off and off is hidden. A
|
|
94
|
+
blank panel would read as the search having failed, which is a
|
|
95
|
+
different thing with a different remedy.
|
|
96
|
+
-->
|
|
97
|
+
<div
|
|
98
|
+
v-else-if="!hasShownModules"
|
|
99
|
+
class="pa-6 text-center text-body-2 text-medium-emphasis"
|
|
100
|
+
>
|
|
101
|
+
Nothing is switched on yet. Show the switched-off modules to
|
|
102
|
+
start granting.
|
|
103
|
+
</div>
|
|
104
|
+
|
|
92
105
|
<template
|
|
93
106
|
v-for="(actions, resourceKey, resourceIndex) in visiblePermissions"
|
|
94
107
|
:key="resourceKey"
|
|
95
108
|
>
|
|
96
|
-
<v-divider
|
|
109
|
+
<v-divider
|
|
110
|
+
v-if="
|
|
111
|
+
isModuleShown(String(resourceKey)) &&
|
|
112
|
+
String(resourceKey) !== firstShownResource
|
|
113
|
+
"
|
|
114
|
+
/>
|
|
97
115
|
|
|
98
116
|
<!--
|
|
99
117
|
Category row. The whole row is the accordion header: one
|
|
@@ -102,6 +120,7 @@
|
|
|
102
120
|
granting a module is never confused with looking at it.
|
|
103
121
|
-->
|
|
104
122
|
<v-list-item
|
|
123
|
+
v-if="isModuleShown(String(resourceKey))"
|
|
105
124
|
density="compact"
|
|
106
125
|
:ripple="false"
|
|
107
126
|
:class="[
|
|
@@ -203,6 +222,19 @@
|
|
|
203
222
|
</div>
|
|
204
223
|
|
|
205
224
|
<div class="role-create__footer">
|
|
225
|
+
<AppButton
|
|
226
|
+
v-if="disabledModuleCount > 0 || !showDisabledModules"
|
|
227
|
+
variant="ghost"
|
|
228
|
+
class="role-create__footer-left"
|
|
229
|
+
@click="showDisabledModules = !showDisabledModules"
|
|
230
|
+
>
|
|
231
|
+
{{
|
|
232
|
+
showDisabledModules
|
|
233
|
+
? "Hide switched-off modules"
|
|
234
|
+
: `Show ${disabledModuleCount} switched-off`
|
|
235
|
+
}}
|
|
236
|
+
</AppButton>
|
|
237
|
+
|
|
206
238
|
<AppButton variant="ghost" @click="cancel">{{ props.cancelText }}</AppButton>
|
|
207
239
|
<AppButton :disabled="!validForm || disable" @click="submit">Submit</AppButton>
|
|
208
240
|
</div>
|
|
@@ -468,6 +500,7 @@ function cancel() {
|
|
|
468
500
|
name.value = "";
|
|
469
501
|
permState.value = { selected: [], enabled: [] };
|
|
470
502
|
expandedResource.value = null;
|
|
503
|
+
showDisabledModules.value = true;
|
|
471
504
|
// A query left behind would greet the next person with a filtered list and
|
|
472
505
|
// no obvious reason for it.
|
|
473
506
|
moduleSearch.value = "";
|
|
@@ -525,6 +558,46 @@ const visiblePermissions = computed(() => {
|
|
|
525
558
|
return matches;
|
|
526
559
|
});
|
|
527
560
|
|
|
561
|
+
/*
|
|
562
|
+
* HIDING THE MODULES THIS ROLE DOES NOT TOUCH -- the same button the update
|
|
563
|
+
* dialog carries.
|
|
564
|
+
*
|
|
565
|
+
* DEFAULTS THE OTHER WAY HERE, and deliberately. A role being CREATED has
|
|
566
|
+
* nothing switched on, so hiding the switched-off modules would open this
|
|
567
|
+
* dialog on an empty list and put a click between the user and the only thing
|
|
568
|
+
* they came to do. Reading an existing role is the opposite case: the four
|
|
569
|
+
* granted modules are the point and the other 27 are noise.
|
|
570
|
+
*
|
|
571
|
+
* PURELY WHAT IS DRAWN. `visiblePermissions` -- not this -- is what Select All
|
|
572
|
+
* and `isAllSelected` act on, so hiding a row never changes what a click grants
|
|
573
|
+
* and never changes what is saved.
|
|
574
|
+
*/
|
|
575
|
+
const showDisabledModules = ref(true);
|
|
576
|
+
|
|
577
|
+
function isModuleShown(resource: string) {
|
|
578
|
+
return showDisabledModules.value || isCategoryEnabled(resource);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
/** The modules actually drawn, in order -- so the divider knows which is first. */
|
|
582
|
+
const shownResources = computed(() =>
|
|
583
|
+
Object.keys(visiblePermissions.value).filter((resource) =>
|
|
584
|
+
isModuleShown(resource)
|
|
585
|
+
)
|
|
586
|
+
);
|
|
587
|
+
|
|
588
|
+
const firstShownResource = computed(() => shownResources.value[0] ?? "");
|
|
589
|
+
|
|
590
|
+
const hasShownModules = computed(() => shownResources.value.length > 0);
|
|
591
|
+
|
|
592
|
+
const disabledModuleCount = computed(
|
|
593
|
+
() =>
|
|
594
|
+
Object.keys(visiblePermissions.value).filter(
|
|
595
|
+
(resource) => !isCategoryEnabled(resource)
|
|
596
|
+
).length
|
|
597
|
+
);
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
|
|
528
601
|
const hasVisiblePermissions = computed(
|
|
529
602
|
() => Object.keys(visiblePermissions.value).length > 0
|
|
530
603
|
);
|
|
@@ -627,6 +700,10 @@ const isAllSelected = computed(() => {
|
|
|
627
700
|
/* The design's dialog footer. Deliberately not the shared
|
|
628
701
|
`.screen-modal__footer` - that class is on the batch-D branch (#1150), not
|
|
629
702
|
on this base, and a second copy in `screens.css` would collide with it. */
|
|
703
|
+
.role-create__footer-left {
|
|
704
|
+
margin-right: auto;
|
|
705
|
+
}
|
|
706
|
+
|
|
630
707
|
.role-create__footer {
|
|
631
708
|
display: flex;
|
|
632
709
|
justify-content: flex-end;
|
|
@@ -53,11 +53,29 @@
|
|
|
53
53
|
role already holds is untouched and will still be saved.
|
|
54
54
|
</div>
|
|
55
55
|
|
|
56
|
+
<!--
|
|
57
|
+
Matched, but every match is switched off and off is hidden. A
|
|
58
|
+
blank panel here would read as the search having failed, which
|
|
59
|
+
is a different thing and has a different remedy.
|
|
60
|
+
-->
|
|
61
|
+
<div
|
|
62
|
+
v-else-if="!hasShownModules"
|
|
63
|
+
class="pa-6 text-center text-body-2 text-medium-emphasis"
|
|
64
|
+
>
|
|
65
|
+
This role grants nothing here yet. Show the switched-off modules
|
|
66
|
+
to grant one.
|
|
67
|
+
</div>
|
|
68
|
+
|
|
56
69
|
<template
|
|
57
70
|
v-for="(actions, resourceKey, resourceIndex) in visiblePermissions"
|
|
58
71
|
:key="resourceKey"
|
|
59
72
|
>
|
|
60
|
-
<v-divider
|
|
73
|
+
<v-divider
|
|
74
|
+
v-if="
|
|
75
|
+
isModuleShown(String(resourceKey)) &&
|
|
76
|
+
String(resourceKey) !== firstShownResource
|
|
77
|
+
"
|
|
78
|
+
/>
|
|
61
79
|
<!--
|
|
62
80
|
The whole row is the accordion header: one module is open at
|
|
63
81
|
a time, so clicking this one closes whichever was open. The
|
|
@@ -66,6 +84,7 @@
|
|
|
66
84
|
mode works the same way, without the switch being live.
|
|
67
85
|
-->
|
|
68
86
|
<v-list-item
|
|
87
|
+
v-if="isModuleShown(String(resourceKey))"
|
|
69
88
|
density="compact"
|
|
70
89
|
:ripple="false"
|
|
71
90
|
:class="[
|
|
@@ -207,6 +226,19 @@
|
|
|
207
226
|
</div>
|
|
208
227
|
|
|
209
228
|
<div class="role-perm__footer">
|
|
229
|
+
<AppButton
|
|
230
|
+
v-if="disabledModuleCount > 0 || showDisabledModules"
|
|
231
|
+
variant="ghost"
|
|
232
|
+
class="role-perm__footer-left"
|
|
233
|
+
@click="showDisabledModules = !showDisabledModules"
|
|
234
|
+
>
|
|
235
|
+
{{
|
|
236
|
+
showDisabledModules
|
|
237
|
+
? "Hide switched-off modules"
|
|
238
|
+
: `Show ${disabledModuleCount} switched-off`
|
|
239
|
+
}}
|
|
240
|
+
</AppButton>
|
|
241
|
+
|
|
210
242
|
<AppButton v-if="!edit" variant="ghost" @click="emit('cancel')">Close</AppButton>
|
|
211
243
|
<AppButton v-else variant="ghost" @click="cancelEdit()">Cancel</AppButton>
|
|
212
244
|
|
|
@@ -480,6 +512,43 @@ const sortedNotOffered = computed(() =>
|
|
|
480
512
|
sortResourcesByLabel(props.notOfferedPermissions as Record<string, any>)
|
|
481
513
|
);
|
|
482
514
|
|
|
515
|
+
/*
|
|
516
|
+
* HIDING THE MODULES THIS ROLE DOES NOT TOUCH.
|
|
517
|
+
*
|
|
518
|
+
* 31 modules, four of them granted: the 27 greyed rows were the bulk of the
|
|
519
|
+
* scroll and none of them said anything. Off is hidden by default and the
|
|
520
|
+
* footer button brings them back.
|
|
521
|
+
*
|
|
522
|
+
* PURELY WHAT IS DRAWN. `visiblePermissions` -- not this -- is what Select All
|
|
523
|
+
* and `isAllSelected` act on, so hiding a row never changes what a click grants
|
|
524
|
+
* and never changes what is saved.
|
|
525
|
+
*/
|
|
526
|
+
const showDisabledModules = ref(false);
|
|
527
|
+
|
|
528
|
+
function isModuleShown(resource: string) {
|
|
529
|
+
return showDisabledModules.value || isCategoryEnabled(resource);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/** The modules actually drawn, in order -- so the divider knows which is first. */
|
|
533
|
+
const shownResources = computed(() =>
|
|
534
|
+
Object.keys(visiblePermissions.value).filter((resource) =>
|
|
535
|
+
isModuleShown(resource)
|
|
536
|
+
)
|
|
537
|
+
);
|
|
538
|
+
|
|
539
|
+
const firstShownResource = computed(() => shownResources.value[0] ?? "");
|
|
540
|
+
|
|
541
|
+
const hasShownModules = computed(() => shownResources.value.length > 0);
|
|
542
|
+
|
|
543
|
+
const disabledModuleCount = computed(
|
|
544
|
+
() =>
|
|
545
|
+
Object.keys(visiblePermissions.value).filter(
|
|
546
|
+
(resource) => !isCategoryEnabled(resource)
|
|
547
|
+
).length
|
|
548
|
+
);
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
|
|
483
552
|
const hasNotOffered = computed(
|
|
484
553
|
() => Object.keys(props.notOfferedPermissions || {}).length > 0
|
|
485
554
|
);
|
|
@@ -488,7 +557,13 @@ const hasVisiblePermissions = computed(
|
|
|
488
557
|
() => Object.keys(visiblePermissions.value).length > 0
|
|
489
558
|
);
|
|
490
559
|
|
|
491
|
-
/**
|
|
560
|
+
/**
|
|
561
|
+
* The `resource:action` keys the search matched -- NOT the subset currently
|
|
562
|
+
* drawn. Hiding the switched-off modules is a view convenience; Select All
|
|
563
|
+
* still means every module the query matched, or the whole catalogue with no
|
|
564
|
+
* query. Tying it to the drawn subset would make Select All a no-op exactly
|
|
565
|
+
* when it is most useful.
|
|
566
|
+
*/
|
|
492
567
|
const visibleKeys = computed(() =>
|
|
493
568
|
Object.entries(visiblePermissions.value).flatMap(([resource, actions]) =>
|
|
494
569
|
Object.keys((actions as Record<string, unknown>) || {}).map(
|
|
@@ -564,6 +639,8 @@ function cancelEdit() {
|
|
|
564
639
|
function resetExpansion() {
|
|
565
640
|
expandedResources.value = [];
|
|
566
641
|
expandedResource.value = null;
|
|
642
|
+
// Back to the quiet default: the next role is read before it is edited.
|
|
643
|
+
showDisabledModules.value = false;
|
|
567
644
|
}
|
|
568
645
|
|
|
569
646
|
// Reopening the dialog on another role must not inherit the last one's open
|
|
@@ -691,6 +768,10 @@ async function submit() {
|
|
|
691
768
|
/* The design's dialog footer. Deliberately not the shared
|
|
692
769
|
`.screen-modal__footer` - that class is on the batch-D branch (#1150), not
|
|
693
770
|
on this base, and a second copy in `screens.css` would collide with it. */
|
|
771
|
+
.role-perm__footer-left {
|
|
772
|
+
margin-right: auto;
|
|
773
|
+
}
|
|
774
|
+
|
|
694
775
|
.role-perm__footer {
|
|
695
776
|
display: flex;
|
|
696
777
|
justify-content: flex-end;
|