@jskit-ai/http-web 0.1.1
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/fixtures/crud-list-date-filters/App.vue +107 -0
- package/fixtures/crud-list-date-filters/index.html +12 -0
- package/fixtures/crud-list-date-filters/main.js +24 -0
- package/fixtures/crud-list-date-filters/vite.config.mjs +18 -0
- package/package.json +150 -0
- package/src/client/bulkActions.js +47 -0
- package/src/client/components/CrudAddEditScreen.vue +186 -0
- package/src/client/components/CrudDeleteAction.vue +93 -0
- package/src/client/components/CrudListBulkActionSurface.vue +126 -0
- package/src/client/components/CrudListDateFilterControl.vue +188 -0
- package/src/client/components/CrudListFilterSurface.vue +388 -0
- package/src/client/components/CrudListRecordActionMenu.vue +120 -0
- package/src/client/components/CrudListScreen.vue +501 -0
- package/src/client/components/CrudViewScreen.vue +197 -0
- package/src/client/composables/crud/crudBindingSupport.js +75 -0
- package/src/client/composables/crud/crudHttpClientSupport.js +57 -0
- package/src/client/composables/crud/crudJsonApiTransportSupport.js +145 -0
- package/src/client/composables/crud/crudLookupFieldLabelSupport.js +151 -0
- package/src/client/composables/crud/crudLookupFieldRuntime.js +251 -0
- package/src/client/composables/crud/crudSchemaFormHelpers.js +464 -0
- package/src/client/composables/internal/crudListFilterLookupSupport.js +161 -0
- package/src/client/composables/internal/crudListParentTitleSupport.js +171 -0
- package/src/client/composables/internal/useOperationScope.js +144 -0
- package/src/client/composables/records/useAddEdit.js +224 -0
- package/src/client/composables/records/useCrudAddEdit.js +227 -0
- package/src/client/composables/records/useCrudList.js +101 -0
- package/src/client/composables/records/useCrudView.js +47 -0
- package/src/client/composables/records/useList.js +500 -0
- package/src/client/composables/records/useView.js +164 -0
- package/src/client/composables/runtime/addEditUiRuntime.js +130 -0
- package/src/client/composables/runtime/listUiRuntime.js +123 -0
- package/src/client/composables/runtime/modelStateHelpers.js +90 -0
- package/src/client/composables/runtime/operationAdapters.js +34 -0
- package/src/client/composables/runtime/operationUiHelpers.js +125 -0
- package/src/client/composables/runtime/operationValidationHelpers.js +51 -0
- package/src/client/composables/runtime/useAddEditCore.js +112 -0
- package/src/client/composables/runtime/useCommandCore.js +123 -0
- package/src/client/composables/runtime/useEndpointResource.js +199 -0
- package/src/client/composables/runtime/useFieldErrorBag.js +61 -0
- package/src/client/composables/runtime/useListCore.js +112 -0
- package/src/client/composables/runtime/useUiFeedback.js +98 -0
- package/src/client/composables/runtime/useViewCore.js +93 -0
- package/src/client/composables/runtime/viewUiRuntime.js +96 -0
- package/src/client/composables/support/errorMessageHelpers.js +66 -0
- package/src/client/composables/support/listQueryParamSupport.js +473 -0
- package/src/client/composables/support/listSearchSupport.js +70 -0
- package/src/client/composables/support/refValueHelpers.js +19 -0
- package/src/client/composables/support/requestQueryRuntimeSupport.js +141 -0
- package/src/client/composables/support/resourceLoadStateHelpers.js +208 -0
- package/src/client/composables/support/routeTemplateHelpers.js +285 -0
- package/src/client/composables/support/scopeHelpers.js +145 -0
- package/src/client/composables/useAccess.js +109 -0
- package/src/client/composables/useCommand.js +118 -0
- package/src/client/composables/useCrudAddEditScreen.js +88 -0
- package/src/client/composables/useCrudDeleteAction.js +160 -0
- package/src/client/composables/useCrudListBulkActions.js +147 -0
- package/src/client/composables/useCrudListFilterLookups.js +146 -0
- package/src/client/composables/useCrudListFilters.js +339 -0
- package/src/client/composables/useCrudListParentTitle.js +151 -0
- package/src/client/composables/useCrudListRowActions.js +144 -0
- package/src/client/composables/useCrudListScreen.js +237 -0
- package/src/client/composables/useCrudViewScreen.js +77 -0
- package/src/client/composables/usePagedCollection.js +181 -0
- package/src/client/composables/useRealtimeQueryInvalidation.js +156 -0
- package/src/client/composables/useScopeRuntime.js +135 -0
- package/src/client/filters.js +15 -0
- package/src/client/index.js +24 -0
- package/src/client/lib/httpClient.js +47 -0
- package/src/client/lib/permissions.js +34 -0
- package/src/client/rowActions.js +47 -0
- package/src/client/support/contractGuards.js +34 -0
- package/src/client/support/crudListDateFilterSupport.js +91 -0
- package/test/addEditUiRuntime.test.js +110 -0
- package/test/crudBindingSupport.test.js +110 -0
- package/test/crudHttpClientSupport.test.js +77 -0
- package/test/crudJsonApiTransportSupport.test.js +179 -0
- package/test/crudListBulkActionSurface.test.js +27 -0
- package/test/crudListDateFilterSupport.test.js +92 -0
- package/test/crudListDateFilterSurface.browser.test.js +182 -0
- package/test/crudListFilterSurface.test.js +90 -0
- package/test/crudLookupFieldRuntime.test.js +264 -0
- package/test/crudScreenComponents.test.js +110 -0
- package/test/errorIntentContract.test.js +31 -0
- package/test/errorMessageHelpers.test.js +28 -0
- package/test/exportsContract.test.js +68 -0
- package/test/listQueryParamSupport.test.js +223 -0
- package/test/listUiRuntime.test.js +102 -0
- package/test/operationValidationHelpers.test.js +64 -0
- package/test/packageBoundary.test.js +31 -0
- package/test/permissions.test.js +35 -0
- package/test/refValueHelpers.test.js +14 -0
- package/test/requestTransportOptions.test.js +457 -0
- package/test/resourceLoadStateHelpers.test.js +189 -0
- package/test/routeTemplateHelpers.test.js +85 -0
- package/test/scopeHelpers.test.js +57 -0
- package/test/useAddEditCore.test.js +124 -0
- package/test/useAddEditRequestQueryParams.test.js +190 -0
- package/test/useCrudAddEdit.test.js +415 -0
- package/test/useCrudDeleteAction.test.js +139 -0
- package/test/useCrudListBulkActions.test.js +65 -0
- package/test/useCrudListFilterLookups.test.js +114 -0
- package/test/useCrudListFilters.test.js +293 -0
- package/test/useCrudListParentTitle.test.js +262 -0
- package/test/useCrudListRowActions.test.js +77 -0
- package/test/useListRouteInitialization.test.js +337 -0
- package/test/useListSearchSupport.test.js +61 -0
- package/test/usePagedCollection.test.js +53 -0
- package/test/useViewRequestQueryParams.test.js +20 -0
- package/test/viewCoreLoading.test.js +44 -0
- package/test/viewUiRuntime.test.js +95 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { computed, proxyRefs, reactive, watch } from "vue";
|
|
2
|
+
import { useRoute, useRouter } from "vue-router";
|
|
3
|
+
import { asPlainObject } from "../support/scopeHelpers.js";
|
|
4
|
+
import { resolveCrudJsonApiTransport } from "../crud/crudJsonApiTransportSupport.js";
|
|
5
|
+
import { resolveCrudHttpClient } from "../crud/crudHttpClientSupport.js";
|
|
6
|
+
import { useAddEdit } from "./useAddEdit.js";
|
|
7
|
+
import {
|
|
8
|
+
resolveCrudBoundValues,
|
|
9
|
+
} from "../crud/crudBindingSupport.js";
|
|
10
|
+
import { resolveOperationRealtimeOptions } from "../useRealtimeQueryInvalidation.js";
|
|
11
|
+
import {
|
|
12
|
+
normalizeCrudFormFields,
|
|
13
|
+
createCrudFormModel,
|
|
14
|
+
buildCrudFormPayload,
|
|
15
|
+
applyCrudPayloadToForm,
|
|
16
|
+
resolveCrudRouteBoundFieldValues,
|
|
17
|
+
resolveCrudFieldErrors
|
|
18
|
+
} from "../crud/crudSchemaFormHelpers.js";
|
|
19
|
+
import { hasResolvedQueryData } from "../support/resourceLoadStateHelpers.js";
|
|
20
|
+
|
|
21
|
+
function normalizeFieldErrorKeys(keys = []) {
|
|
22
|
+
return Array.isArray(keys)
|
|
23
|
+
? keys.map((entry) => String(entry || "").trim()).filter(Boolean)
|
|
24
|
+
: [];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function normalizeSaveSuccessOptions(options = {}) {
|
|
28
|
+
const source = asPlainObject(options);
|
|
29
|
+
const invalidateQueryKey = Array.isArray(source.invalidateQueryKey)
|
|
30
|
+
? source.invalidateQueryKey
|
|
31
|
+
: null;
|
|
32
|
+
const listUrlTemplate = String(source.listUrlTemplate || "").trim();
|
|
33
|
+
const navigateToView = source.navigateToView !== false;
|
|
34
|
+
const navigateToList = source.navigateToList !== false;
|
|
35
|
+
|
|
36
|
+
return Object.freeze({
|
|
37
|
+
invalidateQueryKey,
|
|
38
|
+
listUrlTemplate,
|
|
39
|
+
navigateToView,
|
|
40
|
+
navigateToList
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function useCrudAddEdit({
|
|
45
|
+
resource = null,
|
|
46
|
+
operationName = "",
|
|
47
|
+
formFields = [],
|
|
48
|
+
addEditOptions = {},
|
|
49
|
+
saveSuccess = {},
|
|
50
|
+
fieldBinding = null,
|
|
51
|
+
createModel = null,
|
|
52
|
+
buildPayload = null,
|
|
53
|
+
mapPayloadToModel = null,
|
|
54
|
+
input = null
|
|
55
|
+
} = {}) {
|
|
56
|
+
const router = useRouter();
|
|
57
|
+
const route = useRoute();
|
|
58
|
+
const normalizedFields = normalizeCrudFormFields(formFields);
|
|
59
|
+
const normalizedAddEditOptions = asPlainObject(addEditOptions);
|
|
60
|
+
const resolvedResource = normalizedAddEditOptions.resource || resource;
|
|
61
|
+
const resolvedTransport = resolveCrudJsonApiTransport(
|
|
62
|
+
normalizedAddEditOptions.transport,
|
|
63
|
+
resolvedResource,
|
|
64
|
+
{
|
|
65
|
+
mode: "add-edit",
|
|
66
|
+
operationName
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
const resolvedRealtime = resolveOperationRealtimeOptions({
|
|
70
|
+
realtime: normalizedAddEditOptions.realtime,
|
|
71
|
+
fallbackRealtime: resolvedResource?.operations?.[operationName]?.realtime ||
|
|
72
|
+
resolvedResource?.operations?.list?.realtime ||
|
|
73
|
+
null
|
|
74
|
+
});
|
|
75
|
+
const saveSuccessOptions = normalizeSaveSuccessOptions(saveSuccess);
|
|
76
|
+
const defaultFieldErrorKeys = normalizedFields.map((field) => field.key);
|
|
77
|
+
const providedFieldErrorKeys = normalizeFieldErrorKeys(normalizedAddEditOptions.fieldErrorKeys);
|
|
78
|
+
const fieldErrorKeys = providedFieldErrorKeys.length > 0 ? providedFieldErrorKeys : defaultFieldErrorKeys;
|
|
79
|
+
const providedModel = normalizedAddEditOptions.model;
|
|
80
|
+
const hasProvidedModel = Boolean(providedModel && typeof providedModel === "object" && !Array.isArray(providedModel));
|
|
81
|
+
const defaultModel = typeof createModel === "function"
|
|
82
|
+
? asPlainObject(createModel(normalizedFields))
|
|
83
|
+
: createCrudFormModel(normalizedFields);
|
|
84
|
+
const form = hasProvidedModel ? providedModel : reactive(defaultModel);
|
|
85
|
+
const boundFieldValues = computed(() => {
|
|
86
|
+
return resolveCrudBoundValues({
|
|
87
|
+
binding: fieldBinding,
|
|
88
|
+
routeValues: resolveCrudRouteBoundFieldValues(normalizedFields, route?.params || {}),
|
|
89
|
+
context: Object.freeze({
|
|
90
|
+
route,
|
|
91
|
+
fields: normalizedFields
|
|
92
|
+
})
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
function applyBoundFieldValues(target = {}) {
|
|
97
|
+
Object.assign(target, boundFieldValues.value);
|
|
98
|
+
return target;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
watch(
|
|
102
|
+
boundFieldValues,
|
|
103
|
+
() => {
|
|
104
|
+
applyBoundFieldValues(form);
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
immediate: true,
|
|
108
|
+
deep: true
|
|
109
|
+
}
|
|
110
|
+
);
|
|
111
|
+
const inputOverride = input || normalizedAddEditOptions.input || null;
|
|
112
|
+
const buildPayloadOverride = typeof buildPayload === "function"
|
|
113
|
+
? buildPayload
|
|
114
|
+
: (typeof normalizedAddEditOptions.buildRawPayload === "function" ? normalizedAddEditOptions.buildRawPayload : null);
|
|
115
|
+
const mapPayloadToModelOverride = typeof mapPayloadToModel === "function"
|
|
116
|
+
? mapPayloadToModel
|
|
117
|
+
: (typeof normalizedAddEditOptions.mapLoadedToModel === "function" ? normalizedAddEditOptions.mapLoadedToModel : null);
|
|
118
|
+
const onSaveSuccessOverride = typeof normalizedAddEditOptions.onSaveSuccess === "function"
|
|
119
|
+
? normalizedAddEditOptions.onSaveSuccess
|
|
120
|
+
: null;
|
|
121
|
+
const shouldApplyDefaultMapPayload = normalizedAddEditOptions.readEnabled !== false;
|
|
122
|
+
const resolvedInput = inputOverride || resolvedResource?.operations?.[operationName]?.body || null;
|
|
123
|
+
|
|
124
|
+
function resolveBuildRawPayload(model = {}, context = {}) {
|
|
125
|
+
const payload = buildPayloadOverride
|
|
126
|
+
? buildPayloadOverride(model, {
|
|
127
|
+
...context,
|
|
128
|
+
fields: normalizedFields
|
|
129
|
+
})
|
|
130
|
+
: buildCrudFormPayload(normalizedFields, model);
|
|
131
|
+
applyBoundFieldValues(payload);
|
|
132
|
+
|
|
133
|
+
return payload;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const effectiveMapLoadedToModel = mapPayloadToModelOverride
|
|
137
|
+
? (model = {}, payload = {}, context = {}) => {
|
|
138
|
+
mapPayloadToModelOverride(model, payload, {
|
|
139
|
+
...context,
|
|
140
|
+
fields: normalizedFields
|
|
141
|
+
});
|
|
142
|
+
applyBoundFieldValues(model);
|
|
143
|
+
}
|
|
144
|
+
: (shouldApplyDefaultMapPayload
|
|
145
|
+
? (model = {}, payload = {}) => {
|
|
146
|
+
applyCrudPayloadToForm(normalizedFields, model, payload);
|
|
147
|
+
applyBoundFieldValues(model);
|
|
148
|
+
}
|
|
149
|
+
: undefined);
|
|
150
|
+
|
|
151
|
+
let addEditRuntime = null;
|
|
152
|
+
|
|
153
|
+
async function handleSaveSuccess(payload, context = {}) {
|
|
154
|
+
if (onSaveSuccessOverride) {
|
|
155
|
+
await onSaveSuccessOverride(payload, context);
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const queryClient = context?.queryClient;
|
|
160
|
+
if (queryClient && saveSuccessOptions.invalidateQueryKey?.length > 0) {
|
|
161
|
+
await queryClient.invalidateQueries({
|
|
162
|
+
queryKey: saveSuccessOptions.invalidateQueryKey
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
if (saveSuccessOptions.navigateToView) {
|
|
167
|
+
const viewUrl = addEditRuntime?.resolveSavedViewUrl(payload) ||
|
|
168
|
+
addEditRuntime?.resolveViewUrl(addEditRuntime?.recordId);
|
|
169
|
+
if (viewUrl) {
|
|
170
|
+
await router.push(viewUrl);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (!saveSuccessOptions.navigateToList) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const listUrlTemplate = saveSuccessOptions.listUrlTemplate ||
|
|
180
|
+
String(normalizedAddEditOptions.listUrlTemplate || "").trim();
|
|
181
|
+
const listUrl = addEditRuntime?.resolveParams(listUrlTemplate);
|
|
182
|
+
if (listUrl) {
|
|
183
|
+
await router.push(listUrl);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
const addEdit = useAddEdit({
|
|
188
|
+
...normalizedAddEditOptions,
|
|
189
|
+
resource: resolvedResource,
|
|
190
|
+
client: resolveCrudHttpClient(resolvedResource, {
|
|
191
|
+
client: normalizedAddEditOptions.client
|
|
192
|
+
}),
|
|
193
|
+
transport: resolvedTransport,
|
|
194
|
+
model: form,
|
|
195
|
+
fieldErrorKeys,
|
|
196
|
+
input: resolvedInput,
|
|
197
|
+
buildRawPayload: resolveBuildRawPayload,
|
|
198
|
+
mapLoadedToModel: effectiveMapLoadedToModel,
|
|
199
|
+
realtime: resolvedRealtime,
|
|
200
|
+
onSaveSuccess: handleSaveSuccess
|
|
201
|
+
});
|
|
202
|
+
addEditRuntime = addEdit;
|
|
203
|
+
|
|
204
|
+
function resolveFieldErrors(fieldKey = "") {
|
|
205
|
+
return resolveCrudFieldErrors(addEdit.fieldErrors, fieldKey);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const showFormSkeleton = computed(() => {
|
|
209
|
+
const hasResolvedData = hasResolvedQueryData({
|
|
210
|
+
query: addEdit?.resource?.query,
|
|
211
|
+
data: addEdit?.resource?.data
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
return Boolean(addEdit.isInitialLoading) && !hasResolvedData;
|
|
215
|
+
});
|
|
216
|
+
|
|
217
|
+
return proxyRefs({
|
|
218
|
+
formFields: normalizedFields,
|
|
219
|
+
fieldErrorKeys,
|
|
220
|
+
form,
|
|
221
|
+
addEdit,
|
|
222
|
+
showFormSkeleton,
|
|
223
|
+
resolveFieldErrors
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export { useCrudAddEdit };
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { computed, unref } from "vue";
|
|
2
|
+
import { useRoute } from "vue-router";
|
|
3
|
+
import { resolveCrudJsonApiTransport } from "../crud/crudJsonApiTransportSupport.js";
|
|
4
|
+
import { resolveCrudHttpClient } from "../crud/crudHttpClientSupport.js";
|
|
5
|
+
import {
|
|
6
|
+
resolveLookupFieldDisplayValue,
|
|
7
|
+
resolveRecordTitle
|
|
8
|
+
} from "../crud/crudLookupFieldLabelSupport.js";
|
|
9
|
+
import { resolveCrudBoundValues } from "../crud/crudBindingSupport.js";
|
|
10
|
+
import { resolveCrudListParentDescriptor } from "../internal/crudListParentTitleSupport.js";
|
|
11
|
+
import {
|
|
12
|
+
resolveRouteParamsSource,
|
|
13
|
+
toRouteParamValue
|
|
14
|
+
} from "../support/routeTemplateHelpers.js";
|
|
15
|
+
import { asPlainObject } from "../support/scopeHelpers.js";
|
|
16
|
+
import { resolveOperationRealtimeOptions } from "../useRealtimeQueryInvalidation.js";
|
|
17
|
+
import { useList } from "./useList.js";
|
|
18
|
+
|
|
19
|
+
function resolveRequestQueryParamsInput(requestQueryParams, context = {}) {
|
|
20
|
+
if (typeof requestQueryParams === "function") {
|
|
21
|
+
return asPlainObject(requestQueryParams(context));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return asPlainObject(unref(requestQueryParams));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function resolveCrudParentRequestQueryParams({ resource = {}, route = null, recordIdParam = "recordId" } = {}) {
|
|
28
|
+
const descriptor = resolveCrudListParentDescriptor({
|
|
29
|
+
resource,
|
|
30
|
+
route,
|
|
31
|
+
recordIdParam
|
|
32
|
+
});
|
|
33
|
+
if (!descriptor?.fieldKey || !descriptor?.routeParamKey) {
|
|
34
|
+
return {};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const routeParams = resolveRouteParamsSource(route?.params || {});
|
|
38
|
+
const routeParamValue = toRouteParamValue(routeParams[descriptor.routeParamKey]);
|
|
39
|
+
if (!routeParamValue) {
|
|
40
|
+
return {};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return {
|
|
44
|
+
[descriptor.fieldKey]: routeParamValue
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function useCrudList({
|
|
49
|
+
resource = null,
|
|
50
|
+
requestQueryParams = null,
|
|
51
|
+
parentBinding = null,
|
|
52
|
+
recordIdParam = "recordId",
|
|
53
|
+
route = null,
|
|
54
|
+
realtime = undefined,
|
|
55
|
+
...listOptions
|
|
56
|
+
} = {}) {
|
|
57
|
+
const sourceRoute = route && typeof route === "object" ? route : useRoute();
|
|
58
|
+
const boundParentRequestQueryParams = computed(() => {
|
|
59
|
+
return resolveCrudBoundValues({
|
|
60
|
+
binding: parentBinding,
|
|
61
|
+
routeValues: resolveCrudParentRequestQueryParams({
|
|
62
|
+
resource,
|
|
63
|
+
route: sourceRoute,
|
|
64
|
+
recordIdParam
|
|
65
|
+
}),
|
|
66
|
+
context: Object.freeze({
|
|
67
|
+
route: sourceRoute,
|
|
68
|
+
resource,
|
|
69
|
+
recordIdParam
|
|
70
|
+
})
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
const records = useList({
|
|
74
|
+
...listOptions,
|
|
75
|
+
client: resolveCrudHttpClient(resource, {
|
|
76
|
+
client: listOptions.client
|
|
77
|
+
}),
|
|
78
|
+
transport: resolveCrudJsonApiTransport(listOptions.transport, resource, {
|
|
79
|
+
mode: "list"
|
|
80
|
+
}),
|
|
81
|
+
realtime: resolveOperationRealtimeOptions({
|
|
82
|
+
realtime,
|
|
83
|
+
fallbackRealtime: resource?.operations?.list?.realtime || null
|
|
84
|
+
}),
|
|
85
|
+
recordIdParam,
|
|
86
|
+
requestQueryParams(context = {}) {
|
|
87
|
+
const baseRequestQueryParams = resolveRequestQueryParamsInput(requestQueryParams, context);
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
...baseRequestQueryParams,
|
|
91
|
+
...boundParentRequestQueryParams.value
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
records.resolveFieldDisplay = resolveLookupFieldDisplayValue;
|
|
97
|
+
records.resolveRecordTitle = resolveRecordTitle;
|
|
98
|
+
return records;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export { useCrudList };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { computed } from "vue";
|
|
2
|
+
import { useRoute } from "vue-router";
|
|
3
|
+
import {
|
|
4
|
+
resolveCrudJsonApiTransport
|
|
5
|
+
} from "../crud/crudJsonApiTransportSupport.js";
|
|
6
|
+
import { resolveCrudHttpClient } from "../crud/crudHttpClientSupport.js";
|
|
7
|
+
import {
|
|
8
|
+
resolveLookupFieldDisplayValue,
|
|
9
|
+
resolveRecordTitle
|
|
10
|
+
} from "../crud/crudLookupFieldLabelSupport.js";
|
|
11
|
+
import { resolveCrudBoundValues } from "../crud/crudBindingSupport.js";
|
|
12
|
+
import { asPlainObject } from "../support/scopeHelpers.js";
|
|
13
|
+
import { useView } from "./useView.js";
|
|
14
|
+
|
|
15
|
+
function useCrudView({
|
|
16
|
+
resource = null,
|
|
17
|
+
paramBinding = null,
|
|
18
|
+
route = null,
|
|
19
|
+
...viewOptions
|
|
20
|
+
} = {}) {
|
|
21
|
+
const sourceRoute = route && typeof route === "object" ? route : useRoute();
|
|
22
|
+
const boundRouteParams = computed(() => {
|
|
23
|
+
return resolveCrudBoundValues({
|
|
24
|
+
binding: paramBinding,
|
|
25
|
+
routeValues: asPlainObject(sourceRoute?.params || {}),
|
|
26
|
+
context: Object.freeze({
|
|
27
|
+
route: sourceRoute
|
|
28
|
+
})
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
const view = useView({
|
|
32
|
+
...viewOptions,
|
|
33
|
+
resource,
|
|
34
|
+
client: resolveCrudHttpClient(resource, {
|
|
35
|
+
client: viewOptions.client
|
|
36
|
+
}),
|
|
37
|
+
transport: resolveCrudJsonApiTransport(viewOptions.transport, resource, {
|
|
38
|
+
mode: "view"
|
|
39
|
+
}),
|
|
40
|
+
routeParams: boundRouteParams
|
|
41
|
+
});
|
|
42
|
+
view.resolveFieldDisplay = resolveLookupFieldDisplayValue;
|
|
43
|
+
view.resolveRecordTitle = resolveRecordTitle;
|
|
44
|
+
return view;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { useCrudView };
|