@jskit-ai/users-web 0.1.172 → 0.1.174

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.
Files changed (112) hide show
  1. package/package.json +18 -149
  2. package/src/client/composables/account-settings/accountSettingsAvatarUploadRuntime.js +2 -2
  3. package/src/client/composables/useAccountSettingsRuntime.js +3 -3
  4. package/src/client/index.js +0 -11
  5. package/test/exportsContract.test.js +3 -29
  6. package/test/settingsPlacementContract.test.js +10 -0
  7. package/fixtures/crud-list-date-filters/App.vue +0 -107
  8. package/fixtures/crud-list-date-filters/index.html +0 -12
  9. package/fixtures/crud-list-date-filters/main.js +0 -24
  10. package/fixtures/crud-list-date-filters/vite.config.mjs +0 -18
  11. package/src/client/bulkActions.js +0 -47
  12. package/src/client/components/CrudAddEditScreen.vue +0 -186
  13. package/src/client/components/CrudDeleteAction.vue +0 -93
  14. package/src/client/components/CrudListBulkActionSurface.vue +0 -126
  15. package/src/client/components/CrudListDateFilterControl.vue +0 -188
  16. package/src/client/components/CrudListFilterSurface.vue +0 -388
  17. package/src/client/components/CrudListRecordActionMenu.vue +0 -120
  18. package/src/client/components/CrudListScreen.vue +0 -501
  19. package/src/client/components/CrudViewScreen.vue +0 -197
  20. package/src/client/composables/crud/crudBindingSupport.js +0 -75
  21. package/src/client/composables/crud/crudHttpClientSupport.js +0 -57
  22. package/src/client/composables/crud/crudJsonApiTransportSupport.js +0 -145
  23. package/src/client/composables/crud/crudLookupFieldLabelSupport.js +0 -151
  24. package/src/client/composables/crud/crudLookupFieldRuntime.js +0 -251
  25. package/src/client/composables/crud/crudSchemaFormHelpers.js +0 -464
  26. package/src/client/composables/internal/crudListFilterLookupSupport.js +0 -161
  27. package/src/client/composables/internal/crudListParentTitleSupport.js +0 -171
  28. package/src/client/composables/internal/useOperationScope.js +0 -144
  29. package/src/client/composables/records/useAddEdit.js +0 -224
  30. package/src/client/composables/records/useCrudAddEdit.js +0 -227
  31. package/src/client/composables/records/useCrudList.js +0 -101
  32. package/src/client/composables/records/useCrudView.js +0 -47
  33. package/src/client/composables/records/useList.js +0 -500
  34. package/src/client/composables/records/useView.js +0 -164
  35. package/src/client/composables/runtime/addEditUiRuntime.js +0 -130
  36. package/src/client/composables/runtime/listUiRuntime.js +0 -123
  37. package/src/client/composables/runtime/modelStateHelpers.js +0 -90
  38. package/src/client/composables/runtime/operationAdapters.js +0 -34
  39. package/src/client/composables/runtime/operationUiHelpers.js +0 -125
  40. package/src/client/composables/runtime/operationValidationHelpers.js +0 -51
  41. package/src/client/composables/runtime/useAddEditCore.js +0 -112
  42. package/src/client/composables/runtime/useCommandCore.js +0 -123
  43. package/src/client/composables/runtime/useEndpointResource.js +0 -199
  44. package/src/client/composables/runtime/useFieldErrorBag.js +0 -61
  45. package/src/client/composables/runtime/useListCore.js +0 -112
  46. package/src/client/composables/runtime/useUiFeedback.js +0 -98
  47. package/src/client/composables/runtime/useViewCore.js +0 -93
  48. package/src/client/composables/runtime/viewUiRuntime.js +0 -96
  49. package/src/client/composables/support/errorMessageHelpers.js +0 -66
  50. package/src/client/composables/support/listQueryParamSupport.js +0 -473
  51. package/src/client/composables/support/listSearchSupport.js +0 -70
  52. package/src/client/composables/support/refValueHelpers.js +0 -19
  53. package/src/client/composables/support/requestQueryRuntimeSupport.js +0 -141
  54. package/src/client/composables/support/resourceLoadStateHelpers.js +0 -208
  55. package/src/client/composables/support/routeTemplateHelpers.js +0 -285
  56. package/src/client/composables/support/scopeHelpers.js +0 -145
  57. package/src/client/composables/useAccess.js +0 -109
  58. package/src/client/composables/useCommand.js +0 -118
  59. package/src/client/composables/useCrudAddEditScreen.js +0 -88
  60. package/src/client/composables/useCrudDeleteAction.js +0 -160
  61. package/src/client/composables/useCrudListBulkActions.js +0 -147
  62. package/src/client/composables/useCrudListFilterLookups.js +0 -146
  63. package/src/client/composables/useCrudListFilters.js +0 -339
  64. package/src/client/composables/useCrudListParentTitle.js +0 -151
  65. package/src/client/composables/useCrudListRowActions.js +0 -144
  66. package/src/client/composables/useCrudListScreen.js +0 -237
  67. package/src/client/composables/useCrudViewScreen.js +0 -77
  68. package/src/client/composables/usePagedCollection.js +0 -181
  69. package/src/client/composables/useRealtimeQueryInvalidation.js +0 -156
  70. package/src/client/composables/useScopeRuntime.js +0 -135
  71. package/src/client/filters.js +0 -15
  72. package/src/client/lib/httpClient.js +0 -47
  73. package/src/client/lib/permissions.js +0 -34
  74. package/src/client/rowActions.js +0 -47
  75. package/src/client/support/contractGuards.js +0 -34
  76. package/src/client/support/crudListDateFilterSupport.js +0 -91
  77. package/test/addEditUiRuntime.test.js +0 -110
  78. package/test/crudBindingSupport.test.js +0 -110
  79. package/test/crudHttpClientSupport.test.js +0 -77
  80. package/test/crudJsonApiTransportSupport.test.js +0 -179
  81. package/test/crudListBulkActionSurface.test.js +0 -27
  82. package/test/crudListDateFilterSupport.test.js +0 -92
  83. package/test/crudListDateFilterSurface.browser.test.js +0 -182
  84. package/test/crudListFilterSurface.test.js +0 -90
  85. package/test/crudLookupFieldRuntime.test.js +0 -264
  86. package/test/crudScreenComponents.test.js +0 -117
  87. package/test/errorIntentContract.test.js +0 -31
  88. package/test/errorMessageHelpers.test.js +0 -28
  89. package/test/listQueryParamSupport.test.js +0 -223
  90. package/test/listUiRuntime.test.js +0 -102
  91. package/test/operationValidationHelpers.test.js +0 -64
  92. package/test/permissions.test.js +0 -35
  93. package/test/refValueHelpers.test.js +0 -14
  94. package/test/requestTransportOptions.test.js +0 -457
  95. package/test/resourceLoadStateHelpers.test.js +0 -189
  96. package/test/routeTemplateHelpers.test.js +0 -85
  97. package/test/scopeHelpers.test.js +0 -57
  98. package/test/useAddEditCore.test.js +0 -124
  99. package/test/useAddEditRequestQueryParams.test.js +0 -190
  100. package/test/useCrudAddEdit.test.js +0 -415
  101. package/test/useCrudDeleteAction.test.js +0 -139
  102. package/test/useCrudListBulkActions.test.js +0 -65
  103. package/test/useCrudListFilterLookups.test.js +0 -114
  104. package/test/useCrudListFilters.test.js +0 -293
  105. package/test/useCrudListParentTitle.test.js +0 -262
  106. package/test/useCrudListRowActions.test.js +0 -77
  107. package/test/useListRouteInitialization.test.js +0 -337
  108. package/test/useListSearchSupport.test.js +0 -61
  109. package/test/usePagedCollection.test.js +0 -53
  110. package/test/useViewRequestQueryParams.test.js +0 -20
  111. package/test/viewCoreLoading.test.js +0 -44
  112. package/test/viewUiRuntime.test.js +0 -95
@@ -1,151 +0,0 @@
1
- import { computed, proxyRefs } from "vue";
2
- import { useRoute } from "vue-router";
3
- import { normalizeText } from "@jskit-ai/kernel/shared/support/normalize";
4
- import { inferCrudLookupJsonApiTransport } from "./crud/crudJsonApiTransportSupport.js";
5
- import {
6
- resolveRouteParamsSource,
7
- toRouteParamValue
8
- } from "./support/routeTemplateHelpers.js";
9
- import { useView } from "./records/useView.js";
10
- import {
11
- resolveCrudListParentDescriptor,
12
- resolveCrudListParentRecordTitle,
13
- resolveCrudListParentTitleFromItems
14
- } from "./internal/crudListParentTitleSupport.js";
15
-
16
- function normalizeQueryKeyPrefix(value = []) {
17
- if (Array.isArray(value)) {
18
- return value
19
- .map((entry) => normalizeText(entry))
20
- .filter(Boolean);
21
- }
22
-
23
- const normalizedValue = normalizeText(value);
24
- return normalizedValue ? [normalizedValue] : [];
25
- }
26
-
27
- function useCrudListParentTitle({
28
- listRuntime = null,
29
- resource = {},
30
- adapter = null,
31
- recordIdParam = "recordId",
32
- queryKeyPrefix = ["users-web", "crud-list-parent-title"],
33
- placementSource = "users-web.crud-list-parent-title",
34
- fallbackLoadError = "Unable to load parent record.",
35
- notFoundMessage = "Parent record not found.",
36
- route = null,
37
- viewRuntimeFactory = useView
38
- } = {}) {
39
- const sourceRoute = route && typeof route === "object" ? route : useRoute();
40
- const parentDescriptor = computed(() => {
41
- const descriptor = resolveCrudListParentDescriptor({
42
- resource,
43
- route: sourceRoute,
44
- recordIdParam
45
- });
46
- if (!descriptor) {
47
- return null;
48
- }
49
-
50
- const routeParams = resolveRouteParamsSource(sourceRoute?.params || {});
51
- const routeParamValue = toRouteParamValue(routeParams[descriptor.routeParamKey]);
52
- if (!routeParamValue) {
53
- return null;
54
- }
55
-
56
- return Object.freeze({
57
- ...descriptor,
58
- routeParamValue
59
- });
60
- });
61
-
62
- const initialParentDescriptor = parentDescriptor.value || {};
63
- const parentTransport = (() => {
64
- const baseTransport = inferCrudLookupJsonApiTransport({
65
- namespace: initialParentDescriptor.relationNamespace
66
- });
67
- if (!baseTransport) {
68
- return null;
69
- }
70
-
71
- return Object.freeze({
72
- ...baseTransport,
73
- responseKind: "record"
74
- });
75
- })();
76
- const normalizedQueryKeyPrefix = normalizeQueryKeyPrefix(queryKeyPrefix);
77
- const shouldLoadParentRecord = computed(() => {
78
- const descriptor = parentDescriptor.value;
79
- if (!descriptor?.apiUrlTemplate) {
80
- return false;
81
- }
82
- if (Boolean(listRuntime?.isInitialLoading) || normalizeText(listRuntime?.loadError)) {
83
- return false;
84
- }
85
-
86
- const items = Array.isArray(listRuntime?.items) ? listRuntime.items : [];
87
- if (items.length < 1) {
88
- return true;
89
- }
90
-
91
- const listTitle = resolveCrudListParentTitleFromItems(items, descriptor);
92
- return !listTitle;
93
- });
94
-
95
- const parentView = viewRuntimeFactory({
96
- adapter,
97
- apiUrlTemplate: normalizeText(initialParentDescriptor.apiUrlTemplate),
98
- transport: parentTransport,
99
- readEnabled: shouldLoadParentRecord,
100
- recordIdParam: normalizeText(initialParentDescriptor.routeParamKey) || "recordId",
101
- includeRecordIdInQueryKey: true,
102
- queryKeyFactory: (surfaceId = "", scopeParamValue = "") => [
103
- ...normalizedQueryKeyPrefix,
104
- normalizeText(initialParentDescriptor.relationNamespace),
105
- normalizeText(initialParentDescriptor.routeParamKey),
106
- String(surfaceId || ""),
107
- String(scopeParamValue || "")
108
- ],
109
- placementSource,
110
- fallbackLoadError,
111
- notFoundMessage
112
- });
113
-
114
- const title = computed(() => {
115
- const descriptor = parentDescriptor.value;
116
- if (!descriptor) {
117
- return "";
118
- }
119
-
120
- const parentRecordTitle = resolveCrudListParentRecordTitle(parentView?.record || {}, descriptor);
121
- if (parentRecordTitle && shouldLoadParentRecord.value) {
122
- return parentRecordTitle;
123
- }
124
-
125
- const listTitle = resolveCrudListParentTitleFromItems(listRuntime?.items, descriptor);
126
- if (listTitle) {
127
- return listTitle;
128
- }
129
-
130
- if (parentRecordTitle) {
131
- return parentRecordTitle;
132
- }
133
-
134
- if (descriptor.routeParamValue) {
135
- return `${descriptor.entityLabel} #${descriptor.routeParamValue}`;
136
- }
137
-
138
- return descriptor.entityLabel;
139
- });
140
-
141
- return proxyRefs({
142
- title,
143
- descriptor: parentDescriptor,
144
- shouldLoadParentRecord,
145
- record: computed(() => parentView?.record || null),
146
- isLoading: computed(() => Boolean(parentView?.isLoading)),
147
- loadError: computed(() => normalizeText(parentView?.loadError))
148
- });
149
- }
150
-
151
- export { useCrudListParentTitle };
@@ -1,144 +0,0 @@
1
- import { computed, ref } from "vue";
2
- import { normalizeText } from "@jskit-ai/kernel/shared/support/normalize";
3
- import { defineCrudListRowActions } from "../rowActions.js";
4
-
5
- function normalizeRowActionKey(actionOrKey = "") {
6
- return normalizeText(
7
- actionOrKey && typeof actionOrKey === "object"
8
- ? actionOrKey.key
9
- : actionOrKey
10
- );
11
- }
12
-
13
- function normalizeRowId(value = "") {
14
- return normalizeText(value);
15
- }
16
-
17
- function createExecutionKey(actionKey = "", recordId = "", index = 0) {
18
- return [
19
- actionKey,
20
- recordId || `index-${index}`
21
- ].join(":");
22
- }
23
-
24
- function asContextObject(value = null) {
25
- return value && typeof value === "object" && !Array.isArray(value) ? value : {};
26
- }
27
-
28
- function useCrudListRowActions(actions = [], {
29
- resolveRecordId = null,
30
- resolveContext = null
31
- } = {}) {
32
- const normalizedActions = defineCrudListRowActions(actions);
33
- const executingKeys = ref([]);
34
- const hasActions = computed(() => normalizedActions.length > 0);
35
-
36
- function getRecordId(record = {}, index = 0) {
37
- const resolvedId = typeof resolveRecordId === "function"
38
- ? resolveRecordId(record, index)
39
- : record?.id ?? record?.attributes?.id ?? index;
40
- return normalizeRowId(resolvedId);
41
- }
42
-
43
- function createActionContext(action = {}, record = {}, index = 0) {
44
- const baseContext = typeof resolveContext === "function" ? resolveContext() : {};
45
- return {
46
- ...asContextObject(baseContext),
47
- action,
48
- record,
49
- index,
50
- recordId: getRecordId(record, index)
51
- };
52
- }
53
-
54
- function findAction(actionOrKey = "") {
55
- const actionKey = normalizeRowActionKey(actionOrKey);
56
- return normalizedActions.find((action) => action.key === actionKey) || null;
57
- }
58
-
59
- function resolveActionFlag(action = {}, flagKey = "", record = {}, index = 0, fallback = false) {
60
- const flag = action?.[flagKey];
61
- if (typeof flag === "function") {
62
- return Boolean(flag(createActionContext(action, record, index)));
63
- }
64
- if (flag === undefined || flag === null) {
65
- return fallback;
66
- }
67
- return Boolean(flag);
68
- }
69
-
70
- function isActionVisible(actionOrKey = "", record = {}, index = 0) {
71
- const action = findAction(actionOrKey);
72
- return action ? resolveActionFlag(action, "visible", record, index, true) : false;
73
- }
74
-
75
- function isActionExecuting(actionOrKey = "", record = {}, index = 0) {
76
- const action = findAction(actionOrKey);
77
- if (!action) {
78
- return false;
79
- }
80
-
81
- const executionKey = createExecutionKey(action.key, getRecordId(record, index), index);
82
- return executingKeys.value.includes(executionKey);
83
- }
84
-
85
- function isActionLoading(actionOrKey = "", record = {}, index = 0) {
86
- const action = findAction(actionOrKey);
87
- if (!action) {
88
- return false;
89
- }
90
-
91
- return isActionExecuting(action, record, index) ||
92
- resolveActionFlag(action, "loading", record, index, false);
93
- }
94
-
95
- function isActionDisabled(actionOrKey = "", record = {}, index = 0) {
96
- const action = findAction(actionOrKey);
97
- if (!action || !isActionVisible(action, record, index) || !action.run) {
98
- return true;
99
- }
100
-
101
- return isActionLoading(action, record, index) ||
102
- resolveActionFlag(action, "disabled", record, index, false);
103
- }
104
-
105
- function visibleActionsFor(record = {}, index = 0) {
106
- return normalizedActions.filter((action) => isActionVisible(action, record, index));
107
- }
108
-
109
- function hasVisibleActionsFor(record = {}, index = 0) {
110
- return visibleActionsFor(record, index).length > 0;
111
- }
112
-
113
- async function execute(actionOrKey = "", record = {}, index = 0) {
114
- const action = findAction(actionOrKey);
115
- if (!action || typeof action.run !== "function" || isActionDisabled(action, record, index)) {
116
- return null;
117
- }
118
-
119
- const executionKey = createExecutionKey(action.key, getRecordId(record, index), index);
120
- executingKeys.value = [...executingKeys.value, executionKey];
121
- try {
122
- return await action.run(createActionContext(action, record, index));
123
- } finally {
124
- executingKeys.value = executingKeys.value.filter((key) => key !== executionKey);
125
- }
126
- }
127
-
128
- return Object.freeze({
129
- actions: normalizedActions,
130
- hasActions,
131
- executingKeys,
132
- getRecordId,
133
- findAction,
134
- isActionVisible,
135
- isActionDisabled,
136
- isActionLoading,
137
- isActionExecuting,
138
- visibleActionsFor,
139
- hasVisibleActionsFor,
140
- execute
141
- });
142
- }
143
-
144
- export { useCrudListRowActions };
@@ -1,237 +0,0 @@
1
- import { computed, unref } from "vue";
2
- import { useCrudList } from "./records/useCrudList.js";
3
- import { useCrudListBulkActions } from "./useCrudListBulkActions.js";
4
- import { useCrudListFilters } from "./useCrudListFilters.js";
5
- import { useCrudListRowActions } from "./useCrudListRowActions.js";
6
- import { resolveCrudHttpClient } from "./crud/crudHttpClientSupport.js";
7
-
8
- function buildCrudListActionContext(records, client) {
9
- return Object.freeze({
10
- records,
11
- reload: records.reload,
12
- client
13
- });
14
- }
15
-
16
- function formatCrudListCardValue(value) {
17
- if (value === null || value === undefined || value === "") {
18
- return "-";
19
- }
20
- if (value === true) {
21
- return "Yes";
22
- }
23
- if (value === false) {
24
- return "No";
25
- }
26
- return value;
27
- }
28
-
29
- function asList(value = []) {
30
- const resolved = unref(value);
31
- if (resolved == null) {
32
- return [];
33
- }
34
- return Array.isArray(resolved) ? resolved : [resolved];
35
- }
36
-
37
- function hasSyntheticRowGroups(value = null) {
38
- const source = unref(value);
39
- return Boolean(
40
- source &&
41
- typeof source === "object" &&
42
- !Array.isArray(source) &&
43
- (Object.hasOwn(source, "prepend") || Object.hasOwn(source, "append"))
44
- );
45
- }
46
-
47
- function normalizeSyntheticDisplayRow(source = null, index = 0, placement = "prepend") {
48
- const rawRow = unref(source);
49
- if (!rawRow || typeof rawRow !== "object" || Array.isArray(rawRow)) {
50
- return null;
51
- }
52
-
53
- const hasWrappedRecord = Object.hasOwn(rawRow, "record");
54
- const record = hasWrappedRecord ? unref(rawRow.record) : rawRow;
55
- if (!record || typeof record !== "object" || Array.isArray(record)) {
56
- return null;
57
- }
58
-
59
- const keySource = hasWrappedRecord
60
- ? rawRow.key
61
- : record.id ?? record.attributes?.id;
62
- const recordKey = String(keySource || `synthetic-${placement}-${index + 1}`).trim();
63
-
64
- return Object.freeze({
65
- key: `synthetic:${placement}:${recordKey}`,
66
- recordKey,
67
- record,
68
- index: hasWrappedRecord && Number.isInteger(rawRow.index) ? rawRow.index : -1,
69
- synthetic: true,
70
- selectable: rawRow.selectable === true,
71
- placement
72
- });
73
- }
74
-
75
- function normalizeSyntheticDisplayRows(value = [], placement = "prepend") {
76
- return asList(value)
77
- .map((row, index) => normalizeSyntheticDisplayRow(row, index, placement))
78
- .filter(Boolean);
79
- }
80
-
81
- function normalizeSyntheticDisplayRowGroups(syntheticRows = null) {
82
- const source = unref(syntheticRows);
83
- if (hasSyntheticRowGroups(source)) {
84
- return Object.freeze({
85
- prepend: normalizeSyntheticDisplayRows(source.prepend, "prepend"),
86
- append: normalizeSyntheticDisplayRows(source.append, "append")
87
- });
88
- }
89
-
90
- return Object.freeze({
91
- prepend: normalizeSyntheticDisplayRows(source, "prepend"),
92
- append: []
93
- });
94
- }
95
-
96
- function createCrudListDisplayRow(record = {}, index = 0, records = {}) {
97
- const resolveRowKey = typeof records.resolveRowKey === "function"
98
- ? records.resolveRowKey
99
- : (_record, fallbackIndex) => fallbackIndex;
100
- const recordKey = String(resolveRowKey(record, index) || index);
101
- return Object.freeze({
102
- key: `record:${recordKey}`,
103
- recordKey,
104
- record,
105
- index,
106
- synthetic: false,
107
- selectable: true,
108
- placement: "records"
109
- });
110
- }
111
-
112
- function useCrudListScreen({
113
- adapter = null,
114
- client = null,
115
- resource = null,
116
- resourceNamespace = "resource",
117
- apiSuffix = "",
118
- recordIdParam = "recordId",
119
- recordIdSelector = null,
120
- titleFallbackFieldKey = "",
121
- viewUrlTemplate = "",
122
- editUrlTemplate = "",
123
- newUrlTemplate = "",
124
- recordChangedEvents = [],
125
- listFilters = {},
126
- listBulkActions = [],
127
- listRowActions = [],
128
- syntheticRows = null,
129
- routeQueryBlacklist = Object.freeze(["include", "cursor", "limit"]),
130
- requestQueryParams = null,
131
- requestFieldsets = null,
132
- readEnabled = true,
133
- requestRecoveryLabel = "Records",
134
- fallbackLoadError = "Unable to load records."
135
- } = {}) {
136
- const crudHttpClient = resolveCrudHttpClient(resource, { client });
137
- const filterRuntime = useCrudListFilters(listFilters);
138
- const normalizedRecordChangedEvents = Array.isArray(recordChangedEvents)
139
- ? recordChangedEvents
140
- : [];
141
- const normalizedResourceNamespace = String(resourceNamespace || "resource").trim() || "resource";
142
- const records = useCrudList({
143
- adapter: adapter || undefined,
144
- client: crudHttpClient,
145
- resource,
146
- apiSuffix,
147
- queryKeyFactory: (surfaceId = "", workspaceSlug = "") => [
148
- "ui-generator",
149
- normalizedResourceNamespace,
150
- "list",
151
- String(surfaceId || ""),
152
- String(workspaceSlug || "")
153
- ],
154
- search: {
155
- enabled: true,
156
- mode: "query"
157
- },
158
- queryParams: filterRuntime.queryParams,
159
- routeQueryValueResolvers: filterRuntime.routeQueryValueResolvers,
160
- syncToRoute: {
161
- enabled: true,
162
- mode: "replace",
163
- search: true,
164
- queryParams: true,
165
- queryParamBlacklist: routeQueryBlacklist
166
- },
167
- placementSource: `ui-generator.${normalizedResourceNamespace}.list`,
168
- requestQueryParams,
169
- requestFieldsets,
170
- readEnabled,
171
- requestRecoveryLabel,
172
- fallbackLoadError,
173
- recordIdParam,
174
- recordIdSelector,
175
- viewUrlTemplate,
176
- editUrlTemplate,
177
- realtime: normalizedRecordChangedEvents.length > 0
178
- ? {
179
- events: normalizedRecordChangedEvents
180
- }
181
- : null
182
- });
183
- const displayRows = computed(() => {
184
- const syntheticRowGroups = normalizeSyntheticDisplayRowGroups(syntheticRows);
185
- const recordRows = (Array.isArray(records.items) ? records.items : [])
186
- .map((record, index) => createCrudListDisplayRow(record, index, records));
187
-
188
- return [
189
- ...syntheticRowGroups.prepend,
190
- ...recordRows,
191
- ...syntheticRowGroups.append
192
- ];
193
- });
194
- const selectableRows = computed(() =>
195
- displayRows.value.filter((row) => row.selectable !== false)
196
- );
197
- const bulkActions = useCrudListBulkActions(listBulkActions, {
198
- resolveRecordId: (record, index) => records.resolveRowKey(record, index),
199
- resolveContext: () => buildCrudListActionContext(records, crudHttpClient)
200
- });
201
- const rowActions = useCrudListRowActions(listRowActions, {
202
- resolveRecordId: (record, index) => records.resolveRowKey(record, index),
203
- resolveContext: () => buildCrudListActionContext(records, crudHttpClient)
204
- });
205
- const listPrimaryAction = computed(() =>
206
- newUrlTemplate ? records.resolveParams(newUrlTemplate) : ""
207
- );
208
-
209
- function resolveRecordTitle(record) {
210
- return records.resolveRecordTitle(record, {
211
- fallbackKey: titleFallbackFieldKey,
212
- defaultValue: "Record"
213
- });
214
- }
215
-
216
- return Object.freeze({
217
- records,
218
- listFilters,
219
- filterRuntime,
220
- bulkActions,
221
- listRowActions,
222
- rowActions,
223
- displayRows,
224
- selectableRows,
225
- listPrimaryAction,
226
- hasViewUrl: Boolean(viewUrlTemplate),
227
- hasEditUrl: Boolean(editUrlTemplate),
228
- resolveRecordTitle,
229
- formatListCardValue: formatCrudListCardValue
230
- });
231
- }
232
-
233
- const __testables = Object.freeze({
234
- buildCrudListActionContext
235
- });
236
-
237
- export { __testables, useCrudListScreen };
@@ -1,77 +0,0 @@
1
- import { computed, unref } from "vue";
2
- import { useRoute } from "vue-router";
3
- import { useCrudView } from "./records/useCrudView.js";
4
-
5
- function useCrudViewScreen({
6
- adapter = null,
7
- resource = null,
8
- resourceNamespace = "resource",
9
- apiUrlTemplate = "",
10
- recordIdParam = "recordId",
11
- titleFallbackFieldKey = "",
12
- listUrlTemplate = "",
13
- editUrlTemplate = "",
14
- recordChangedEvent = "",
15
- requestQueryParams = null,
16
- requestFieldsets = null,
17
- readEnabled = true,
18
- queryKeyFactory = null,
19
- requestRecoveryLabel = "Record",
20
- fallbackLoadError = "Unable to load record.",
21
- notFoundMessage = "Record not found."
22
- } = {}) {
23
- const route = useRoute();
24
- const normalizedResourceNamespace = String(resourceNamespace || "resource").trim() || "resource";
25
- const defaultQueryKeyFactory = (surfaceId = "", workspaceSlug = "") => [
26
- "ui-generator",
27
- normalizedResourceNamespace,
28
- "view",
29
- String(surfaceId || ""),
30
- String(workspaceSlug || "")
31
- ];
32
- const view = useCrudView({
33
- adapter: adapter || undefined,
34
- resource,
35
- apiUrlTemplate,
36
- recordIdParam,
37
- includeRecordIdInQueryKey: true,
38
- queryKeyFactory: typeof queryKeyFactory === "function" ? queryKeyFactory : defaultQueryKeyFactory,
39
- requestQueryParams,
40
- requestFieldsets,
41
- readEnabled,
42
- placementSource: `ui-generator.${normalizedResourceNamespace}.view`,
43
- requestRecoveryLabel,
44
- fallbackLoadError,
45
- notFoundMessage,
46
- listUrlTemplate,
47
- editUrlTemplate,
48
- realtime: recordChangedEvent
49
- ? {
50
- event: recordChangedEvent
51
- }
52
- : null
53
- });
54
- const recordTitle = computed(() =>
55
- view.resolveRecordTitle(view.record, {
56
- fallbackKey: titleFallbackFieldKey,
57
- defaultValue: "Record"
58
- })
59
- );
60
-
61
- function resolveRouteLocation(urlTemplate = "") {
62
- const path = view.resolveParams(unref(urlTemplate));
63
- return path ? { path, query: route.query } : null;
64
- }
65
-
66
- const listLocation = computed(() => resolveRouteLocation(listUrlTemplate));
67
- const editLocation = computed(() => resolveRouteLocation(editUrlTemplate));
68
-
69
- return Object.freeze({
70
- view,
71
- recordTitle,
72
- listLocation,
73
- editLocation
74
- });
75
- }
76
-
77
- export { useCrudViewScreen };