@verikit/vue 0.24.4 → 0.25.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/README.md +5 -1
- package/dist/components/combobox.d.ts +163 -0
- package/dist/components/combobox.d.ts.map +1 -0
- package/dist/components/combobox.js +179 -0
- package/dist/layout/render-schema-node.d.ts.map +1 -1
- package/dist/layout/render-schema-node.js +6 -3
- package/dist/layout/types.d.ts +5 -0
- package/dist/layout/types.d.ts.map +1 -1
- package/dist/query/use-resource-table.d.ts +7 -2
- package/dist/query/use-resource-table.d.ts.map +1 -1
- package/dist/query/use-resource-table.js +27 -8
- package/dist/relationships/belongs-to-field.d.ts +39 -2
- package/dist/relationships/belongs-to-field.d.ts.map +1 -1
- package/dist/relationships/belongs-to-field.js +92 -41
- package/dist/relationships/use-relationship-picker.d.ts +41 -0
- package/dist/relationships/use-relationship-picker.d.ts.map +1 -0
- package/dist/relationships/use-relationship-picker.js +92 -0
- package/dist/resource/resource-detail.d.ts +14 -1
- package/dist/resource/resource-detail.d.ts.map +1 -1
- package/dist/resource/resource-detail.js +40 -10
- package/dist/resource/resource-form.d.ts.map +1 -1
- package/dist/resource/resource-form.js +1 -0
- package/dist/resource/resource-table.d.ts +46 -0
- package/dist/resource/resource-table.d.ts.map +1 -1
- package/dist/resource/resource-table.js +65 -8
- package/package.json +23 -13
- package/tailwind-sources.css +3 -0
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
import { defineComponent, h } from "vue";
|
|
1
|
+
import { defineComponent, h, ref } from "vue";
|
|
2
|
+
import { Combobox, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxList, } from "#components/combobox";
|
|
2
3
|
import { Label } from "#components/label";
|
|
3
|
-
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "#components/select";
|
|
4
4
|
import { cn } from "#lib/utils";
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const RELATIONSHIP_PICKER_PAGE_SIZE = 100;
|
|
9
|
-
function recordId(record) {
|
|
10
|
-
return String(record.id);
|
|
11
|
-
}
|
|
12
|
-
function recordLabel(record, displayField) {
|
|
13
|
-
const raw = displayField ? record[displayField] : undefined;
|
|
14
|
-
return raw === null || raw === undefined ? recordId(record) : String(raw);
|
|
5
|
+
import { useRelationshipPicker } from "./use-relationship-picker.js";
|
|
6
|
+
function valueString(value) {
|
|
7
|
+
return value === null || value === undefined ? "" : String(value);
|
|
15
8
|
}
|
|
16
9
|
/**
|
|
17
|
-
* Renders a `belongsTo` relationship as a permission-aware
|
|
18
|
-
* reading and writing the related record's ID through its `.via()`
|
|
10
|
+
* Renders a `belongsTo` relationship as a permission-aware, searchable
|
|
11
|
+
* combobox, reading and writing the related record's ID through its `.via()`
|
|
12
|
+
* field. Typing searches the server (the target's `displayField` and
|
|
13
|
+
* `.searchable()` fields), options load 25 at a time with "Load more", and the
|
|
14
|
+
* selected record's label is shown even when it isn't among the loaded
|
|
15
|
+
* options.
|
|
19
16
|
*/
|
|
20
17
|
export const BelongsToRelationshipField = defineComponent({
|
|
21
18
|
name: "BelongsToRelationshipField",
|
|
@@ -24,79 +21,133 @@ export const BelongsToRelationshipField = defineComponent({
|
|
|
24
21
|
type: Object,
|
|
25
22
|
required: true,
|
|
26
23
|
},
|
|
24
|
+
/**
|
|
25
|
+
* Name of the resource that owns the relationship (the one being edited).
|
|
26
|
+
* Options come from its `/relationships/:name` route. Defaults to the
|
|
27
|
+
* target resource, which only matches for a self-referencing relationship.
|
|
28
|
+
*/
|
|
29
|
+
resourceName: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: undefined,
|
|
32
|
+
},
|
|
27
33
|
id: { type: String, default: undefined },
|
|
34
|
+
/** Current foreign-key value (the selected record's id), if any. */
|
|
28
35
|
value: { type: null, required: false },
|
|
36
|
+
/** Error content shown below the picker and linked with ARIA. */
|
|
29
37
|
error: { type: null, required: false },
|
|
38
|
+
/** Disables the picker. */
|
|
30
39
|
disabled: {
|
|
31
40
|
type: Boolean,
|
|
32
41
|
default: undefined,
|
|
33
42
|
},
|
|
43
|
+
/** Marks the picker as read-only. */
|
|
34
44
|
readOnly: {
|
|
35
45
|
type: Boolean,
|
|
36
46
|
default: undefined,
|
|
37
47
|
},
|
|
48
|
+
/** Class name applied to the outer wrapper. */
|
|
38
49
|
className: {
|
|
39
50
|
type: String,
|
|
40
51
|
default: undefined,
|
|
41
52
|
},
|
|
53
|
+
/** Called with the next foreign-key value (or `null` when cleared). */
|
|
42
54
|
onValueChange: {
|
|
43
55
|
type: Function,
|
|
44
56
|
default: undefined,
|
|
45
57
|
},
|
|
58
|
+
/** Called when the picker's input loses focus. */
|
|
46
59
|
onBlur: {
|
|
47
60
|
type: Function,
|
|
48
61
|
default: undefined,
|
|
49
62
|
},
|
|
50
63
|
},
|
|
51
64
|
setup(props) {
|
|
52
|
-
//
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
const
|
|
65
|
+
// While the popup is open the input holds what's typed (the selected
|
|
66
|
+
// record's label stays visible as the placeholder); closed, it shows that
|
|
67
|
+
// label.
|
|
68
|
+
const open = ref(false);
|
|
69
|
+
const search = ref("");
|
|
70
|
+
// Created once in setup: calling composables during render would add
|
|
71
|
+
// watchers on every update.
|
|
72
|
+
const picker = useRelationshipPicker({
|
|
73
|
+
resourceName: props.resourceName ?? props.relationship.resource,
|
|
74
|
+
relationship: props.relationship,
|
|
75
|
+
value: () => valueString(props.value),
|
|
76
|
+
search,
|
|
77
|
+
});
|
|
78
|
+
function handleOpenChange(next) {
|
|
79
|
+
// A read-only picker still opens on arrow keys; keep it shut.
|
|
80
|
+
if (next && props.readOnly === true)
|
|
81
|
+
return;
|
|
82
|
+
open.value = next;
|
|
83
|
+
if (!next)
|
|
84
|
+
search.value = "";
|
|
85
|
+
}
|
|
56
86
|
return () => {
|
|
57
87
|
const inputId = props.id ??
|
|
58
|
-
`verikit-relationship-${props.relationship.resource}-${
|
|
88
|
+
`verikit-relationship-${props.relationship.resource}-${props.relationship.name ?? ""}`;
|
|
59
89
|
const errorId = props.error ? `${inputId}-error` : undefined;
|
|
60
|
-
const
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
: String(props.value);
|
|
90
|
+
const currentValue = valueString(props.value);
|
|
91
|
+
const selectedLabel = currentValue ? picker.labelFor(currentValue) : "";
|
|
92
|
+
const editable = props.disabled !== true && props.readOnly !== true;
|
|
64
93
|
return h("div", { class: cn("grid gap-2", props.className) }, [
|
|
65
94
|
props.relationship.label
|
|
66
95
|
? h(Label, { for: inputId }, { default: () => props.relationship.label })
|
|
67
96
|
: null,
|
|
68
|
-
h(
|
|
69
|
-
|
|
70
|
-
|
|
97
|
+
h(Combobox, {
|
|
98
|
+
value: currentValue === "" ? null : currentValue,
|
|
99
|
+
open: open.value,
|
|
100
|
+
// Options are already searched on the server.
|
|
101
|
+
ignoreFilter: true,
|
|
102
|
+
name: props.relationship.name,
|
|
71
103
|
disabled: props.disabled === true,
|
|
72
|
-
|
|
104
|
+
onOpenChange: handleOpenChange,
|
|
105
|
+
onValueChange: (next) => props.onValueChange?.(next),
|
|
73
106
|
}, {
|
|
74
107
|
default: () => [
|
|
75
|
-
h(
|
|
108
|
+
h(ComboboxInput, {
|
|
76
109
|
id: inputId,
|
|
77
|
-
|
|
110
|
+
value: open.value ? search.value : selectedLabel,
|
|
111
|
+
placeholder: picker.isLoading.value
|
|
112
|
+
? "Loading…"
|
|
113
|
+
: selectedLabel || "Search…",
|
|
114
|
+
showClear: editable && currentValue !== "",
|
|
115
|
+
readOnly: props.readOnly === true,
|
|
116
|
+
onInputValueChange: (text) => {
|
|
117
|
+
search.value = text;
|
|
118
|
+
},
|
|
78
119
|
onBlur: props.onBlur,
|
|
79
120
|
"aria-describedby": errorId,
|
|
80
121
|
"aria-invalid": props.error ? true : undefined,
|
|
81
|
-
}, {
|
|
82
|
-
default: () => h(SelectValue, {
|
|
83
|
-
placeholder: relationshipQuery.isLoading.value
|
|
84
|
-
? "Loading…"
|
|
85
|
-
: "Select…",
|
|
86
|
-
}),
|
|
87
122
|
}),
|
|
88
|
-
h(
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
123
|
+
h(ComboboxContent, {}, {
|
|
124
|
+
// Read reactive state inside these slots, not above: Reka's
|
|
125
|
+
// popper content is memoized, so only its own re-renders
|
|
126
|
+
// pick up newly loaded options.
|
|
127
|
+
default: () => [
|
|
128
|
+
h(ComboboxEmpty, {}, {
|
|
129
|
+
default: () => picker.isLoading.value ? "Loading…" : "No matches.",
|
|
130
|
+
}),
|
|
131
|
+
h(ComboboxList, {}, {
|
|
132
|
+
default: () => picker.ids.value.map((optionId) => h(ComboboxItem, { key: optionId, value: optionId }, { default: () => picker.labelFor(optionId) })),
|
|
133
|
+
}),
|
|
134
|
+
picker.hasMore.value
|
|
135
|
+
? h("button", {
|
|
136
|
+
type: "button",
|
|
137
|
+
class: "w-full rounded-md px-1.5 py-1 text-left text-sm text-muted-foreground hover:bg-accent disabled:opacity-50",
|
|
138
|
+
disabled: picker.isLoadingMore.value,
|
|
139
|
+
onClick: picker.loadMore,
|
|
140
|
+
}, picker.isLoadingMore.value ? "Loading…" : "Load more")
|
|
141
|
+
: null,
|
|
142
|
+
],
|
|
92
143
|
}),
|
|
93
144
|
],
|
|
94
145
|
}),
|
|
95
146
|
props.error
|
|
96
147
|
? h("p", { id: errorId, class: "text-sm text-destructive" }, props.error)
|
|
97
148
|
: null,
|
|
98
|
-
|
|
99
|
-
? h("p", { role: "alert", class: "text-sm text-destructive" },
|
|
149
|
+
picker.error.value
|
|
150
|
+
? h("p", { role: "alert", class: "text-sm text-destructive" }, picker.error.value.message)
|
|
100
151
|
: null,
|
|
101
152
|
]);
|
|
102
153
|
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { BelongsToRelationshipSchema } from "@verikit/core";
|
|
2
|
+
import { type ComputedRef, type MaybeRefOrGetter } from "vue";
|
|
3
|
+
/** Records fetched per page as the picker's list is scrolled through. */
|
|
4
|
+
export declare const RELATIONSHIP_PICKER_PAGE_SIZE = 25;
|
|
5
|
+
/** How long the picker waits after the last keystroke before searching. */
|
|
6
|
+
export declare const RELATIONSHIP_SEARCH_DEBOUNCE_MS = 250;
|
|
7
|
+
type PickerRecord = Record<string, unknown>;
|
|
8
|
+
/** A record's label: its `displayField` value, or its id when that's empty. */
|
|
9
|
+
export declare function relationshipRecordLabel(record: PickerRecord, displayField: string | undefined): string;
|
|
10
|
+
/** Options for {@link useRelationshipPicker}. */
|
|
11
|
+
export interface UseRelationshipPickerOptions {
|
|
12
|
+
/** Resource that owns the relationship; options come from its picker route. */
|
|
13
|
+
resourceName: string;
|
|
14
|
+
relationship: BelongsToRelationshipSchema;
|
|
15
|
+
/** The selected record's id, or `""` for none. */
|
|
16
|
+
value: MaybeRefOrGetter<string>;
|
|
17
|
+
/** The text typed into the picker, searched after a short pause. */
|
|
18
|
+
search: MaybeRefOrGetter<string>;
|
|
19
|
+
}
|
|
20
|
+
/** State returned by {@link useRelationshipPicker}. */
|
|
21
|
+
export interface UseRelationshipPickerResult {
|
|
22
|
+
/** Ids of the loaded options, in server order. */
|
|
23
|
+
ids: ComputedRef<string[]>;
|
|
24
|
+
/** Label for an id: loaded, or looked up for the selected value. */
|
|
25
|
+
labelFor: (id: string) => string;
|
|
26
|
+
isLoading: ComputedRef<boolean>;
|
|
27
|
+
error: ComputedRef<Error | null>;
|
|
28
|
+
/** True when the server has more matching records than are loaded. */
|
|
29
|
+
hasMore: ComputedRef<boolean>;
|
|
30
|
+
isLoadingMore: ComputedRef<boolean>;
|
|
31
|
+
loadMore: () => void;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Loads a `belongsTo` picker's options from the server: searched by what's
|
|
35
|
+
* typed (the server searches the target's `displayField` and `.searchable()`
|
|
36
|
+
* fields), a page at a time. When the selected record isn't among the loaded
|
|
37
|
+
* options, it is fetched by id so its label can still be shown.
|
|
38
|
+
*/
|
|
39
|
+
export declare function useRelationshipPicker({ resourceName, relationship, value, search, }: UseRelationshipPickerOptions): UseRelationshipPickerResult;
|
|
40
|
+
export {};
|
|
41
|
+
//# sourceMappingURL=use-relationship-picker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-relationship-picker.d.ts","sourceRoot":"","sources":["../../src/relationships/use-relationship-picker.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,eAAe,CAAC;AAEjE,OAAO,EAKL,KAAK,WAAW,EAChB,KAAK,gBAAgB,EAEtB,MAAM,KAAK,CAAC;AAGb,yEAAyE;AACzE,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAEhD,2EAA2E;AAC3E,eAAO,MAAM,+BAA+B,MAAM,CAAC;AAEnD,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAyB5C,+EAA+E;AAC/E,wBAAgB,uBAAuB,CACrC,MAAM,EAAE,YAAY,EACpB,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,MAAM,CAIR;AAED,iDAAiD;AACjD,MAAM,WAAW,4BAA4B;IAC3C,+EAA+E;IAC/E,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,2BAA2B,CAAC;IAC1C,kDAAkD;IAClD,KAAK,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAChC,oEAAoE;IACpE,MAAM,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;CAClC;AAED,uDAAuD;AACvD,MAAM,WAAW,2BAA2B;IAC1C,kDAAkD;IAClD,GAAG,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;IAC3B,oEAAoE;IACpE,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;IACjC,SAAS,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAChC,KAAK,EAAE,WAAW,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;IACjC,sEAAsE;IACtE,OAAO,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IAC9B,aAAa,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;IACpC,QAAQ,EAAE,MAAM,IAAI,CAAC;CACtB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,EACpC,YAAY,EACZ,YAAY,EACZ,KAAK,EACL,MAAM,GACP,EAAE,4BAA4B,GAAG,2BAA2B,CAyF5D"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { useInfiniteQuery, useQuery } from "@tanstack/vue-query";
|
|
2
|
+
import { resourceQueryKeys } from "@verikit/ui-core/query/query-keys";
|
|
3
|
+
import { computed, ref, toValue, watch, } from "vue";
|
|
4
|
+
import { useVerikitClient } from "../client/use-verikit-client.js";
|
|
5
|
+
/** Records fetched per page as the picker's list is scrolled through. */
|
|
6
|
+
export const RELATIONSHIP_PICKER_PAGE_SIZE = 25;
|
|
7
|
+
/** How long the picker waits after the last keystroke before searching. */
|
|
8
|
+
export const RELATIONSHIP_SEARCH_DEBOUNCE_MS = 250;
|
|
9
|
+
function useDebouncedValue(source, delay) {
|
|
10
|
+
const debounced = ref(toValue(source));
|
|
11
|
+
watch(() => toValue(source), (value, _previous, onCleanup) => {
|
|
12
|
+
const timer = setTimeout(() => {
|
|
13
|
+
debounced.value = value;
|
|
14
|
+
}, delay);
|
|
15
|
+
onCleanup(() => clearTimeout(timer));
|
|
16
|
+
});
|
|
17
|
+
return debounced;
|
|
18
|
+
}
|
|
19
|
+
function recordId(record) {
|
|
20
|
+
return String(record.id);
|
|
21
|
+
}
|
|
22
|
+
/** A record's label: its `displayField` value, or its id when that's empty. */
|
|
23
|
+
export function relationshipRecordLabel(record, displayField) {
|
|
24
|
+
const raw = displayField ? record[displayField] : undefined;
|
|
25
|
+
return raw === null || raw === undefined ? recordId(record) : String(raw);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Loads a `belongsTo` picker's options from the server: searched by what's
|
|
29
|
+
* typed (the server searches the target's `displayField` and `.searchable()`
|
|
30
|
+
* fields), a page at a time. When the selected record isn't among the loaded
|
|
31
|
+
* options, it is fetched by id so its label can still be shown.
|
|
32
|
+
*/
|
|
33
|
+
export function useRelationshipPicker({ resourceName, relationship, value, search, }) {
|
|
34
|
+
const client = useVerikitClient();
|
|
35
|
+
const keys = resourceQueryKeys(resourceName, client);
|
|
36
|
+
const relationshipName = relationship.name ?? "";
|
|
37
|
+
const enabled = relationshipName.length > 0;
|
|
38
|
+
const term = useDebouncedValue(() => toValue(search).trim(), RELATIONSHIP_SEARCH_DEBOUNCE_MS);
|
|
39
|
+
const params = computed(() => ({
|
|
40
|
+
pageSize: RELATIONSHIP_PICKER_PAGE_SIZE,
|
|
41
|
+
...(term.value && { search: term.value }),
|
|
42
|
+
}));
|
|
43
|
+
const pages = useInfiniteQuery({
|
|
44
|
+
queryKey: computed(() => keys.relationshipPages(relationshipName, params.value)),
|
|
45
|
+
queryFn: ({ pageParam, signal }) => client
|
|
46
|
+
.resource(resourceName)
|
|
47
|
+
.relationship(relationshipName, { ...params.value, page: pageParam }, { signal }),
|
|
48
|
+
initialPageParam: 1,
|
|
49
|
+
getNextPageParam: (last, all) => all.reduce((count, page) => count + page.records.length, 0) <
|
|
50
|
+
last.total && last.records.length > 0
|
|
51
|
+
? last.page + 1
|
|
52
|
+
: undefined,
|
|
53
|
+
enabled,
|
|
54
|
+
});
|
|
55
|
+
const records = computed(() => pages.data.value?.pages.flatMap((page) => page.records) ?? []);
|
|
56
|
+
const loaded = computed(() => records.value.some((record) => recordId(record) === toValue(value)));
|
|
57
|
+
const selectedParams = computed(() => ({
|
|
58
|
+
ids: [toValue(value)],
|
|
59
|
+
pageSize: 1,
|
|
60
|
+
}));
|
|
61
|
+
const selected = useQuery({
|
|
62
|
+
queryKey: computed(() => keys.relationship(relationshipName, selectedParams.value)),
|
|
63
|
+
queryFn: ({ signal }) => client
|
|
64
|
+
.resource(resourceName)
|
|
65
|
+
.relationship(relationshipName, selectedParams.value, {
|
|
66
|
+
signal,
|
|
67
|
+
}),
|
|
68
|
+
enabled: computed(() => enabled &&
|
|
69
|
+
toValue(value) !== "" &&
|
|
70
|
+
!loaded.value &&
|
|
71
|
+
pages.isSuccess.value),
|
|
72
|
+
});
|
|
73
|
+
const labels = computed(() => {
|
|
74
|
+
const map = new Map();
|
|
75
|
+
for (const record of [
|
|
76
|
+
...(selected.data.value?.records ?? []),
|
|
77
|
+
...records.value,
|
|
78
|
+
]) {
|
|
79
|
+
map.set(recordId(record), relationshipRecordLabel(record, relationship.displayField));
|
|
80
|
+
}
|
|
81
|
+
return map;
|
|
82
|
+
});
|
|
83
|
+
return {
|
|
84
|
+
ids: computed(() => [...new Set(records.value.map(recordId))]),
|
|
85
|
+
labelFor: (id) => labels.value.get(id) ?? id,
|
|
86
|
+
isLoading: computed(() => pages.isLoading.value),
|
|
87
|
+
error: computed(() => pages.error.value),
|
|
88
|
+
hasMore: computed(() => pages.hasNextPage.value),
|
|
89
|
+
isLoadingMore: computed(() => pages.isFetchingNextPage.value),
|
|
90
|
+
loadMore: () => void pages.fetchNextPage(),
|
|
91
|
+
};
|
|
92
|
+
}
|
|
@@ -19,6 +19,10 @@ export interface ResourceDetailProps {
|
|
|
19
19
|
* Renders the built-in Delete action, which opens a confirmation dialog. Hidden when the server reports the actor can't delete the record, or when a delete is denied (403 or 404) for the rest of this component's lifetime. Defaults to `actions`.
|
|
20
20
|
*/
|
|
21
21
|
deleteAction?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Replaces the built-in edit dialog: the Edit action calls this with the record instead (for example, to navigate to an edit page). Edit is still hidden when the server reports the actor can't update the record. Bind it as a prop (`:on-edit`) or a listener (`@edit`).
|
|
24
|
+
*/
|
|
25
|
+
onEdit?: (record: DetailRecord) => void;
|
|
22
26
|
/**
|
|
23
27
|
* Renders the record-scoped actions declared on the resource via `defineResource({ actions })`. The page asks the server which of them the actor can't run on this record: those it may not run are hidden, and those that can't run right now are disabled, with the reason as a tooltip. An action denied when run (403 or 404) is hidden for the rest of this component's lifetime. Defaults to `actions`.
|
|
24
28
|
*/
|
|
@@ -33,7 +37,7 @@ export interface ResourceDetailProps {
|
|
|
33
37
|
className?: string;
|
|
34
38
|
}
|
|
35
39
|
/**
|
|
36
|
-
* Shows one record's fields as a label/value list, with its actions: the built-in Edit and Delete, and the record-scoped actions declared on the resource. Edit and Delete are hidden up front when the server reports the actor can't update or delete the record. Fields marked `.hidden()`, or left out by the server because the actor can't read them, aren't shown. A record the actor can't read shows as not found, as the server doesn't reveal whether it exists.
|
|
40
|
+
* Shows one record's fields as a label/value list, with its actions: the built-in Edit and Delete, and the record-scoped actions declared on the resource. Edit and Delete are hidden up front when the server reports the actor can't update or delete the record. Fields marked `.hidden()`, or left out by the server because the actor can't read them, aren't shown. A `belongsTo` relationship is shown in place of its foreign-key field, as the related record's `displayField` (or the raw key when the actor can't read that). A record the actor can't read shows as not found, as the server doesn't reveal whether it exists.
|
|
37
41
|
*/
|
|
38
42
|
export declare const ResourceDetail: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
39
43
|
resource: {
|
|
@@ -64,6 +68,10 @@ export declare const ResourceDetail: import("vue").DefineComponent<import("vue")
|
|
|
64
68
|
type: PropType<ResourceDetailProps["renderActions"]>;
|
|
65
69
|
default: undefined;
|
|
66
70
|
};
|
|
71
|
+
onEdit: {
|
|
72
|
+
type: PropType<ResourceDetailProps["onEdit"]>;
|
|
73
|
+
default: undefined;
|
|
74
|
+
};
|
|
67
75
|
onDeleted: {
|
|
68
76
|
type: PropType<ResourceDetailProps["onDeleted"]>;
|
|
69
77
|
default: undefined;
|
|
@@ -103,6 +111,10 @@ export declare const ResourceDetail: import("vue").DefineComponent<import("vue")
|
|
|
103
111
|
type: PropType<ResourceDetailProps["renderActions"]>;
|
|
104
112
|
default: undefined;
|
|
105
113
|
};
|
|
114
|
+
onEdit: {
|
|
115
|
+
type: PropType<ResourceDetailProps["onEdit"]>;
|
|
116
|
+
default: undefined;
|
|
117
|
+
};
|
|
106
118
|
onDeleted: {
|
|
107
119
|
type: PropType<ResourceDetailProps["onDeleted"]>;
|
|
108
120
|
default: undefined;
|
|
@@ -115,6 +127,7 @@ export declare const ResourceDetail: import("vue").DefineComponent<import("vue")
|
|
|
115
127
|
className: string | undefined;
|
|
116
128
|
actions: boolean;
|
|
117
129
|
renderActions: ((record: DetailRecord) => VNodeChild) | undefined;
|
|
130
|
+
onEdit: ((record: DetailRecord) => void) | undefined;
|
|
118
131
|
onDeleted: ((record: DetailRecord) => void) | undefined;
|
|
119
132
|
editAction: boolean | undefined;
|
|
120
133
|
deleteAction: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-detail.d.ts","sourceRoot":"","sources":["../../src/resource/resource-detail.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,KAAK,CAAC;AAa9E,OAAO,KAAK,EAAoB,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"resource-detail.d.ts","sourceRoot":"","sources":["../../src/resource/resource-detail.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,KAAK,CAAC;AAa9E,OAAO,KAAK,EAAoB,QAAQ,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAqBhF,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAE5C,wCAAwC;AACxC,MAAM,WAAW,mBAAmB;IAClC,4EAA4E;IAC5E,QAAQ,EAAE,QAAQ,GAAG,cAAc,CAAC;IACpC,gCAAgC;IAChC,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,YAAY,CAAC,EAA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AM,GAAG,SAAS,CAAC;;;;;;6BAhDvB,YAAY,KAAK,UAAU;sBANlC,YAAY,KAAK,IAAI;yBAUlB,YAAY,KAAK,IAAI;;;;4EAya1C,CAAC"}
|
|
@@ -4,15 +4,15 @@ import { Button } from "#components/button";
|
|
|
4
4
|
import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from "#components/dialog";
|
|
5
5
|
import { cn } from "#lib/utils";
|
|
6
6
|
import { actionNeedsDialog, resourceActionSchemas, } from "@verikit/ui-core/actions/resource-actions";
|
|
7
|
-
import { resolveVerikitFields } from "@verikit/ui-core/form/resolve-fields";
|
|
8
7
|
import { formatFieldValue } from "@verikit/ui-core/layout/format-value";
|
|
8
|
+
import { relationshipCellText, resourceColumnSpecs, } from "@verikit/ui-core/layout/table-columns";
|
|
9
9
|
import { useDeleteResource } from "../query/use-resource-mutations.js";
|
|
10
10
|
import { useResourceFindWithActions } from "../query/use-resource-queries.js";
|
|
11
11
|
import { declaredActionButton } from "./declared-action-button.js";
|
|
12
12
|
import { hasStatus, isActionDenied, ResourceActionDialog, useRunResourceAction, } from "./resource-action-dialog.js";
|
|
13
13
|
import { ResourceForm } from "./resource-form.js";
|
|
14
14
|
/**
|
|
15
|
-
* Shows one record's fields as a label/value list, with its actions: the built-in Edit and Delete, and the record-scoped actions declared on the resource. Edit and Delete are hidden up front when the server reports the actor can't update or delete the record. Fields marked `.hidden()`, or left out by the server because the actor can't read them, aren't shown. A record the actor can't read shows as not found, as the server doesn't reveal whether it exists.
|
|
15
|
+
* Shows one record's fields as a label/value list, with its actions: the built-in Edit and Delete, and the record-scoped actions declared on the resource. Edit and Delete are hidden up front when the server reports the actor can't update or delete the record. Fields marked `.hidden()`, or left out by the server because the actor can't read them, aren't shown. A `belongsTo` relationship is shown in place of its foreign-key field, as the related record's `displayField` (or the raw key when the actor can't read that). A record the actor can't read shows as not found, as the server doesn't reveal whether it exists.
|
|
16
16
|
*/
|
|
17
17
|
export const ResourceDetail = defineComponent({
|
|
18
18
|
name: "ResourceDetail",
|
|
@@ -39,6 +39,12 @@ export const ResourceDetail = defineComponent({
|
|
|
39
39
|
type: Function,
|
|
40
40
|
default: undefined,
|
|
41
41
|
},
|
|
42
|
+
// A prop rather than an emit, so the page can tell whether a parent
|
|
43
|
+
// handles it and skip its built-in dialog; `@edit` still binds here.
|
|
44
|
+
onEdit: {
|
|
45
|
+
type: Function,
|
|
46
|
+
default: undefined,
|
|
47
|
+
},
|
|
42
48
|
onDeleted: {
|
|
43
49
|
type: Function,
|
|
44
50
|
default: undefined,
|
|
@@ -51,7 +57,7 @@ export const ResourceDetail = defineComponent({
|
|
|
51
57
|
setup(props) {
|
|
52
58
|
const deleted = ref(false);
|
|
53
59
|
const query = useResourceFindWithActions(props.resource.name, () => props.id, { enabled: () => !deleted.value });
|
|
54
|
-
const
|
|
60
|
+
const rows = resourceColumnSpecs(props.resource, { view: "detail" });
|
|
55
61
|
const recordActions = (props.resourceActions ?? props.actions)
|
|
56
62
|
? resourceActionSchemas(props.resource, "record")
|
|
57
63
|
: [];
|
|
@@ -126,7 +132,12 @@ export const ResourceDetail = defineComponent({
|
|
|
126
132
|
variant: "outline",
|
|
127
133
|
size: "sm",
|
|
128
134
|
onClick: () => {
|
|
129
|
-
|
|
135
|
+
if (props.onEdit) {
|
|
136
|
+
props.onEdit(record);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
editOpen.value = true;
|
|
140
|
+
}
|
|
130
141
|
},
|
|
131
142
|
}, { default: () => [h(PencilIcon), "Edit"] })
|
|
132
143
|
: null,
|
|
@@ -233,12 +244,31 @@ export const ResourceDetail = defineComponent({
|
|
|
233
244
|
class: cn("text-sm text-destructive", props.className),
|
|
234
245
|
}, error.message);
|
|
235
246
|
}
|
|
236
|
-
const { record, operations } = query.data.value;
|
|
247
|
+
const { record, operations, relationships } = query.data.value;
|
|
237
248
|
const editEnabled = props.editAction ?? props.actions;
|
|
238
249
|
const deleteEnabled = props.deleteAction ?? props.actions;
|
|
239
250
|
const showEdit = editEnabled && !deniedUpdate.value && !operations.update;
|
|
240
251
|
const showDelete = deleteEnabled && !deniedDelete.value && !operations.delete;
|
|
241
|
-
|
|
252
|
+
// The server leaves out fields the actor can't read.
|
|
253
|
+
const visibleRows = rows.flatMap((row) => row.kind === "field"
|
|
254
|
+
? Object.hasOwn(record, row.field.name)
|
|
255
|
+
? [
|
|
256
|
+
{
|
|
257
|
+
key: row.field.name,
|
|
258
|
+
label: row.field.label ?? row.field.name,
|
|
259
|
+
value: formatFieldValue(record[row.field.name]),
|
|
260
|
+
},
|
|
261
|
+
]
|
|
262
|
+
: []
|
|
263
|
+
: Object.hasOwn(record, row.foreignKey)
|
|
264
|
+
? [
|
|
265
|
+
{
|
|
266
|
+
key: row.name,
|
|
267
|
+
label: row.label,
|
|
268
|
+
value: relationshipCellText(relationships, row, record),
|
|
269
|
+
},
|
|
270
|
+
]
|
|
271
|
+
: []);
|
|
242
272
|
const hasActions = showEdit ||
|
|
243
273
|
showDelete ||
|
|
244
274
|
recordActions.length > 0 ||
|
|
@@ -250,9 +280,9 @@ export const ResourceDetail = defineComponent({
|
|
|
250
280
|
: null,
|
|
251
281
|
h("dl", {
|
|
252
282
|
class: "grid gap-x-6 gap-y-3 rounded-lg border border-border p-4 sm:grid-cols-[minmax(8rem,max-content)_1fr]",
|
|
253
|
-
},
|
|
254
|
-
h("dt", { class: "text-sm font-medium text-muted-foreground" },
|
|
255
|
-
h("dd", { class: "text-sm break-words" },
|
|
283
|
+
}, visibleRows.map((row) => h("div", { key: row.key, class: "contents" }, [
|
|
284
|
+
h("dt", { class: "text-sm font-medium text-muted-foreground" }, row.label),
|
|
285
|
+
h("dd", { class: "text-sm break-words" }, row.value),
|
|
256
286
|
]))),
|
|
257
287
|
recordActions.length > 0
|
|
258
288
|
? h(ResourceActionDialog, {
|
|
@@ -265,7 +295,7 @@ export const ResourceDetail = defineComponent({
|
|
|
265
295
|
onDenied: denyAction,
|
|
266
296
|
})
|
|
267
297
|
: null,
|
|
268
|
-
editEnabled ? editDialog(record) : null,
|
|
298
|
+
editEnabled && !props.onEdit ? editDialog(record) : null,
|
|
269
299
|
deleteEnabled ? deleteDialog() : null,
|
|
270
300
|
]);
|
|
271
301
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-form.d.ts","sourceRoot":"","sources":["../../src/resource/resource-form.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,EAAsB,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,KAAK,CAAC;AAGzE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE/D,OAAO,EAEL,KAAK,gCAAgC,EACtC,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAEvF,sCAAsC;AACtC,MAAM,WAAW,iBAAiB,CAChC,OAAO,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAChD,SAAQ,gCAAgC,CAAC,OAAO,CAAC;IACjD,8EAA8E;IAC9E,QAAQ,EAAE,uBAAuB,CAAC;IAClC,uDAAuD;IACvD,QAAQ,CAAC,EAAE,OAAO,CAAC,oBAAoB,CAAC,CAAC;IACzC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,CAAC,IAAI,EAAE,gBAAgB,EAAE,IAAI,EAAE,UAAU,KAAK,UAAU,CAAC;IAC9E,yEAAyE;IACzE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,eAAO,MAAM,YAAY;;cAIH,QAAQ,CAAC,uBAAuB,CAAC;;;;cAG7B,QAAQ,CAAC,MAAM,GAAG,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uBAAuB,CAAC;;;;cAG7B,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC;;;;cAEhC,QAAQ,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;;;;cAItC,QAAQ,CAAC,iBAAiB,CAAC,eAAe,CAAC,CAAC;;;;cAI1C,QAAQ,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;;;;cAIxC,QAAQ,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;;;;cAIxC,QAAQ,CAAC,OAAO,CAAC,oBAAoB,CAAC,GAAG,SAAS,CAAC;;;;cAIjD,QAAQ,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,CAAC;;;;;;;;cAKnD,QAAQ,CAAC,MAAM,GAAG,SAAS,CAAC;;;;;;;;;;gCA7CpB,gBAAgB,QAAQ,UAAU,KAAK,UAAU;;;4EAqG7E,CAAC"}
|
|
@@ -10,6 +10,25 @@ export interface ResourceTableProps<TRecord extends RowData = Record<string, unk
|
|
|
10
10
|
* Edit/Delete row actions.
|
|
11
11
|
*/
|
|
12
12
|
actions?: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Replaces the built-in create dialog: the New button calls this instead
|
|
15
|
+
* (for example, to navigate to a create page). Only used with `actions`.
|
|
16
|
+
* Bind it as a prop (`:on-create`) or a listener (`@create`).
|
|
17
|
+
*/
|
|
18
|
+
onCreate?: () => void;
|
|
19
|
+
/**
|
|
20
|
+
* Replaces the built-in edit dialog: each row's Edit button calls this with
|
|
21
|
+
* its record instead (for example, to navigate to an edit page). Only used
|
|
22
|
+
* with `actions`. Bind it as a prop (`:on-edit`) or a listener (`@edit`).
|
|
23
|
+
*/
|
|
24
|
+
onEdit?: (record: TRecord) => void;
|
|
25
|
+
/**
|
|
26
|
+
* Opens a record (for example, to navigate to its page): adds a View
|
|
27
|
+
* button to each row, and clicking a row anywhere other than its controls
|
|
28
|
+
* calls this too. Independent of `actions`. Bind it as a prop (`:on-view`)
|
|
29
|
+
* or a listener (`@view`).
|
|
30
|
+
*/
|
|
31
|
+
onView?: (record: TRecord) => void;
|
|
13
32
|
/**
|
|
14
33
|
* Renders the actions declared on the resource via `defineResource({ actions })`: record-scoped ones per row, collection-scoped ones in the toolbar. Labels, confirmations, and input forms come from each declaration; actions with neither a confirmation nor a form run on click. The table asks the server which of them the actor can't run on each page: those it may not run are hidden, and those that can't run right now are disabled, with the reason as a tooltip. An action denied when run (403, or 404 for a record action, which the server returns so as not to reveal whether the record exists) is hidden for the rest of this component's lifetime. Defaults to `actions`.
|
|
15
34
|
*/
|
|
@@ -40,6 +59,18 @@ export declare const ResourceTable: import("vue").DefineComponent<import("vue").
|
|
|
40
59
|
type: BooleanConstructor;
|
|
41
60
|
default: boolean;
|
|
42
61
|
};
|
|
62
|
+
onCreate: {
|
|
63
|
+
type: PropType<ResourceTableProps["onCreate"]>;
|
|
64
|
+
default: undefined;
|
|
65
|
+
};
|
|
66
|
+
onEdit: {
|
|
67
|
+
type: PropType<ResourceTableProps["onEdit"]>;
|
|
68
|
+
default: undefined;
|
|
69
|
+
};
|
|
70
|
+
onView: {
|
|
71
|
+
type: PropType<ResourceTableProps["onView"]>;
|
|
72
|
+
default: undefined;
|
|
73
|
+
};
|
|
43
74
|
resourceActions: {
|
|
44
75
|
type: PropType<boolean | undefined>;
|
|
45
76
|
default: undefined;
|
|
@@ -75,6 +106,18 @@ export declare const ResourceTable: import("vue").DefineComponent<import("vue").
|
|
|
75
106
|
type: BooleanConstructor;
|
|
76
107
|
default: boolean;
|
|
77
108
|
};
|
|
109
|
+
onCreate: {
|
|
110
|
+
type: PropType<ResourceTableProps["onCreate"]>;
|
|
111
|
+
default: undefined;
|
|
112
|
+
};
|
|
113
|
+
onEdit: {
|
|
114
|
+
type: PropType<ResourceTableProps["onEdit"]>;
|
|
115
|
+
default: undefined;
|
|
116
|
+
};
|
|
117
|
+
onView: {
|
|
118
|
+
type: PropType<ResourceTableProps["onView"]>;
|
|
119
|
+
default: undefined;
|
|
120
|
+
};
|
|
78
121
|
resourceActions: {
|
|
79
122
|
type: PropType<boolean | undefined>;
|
|
80
123
|
default: undefined;
|
|
@@ -100,7 +143,10 @@ export declare const ResourceTable: import("vue").DefineComponent<import("vue").
|
|
|
100
143
|
actions: boolean;
|
|
101
144
|
pageSize: number | undefined;
|
|
102
145
|
renderActions: ((record: Record<string, unknown>) => VNodeChild) | undefined;
|
|
146
|
+
onEdit: ((record: Record<string, unknown>) => void) | undefined;
|
|
103
147
|
resourceActions: boolean | undefined;
|
|
148
|
+
onCreate: (() => void) | undefined;
|
|
149
|
+
onView: ((record: Record<string, unknown>) => void) | undefined;
|
|
104
150
|
renderBulkActions: ((records: Record<string, unknown>[], clearSelection: () => void) => VNodeChild) | undefined;
|
|
105
151
|
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
106
152
|
//# sourceMappingURL=resource-table.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource-table.d.ts","sourceRoot":"","sources":["../../src/resource/resource-table.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"resource-table.d.ts","sourceRoot":"","sources":["../../src/resource/resource-table.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,QAAQ,EAAE,KAAK,UAAU,EAAE,MAAM,KAAK,CAAC;AAa9E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAuBnD,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC5B,MAAM,gCAAgC,CAAC;AA0BxC,uCAAuC;AACvC,MAAM,WAAW,kBAAkB,CACjC,OAAO,SAAS,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CACjD,SAAQ,uBAAuB;IAC/B,oFAAoF;IACpF,QAAQ,EAAE,sBAAsB,CAAC;IACjC;;;OAGG;IACH,OAAO,C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