@jskit-ai/http-web 0.2.8 → 0.2.9
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/package.json +7 -6
- package/src/client/bulkActions.js +2 -0
- package/src/client/components/CrudAddEditScreen.vue +13 -18
- package/src/client/components/CrudDeleteAction.vue +1 -1
- package/src/client/components/CrudListBulkActionSurface.vue +13 -13
- package/src/client/components/CrudListDateFilterControl.vue +2 -2
- package/src/client/components/CrudListFilterControls.vue +4 -4
- package/src/client/components/CrudListFilterSurface.vue +8 -8
- package/src/client/components/CrudListRecordActionMenu.vue +9 -19
- package/src/client/components/CrudListScreen.vue +21 -39
- package/src/client/components/CrudViewScreen.vue +4 -4
- package/src/client/components/SelectField.vue +1 -0
- package/src/client/composables/crud/crudHttpClientSupport.js +10 -10
- package/src/client/composables/crud/crudJsonApiTransportSupport.js +1 -0
- package/src/client/composables/crud/crudLookupFieldRuntime.js +3 -3
- package/src/client/composables/crud/crudSchemaFormHelpers.js +3 -3
- package/src/client/composables/internal/crudListFilterLookupSupport.js +10 -8
- package/src/client/composables/internal/crudListParentTitleSupport.js +2 -2
- package/src/client/composables/internal/useOperationScope.js +7 -5
- package/src/client/composables/records/useAddEdit.js +12 -11
- package/src/client/composables/records/useCrudAddEdit.js +27 -40
- package/src/client/composables/records/useCrudList.js +4 -11
- package/src/client/composables/records/useCrudView.js +4 -10
- package/src/client/composables/records/useList.js +18 -11
- package/src/client/composables/records/useView.js +18 -11
- package/src/client/composables/runtime/addEditUiRuntime.js +10 -17
- package/src/client/composables/runtime/listUiRuntime.js +17 -20
- package/src/client/composables/runtime/modelStateHelpers.js +18 -8
- package/src/client/composables/runtime/operationUiHelpers.js +20 -20
- package/src/client/composables/runtime/operationValidationHelpers.js +10 -5
- package/src/client/composables/runtime/useAddEditCore.js +39 -36
- package/src/client/composables/runtime/useCommandCore.js +33 -32
- package/src/client/composables/runtime/useEndpointResource.js +10 -14
- package/src/client/composables/runtime/useFieldErrorBag.js +3 -2
- package/src/client/composables/runtime/useListCore.js +7 -11
- package/src/client/composables/runtime/useUiFeedback.js +3 -2
- package/src/client/composables/runtime/useViewCore.js +10 -20
- package/src/client/composables/runtime/viewUiRuntime.js +7 -6
- package/src/client/composables/support/listQueryParamSupport.js +6 -10
- package/src/client/composables/support/refValueHelpers.js +2 -6
- package/src/client/composables/support/requestQueryRuntimeSupport.js +2 -2
- package/src/client/composables/support/routeTemplateHelpers.js +13 -12
- package/src/client/composables/support/scopeHelpers.js +5 -4
- package/src/client/composables/useAccess.js +8 -5
- package/src/client/composables/useCommand.js +7 -6
- package/src/client/composables/useCrudAddEditScreen.js +13 -12
- package/src/client/composables/useCrudDeleteAction.js +13 -25
- package/src/client/composables/useCrudListBulkActions.js +18 -14
- package/src/client/composables/useCrudListFilterLookups.js +8 -4
- package/src/client/composables/useCrudListFilters.js +13 -6
- package/src/client/composables/useCrudListParentTitle.js +10 -9
- package/src/client/composables/useCrudListRowActions.js +15 -11
- package/src/client/composables/useCrudListScreen.js +17 -16
- package/src/client/composables/useCrudViewScreen.js +8 -7
- package/src/client/composables/usePagedCollection.js +9 -18
- package/src/client/composables/useRealtimeQueryInvalidation.js +15 -13
- package/src/client/composables/useScopeRuntime.js +3 -2
- package/src/client/lib/httpClient.js +12 -10
- package/src/client/rowActions.js +2 -0
- package/src/client/support/crudListActionSupport.js +16 -8
- package/src/client/types.js +596 -0
- package/test/crudScreenComponents.test.js +4 -2
- package/test/exportsContract.test.js +1 -0
- package/test/requestTransportOptions.test.js +7 -7
- package/test/translation.test.js +3 -0
- package/test/useAddEditCore.test.js +4 -0
- package/test/useCrudDeleteAction.test.js +4 -4
- package/test/viewCoreLoading.test.js +0 -19
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/http-web",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "node --test --test-concurrency=1"
|
|
@@ -43,17 +43,18 @@
|
|
|
43
43
|
"./client/lib/httpClient": "./src/client/lib/httpClient.js",
|
|
44
44
|
"./client/lib/permissions": "./src/client/lib/permissions.js",
|
|
45
45
|
"./client/support/contractGuards": "./src/client/support/contractGuards.js",
|
|
46
|
+
"./client/types": "./src/client/types.js",
|
|
46
47
|
"./locales/en.json": "./locales/en.json"
|
|
47
48
|
},
|
|
48
49
|
"dependencies": {
|
|
49
|
-
"@jskit-ai/resource-crud-core": "0.1.
|
|
50
|
+
"@jskit-ai/resource-crud-core": "0.1.196",
|
|
50
51
|
"@mdi/js": "^7.4.47"
|
|
51
52
|
},
|
|
52
53
|
"peerDependencies": {
|
|
53
|
-
"@jskit-ai/http-runtime": "0.2.
|
|
54
|
-
"@jskit-ai/kernel": "0.2.
|
|
55
|
-
"@jskit-ai/realtime": "0.2.
|
|
56
|
-
"@jskit-ai/shell-web": "0.2.
|
|
54
|
+
"@jskit-ai/http-runtime": "0.2.5",
|
|
55
|
+
"@jskit-ai/kernel": "0.2.5",
|
|
56
|
+
"@jskit-ai/realtime": "0.2.8",
|
|
57
|
+
"@jskit-ai/shell-web": "0.2.5",
|
|
57
58
|
"@tanstack/vue-query": "^5.90.5",
|
|
58
59
|
"vue": "^3.5.13",
|
|
59
60
|
"vue-router": "^5.0.4",
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { normalizeText } from "@jskit-ai/kernel/shared/support/normalize";
|
|
2
2
|
import { defineCrudListActions } from "./support/crudListActionSupport.js";
|
|
3
3
|
|
|
4
|
+
/** @param {import("./types.js").CrudListBulkActionDefinition[]} [actions] */
|
|
4
5
|
function defineCrudListBulkActions(actions = []) {
|
|
5
6
|
return defineCrudListActions(actions, {
|
|
6
7
|
name: "defineCrudListBulkActions",
|
|
@@ -11,6 +12,7 @@ function defineCrudListBulkActions(actions = []) {
|
|
|
11
12
|
color: normalizeText(rawAction.color, { fallback: "primary" }),
|
|
12
13
|
variant: normalizeText(rawAction.variant, { fallback: "tonal" }),
|
|
13
14
|
confirmLabel: normalizeText(rawAction.confirmLabel),
|
|
15
|
+
// readable-check: allow method-probe - optional operation: a bulk action with no run shows and does nothing
|
|
14
16
|
run: typeof rawAction.run === "function" ? rawAction.run : null,
|
|
15
17
|
disabled: rawAction.disabled
|
|
16
18
|
})
|
|
@@ -4,21 +4,25 @@ import { useJskitText } from "../i18n.js";
|
|
|
4
4
|
|
|
5
5
|
const props = defineProps({
|
|
6
6
|
screen: {
|
|
7
|
-
type: Object,
|
|
7
|
+
type: /** @type {import("vue").PropType<import("../types.js").CrudAddEditScreen>} */ (Object),
|
|
8
8
|
required: true
|
|
9
9
|
},
|
|
10
|
+
// readable-check: allow collaborator-prop - optional operation: a form without lookup fields passes no lookup functions, and its fields slot receives null
|
|
10
11
|
resolveLookupItems: {
|
|
11
12
|
type: Function,
|
|
12
13
|
default: null
|
|
13
14
|
},
|
|
15
|
+
// readable-check: allow collaborator-prop - optional operation: a form without lookup fields passes no lookup functions, and its fields slot receives null
|
|
14
16
|
resolveLookupLoading: {
|
|
15
17
|
type: Function,
|
|
16
18
|
default: null
|
|
17
19
|
},
|
|
20
|
+
// readable-check: allow collaborator-prop - optional operation: a form without lookup fields passes no lookup functions, and its fields slot receives null
|
|
18
21
|
resolveLookupSearch: {
|
|
19
22
|
type: Function,
|
|
20
23
|
default: null
|
|
21
24
|
},
|
|
25
|
+
// readable-check: allow collaborator-prop - optional operation: a form without lookup fields passes no lookup functions, and its fields slot receives null
|
|
22
26
|
setLookupSearch: {
|
|
23
27
|
type: Function,
|
|
24
28
|
default: null
|
|
@@ -26,30 +30,21 @@ const props = defineProps({
|
|
|
26
30
|
});
|
|
27
31
|
|
|
28
32
|
const { t, text } = useJskitText();
|
|
29
|
-
const formRuntime = computed(() => props.screen
|
|
30
|
-
const addEdit = computed(() => props.screen
|
|
31
|
-
const formState = computed(() => props.screen
|
|
32
|
-
const mode = computed(() => String(unref(props.screen
|
|
33
|
+
const formRuntime = computed(() => props.screen.formRuntime);
|
|
34
|
+
const addEdit = computed(() => props.screen.addEdit);
|
|
35
|
+
const formState = computed(() => props.screen.formState);
|
|
36
|
+
const mode = computed(() => String(unref(props.screen.mode) || "new").trim() || "new");
|
|
33
37
|
const saveLabel = computed(() =>
|
|
34
|
-
String(text(unref(props.screen
|
|
38
|
+
String(text(unref(props.screen.saveLabel)) || "").trim() || t("jskit.http.actions.save")
|
|
35
39
|
);
|
|
36
|
-
const cancelTo = computed(() => unref(props.screen
|
|
40
|
+
const cancelTo = computed(() => unref(props.screen.cancelTo) || "");
|
|
37
41
|
|
|
38
42
|
function resolveFieldErrors(fieldKey) {
|
|
39
|
-
|
|
40
|
-
return props.screen.resolveFieldErrors(fieldKey);
|
|
41
|
-
}
|
|
42
|
-
if (typeof formRuntime.value?.resolveFieldErrors === "function") {
|
|
43
|
-
return formRuntime.value.resolveFieldErrors(fieldKey);
|
|
44
|
-
}
|
|
45
|
-
return [];
|
|
43
|
+
return props.screen.resolveFieldErrors(fieldKey);
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
function resolveCancelTo(target = cancelTo.value) {
|
|
49
|
-
|
|
50
|
-
return props.screen.resolveCancelTo(target);
|
|
51
|
-
}
|
|
52
|
-
return target || "";
|
|
47
|
+
return props.screen.resolveCancelTo(target);
|
|
53
48
|
}
|
|
54
49
|
</script>
|
|
55
50
|
|
|
@@ -5,8 +5,8 @@ import { useJskitText } from "../i18n.js";
|
|
|
5
5
|
|
|
6
6
|
const props = defineProps({
|
|
7
7
|
runtime: {
|
|
8
|
-
type: Object,
|
|
9
|
-
|
|
8
|
+
type: /** @type {import("vue").PropType<import("../types.js").CrudListBulkActions>} */ (Object),
|
|
9
|
+
required: true
|
|
10
10
|
},
|
|
11
11
|
title: {
|
|
12
12
|
type: String,
|
|
@@ -21,28 +21,28 @@ const resolvedTitle = computed(() =>
|
|
|
21
21
|
|
|
22
22
|
const { smAndDown: isCompactLayout } = useDisplay();
|
|
23
23
|
|
|
24
|
-
const actions = computed(() =>
|
|
25
|
-
const selectedCount = computed(() =>
|
|
24
|
+
const actions = computed(() => props.runtime.actions);
|
|
25
|
+
const selectedCount = computed(() => props.runtime.selectedCount.value);
|
|
26
26
|
const shouldRender = computed(() =>
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
props.runtime.hasActions.value &&
|
|
28
|
+
props.runtime.hasSelection.value &&
|
|
29
29
|
selectedCount.value > 0
|
|
30
30
|
);
|
|
31
31
|
|
|
32
32
|
function clearSelection() {
|
|
33
|
-
props.runtime
|
|
33
|
+
props.runtime.clearSelection();
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
-
function execute(action
|
|
37
|
-
props.runtime
|
|
36
|
+
function execute(action) {
|
|
37
|
+
props.runtime.execute(action);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
function isActionDisabled(action
|
|
41
|
-
return
|
|
40
|
+
function isActionDisabled(action) {
|
|
41
|
+
return props.runtime.isActionDisabled(action);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
function isActionExecuting(action
|
|
45
|
-
return
|
|
44
|
+
function isActionExecuting(action) {
|
|
45
|
+
return props.runtime.isActionExecuting(action);
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
// Action labels may be message keys.
|
|
@@ -54,13 +54,13 @@ const resolvedControlId = computed(() => props.controlId || `crud-list-date-${ge
|
|
|
54
54
|
const pickerId = computed(() => `${resolvedControlId.value}-picker`);
|
|
55
55
|
const pickerValue = computed(() => parseDateOnlyValue(props.modelValue));
|
|
56
56
|
const displayValue = computed(() => formatDateOnlyDisplay(props.modelValue, {
|
|
57
|
-
locale: currentLocale
|
|
57
|
+
locale: currentLocale.value
|
|
58
58
|
}));
|
|
59
59
|
const pickerTitle = computed(() => t("jskit.http.crud.filters.calendar", { label: props.label }));
|
|
60
60
|
|
|
61
61
|
function restoreFocus() {
|
|
62
62
|
void nextTick(() => {
|
|
63
|
-
textFieldRef.value?.focus
|
|
63
|
+
textFieldRef.value?.focus();
|
|
64
64
|
});
|
|
65
65
|
}
|
|
66
66
|
|
|
@@ -9,8 +9,8 @@ const props = defineProps({
|
|
|
9
9
|
default: () => []
|
|
10
10
|
},
|
|
11
11
|
runtime: {
|
|
12
|
-
type: Object,
|
|
13
|
-
|
|
12
|
+
type: /** @type {import("vue").PropType<import("../types.js").CrudListFilterRuntime>} */ (Object),
|
|
13
|
+
required: true
|
|
14
14
|
},
|
|
15
15
|
stacked: {
|
|
16
16
|
type: Boolean,
|
|
@@ -19,7 +19,7 @@ const props = defineProps({
|
|
|
19
19
|
});
|
|
20
20
|
|
|
21
21
|
const { t, text } = useJskitText();
|
|
22
|
-
const runtimeValues = computed(() => props.runtime
|
|
22
|
+
const runtimeValues = computed(() => props.runtime.values);
|
|
23
23
|
|
|
24
24
|
function optionItems(filter = {}) {
|
|
25
25
|
return Array.isArray(filter.options) ? filter.options : [];
|
|
@@ -32,7 +32,7 @@ function filterLabel(filter = {}, key = "", params = {}) {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
function placeholder(filter = {}, fallbackKey = "") {
|
|
35
|
-
return String(text(filter
|
|
35
|
+
return String(text(filter.ui?.placeholder) || (fallbackKey ? t(fallbackKey) : "")).trim();
|
|
36
36
|
}
|
|
37
37
|
</script>
|
|
38
38
|
|
|
@@ -10,8 +10,8 @@ const props = defineProps({
|
|
|
10
10
|
default: () => ({})
|
|
11
11
|
},
|
|
12
12
|
runtime: {
|
|
13
|
-
type: Object,
|
|
14
|
-
|
|
13
|
+
type: /** @type {import("vue").PropType<import("../types.js").CrudListFilterRuntime>} */ (Object),
|
|
14
|
+
required: true
|
|
15
15
|
},
|
|
16
16
|
title: {
|
|
17
17
|
type: String,
|
|
@@ -34,16 +34,16 @@ const filterEntries = computed(() =>
|
|
|
34
34
|
: {})
|
|
35
35
|
.filter((filter) => filter?.key && filter?.type)
|
|
36
36
|
);
|
|
37
|
-
const activeChips = computed(() =>
|
|
38
|
-
const hasActiveFilters = computed(() =>
|
|
39
|
-
const shouldRender = computed(() => filterEntries.value.length > 0
|
|
37
|
+
const activeChips = computed(() => props.runtime.activeChips.value);
|
|
38
|
+
const hasActiveFilters = computed(() => props.runtime.hasActiveFilters.value);
|
|
39
|
+
const shouldRender = computed(() => filterEntries.value.length > 0);
|
|
40
40
|
|
|
41
|
-
function clearChip(chip
|
|
42
|
-
props.runtime
|
|
41
|
+
function clearChip(chip) {
|
|
42
|
+
props.runtime.clearChip(chip);
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
function clearFilters() {
|
|
46
|
-
props.runtime
|
|
46
|
+
props.runtime.clearFilters();
|
|
47
47
|
}
|
|
48
48
|
</script>
|
|
49
49
|
|
|
@@ -12,8 +12,8 @@ const props = defineProps({
|
|
|
12
12
|
default: 0
|
|
13
13
|
},
|
|
14
14
|
rowActions: {
|
|
15
|
-
type: Object,
|
|
16
|
-
|
|
15
|
+
type: /** @type {import("vue").PropType<import("../types.js").CrudListRowActions>} */ (Object),
|
|
16
|
+
required: true
|
|
17
17
|
},
|
|
18
18
|
viewLocation: {
|
|
19
19
|
type: Object,
|
|
@@ -50,38 +50,28 @@ const resolvedButtonLabel = computed(() =>
|
|
|
50
50
|
props.buttonLabel === undefined ? t("jskit.http.actions.actions") : text(props.buttonLabel)
|
|
51
51
|
);
|
|
52
52
|
|
|
53
|
-
const visibleRowActions = computed(() =>
|
|
54
|
-
if (typeof props.rowActions?.visibleActionsFor !== "function") {
|
|
55
|
-
return [];
|
|
56
|
-
}
|
|
57
|
-
return props.rowActions.visibleActionsFor(props.record, props.index);
|
|
58
|
-
});
|
|
53
|
+
const visibleRowActions = computed(() => props.rowActions.visibleActionsFor(props.record, props.index));
|
|
59
54
|
const hasViewAction = computed(() => Boolean(props.showView && props.viewLocation));
|
|
60
55
|
const hasEditAction = computed(() => Boolean(props.showEdit && props.editLocation));
|
|
61
56
|
const hasActions = computed(() =>
|
|
62
57
|
hasViewAction.value || hasEditAction.value || visibleRowActions.value.length > 0
|
|
63
58
|
);
|
|
64
59
|
|
|
65
|
-
function isRowActionLoading(action
|
|
66
|
-
return
|
|
67
|
-
props.rowActions.isActionLoading(action, props.record, props.index);
|
|
60
|
+
function isRowActionLoading(action) {
|
|
61
|
+
return props.rowActions.isActionLoading(action, props.record, props.index);
|
|
68
62
|
}
|
|
69
63
|
|
|
70
64
|
// Action labels may be message keys.
|
|
71
|
-
function rowActionLabel(action
|
|
65
|
+
function rowActionLabel(action) {
|
|
72
66
|
const label = text(action.label);
|
|
73
67
|
return isRowActionLoading(action) ? t("jskit.http.actions.running", { label }) : label;
|
|
74
68
|
}
|
|
75
69
|
|
|
76
|
-
function isRowActionDisabled(action
|
|
77
|
-
return
|
|
78
|
-
props.rowActions.isActionDisabled(action, props.record, props.index);
|
|
70
|
+
function isRowActionDisabled(action) {
|
|
71
|
+
return props.rowActions.isActionDisabled(action, props.record, props.index);
|
|
79
72
|
}
|
|
80
73
|
|
|
81
|
-
function runRowAction(action
|
|
82
|
-
if (typeof props.rowActions?.execute !== "function") {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
74
|
+
function runRowAction(action) {
|
|
85
75
|
void props.rowActions.execute(action, props.record, props.index);
|
|
86
76
|
}
|
|
87
77
|
</script>
|
|
@@ -9,7 +9,7 @@ import { useJskitText } from "../i18n.js";
|
|
|
9
9
|
// Unset copy comes from the catalog; passed copy may be a message key.
|
|
10
10
|
const props = defineProps({
|
|
11
11
|
screen: {
|
|
12
|
-
type: Object,
|
|
12
|
+
type: /** @type {import("vue").PropType<import("../types.js").CrudListScreen>} */ (Object),
|
|
13
13
|
required: true
|
|
14
14
|
},
|
|
15
15
|
createLabel: {
|
|
@@ -38,61 +38,46 @@ const resolvedEmptyBody = computed(() =>
|
|
|
38
38
|
);
|
|
39
39
|
|
|
40
40
|
const route = useRoute();
|
|
41
|
-
const records = computed(() => props.screen
|
|
42
|
-
const bulkActions = computed(() => props.screen
|
|
43
|
-
const rowActions = computed(() => props.screen
|
|
44
|
-
const listFilters = computed(() => props.screen
|
|
45
|
-
const filterRuntime = computed(() => props.screen
|
|
46
|
-
const displayRows = computed(() => unref(props.screen
|
|
47
|
-
const selectableRows = computed(() => unref(props.screen
|
|
48
|
-
const listPrimaryAction = computed(() => unref(props.screen
|
|
49
|
-
const hasBulkActions = computed(() => Boolean(unref(bulkActions.value
|
|
50
|
-
const hasRowActions = computed(() => Boolean(unref(rowActions.value
|
|
51
|
-
const hasViewUrl = computed(() => Boolean(props.screen
|
|
52
|
-
const hasEditUrl = computed(() => Boolean(props.screen
|
|
41
|
+
const records = computed(() => props.screen.records);
|
|
42
|
+
const bulkActions = computed(() => props.screen.bulkActions);
|
|
43
|
+
const rowActions = computed(() => props.screen.rowActions);
|
|
44
|
+
const listFilters = computed(() => props.screen.listFilters);
|
|
45
|
+
const filterRuntime = computed(() => props.screen.filterRuntime);
|
|
46
|
+
const displayRows = computed(() => unref(props.screen.displayRows));
|
|
47
|
+
const selectableRows = computed(() => unref(props.screen.selectableRows));
|
|
48
|
+
const listPrimaryAction = computed(() => unref(props.screen.listPrimaryAction) || "");
|
|
49
|
+
const hasBulkActions = computed(() => Boolean(unref(bulkActions.value.hasActions)));
|
|
50
|
+
const hasRowActions = computed(() => Boolean(unref(rowActions.value.hasActions)));
|
|
51
|
+
const hasViewUrl = computed(() => Boolean(props.screen.hasViewUrl));
|
|
52
|
+
const hasEditUrl = computed(() => Boolean(props.screen.hasEditUrl));
|
|
53
53
|
|
|
54
54
|
function resolveListRecordTitle(record) {
|
|
55
|
-
|
|
56
|
-
return props.screen.resolveRecordTitle(record);
|
|
57
|
-
}
|
|
58
|
-
return t("jskit.http.crud.record");
|
|
55
|
+
return props.screen.resolveRecordTitle(record);
|
|
59
56
|
}
|
|
60
57
|
|
|
61
58
|
function formatListCardValue(value) {
|
|
62
|
-
|
|
63
|
-
return props.screen.formatListCardValue(value);
|
|
64
|
-
}
|
|
65
|
-
return value;
|
|
59
|
+
return props.screen.formatListCardValue(value);
|
|
66
60
|
}
|
|
67
61
|
|
|
68
62
|
function resolveViewLocation(record) {
|
|
69
|
-
const path =
|
|
70
|
-
? records.value.resolveViewUrl(record)
|
|
71
|
-
: "";
|
|
63
|
+
const path = records.value.resolveViewUrl(record);
|
|
72
64
|
return path ? { path, query: route.query } : null;
|
|
73
65
|
}
|
|
74
66
|
|
|
75
67
|
function resolveEditLocation(record) {
|
|
76
|
-
const path =
|
|
77
|
-
? records.value.resolveEditUrl(record)
|
|
78
|
-
: "";
|
|
68
|
+
const path = records.value.resolveEditUrl(record);
|
|
79
69
|
return path ? { path, query: route.query } : null;
|
|
80
70
|
}
|
|
81
71
|
|
|
82
72
|
function hasRowActionsFor(record, index) {
|
|
83
|
-
return
|
|
84
|
-
rowActions.value.hasVisibleActionsFor(record, index);
|
|
73
|
+
return rowActions.value.hasVisibleActionsFor(record, index);
|
|
85
74
|
}
|
|
86
75
|
|
|
87
|
-
function isBulkRowSelected(row
|
|
88
|
-
return
|
|
89
|
-
bulkActions.value.isRecordSelected(row.record, row.index);
|
|
76
|
+
function isBulkRowSelected(row) {
|
|
77
|
+
return bulkActions.value.isRecordSelected(row.record, row.index);
|
|
90
78
|
}
|
|
91
79
|
|
|
92
|
-
function setBulkRowSelected(row
|
|
93
|
-
if (typeof bulkActions.value?.setRecordSelected !== "function") {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
80
|
+
function setBulkRowSelected(row, selected = true) {
|
|
96
81
|
bulkActions.value.setRecordSelected(row.record, row.index, selected);
|
|
97
82
|
}
|
|
98
83
|
|
|
@@ -105,9 +90,6 @@ function someSelectableRowsSelected() {
|
|
|
105
90
|
}
|
|
106
91
|
|
|
107
92
|
function setSelectableRowsSelected(selected = true) {
|
|
108
|
-
if (typeof bulkActions.value?.setRecordSelected !== "function") {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
93
|
for (const row of selectableRows.value) {
|
|
112
94
|
bulkActions.value.setRecordSelected(row.record, row.index, selected);
|
|
113
95
|
}
|
|
@@ -5,7 +5,7 @@ import { useJskitText } from "../i18n.js";
|
|
|
5
5
|
// Unset titles come from the catalog; passed titles may be message keys.
|
|
6
6
|
const props = defineProps({
|
|
7
7
|
screen: {
|
|
8
|
-
type: Object,
|
|
8
|
+
type: /** @type {import("vue").PropType<import("../types.js").CrudViewScreen>} */ (Object),
|
|
9
9
|
required: true
|
|
10
10
|
},
|
|
11
11
|
resourceSingularTitle: {
|
|
@@ -26,9 +26,9 @@ const pluralTitle = computed(() =>
|
|
|
26
26
|
props.resourcePluralTitle === undefined ? t("jskit.http.crud.records") : text(props.resourcePluralTitle)
|
|
27
27
|
);
|
|
28
28
|
|
|
29
|
-
const view = computed(() => props.screen
|
|
30
|
-
const listLocation = computed(() => unref(props.screen
|
|
31
|
-
const editLocation = computed(() => unref(props.screen
|
|
29
|
+
const view = computed(() => props.screen.view);
|
|
30
|
+
const listLocation = computed(() => unref(props.screen.listLocation) || null);
|
|
31
|
+
const editLocation = computed(() => unref(props.screen.editLocation) || null);
|
|
32
32
|
</script>
|
|
33
33
|
|
|
34
34
|
<template>
|
|
@@ -9,6 +9,7 @@ defineOptions({ inheritAttrs: false });
|
|
|
9
9
|
|
|
10
10
|
const props = defineProps({
|
|
11
11
|
searchable: { type: Boolean, default: false },
|
|
12
|
+
// readable-check: allow prop-untyped - data: a select's value is whatever its items hold, or a list of them
|
|
12
13
|
modelValue: { type: null, default: null },
|
|
13
14
|
items: { type: Array, default: () => [] },
|
|
14
15
|
itemTitle: { type: [String, Array, Function], default: "title" },
|
|
@@ -21,17 +21,17 @@ function normalizeCrudApiAccess(value = "") {
|
|
|
21
21
|
);
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
/**
|
|
25
|
+
* @param {import("../../types.js").CrudResource | null} [resource]
|
|
26
|
+
* @param {{ client?: import("../../types.js").HttpClient }} [options]
|
|
27
|
+
* @returns {import("../../types.js").HttpClient}
|
|
28
|
+
*/
|
|
29
|
+
function resolveCrudHttpClient(resource = null, { client = getHttpWebClient() } = {}) {
|
|
30
30
|
if (normalizeCrudApiAccess(resource?.apiAccess) !== CRUD_API_ACCESS_PUBLIC) {
|
|
31
|
-
return
|
|
31
|
+
return client;
|
|
32
32
|
}
|
|
33
|
-
if (publicCrudClients.has(
|
|
34
|
-
return
|
|
33
|
+
if (publicCrudClients.has(client)) {
|
|
34
|
+
return client;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
const publicClient = Object.freeze({
|
|
@@ -39,7 +39,7 @@ function resolveCrudHttpClient(resource = null, { client = null } = {}) {
|
|
|
39
39
|
const requestOptions = options && typeof options === "object" && !Array.isArray(options)
|
|
40
40
|
? options
|
|
41
41
|
: {};
|
|
42
|
-
return
|
|
42
|
+
return client.request(url, {
|
|
43
43
|
...requestOptions,
|
|
44
44
|
csrf: false
|
|
45
45
|
});
|
|
@@ -8,6 +8,7 @@ const CRUD_RESPONSE_KIND_BY_MODE = Object.freeze({
|
|
|
8
8
|
"add-edit": "record"
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
+
// readable-check: allow method-probe - input validation: an operation's output may declare no schema, or one without field definitions
|
|
11
12
|
function resolveSchemaFieldDefinitions(definition = null) {
|
|
12
13
|
const schema = definition?.schema;
|
|
13
14
|
if (!schema || typeof schema.getFieldDefinitions !== "function") {
|
|
@@ -148,7 +148,7 @@ function createCrudLookupFieldRuntime({
|
|
|
148
148
|
|
|
149
149
|
const items = (Array.isArray(entry.runtime.items) ? entry.runtime.items : []).map((item = {}) => {
|
|
150
150
|
const sourceRecord = asPlainObject(item);
|
|
151
|
-
const value = normalizeLookupValue(
|
|
151
|
+
const value = normalizeLookupValue(sourceRecord[entry.valueKey]);
|
|
152
152
|
const resolvedLabel = resolveLookupItemLabel(item, entry.labelKey);
|
|
153
153
|
const label = resolvedLabel || value;
|
|
154
154
|
return {
|
|
@@ -159,8 +159,8 @@ function createCrudLookupFieldRuntime({
|
|
|
159
159
|
});
|
|
160
160
|
|
|
161
161
|
const selectedItem = createSelectedLookupItem(
|
|
162
|
-
options
|
|
163
|
-
options
|
|
162
|
+
options.selectedValue,
|
|
163
|
+
options.selectedRecord,
|
|
164
164
|
entry
|
|
165
165
|
);
|
|
166
166
|
if (!selectedItem) {
|
|
@@ -48,11 +48,11 @@ function resolveFormFieldFormat(field = {}) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
function isNullableFormField(field = {}) {
|
|
51
|
-
return field
|
|
51
|
+
return field.nullable === true;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
function isLookupFormField(field = {}) {
|
|
55
|
-
return field
|
|
55
|
+
return field.component === "lookup" || field.relation?.kind === "lookup";
|
|
56
56
|
}
|
|
57
57
|
|
|
58
58
|
function padDateTimePart(value) {
|
|
@@ -232,7 +232,7 @@ function resolveFormFieldInitialValue(field = {}) {
|
|
|
232
232
|
}
|
|
233
233
|
|
|
234
234
|
function shouldSerializeClearedFieldAsNull(field = {}) {
|
|
235
|
-
if (field
|
|
235
|
+
if (field.nullable !== true) {
|
|
236
236
|
return false;
|
|
237
237
|
}
|
|
238
238
|
|
|
@@ -62,7 +62,7 @@ function normalizeLookupRequestQueryParamsMap(value = {}) {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
function resolveLookupSelectedValues(filter = {}, rawValue = undefined) {
|
|
65
|
-
if (filter
|
|
65
|
+
if (filter.type === CRUD_LIST_FILTER_TYPE_RECORD_ID_MANY) {
|
|
66
66
|
return normalizeUniqueTextList(rawValue, {
|
|
67
67
|
acceptSingle: true
|
|
68
68
|
});
|
|
@@ -72,18 +72,20 @@ function resolveLookupSelectedValues(filter = {}, rawValue = undefined) {
|
|
|
72
72
|
return normalizedValue ? Object.freeze([normalizedValue]) : Object.freeze([]);
|
|
73
73
|
}
|
|
74
74
|
|
|
75
|
-
function
|
|
75
|
+
function noCustomLookupLabel() {
|
|
76
|
+
return "";
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function createLookupOptionFromItem(item, filter, labelResolver) {
|
|
76
80
|
const sourceRecord = asPlainObject(item);
|
|
77
|
-
const valueKey = normalizeText(filter
|
|
78
|
-
const labelKey = normalizeText(filter
|
|
81
|
+
const valueKey = normalizeText(filter.lookup?.valueKey) || "id";
|
|
82
|
+
const labelKey = normalizeText(filter.lookup?.labelKey);
|
|
79
83
|
const value = normalizeText(sourceRecord[valueKey]);
|
|
80
84
|
if (!value) {
|
|
81
85
|
return null;
|
|
82
86
|
}
|
|
83
87
|
|
|
84
|
-
const customLabel =
|
|
85
|
-
? normalizeText(labelResolver(sourceRecord, filter))
|
|
86
|
-
: "";
|
|
88
|
+
const customLabel = normalizeText(labelResolver(sourceRecord, filter));
|
|
87
89
|
const fallbackLabel = resolveLookupItemLabel(sourceRecord, labelKey) || value;
|
|
88
90
|
|
|
89
91
|
return Object.freeze({
|
|
@@ -93,7 +95,7 @@ function createLookupOptionFromItem(item = {}, filter = {}, labelResolver = null
|
|
|
93
95
|
});
|
|
94
96
|
}
|
|
95
97
|
|
|
96
|
-
function createLookupOptionsFromItems(items = [], filter = {}, labelResolver =
|
|
98
|
+
function createLookupOptionsFromItems(items = [], filter = {}, labelResolver = noCustomLookupLabel) {
|
|
97
99
|
const optionMap = new Map();
|
|
98
100
|
for (const item of Array.isArray(items) ? items : []) {
|
|
99
101
|
const option = createLookupOptionFromItem(item, filter, labelResolver);
|
|
@@ -102,7 +102,7 @@ function resolveCrudListParentDescriptor({ resource = {}, route = null, recordId
|
|
|
102
102
|
const relation = fieldContractEntry.relation || {};
|
|
103
103
|
const relationNamespace = normalizeText(relation.namespace);
|
|
104
104
|
const containerKey = normalizeCrudLookupContainerKey(relation.containerKey, {
|
|
105
|
-
defaultValue: resource
|
|
105
|
+
defaultValue: resource.contract?.lookup?.containerKey || "lookups"
|
|
106
106
|
});
|
|
107
107
|
|
|
108
108
|
return Object.freeze({
|
|
@@ -159,7 +159,7 @@ function resolveCrudListParentRecordTitle(record = {}, descriptor = null) {
|
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
const entityLabel = normalizeText(descriptor?.entityLabel) || t("jskit.http.crud.record");
|
|
162
|
-
const recordId = toRouteParamValue(record
|
|
162
|
+
const recordId = toRouteParamValue(record.id);
|
|
163
163
|
if (recordId) {
|
|
164
164
|
return t("jskit.http.crud.parent.recordWithId", { label: entityLabel, id: recordId });
|
|
165
165
|
}
|
|
@@ -32,6 +32,7 @@ function hasAnyPermissions(permissionSets = {}) {
|
|
|
32
32
|
return false;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/** @param {import("../../types.js").OperationScopeOptions} options */
|
|
35
36
|
function useOperationScope({
|
|
36
37
|
ownershipFilter = ROUTE_VISIBILITY_WORKSPACE,
|
|
37
38
|
surfaceId = "",
|
|
@@ -39,10 +40,10 @@ function useOperationScope({
|
|
|
39
40
|
apiSuffix = "",
|
|
40
41
|
model,
|
|
41
42
|
readEnabled = true,
|
|
42
|
-
queryKeyFactory
|
|
43
|
+
queryKeyFactory,
|
|
43
44
|
permissionSets = {},
|
|
44
|
-
realtime
|
|
45
|
-
}
|
|
45
|
+
realtime
|
|
46
|
+
}) {
|
|
46
47
|
const normalizedPermissionSets = normalizePermissionSets(permissionSets);
|
|
47
48
|
const scopeRuntime = useScopeRuntime({
|
|
48
49
|
ownershipFilter,
|
|
@@ -80,6 +81,7 @@ function useOperationScope({
|
|
|
80
81
|
);
|
|
81
82
|
const realtimeBinding = useOperationRealtime({
|
|
82
83
|
realtime,
|
|
84
|
+
// readable-check: allow method-probe - optional operation: a command reads nothing, so it has no queryKeyFactory and no key to refresh
|
|
83
85
|
queryKey: typeof queryKeyFactory === "function" ? queryKey : null,
|
|
84
86
|
enabled: computed(() => hasRequiredRouteScope.value && Boolean(apiPath.value))
|
|
85
87
|
});
|
|
@@ -121,7 +123,7 @@ function useOperationScope({
|
|
|
121
123
|
return computed(() => Boolean(unref(baseLoading)) || accessRuntime.awaitingPlacementPermissions.value);
|
|
122
124
|
}
|
|
123
125
|
|
|
124
|
-
return
|
|
126
|
+
return {
|
|
125
127
|
scopeRuntime,
|
|
126
128
|
routeContext,
|
|
127
129
|
normalizedOwnershipFilter,
|
|
@@ -136,7 +138,7 @@ function useOperationScope({
|
|
|
136
138
|
permissionGate,
|
|
137
139
|
loadError,
|
|
138
140
|
isLoading
|
|
139
|
-
}
|
|
141
|
+
};
|
|
140
142
|
}
|
|
141
143
|
|
|
142
144
|
export { useOperationScope };
|