@quazardous/qdadm 2.52.0 → 2.54.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/dist/node/cards/tools/cardsTool.js +2 -1
- package/dist/styles/qdadm.css +1 -1
- package/package.json +1 -1
- package/src/cards/QdCard.vue +4 -0
- package/src/cards/QdCardView.vue +7 -2
- package/src/cards/QdFavoritesCard.vue +73 -14
- package/src/cards/builtin/agenda/meta.json +1 -0
- package/src/cards/builtin/cards-index.json +19 -1
- package/src/cards/builtin/favorites/FavoritesCard.vue +69 -10
- package/src/cards/builtin/favorites/meta.json +4 -2
- package/src/cards/builtin/favorites/schema.json +3 -1
- package/src/cards/builtin/feed/meta.json +1 -0
- package/src/cards/builtin/index.ts +6 -5
- package/src/cards/builtin/pills.ts +36 -0
- package/src/cards/builtin/queue/meta.json +1 -0
- package/src/cards/builtin/recent/meta.json +1 -0
- package/src/cards/index.ts +1 -0
- package/src/cards/tools/cardsTool.ts +2 -1
- package/src/cards/types.ts +16 -0
- package/src/components/edit/FormPage.vue +1 -1
- package/src/components/layout/AppLayout.vue +4 -0
- package/src/components/layout/BaseLayout.vue +4 -0
- package/src/components/layout/PageHeader.vue +8 -0
- package/src/components/show/ShowPage.vue +1 -1
- package/src/domain/QdBadge.vue +36 -0
- package/src/domain/QdDomainBar.vue +213 -0
- package/src/domain/QdDomainBarZone.vue +19 -0
- package/src/domain/index.ts +6 -0
- package/src/domain/registry.ts +122 -0
- package/src/i18n/defaults/core.en.generated.ts +14 -0
- package/src/i18n/defaults/core.en.yml +14 -0
- package/src/i18n/defaults/core.fr.generated.ts +14 -0
- package/src/i18n/defaults/core.fr.yml +14 -0
- package/src/index.ts +1 -0
- package/src/kernel/KernelContext.routing.ts +10 -1
- package/src/kernel/KernelContext.ts +7 -0
- package/src/kernel/KernelContext.types.ts +2 -0
- package/src/module/moduleRegistry.ts +4 -0
- package/src/styles/_qd-cards.scss +93 -0
- package/src/styles/_qd-domain-bar.scss +159 -0
- package/src/styles/index.scss +1 -0
package/src/cards/QdCardView.vue
CHANGED
|
@@ -21,8 +21,10 @@ const props = withDefaults(
|
|
|
21
21
|
envelope: CardEnvelope
|
|
22
22
|
data?: unknown
|
|
23
23
|
options?: Record<string, unknown>
|
|
24
|
+
/** Listeners for the body's own events (a favourite removed…) */
|
|
25
|
+
on?: Record<string, (...args: never[]) => unknown>
|
|
24
26
|
}>(),
|
|
25
|
-
{ data: undefined, options: () => ({}) }
|
|
27
|
+
{ data: undefined, options: () => ({}), on: () => ({}) }
|
|
26
28
|
)
|
|
27
29
|
|
|
28
30
|
const definition = computed(() => getCard(props.type))
|
|
@@ -37,6 +39,8 @@ const problems = computed<SchemaProblem[]>(() => {
|
|
|
37
39
|
|
|
38
40
|
const shownState = computed(() => (problems.value.length ? 'invalid' : state.value))
|
|
39
41
|
const options = computed(() => (definition.value ? resolveCardOptions(definition.value.meta, props.options) : {}))
|
|
42
|
+
// The envelope's icon, else the type's; `null` or '' says none
|
|
43
|
+
const icon = computed(() => (props.envelope.icon !== undefined ? props.envelope.icon || null : definition.value?.meta.icon ?? null))
|
|
40
44
|
const size = computed(() => props.envelope.size ?? definition.value?.meta.sizes[0] ?? 's')
|
|
41
45
|
</script>
|
|
42
46
|
|
|
@@ -44,10 +48,11 @@ const size = computed(() => props.envelope.size ?? definition.value?.meta.sizes[
|
|
|
44
48
|
<QdCard
|
|
45
49
|
v-bind="envelope"
|
|
46
50
|
:size="size"
|
|
51
|
+
:icon="icon"
|
|
47
52
|
:state="shownState"
|
|
48
53
|
:problems="problems"
|
|
49
54
|
:data-card-type="type"
|
|
50
55
|
>
|
|
51
|
-
<component :is="definition!.component" v-if="definition" :data="data" :options="options" :size="size" />
|
|
56
|
+
<component :is="definition!.component" v-if="definition" :data="data" :options="options" :size="size" v-on="on" />
|
|
52
57
|
</QdCard>
|
|
53
58
|
</template>
|
|
@@ -4,34 +4,83 @@
|
|
|
4
4
|
* a page header, a search saved, show here at once.
|
|
5
5
|
*
|
|
6
6
|
* ctx.block(DASHBOARD_ZONES.WIDGETS, { id: 'favorites', component: QdFavoritesCard, card: { title: 'Favourites' } })
|
|
7
|
+
*
|
|
8
|
+
* A × beside each line removes it (#5392), at once; the line stays a few
|
|
9
|
+
* seconds where it was, saying so, with an Undo that adds it back.
|
|
10
|
+
* Renaming and ordering are the app's to offer: `useFavorites().rename`.
|
|
7
11
|
*/
|
|
8
|
-
import { computed, onMounted } from 'vue'
|
|
12
|
+
import { computed, onBeforeUnmount, onMounted, ref } from 'vue'
|
|
9
13
|
import QdCardView from './QdCardView.vue'
|
|
10
14
|
import { useI18n } from '../i18n/useI18n'
|
|
11
15
|
import { useFavorites } from '../favorites/useFavorites'
|
|
16
|
+
import type { Favorite } from '../favorites/store'
|
|
12
17
|
import type { CardSize } from './types'
|
|
13
18
|
|
|
14
|
-
const props = withDefaults(
|
|
15
|
-
title
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
const props = withDefaults(
|
|
20
|
+
defineProps<{ title?: string | null; size?: CardSize; maxItems?: number; groupByKind?: boolean; removable?: boolean; icon?: string | null }>(),
|
|
21
|
+
{
|
|
22
|
+
title: null,
|
|
23
|
+
size: 's',
|
|
24
|
+
maxItems: 8,
|
|
25
|
+
groupByKind: true,
|
|
26
|
+
removable: true,
|
|
27
|
+
icon: undefined,
|
|
28
|
+
}
|
|
29
|
+
)
|
|
20
30
|
const { tOr } = useI18n()
|
|
21
31
|
const favorites = useFavorites()
|
|
22
32
|
// Read again when it shows: another tab or a page may have changed them
|
|
23
33
|
onMounted(() => void favorites.reload())
|
|
24
34
|
|
|
35
|
+
/** How long a removed line stays, with its Undo */
|
|
36
|
+
const UNDO_MS = 8000
|
|
37
|
+
|
|
38
|
+
// The lines just removed: where they were in the list, until their Undo goes
|
|
39
|
+
interface Removed {
|
|
40
|
+
fav: Favorite
|
|
41
|
+
index: number
|
|
42
|
+
timer: ReturnType<typeof setTimeout>
|
|
43
|
+
}
|
|
44
|
+
const removed = ref<Removed[]>([])
|
|
45
|
+
|
|
46
|
+
function drop(id: string): void {
|
|
47
|
+
const r = removed.value.find((x) => x.fav.id === id)
|
|
48
|
+
if (r) clearTimeout(r.timer)
|
|
49
|
+
removed.value = removed.value.filter((x) => x.fav.id !== id)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async function onRemove(id: string): Promise<void> {
|
|
53
|
+
const shown = [...favorites.list.value].reverse()
|
|
54
|
+
const index = shown.findIndex((f) => f.id === id)
|
|
55
|
+
if (index < 0) return
|
|
56
|
+
const fav = shown[index]!
|
|
57
|
+
removed.value = [...removed.value, { fav, index, timer: setTimeout(() => drop(id), UNDO_MS) }]
|
|
58
|
+
await favorites.remove(id)
|
|
59
|
+
// It failed: it is back in the list, no Undo to show
|
|
60
|
+
if (favorites.list.value.some((f) => f.id === id)) drop(id)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function onRestore(id: string): Promise<void> {
|
|
64
|
+
const r = removed.value.find((x) => x.fav.id === id)
|
|
65
|
+
if (!r) return
|
|
66
|
+
drop(id)
|
|
67
|
+
const { id: _id, at: _at, ...entry } = r.fav
|
|
68
|
+
await favorites.add(entry)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
onBeforeUnmount(() => removed.value.forEach((r) => clearTimeout(r.timer)))
|
|
72
|
+
|
|
25
73
|
const envelope = computed(() => ({
|
|
26
74
|
title: props.title ?? tOr('core.favorites.title', 'Favourites'),
|
|
75
|
+
...(props.icon !== undefined ? { icon: props.icon } : {}),
|
|
27
76
|
size: props.size,
|
|
28
77
|
state: !favorites.available
|
|
29
78
|
? ('empty' as const)
|
|
30
79
|
: !favorites.loaded.value
|
|
31
80
|
? ('loading' as const)
|
|
32
|
-
: favorites.error.value && !favorites.list.value.length
|
|
81
|
+
: favorites.error.value && !favorites.list.value.length && !removed.value.length
|
|
33
82
|
? ('unreachable' as const)
|
|
34
|
-
: favorites.list.value.length
|
|
83
|
+
: favorites.list.value.length || removed.value.length
|
|
35
84
|
? ('ready' as const)
|
|
36
85
|
: ('empty' as const),
|
|
37
86
|
error: favorites.error.value ?? undefined,
|
|
@@ -39,12 +88,22 @@ const envelope = computed(() => ({
|
|
|
39
88
|
? tOr('core.favorites.none', 'No favourites yet: the star beside a page title adds one')
|
|
40
89
|
: tOr('core.favorites.noEntity', 'No favorites entity is declared'),
|
|
41
90
|
}))
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
91
|
+
|
|
92
|
+
const line = (f: Favorite, gone = false) => ({ id: f.id, label: f.label, to: f.to, kind: f.kind, ...(gone ? { removed: true } : {}) })
|
|
93
|
+
const data = computed(() => {
|
|
94
|
+
// The latest first, each removed line back where it was
|
|
95
|
+
const items = [...favorites.list.value].reverse().map((f) => line(f))
|
|
96
|
+
for (const r of [...removed.value].sort((a, b) => a.index - b.index)) items.splice(Math.min(r.index, items.length), 0, line(r.fav, true))
|
|
97
|
+
return { items }
|
|
98
|
+
})
|
|
46
99
|
</script>
|
|
47
100
|
|
|
48
101
|
<template>
|
|
49
|
-
<QdCardView
|
|
102
|
+
<QdCardView
|
|
103
|
+
type="favorites"
|
|
104
|
+
:envelope="envelope"
|
|
105
|
+
:data="data"
|
|
106
|
+
:options="{ maxItems, groupByKind, removable }"
|
|
107
|
+
:on="{ remove: onRemove, restore: onRestore }"
|
|
108
|
+
/>
|
|
50
109
|
</template>
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"type": "agenda",
|
|
6
6
|
"title": "Agenda",
|
|
7
7
|
"question": "What is coming?",
|
|
8
|
+
"icon": "pi pi-calendar",
|
|
8
9
|
"readings": [
|
|
9
10
|
"each line: when (a time today, \"tomorrow\", a date) and what",
|
|
10
11
|
"the first ones first"
|
|
@@ -336,6 +337,7 @@
|
|
|
336
337
|
"type": "favorites",
|
|
337
338
|
"title": "Favourites",
|
|
338
339
|
"question": "What do I follow?",
|
|
340
|
+
"icon": "pi pi-star",
|
|
339
341
|
"readings": [
|
|
340
342
|
"the pages the person starred and the searches they saved, by kind",
|
|
341
343
|
"each line opens its page, filtered as it was for a search"
|
|
@@ -363,9 +365,14 @@
|
|
|
363
365
|
"type": "boolean",
|
|
364
366
|
"default": true,
|
|
365
367
|
"description": "Group the lines by kind (records, lists, searches, boards)"
|
|
368
|
+
},
|
|
369
|
+
"removable": {
|
|
370
|
+
"type": "boolean",
|
|
371
|
+
"default": false,
|
|
372
|
+
"description": "A remove button on each line that has an id: the card emits `remove` and `restore` with it (QdFavoritesCard turns it on)"
|
|
366
373
|
}
|
|
367
374
|
},
|
|
368
|
-
"action": "none: each line is its own gesture",
|
|
375
|
+
"action": "none: each line is its own gesture; with removable, a × beside it removes it, Undo puts it back",
|
|
369
376
|
"example": {
|
|
370
377
|
"envelope": {
|
|
371
378
|
"title": "Favourites",
|
|
@@ -413,6 +420,10 @@
|
|
|
413
420
|
],
|
|
414
421
|
"additionalProperties": false,
|
|
415
422
|
"properties": {
|
|
423
|
+
"id": {
|
|
424
|
+
"type": "string",
|
|
425
|
+
"description": "The favourite's id: what a removal names"
|
|
426
|
+
},
|
|
416
427
|
"label": {
|
|
417
428
|
"type": "string"
|
|
418
429
|
},
|
|
@@ -432,6 +443,10 @@
|
|
|
432
443
|
"board"
|
|
433
444
|
],
|
|
434
445
|
"description": "What it is: a record, a list, a saved search, a board"
|
|
446
|
+
},
|
|
447
|
+
"removed": {
|
|
448
|
+
"type": "boolean",
|
|
449
|
+
"description": "Just removed: drawn as such, with its Undo"
|
|
435
450
|
}
|
|
436
451
|
}
|
|
437
452
|
}
|
|
@@ -443,6 +458,7 @@
|
|
|
443
458
|
"type": "feed",
|
|
444
459
|
"title": "Feed",
|
|
445
460
|
"question": "What happened?",
|
|
461
|
+
"icon": "pi pi-bell",
|
|
446
462
|
"readings": [
|
|
447
463
|
"each line: when, and what happened",
|
|
448
464
|
"its status, when it has one: a side mark and a word"
|
|
@@ -1069,6 +1085,7 @@
|
|
|
1069
1085
|
"type": "queue",
|
|
1070
1086
|
"title": "Queue",
|
|
1071
1087
|
"question": "What do I have to do?",
|
|
1088
|
+
"icon": "pi pi-inbox",
|
|
1072
1089
|
"readings": [
|
|
1073
1090
|
"the big number: how many are waiting, with a short note (\"1 expires tomorrow\")",
|
|
1074
1091
|
"each line: one item to process, with its own gesture",
|
|
@@ -1338,6 +1355,7 @@
|
|
|
1338
1355
|
"type": "recent",
|
|
1339
1356
|
"title": "Recent",
|
|
1340
1357
|
"question": "What was I just looking at?",
|
|
1358
|
+
"icon": "pi pi-history",
|
|
1341
1359
|
"readings": [
|
|
1342
1360
|
"the last records the person opened, the last one first",
|
|
1343
1361
|
"what each one is, and when it was seen"
|
|
@@ -5,19 +5,31 @@
|
|
|
5
5
|
* The pages someone starred and the searches they saved, grouped by kind,
|
|
6
6
|
* each opening its page. QdFavoritesCard feeds it live from useFavorites.
|
|
7
7
|
* See meta.json for the sheet.
|
|
8
|
+
*
|
|
9
|
+
* `removable` (#5392): a × beside each line that has an id, shown on hover
|
|
10
|
+
* and focus (always on a touch screen). The card only says it: `remove` with
|
|
11
|
+
* the id; a line marked `removed` reads so, with an Undo that says `restore`.
|
|
8
12
|
*/
|
|
9
|
-
import { computed } from 'vue'
|
|
13
|
+
import { computed, nextTick, ref, watch } from 'vue'
|
|
10
14
|
import { RouterLink, type RouteLocationRaw } from 'vue-router'
|
|
11
15
|
import { useI18n } from '../../../i18n/useI18n'
|
|
12
16
|
import type { CardSize } from '../../types'
|
|
13
17
|
|
|
14
18
|
type Kind = 'item' | 'list' | 'search' | 'board'
|
|
19
|
+
interface FavoriteLine {
|
|
20
|
+
id?: string
|
|
21
|
+
label: string
|
|
22
|
+
to: RouteLocationRaw
|
|
23
|
+
kind?: Kind
|
|
24
|
+
removed?: boolean
|
|
25
|
+
}
|
|
15
26
|
interface FavoritesData {
|
|
16
|
-
items:
|
|
27
|
+
items: FavoriteLine[]
|
|
17
28
|
}
|
|
18
29
|
|
|
19
|
-
const props = defineProps<{ data: FavoritesData; options: { maxItems?: number; groupByKind?: boolean }; size: CardSize }>()
|
|
20
|
-
const {
|
|
30
|
+
const props = defineProps<{ data: FavoritesData; options: { maxItems?: number; groupByKind?: boolean; removable?: boolean }; size: CardSize }>()
|
|
31
|
+
const emit = defineEmits<{ remove: [id: string]; restore: [id: string] }>()
|
|
32
|
+
const { t, tOr } = useI18n()
|
|
21
33
|
|
|
22
34
|
const KINDS: Kind[] = ['item', 'list', 'search', 'board']
|
|
23
35
|
const ICON: Record<Kind, string> = { item: 'pi pi-file', list: 'pi pi-list', search: 'pi pi-filter', board: 'pi pi-th-large' }
|
|
@@ -30,18 +42,65 @@ const groups = computed(() => {
|
|
|
30
42
|
return byKind
|
|
31
43
|
})
|
|
32
44
|
const more = computed(() => props.data.items.length - shown.value.length)
|
|
45
|
+
const canRemove = (item: FavoriteLine) => !!props.options.removable && !!item.id
|
|
46
|
+
|
|
47
|
+
// The × goes with its line: the focus moves to the Undo that replaces it
|
|
48
|
+
const root = ref<HTMLElement | null>(null)
|
|
49
|
+
const removing = ref<string | null>(null)
|
|
50
|
+
function remove(id: string): void {
|
|
51
|
+
removing.value = id
|
|
52
|
+
emit('remove', id)
|
|
53
|
+
}
|
|
54
|
+
watch(
|
|
55
|
+
() => props.data.items,
|
|
56
|
+
async () => {
|
|
57
|
+
const id = removing.value
|
|
58
|
+
if (!id || !props.data.items.some((i) => i.id === id && i.removed)) return
|
|
59
|
+
removing.value = null
|
|
60
|
+
await nextTick()
|
|
61
|
+
const buttons = root.value ? Array.from(root.value.querySelectorAll('[data-favorite-undo]')) : []
|
|
62
|
+
const undo = buttons.find((b) => (b.closest('[data-favorite]') as HTMLElement | null)?.dataset.favorite === id) as HTMLElement | undefined
|
|
63
|
+
undo?.focus()
|
|
64
|
+
}
|
|
65
|
+
)
|
|
33
66
|
</script>
|
|
34
67
|
|
|
35
68
|
<template>
|
|
36
|
-
<div class="qd-favorites">
|
|
69
|
+
<div ref="root" class="qd-favorites" :class="{ 'qd-favorites--removable': options.removable }">
|
|
37
70
|
<section v-for="g in groups" :key="g.kind ?? 'all'" class="qd-favorites-group">
|
|
38
71
|
<h3 v-if="g.kind" class="qd-favorites-kind">{{ t(`core.favorites.kind.${g.kind}`) }}</h3>
|
|
39
72
|
<ul class="qd-favorites-list">
|
|
40
|
-
<li v-for="(item, i) in g.items" :key="i">
|
|
41
|
-
<
|
|
42
|
-
<
|
|
43
|
-
<
|
|
44
|
-
|
|
73
|
+
<li v-for="(item, i) in g.items" :key="item.id ?? i" class="qd-favorites-item" :data-favorite="item.id" :data-removed="item.removed || undefined">
|
|
74
|
+
<template v-if="item.removed">
|
|
75
|
+
<span class="qd-favorites-removed" role="status">{{ tOr('core.favorites.removed', '{label} removed from favourites', { label: item.label }) }}</span>
|
|
76
|
+
<button
|
|
77
|
+
v-if="item.id"
|
|
78
|
+
type="button"
|
|
79
|
+
class="qd-favorites-undo"
|
|
80
|
+
:aria-label="tOr('core.favorites.undoLabel', 'Put {label} back in favourites', { label: item.label })"
|
|
81
|
+
data-favorite-undo
|
|
82
|
+
@click="emit('restore', item.id)"
|
|
83
|
+
>
|
|
84
|
+
{{ tOr('core.favorites.undo', 'Undo') }}
|
|
85
|
+
</button>
|
|
86
|
+
</template>
|
|
87
|
+
<template v-else>
|
|
88
|
+
<RouterLink :to="item.to" class="qd-favorites-link" :title="item.label">
|
|
89
|
+
<i :class="ICON[item.kind ?? 'item']" aria-hidden="true"></i>
|
|
90
|
+
<span class="qd-favorites-label">{{ item.label }}</span>
|
|
91
|
+
</RouterLink>
|
|
92
|
+
<button
|
|
93
|
+
v-if="canRemove(item)"
|
|
94
|
+
type="button"
|
|
95
|
+
class="qd-favorites-remove"
|
|
96
|
+
:aria-label="tOr('core.favorites.remove', 'Remove {label} from favourites', { label: item.label })"
|
|
97
|
+
:title="tOr('core.favorites.remove', 'Remove {label} from favourites', { label: item.label })"
|
|
98
|
+
data-favorite-remove
|
|
99
|
+
@click="remove(item.id!)"
|
|
100
|
+
>
|
|
101
|
+
<i class="pi pi-times" aria-hidden="true"></i>
|
|
102
|
+
</button>
|
|
103
|
+
</template>
|
|
45
104
|
</li>
|
|
46
105
|
</ul>
|
|
47
106
|
</section>
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
"type": "favorites",
|
|
3
3
|
"title": "Favourites",
|
|
4
4
|
"question": "What do I follow?",
|
|
5
|
+
"icon": "pi pi-star",
|
|
5
6
|
"readings": [
|
|
6
7
|
"the pages the person starred and the searches they saved, by kind",
|
|
7
8
|
"each line opens its page, filtered as it was for a search"
|
|
@@ -16,9 +17,10 @@
|
|
|
16
17
|
"sizes": ["s", "m"],
|
|
17
18
|
"options": {
|
|
18
19
|
"maxItems": { "type": "integer", "minimum": 1, "maximum": 20, "default": 8, "description": "How many lines to show" },
|
|
19
|
-
"groupByKind": { "type": "boolean", "default": true, "description": "Group the lines by kind (records, lists, searches, boards)" }
|
|
20
|
+
"groupByKind": { "type": "boolean", "default": true, "description": "Group the lines by kind (records, lists, searches, boards)" },
|
|
21
|
+
"removable": { "type": "boolean", "default": false, "description": "A remove button on each line that has an id: the card emits `remove` and `restore` with it (QdFavoritesCard turns it on)" }
|
|
20
22
|
},
|
|
21
|
-
"action": "none: each line is its own gesture",
|
|
23
|
+
"action": "none: each line is its own gesture; with removable, a × beside it removes it, Undo puts it back",
|
|
22
24
|
"example": {
|
|
23
25
|
"envelope": { "title": "Favourites", "status": "info", "size": "s" },
|
|
24
26
|
"data": {
|
|
@@ -10,9 +10,11 @@
|
|
|
10
10
|
"required": ["label", "to"],
|
|
11
11
|
"additionalProperties": false,
|
|
12
12
|
"properties": {
|
|
13
|
+
"id": { "type": "string", "description": "The favourite's id: what a removal names" },
|
|
13
14
|
"label": { "type": "string" },
|
|
14
15
|
"to": { "type": ["string", "object"], "description": "The page it opens" },
|
|
15
|
-
"kind": { "type": "string", "enum": ["item", "list", "search", "board"], "description": "What it is: a record, a list, a saved search, a board" }
|
|
16
|
+
"kind": { "type": "string", "enum": ["item", "list", "search", "board"], "description": "What it is: a record, a list, a saved search, a board" },
|
|
17
|
+
"removed": { "type": "boolean", "description": "Just removed: drawn as such, with its Undo" }
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
}
|
|
@@ -46,6 +46,7 @@ import FavoritesCard from './favorites/FavoritesCard.vue'
|
|
|
46
46
|
import favoritesMeta from './favorites/meta.json'
|
|
47
47
|
import favoritesSchema from './favorites/schema.json'
|
|
48
48
|
import RecentCard from './recent/RecentCard.vue'
|
|
49
|
+
import { PILLS } from './pills'
|
|
49
50
|
import recentMeta from './recent/meta.json'
|
|
50
51
|
import recentSchema from './recent/schema.json'
|
|
51
52
|
|
|
@@ -53,14 +54,14 @@ import recentSchema from './recent/schema.json'
|
|
|
53
54
|
export const BUILTIN_CARDS = ['metric', 'queue', 'goal', 'bullet', 'compare', 'trend', 'ranking', 'split', 'funnel', 'heat', 'agenda', 'feed', 'favorites', 'recent'] as const
|
|
54
55
|
|
|
55
56
|
export function registerBuiltinCards(): void {
|
|
56
|
-
registerCard({ type: 'metric', component: MetricCard, meta: metricMeta as CardMeta, schema: metricSchema as CardSchema })
|
|
57
|
-
registerCard({ type: 'queue', component: QueueCard, meta: queueMeta as CardMeta, schema: queueSchema as CardSchema })
|
|
58
|
-
registerCard({ type: 'goal', component: GoalCard, meta: goalMeta as CardMeta, schema: goalSchema as CardSchema })
|
|
57
|
+
registerCard({ type: 'metric', component: MetricCard, meta: metricMeta as CardMeta, schema: metricSchema as CardSchema, pill: PILLS.metric })
|
|
58
|
+
registerCard({ type: 'queue', component: QueueCard, meta: queueMeta as CardMeta, schema: queueSchema as CardSchema, pill: PILLS.queue })
|
|
59
|
+
registerCard({ type: 'goal', component: GoalCard, meta: goalMeta as CardMeta, schema: goalSchema as CardSchema, pill: PILLS.goal })
|
|
59
60
|
registerCard({ type: 'bullet', component: BulletCard, meta: bulletMeta as CardMeta, schema: bulletSchema as CardSchema })
|
|
60
|
-
registerCard({ type: 'compare', component: CompareCard, meta: compareMeta as CardMeta, schema: compareSchema as CardSchema })
|
|
61
|
+
registerCard({ type: 'compare', component: CompareCard, meta: compareMeta as CardMeta, schema: compareSchema as CardSchema, pill: PILLS.compare })
|
|
61
62
|
registerCard({ type: 'trend', component: TrendCard, meta: trendMeta as CardMeta, schema: trendSchema as CardSchema })
|
|
62
63
|
registerCard({ type: 'ranking', component: RankingCard, meta: rankingMeta as CardMeta, schema: rankingSchema as CardSchema })
|
|
63
|
-
registerCard({ type: 'split', component: SplitCard, meta: splitMeta as CardMeta, schema: splitSchema as CardSchema })
|
|
64
|
+
registerCard({ type: 'split', component: SplitCard, meta: splitMeta as CardMeta, schema: splitSchema as CardSchema, pill: PILLS.split })
|
|
64
65
|
registerCard({ type: 'funnel', component: FunnelCard, meta: funnelMeta as CardMeta, schema: funnelSchema as CardSchema })
|
|
65
66
|
registerCard({ type: 'heat', component: HeatCard, meta: heatMeta as CardMeta, schema: heatSchema as CardSchema })
|
|
66
67
|
registerCard({ type: 'agenda', component: AgendaCard, meta: agendaMeta as CardMeta, schema: agendaSchema as CardSchema })
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The pill form of the generic cards (#5389): the one figure the domain bar
|
|
3
|
+
* keeps of each, and the count its badge shows.
|
|
4
|
+
*/
|
|
5
|
+
import type { CardPill } from '../types'
|
|
6
|
+
import { formatNumber } from './shared'
|
|
7
|
+
|
|
8
|
+
type Opts = Record<string, unknown>
|
|
9
|
+
const fmt = (n: number, o: Opts, locale: string): string =>
|
|
10
|
+
formatNumber(n, locale, { decimals: typeof o.decimals === 'number' ? o.decimals : undefined, unit: typeof o.unit === 'string' ? o.unit : undefined })
|
|
11
|
+
const count = (n: unknown): number | null => (typeof n === 'number' && Number.isFinite(n) ? n : null)
|
|
12
|
+
|
|
13
|
+
export const PILLS: Record<string, (data: unknown, options: Opts, locale: string) => CardPill> = {
|
|
14
|
+
metric: (d, o, l) => {
|
|
15
|
+
const v = (d as { value: number }).value
|
|
16
|
+
return { value: fmt(v, o, l), count: count(v) }
|
|
17
|
+
},
|
|
18
|
+
queue: (d, _o, l) => {
|
|
19
|
+
const q = d as { total?: number; items: unknown[] }
|
|
20
|
+
const n = q.total ?? q.items.length
|
|
21
|
+
return { value: formatNumber(n, l), count: n }
|
|
22
|
+
},
|
|
23
|
+
goal: (d, o, l) => {
|
|
24
|
+
const g = d as { value: number; target: number }
|
|
25
|
+
return { value: `${fmt(g.value, o, l)} / ${fmt(g.target, o, l)}`, count: null }
|
|
26
|
+
},
|
|
27
|
+
compare: (d, o, l) => {
|
|
28
|
+
const v = (d as { now: { value: number } }).now.value
|
|
29
|
+
return { value: fmt(v, o, l), count: null }
|
|
30
|
+
},
|
|
31
|
+
split: (d, o, l) => {
|
|
32
|
+
const s = d as { total?: number; parts: Array<{ value: number }> }
|
|
33
|
+
const n = s.total ?? s.parts.reduce((sum, p) => sum + p.value, 0)
|
|
34
|
+
return { value: fmt(n, o, l), count: count(n) }
|
|
35
|
+
},
|
|
36
|
+
}
|
package/src/cards/index.ts
CHANGED
|
@@ -86,6 +86,7 @@ export function renderBestiary(cards: CardFolder[], title = 'Cards'): string {
|
|
|
86
86
|
'| Field | What it says |',
|
|
87
87
|
'|---|---|',
|
|
88
88
|
'| `title` | What the card counts |',
|
|
89
|
+
'| `icon` | An icon class before the title; default the type\'s own (below), `null` for none |',
|
|
89
90
|
'| `status` | `critical`, `watch`, `good` or `info`: a side bar, a hue and a word |',
|
|
90
91
|
'| `source`, `freshness` | Where the data comes from, and when it was read |',
|
|
91
92
|
'| `to` | The surface: the whole card opens the domain\'s board |',
|
|
@@ -117,7 +118,7 @@ export function renderBestiary(cards: CardFolder[], title = 'Cards'): string {
|
|
|
117
118
|
'',
|
|
118
119
|
list(m.avoid),
|
|
119
120
|
'',
|
|
120
|
-
`**Sizes**: ${(m.sizes as string[] | undefined)?.join(', ') ?? 's'}. **Main action**: ${String(m.action)}`,
|
|
121
|
+
`**Sizes**: ${(m.sizes as string[] | undefined)?.join(', ') ?? 's'}.${m.icon ? ` **Icon**: \`${String(m.icon)}\`.` : ''} **Main action**: ${String(m.action)}`,
|
|
121
122
|
''
|
|
122
123
|
)
|
|
123
124
|
if (Object.keys(options).length) {
|
package/src/cards/types.ts
CHANGED
|
@@ -36,6 +36,8 @@ export interface CardAction {
|
|
|
36
36
|
/** What the envelope shows around the body */
|
|
37
37
|
export interface CardEnvelope {
|
|
38
38
|
title: string
|
|
39
|
+
/** An icon class beside the title (`pi pi-star`); default the type's own, `null` for none */
|
|
40
|
+
icon?: string | null
|
|
39
41
|
status?: CardStatus
|
|
40
42
|
/** Where the data comes from ("boutique") */
|
|
41
43
|
source?: string
|
|
@@ -64,6 +66,8 @@ export interface CardMeta {
|
|
|
64
66
|
title: string
|
|
65
67
|
/** The question it answers */
|
|
66
68
|
question: string
|
|
69
|
+
/** The icon its cards show beside their title, unless the envelope says otherwise */
|
|
70
|
+
icon?: string
|
|
67
71
|
/** What each visual channel says */
|
|
68
72
|
readings: string[]
|
|
69
73
|
strengths: string[]
|
|
@@ -81,6 +85,16 @@ export interface CardMeta {
|
|
|
81
85
|
}
|
|
82
86
|
}
|
|
83
87
|
|
|
88
|
+
/**
|
|
89
|
+
* A card reduced to a pill (#5389): what the domain bar shows of it. `count`
|
|
90
|
+
* is the badge's number, `null` when the card counts nothing.
|
|
91
|
+
*/
|
|
92
|
+
export interface CardPill {
|
|
93
|
+
/** The value as written: "14", "68 / 100" */
|
|
94
|
+
value: string
|
|
95
|
+
count: number | null
|
|
96
|
+
}
|
|
97
|
+
|
|
84
98
|
/** A card type, as registerCard takes it */
|
|
85
99
|
export interface CardDefinition {
|
|
86
100
|
type: string
|
|
@@ -89,6 +103,8 @@ export interface CardDefinition {
|
|
|
89
103
|
meta: CardMeta
|
|
90
104
|
/** The JSON Schema of `data` */
|
|
91
105
|
schema: CardSchema
|
|
106
|
+
/** Its pill form, for the domain bar (#5389); without it, the type is not offered there */
|
|
107
|
+
pill?: (data: unknown, options: Record<string, unknown>, locale: string) => CardPill
|
|
92
108
|
}
|
|
93
109
|
|
|
94
110
|
/** What a body receives */
|
|
@@ -175,7 +175,7 @@ function onGuardStay(): void {
|
|
|
175
175
|
<!-- Nav slot for PageNav (child routes) -->
|
|
176
176
|
<slot name="nav" />
|
|
177
177
|
|
|
178
|
-
<PageHeader :title="title" :title-parts="titleParts" :favorite="favorite && isEdit ? { kind: 'item', entity, itemId: entityId } : null">
|
|
178
|
+
<PageHeader :title="title" :title-parts="titleParts" :favorite="favorite && isEdit ? { kind: 'item', entity, itemId: entityId, ready: !loading } : null">
|
|
179
179
|
<template #actions>
|
|
180
180
|
<slot name="header-actions" />
|
|
181
181
|
<!-- Header actions from builder (excludes save/delete/cancel) -->
|
|
@@ -31,6 +31,7 @@ import SidebarBox from './SidebarBox.vue'
|
|
|
31
31
|
import Zone from './Zone.vue'
|
|
32
32
|
import AppBanner from './AppBanner.vue'
|
|
33
33
|
import NavlinksGroup from './NavlinksGroup.vue'
|
|
34
|
+
import QdDomainBarZone from '../../domain/QdDomainBarZone.vue'
|
|
34
35
|
import qdadmLogo from '../../assets/logo.svg'
|
|
35
36
|
import { version as qdadmVersion } from '../../../package.json'
|
|
36
37
|
|
|
@@ -409,6 +410,9 @@ const showBreadcrumb = computed<boolean>(() => {
|
|
|
409
410
|
<span class="mobile-header-title">{{ app.name }}</span>
|
|
410
411
|
</div>
|
|
411
412
|
|
|
413
|
+
<!-- The domain's bar, on every page of a domain (#5389) -->
|
|
414
|
+
<QdDomainBarZone />
|
|
415
|
+
|
|
412
416
|
<!-- Breadcrumb + Navlinks bar -->
|
|
413
417
|
<div v-if="showBreadcrumb" class="layout-nav-bar">
|
|
414
418
|
<Breadcrumb :model="breadcrumbItems" class="layout-breadcrumb">
|
|
@@ -34,6 +34,7 @@ import { useSlots, provide, ref } from 'vue'
|
|
|
34
34
|
import { RouterView } from 'vue-router'
|
|
35
35
|
import ConfirmDialog from 'primevue/confirmdialog'
|
|
36
36
|
import Zone from './Zone.vue'
|
|
37
|
+
import QdDomainBarZone from '../../domain/QdDomainBarZone.vue'
|
|
37
38
|
import AppBanner from './AppBanner.vue'
|
|
38
39
|
import { LAYOUT_ZONES } from '../../zones/zones'
|
|
39
40
|
import { useGuardDialog, GUARD_DIALOG_HOST } from '../../composables/useGuardStore'
|
|
@@ -99,6 +100,9 @@ provide('qdadmNavlinksOverride', navlinksOverride)
|
|
|
99
100
|
|
|
100
101
|
<!-- Main content area -->
|
|
101
102
|
<div class="main-area">
|
|
103
|
+
<!-- The domain's bar, on every page of a domain (#5389) -->
|
|
104
|
+
<QdDomainBarZone />
|
|
105
|
+
|
|
102
106
|
<!-- Breadcrumb zone -->
|
|
103
107
|
<Zone
|
|
104
108
|
:name="LAYOUT_ZONES.BREADCRUMB"
|
|
@@ -40,6 +40,8 @@ interface FavoriteConfig {
|
|
|
40
40
|
kind: 'item' | 'list' | 'search' | 'board'
|
|
41
41
|
entity?: string | null
|
|
42
42
|
itemId?: string | number | null
|
|
43
|
+
/** The record is read (#5392): without a label of its own, it is named by its id */
|
|
44
|
+
ready?: boolean
|
|
43
45
|
}
|
|
44
46
|
|
|
45
47
|
interface Props {
|
|
@@ -80,6 +82,12 @@ const favoriteLabel = computed((): string => {
|
|
|
80
82
|
if (simpleTitle.value) return simpleTitle.value
|
|
81
83
|
const parts = effectiveTitleParts.value
|
|
82
84
|
if (parts?.entityLabel) return parts.entityLabel
|
|
85
|
+
// A record's page before its record is read (#5392): "View Task" would be
|
|
86
|
+
// its favourite's name; no star until the record's own label is known
|
|
87
|
+
const itemId = props.favorite?.itemId
|
|
88
|
+
if (itemId !== null && itemId !== undefined && itemId !== '') {
|
|
89
|
+
return props.favorite?.ready ? [parts?.entityName, `#${itemId}`].filter(Boolean).join(' ') : ''
|
|
90
|
+
}
|
|
83
91
|
if (parts) return [parts.action, parts.entityName].filter(Boolean).join(' ')
|
|
84
92
|
return props.title ?? ''
|
|
85
93
|
})
|
|
@@ -191,7 +191,7 @@ type ShowFieldValue = string | number | boolean | Date | Record<string, unknown>
|
|
|
191
191
|
<!-- Nav slot for PageNav (child routes) -->
|
|
192
192
|
<slot name="nav" />
|
|
193
193
|
|
|
194
|
-
<PageHeader :title="title" :title-parts="titleParts" :badges="badges" :favorite="favorite ? { kind: 'item', entity, itemId: entityId } : null">
|
|
194
|
+
<PageHeader :title="title" :title-parts="titleParts" :badges="badges" :favorite="favorite ? { kind: 'item', entity, itemId: entityId, ready: !!data } : null">
|
|
195
195
|
<template #actions>
|
|
196
196
|
<slot name="header-actions" />
|
|
197
197
|
<!-- Header actions from builder (e.g., edit) -->
|