@7365admin1/layer-common 4.28.1-staging.358 → 4.28.1-staging.360
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/assets/css/robot-hero.css +466 -0
- package/components/Robot/Battery.vue +18 -0
- package/components/Robot/CapabilityTag.vue +14 -0
- package/components/Robot/Card.vue +56 -0
- package/components/Robot/CommandBar.vue +47 -0
- package/components/Robot/CredentialField.vue +37 -0
- package/components/Robot/FaultBadge.vue +26 -0
- package/components/Robot/FloorLabel.vue +12 -0
- package/components/Robot/Hero.vue +32 -0
- package/components/Robot/LiftQueueRow.vue +28 -0
- package/components/Robot/MapToolbar.vue +53 -0
- package/components/Robot/NoMonitoring.vue +14 -0
- package/components/Robot/Reconnecting.vue +7 -0
- package/components/Robot/StatusChip.vue +15 -0
- package/components/Robot/SummaryCell.vue +64 -0
- package/components/Robot/SummaryStrip.vue +19 -0
- package/components/Robot/Table.vue +115 -0
- package/components/Robot/Toast.vue +27 -0
- package/components/Robot/ViewOnlyNotice.vue +3 -0
- package/components/RolePermissionFormCreate.vue +78 -1
- package/components/RolePermissionFormPreviewUpdate.vue +83 -2
- package/components/VehicleManagement.vue +150 -10
- package/package.json +1 -1
- package/plugins/API.ts +7 -2
- package/plugins/vuetify.ts +8 -1
- package/types/vehicle.d.ts +11 -0
- package/utils/permission-refusal.ts +40 -0
- package/utils/robot-display.ts +304 -0
- package/utils/theme.ts +152 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!--
|
|
3
|
+
The HERO scope. Everything inside draws in the robot fleet's look
|
|
4
|
+
(Archivo, square corners, red accent); nothing outside changes. The theme
|
|
5
|
+
follows the app's own light/dark setting.
|
|
6
|
+
-->
|
|
7
|
+
<v-theme-provider :theme="themeName" with-background class="hero">
|
|
8
|
+
<slot />
|
|
9
|
+
</v-theme-provider>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup lang="ts">
|
|
13
|
+
import { computed, onMounted } from "vue";
|
|
14
|
+
import { useTheme } from "vuetify";
|
|
15
|
+
import { heroThemeName } from "../../utils/robot-display";
|
|
16
|
+
import "../../assets/css/robot-hero.css";
|
|
17
|
+
|
|
18
|
+
const theme = useTheme();
|
|
19
|
+
const themeName = computed(() => heroThemeName(theme.current.value.dark));
|
|
20
|
+
|
|
21
|
+
// Archivo is requested the first time a HERO scope mounts, so the rest of the
|
|
22
|
+
// product never downloads it (Manrope stays in nuxt.config for everything else).
|
|
23
|
+
const FONT_ID = "hero-archivo-font";
|
|
24
|
+
onMounted(() => {
|
|
25
|
+
if (document.getElementById(FONT_ID)) return;
|
|
26
|
+
const link = document.createElement("link");
|
|
27
|
+
link.id = FONT_ID;
|
|
28
|
+
link.rel = "stylesheet";
|
|
29
|
+
link.href = "https://fonts.googleapis.com/css2?family=Archivo:wght@400;600;800&display=swap";
|
|
30
|
+
document.head.appendChild(link);
|
|
31
|
+
});
|
|
32
|
+
</script>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="hero-lift-row">
|
|
3
|
+
<span class="hero-lift-row__n">{{ n }}</span>
|
|
4
|
+
<div>
|
|
5
|
+
<b>{{ robot }}</b><span class="hero-lift-row__route"> · {{ from }} → {{ to }}</span>
|
|
6
|
+
</div>
|
|
7
|
+
<span class="hero-lift-row__wait">{{ wait }}</span>
|
|
8
|
+
<span class="hero-chip" :class="`hero-tone--${ls.tone}`">{{ ls.label }}</span>
|
|
9
|
+
<span v-if="ls.stripe !== 'none'" class="hero-lift-row__stripe" :class="`hero-lift-row__stripe--${ls.stripe}`" aria-hidden="true" />
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup lang="ts">
|
|
14
|
+
import { computed } from "vue";
|
|
15
|
+
import { liftState } from "../../utils/robot-display";
|
|
16
|
+
|
|
17
|
+
const props = defineProps<{
|
|
18
|
+
n: number | string;
|
|
19
|
+
robot: string;
|
|
20
|
+
from: string;
|
|
21
|
+
to: string;
|
|
22
|
+
/** Already formatted: "24 s", "on board", "done". */
|
|
23
|
+
wait?: string;
|
|
24
|
+
/** requested · riding · released · timed out */
|
|
25
|
+
state: string;
|
|
26
|
+
}>();
|
|
27
|
+
const ls = computed(() => liftState(props.state));
|
|
28
|
+
</script>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="hero-maptools">
|
|
3
|
+
<div class="hero-seg" role="toolbar" aria-label="Map editor tools">
|
|
4
|
+
<button
|
|
5
|
+
v-for="t in MAP_TOOLS"
|
|
6
|
+
:key="t.id"
|
|
7
|
+
type="button"
|
|
8
|
+
class="hero-seg__opt"
|
|
9
|
+
:aria-pressed="modelValue === t.id"
|
|
10
|
+
@click="emit('update:modelValue', t.id)"
|
|
11
|
+
>
|
|
12
|
+
{{ t.label }}
|
|
13
|
+
</button>
|
|
14
|
+
<button type="button" class="hero-seg__opt hero-seg__opt--gap" :disabled="!canUndo" @click="emit('undo')">
|
|
15
|
+
Undo ⌃Z
|
|
16
|
+
</button>
|
|
17
|
+
<button type="button" class="hero-seg__opt hero-seg__opt--save" :disabled="saving" @click="emit('save')">
|
|
18
|
+
Save
|
|
19
|
+
</button>
|
|
20
|
+
</div>
|
|
21
|
+
<div v-if="modelValue === 'zone'" class="hero-field">
|
|
22
|
+
<input
|
|
23
|
+
class="hero-input"
|
|
24
|
+
style="width: 180px"
|
|
25
|
+
aria-label="Zone name"
|
|
26
|
+
placeholder="Zone name"
|
|
27
|
+
:value="zoneName"
|
|
28
|
+
@input="emit('update:zoneName', ($event.target as HTMLInputElement).value)"
|
|
29
|
+
/>
|
|
30
|
+
</div>
|
|
31
|
+
</div>
|
|
32
|
+
</template>
|
|
33
|
+
|
|
34
|
+
<script setup lang="ts">
|
|
35
|
+
import { MAP_TOOLS } from "../../utils/robot-display";
|
|
36
|
+
|
|
37
|
+
withDefaults(
|
|
38
|
+
defineProps<{
|
|
39
|
+
/** The active tool id: wall · zone · door · lift · move · delete. */
|
|
40
|
+
modelValue?: string;
|
|
41
|
+
zoneName?: string;
|
|
42
|
+
canUndo?: boolean;
|
|
43
|
+
saving?: boolean;
|
|
44
|
+
}>(),
|
|
45
|
+
{ modelValue: "wall", zoneName: "", canUndo: true, saving: false },
|
|
46
|
+
);
|
|
47
|
+
const emit = defineEmits<{
|
|
48
|
+
"update:modelValue": [tool: string];
|
|
49
|
+
"update:zoneName": [name: string];
|
|
50
|
+
undo: [];
|
|
51
|
+
save: [];
|
|
52
|
+
}>();
|
|
53
|
+
</script>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!-- A no-interface brand: listed with its details, no live status, no controls. -->
|
|
3
|
+
<div class="hero-notice hero-notice--panel" role="note">
|
|
4
|
+
<div class="hero-notice__title">Monitoring not available for this model</div>
|
|
5
|
+
<div class="hero-notice__body">
|
|
6
|
+
<template v-if="brandName">{{ brandName }}<template v-if="model"> · {{ model }}</template> has no interface yet. </template>
|
|
7
|
+
Details are listed; live status and commands will appear when the brand integration ships.
|
|
8
|
+
</div>
|
|
9
|
+
</div>
|
|
10
|
+
</template>
|
|
11
|
+
|
|
12
|
+
<script setup lang="ts">
|
|
13
|
+
defineProps<{ brandName?: string; model?: string }>();
|
|
14
|
+
</script>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span class="hero-chip" :class="`hero-tone--${status.tone}`">
|
|
3
|
+
<span class="hero-chip__dot" :class="{ 'hero-chip__dot--blink': status.blink }" aria-hidden="true" />
|
|
4
|
+
{{ status.label }}
|
|
5
|
+
</span>
|
|
6
|
+
</template>
|
|
7
|
+
|
|
8
|
+
<script setup lang="ts">
|
|
9
|
+
import { computed } from "vue";
|
|
10
|
+
import { robotStatus } from "../../utils/robot-display";
|
|
11
|
+
|
|
12
|
+
/** `mode` is the API's state mode; `type` "security" turns Working into Patrolling. */
|
|
13
|
+
const props = defineProps<{ mode?: unknown; type?: string }>();
|
|
14
|
+
const status = computed(() => robotStatus(props.mode, props.type));
|
|
15
|
+
</script>
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="hero-cell" :class="{ 'hero-cell--alert': alert }">
|
|
3
|
+
<span class="hero-cell__corner hero-cell__corner--tl" aria-hidden="true" />
|
|
4
|
+
<span class="hero-cell__corner hero-cell__corner--br" aria-hidden="true" />
|
|
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>
|
|
7
|
+
<div class="hero-cell__ticks" aria-hidden="true">
|
|
8
|
+
<span
|
|
9
|
+
v-for="i in 20"
|
|
10
|
+
:key="i"
|
|
11
|
+
class="hero-cell__tick"
|
|
12
|
+
:class="{ 'hero-cell__tick--on': i <= filled, 'hero-cell__tick--shown': i <= filled && progress >= i / 20 }"
|
|
13
|
+
/>
|
|
14
|
+
</div>
|
|
15
|
+
<div v-if="split" class="hero-cell__split">{{ split }}</div>
|
|
16
|
+
<span class="hero-cell__shimmer" aria-hidden="true" />
|
|
17
|
+
</div>
|
|
18
|
+
</template>
|
|
19
|
+
|
|
20
|
+
<script setup lang="ts">
|
|
21
|
+
import { computed, onBeforeUnmount, onMounted, ref, watch } from "vue";
|
|
22
|
+
import { countUpValue, summaryAlert, summaryTicks } from "../../utils/robot-display";
|
|
23
|
+
|
|
24
|
+
const props = withDefaults(
|
|
25
|
+
defineProps<{
|
|
26
|
+
label: string;
|
|
27
|
+
value: number;
|
|
28
|
+
/** What the tick bar is a ratio of. */
|
|
29
|
+
total?: number;
|
|
30
|
+
/** "faults" / "offline" turn accent when above zero. */
|
|
31
|
+
kind?: string;
|
|
32
|
+
split?: string;
|
|
33
|
+
duration?: number;
|
|
34
|
+
}>(),
|
|
35
|
+
{ total: 0, kind: "", split: "", duration: 900 },
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const filled = computed(() => summaryTicks(props.value, props.total));
|
|
39
|
+
const alert = computed(() => summaryAlert(props.kind, props.value));
|
|
40
|
+
|
|
41
|
+
// The count-up and the tick reveal share one clock.
|
|
42
|
+
const elapsed = ref(0);
|
|
43
|
+
const shown = computed(() => countUpValue(props.value, elapsed.value, props.duration));
|
|
44
|
+
const progress = computed(() => Math.min(1, elapsed.value / props.duration));
|
|
45
|
+
|
|
46
|
+
let frame = 0;
|
|
47
|
+
function run() {
|
|
48
|
+
cancelAnimationFrame(frame);
|
|
49
|
+
if (window.matchMedia?.("(prefers-reduced-motion: reduce)").matches) {
|
|
50
|
+
elapsed.value = props.duration;
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const start = performance.now();
|
|
54
|
+
elapsed.value = 0;
|
|
55
|
+
const step = (now: number) => {
|
|
56
|
+
elapsed.value = now - start;
|
|
57
|
+
if (elapsed.value < props.duration) frame = requestAnimationFrame(step);
|
|
58
|
+
};
|
|
59
|
+
frame = requestAnimationFrame(step);
|
|
60
|
+
}
|
|
61
|
+
onMounted(run);
|
|
62
|
+
watch(() => props.value, run);
|
|
63
|
+
onBeforeUnmount(() => cancelAnimationFrame(frame));
|
|
64
|
+
</script>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="hero-summary" role="group" :aria-label="label">
|
|
3
|
+
<slot>
|
|
4
|
+
<RobotSummaryCell v-for="c in cells" :key="c.label" v-bind="c" />
|
|
5
|
+
</slot>
|
|
6
|
+
</div>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script setup lang="ts">
|
|
10
|
+
import RobotSummaryCell from "./SummaryCell.vue";
|
|
11
|
+
|
|
12
|
+
withDefaults(
|
|
13
|
+
defineProps<{
|
|
14
|
+
cells?: Array<{ label: string; value: number; total?: number; kind?: string; split?: string }>;
|
|
15
|
+
label?: string;
|
|
16
|
+
}>(),
|
|
17
|
+
{ cells: () => [], label: "Fleet summary" },
|
|
18
|
+
);
|
|
19
|
+
</script>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<!--
|
|
3
|
+
The robot table: server-side pages (never every robot at once), sortable
|
|
4
|
+
columns, optional grouping, skeleton rows while loading and a plain empty
|
|
5
|
+
state. Every v-data-table-server prop, event and item slot passes through.
|
|
6
|
+
-->
|
|
7
|
+
<div class="hero-table" :class="{ 'hero-table--compact': compact }">
|
|
8
|
+
<v-data-table-server
|
|
9
|
+
v-bind="$attrs"
|
|
10
|
+
:headers="columns"
|
|
11
|
+
:items="loading ? [] : items"
|
|
12
|
+
:items-length="itemsLength"
|
|
13
|
+
:page="range.page"
|
|
14
|
+
:items-per-page="itemsPerPage"
|
|
15
|
+
:loading="loading"
|
|
16
|
+
:group-by="groupBy"
|
|
17
|
+
hide-default-footer
|
|
18
|
+
@update:page="emit('update:page', $event)"
|
|
19
|
+
>
|
|
20
|
+
<template v-for="name in passSlots" #[name]="scope">
|
|
21
|
+
<slot :name="name" v-bind="scope ?? {}" />
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<template #loading>
|
|
25
|
+
<div class="hero-skel" aria-label="Loading robots">
|
|
26
|
+
<div v-for="i in skeletonRows" :key="i" class="hero-skel__row" />
|
|
27
|
+
</div>
|
|
28
|
+
</template>
|
|
29
|
+
|
|
30
|
+
<template #no-data>
|
|
31
|
+
<slot name="no-data">
|
|
32
|
+
<div class="hero-empty">
|
|
33
|
+
<div class="hero-empty__title">{{ emptyTitle }}</div>
|
|
34
|
+
<div v-if="emptyHint" class="hero-empty__hint">{{ emptyHint }}</div>
|
|
35
|
+
</div>
|
|
36
|
+
</slot>
|
|
37
|
+
</template>
|
|
38
|
+
|
|
39
|
+
<template #group-header="scope">
|
|
40
|
+
<slot name="group-header" v-bind="scope">
|
|
41
|
+
<tr class="hero-table__group" @vue:mounted="openOnMount(scope)">
|
|
42
|
+
<td :colspan="scope.columns.length">
|
|
43
|
+
<button type="button" :aria-expanded="scope.isGroupOpen(scope.item)" @click="scope.toggleGroup(scope.item)">
|
|
44
|
+
{{ scope.item.value }} <span class="hero-muted">· {{ scope.item.items.length }} {{ noun }}</span>
|
|
45
|
+
</button>
|
|
46
|
+
</td>
|
|
47
|
+
</tr>
|
|
48
|
+
</slot>
|
|
49
|
+
</template>
|
|
50
|
+
</v-data-table-server>
|
|
51
|
+
|
|
52
|
+
<div v-if="!loading && range.total" class="hero-table__foot">
|
|
53
|
+
<span>{{ range.text }}</span>
|
|
54
|
+
<div v-if="range.pages > 1" class="hero-table__pager">
|
|
55
|
+
<v-btn variant="outlined" :disabled="!range.hasPrev" @click="emit('update:page', range.page - 1)">Prev</v-btn>
|
|
56
|
+
<v-btn variant="outlined" :disabled="!range.hasNext" @click="emit('update:page', range.page + 1)">Next</v-btn>
|
|
57
|
+
</div>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
</template>
|
|
61
|
+
|
|
62
|
+
<script setup lang="ts">
|
|
63
|
+
import { computed, useSlots } from "vue";
|
|
64
|
+
import { pageRange } from "../../utils/robot-display";
|
|
65
|
+
|
|
66
|
+
defineOptions({ inheritAttrs: false });
|
|
67
|
+
|
|
68
|
+
const props = withDefaults(
|
|
69
|
+
defineProps<{
|
|
70
|
+
headers: any[];
|
|
71
|
+
items: any[];
|
|
72
|
+
/** The server's total, not the page's length. */
|
|
73
|
+
itemsLength: number;
|
|
74
|
+
/** 1-based, like Vuetify. */
|
|
75
|
+
page?: number;
|
|
76
|
+
itemsPerPage?: number;
|
|
77
|
+
loading?: boolean;
|
|
78
|
+
groupBy?: Array<{ key: string; order?: "asc" | "desc" }>;
|
|
79
|
+
noun?: string;
|
|
80
|
+
emptyTitle?: string;
|
|
81
|
+
emptyHint?: string;
|
|
82
|
+
skeletonRows?: number;
|
|
83
|
+
/** 12.5px rows, for the Network table. */
|
|
84
|
+
compact?: boolean;
|
|
85
|
+
}>(),
|
|
86
|
+
{
|
|
87
|
+
page: 1,
|
|
88
|
+
itemsPerPage: 25,
|
|
89
|
+
loading: false,
|
|
90
|
+
groupBy: () => [],
|
|
91
|
+
noun: "robots",
|
|
92
|
+
emptyTitle: "No robots match",
|
|
93
|
+
emptyHint: "",
|
|
94
|
+
skeletonRows: 6,
|
|
95
|
+
compact: false,
|
|
96
|
+
},
|
|
97
|
+
);
|
|
98
|
+
const emit = defineEmits<{ "update:page": [page: number] }>();
|
|
99
|
+
|
|
100
|
+
const OWN = new Set(["loading", "no-data", "group-header"]);
|
|
101
|
+
const slots = useSlots();
|
|
102
|
+
const passSlots = computed(() => Object.keys(slots).filter((n) => !OWN.has(n)));
|
|
103
|
+
|
|
104
|
+
// Vuetify adds its own "Group" column when grouping; the handoff has none, so
|
|
105
|
+
// an empty, zero-width one is supplied in its place.
|
|
106
|
+
const GROUP_COL = { key: "data-table-group", title: "", sortable: false, headerProps: { class: "hero-table__groupcol" }, cellProps: { class: "hero-table__groupcol" } };
|
|
107
|
+
const columns = computed(() => (props.groupBy.length ? [GROUP_COL, ...props.headers] : props.headers));
|
|
108
|
+
|
|
109
|
+
// The handoff lists grouped rows under their header, so a group starts open.
|
|
110
|
+
function openOnMount(scope: any) {
|
|
111
|
+
if (!scope.isGroupOpen(scope.item)) scope.toggleGroup(scope.item);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const range = computed(() => pageRange(props.page, props.itemsPerPage, props.itemsLength, props.noun));
|
|
115
|
+
</script>
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div v-if="modelValue" class="hero-toast" role="status" aria-live="polite">
|
|
3
|
+
<span class="hero-toast__square" aria-hidden="true" />{{ modelValue }}
|
|
4
|
+
</div>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup lang="ts">
|
|
8
|
+
import { onBeforeUnmount, watch } from "vue";
|
|
9
|
+
|
|
10
|
+
/** The message; the toast clears it after `timeout` ms (2.6s, the handoff's). */
|
|
11
|
+
const props = withDefaults(defineProps<{ modelValue?: string; timeout?: number }>(), {
|
|
12
|
+
modelValue: "",
|
|
13
|
+
timeout: 2600,
|
|
14
|
+
});
|
|
15
|
+
const emit = defineEmits<{ "update:modelValue": [value: string] }>();
|
|
16
|
+
|
|
17
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
18
|
+
watch(
|
|
19
|
+
() => props.modelValue,
|
|
20
|
+
(msg) => {
|
|
21
|
+
clearTimeout(timer);
|
|
22
|
+
if (msg && props.timeout > 0) timer = setTimeout(() => emit("update:modelValue", ""), props.timeout);
|
|
23
|
+
},
|
|
24
|
+
{ immediate: true },
|
|
25
|
+
);
|
|
26
|
+
onBeforeUnmount(() => clearTimeout(timer));
|
|
27
|
+
</script>
|
|
@@ -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;
|