@headless-adminapp/app 0.0.17-alpha.5 → 0.0.17-alpha.52
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/app/AppProvider.js +2 -1
- package/app/AuthWrapper.d.ts +1 -1
- package/app/AuthWrapper.js +4 -1
- package/app/LayoutProvider.d.ts +8 -7
- package/app/LayoutProvider.js +37 -2
- package/auth/AuthProvider.d.ts +1 -1
- package/auth/AuthProvider.js +23 -3
- package/auth/context.d.ts +1 -0
- package/auth/hooks/useIsSkipAuthCheck.d.ts +1 -0
- package/auth/hooks/useIsSkipAuthCheck.js +8 -0
- package/board/BoardColumnDataResolver.d.ts +1 -0
- package/board/BoardColumnDataResolver.js +64 -0
- package/board/BoardColumnProvider.d.ts +7 -0
- package/board/BoardColumnProvider.js +36 -0
- package/board/context.d.ts +19 -0
- package/board/context.js +6 -0
- package/board/hooks/index.d.ts +6 -0
- package/board/hooks/index.js +15 -0
- package/board/hooks/useBoardColumnConfig.d.ts +2 -0
- package/board/hooks/useBoardColumnConfig.js +8 -0
- package/board/hooks/useBoardColumnData.d.ts +1 -0
- package/board/hooks/useBoardColumnData.js +9 -0
- package/board/hooks/useBoardColumnDataState.d.ts +5 -0
- package/board/hooks/useBoardColumnDataState.js +9 -0
- package/board/hooks/useBoardConfig.d.ts +3 -0
- package/board/hooks/useBoardConfig.js +8 -0
- package/board/hooks/useBoardSchema.d.ts +2 -0
- package/board/hooks/useBoardSchema.js +7 -0
- package/board/hooks/useSearchText.d.ts +1 -0
- package/board/hooks/useSearchText.js +14 -0
- package/board/types.d.ts +47 -0
- package/board/utils.d.ts +3 -0
- package/board/utils.js +6 -0
- package/builders/CommandBuilder/CommandBuilder.d.ts +10 -0
- package/builders/CommandBuilder/CommandBuilder.js +14 -0
- package/builders/CommandBuilder/DefaultCommandBuilder.d.ts +88 -0
- package/builders/CommandBuilder/DefaultCommandBuilder.js +191 -0
- package/builders/CommandBuilder/FormCommandBuilder.d.ts +46 -0
- package/builders/CommandBuilder/FormCommandBuilder.js +171 -0
- package/builders/CommandBuilder/SubgridCommandBuilder.d.ts +45 -0
- package/builders/CommandBuilder/SubgridCommandBuilder.js +240 -0
- package/builders/CommandBuilder/ViewCommandBuilder.d.ts +63 -0
- package/builders/CommandBuilder/ViewCommandBuilder.js +242 -0
- package/builders/CommandBuilder/index.d.ts +1 -0
- package/builders/CommandBuilder/index.js +5 -0
- package/builders/CommandBuilder/utils.d.ts +3 -0
- package/builders/CommandBuilder/utils.js +21 -0
- package/builders/SchemaExperienceBuilder.d.ts +5 -8
- package/builders/SchemaExperienceBuilder.js +4 -4
- package/builders/index.d.ts +1 -1
- package/builders/index.js +1 -2
- package/builders/utils.d.ts +28 -0
- package/builders/utils.js +185 -0
- package/command/hooks/useBaseCommandHandlerContext.js +22 -4
- package/command/hooks/useCommands.d.ts +1 -1
- package/command/hooks/useCommands.js +1 -1
- package/components/ScrollbarWithMoreDataRequest/index.d.ts +9 -0
- package/components/ScrollbarWithMoreDataRequest/index.js +33 -0
- package/dataform/DataFormProvider/DataResolver.js +6 -6
- package/dataform/DataFormProvider/InitialValueResolver.js +4 -2
- package/dataform/DataFormProvider/index.js +3 -3
- package/dataform/hooks/index.d.ts +1 -0
- package/dataform/hooks/index.js +1 -0
- package/dataform/hooks/useFormSave.js +9 -2
- package/dataform/hooks/useLoadFormGridPage.js +8 -2
- package/dataform/hooks/useMainFormCommands.d.ts +1 -12
- package/dataform/hooks/useMainFormCommands.js +9 -1
- package/dataform/hooks/useProcessFlowSteps.d.ts +1 -0
- package/dataform/hooks/useProcessFlowSteps.js +44 -0
- package/dataform/hooks/useRecordTitle.d.ts +1 -1
- package/dataform/hooks/useRecordTitle.js +9 -2
- package/dataform/utils/defaultParameters.d.ts +3 -0
- package/dataform/utils/defaultParameters.js +37 -0
- package/dataform/utils/index.d.ts +3 -22
- package/dataform/utils/index.js +88 -134
- package/dataform/utils/saveRecord.d.ts +25 -0
- package/dataform/utils/saveRecord.js +167 -0
- package/datagrid/DataGridProvider/DataResolver.js +25 -149
- package/datagrid/DataGridProvider/index.d.ts +5 -0
- package/datagrid/DataGridProvider/index.js +8 -0
- package/datagrid/DataGridProvider/transformViewColumns.js +4 -4
- package/datagrid/DataGridProvider/utils.d.ts +7 -2
- package/datagrid/DataGridProvider/utils.js +52 -2
- package/datagrid/column-filter/constants.js +38 -3
- package/datagrid/context.d.ts +9 -6
- package/datagrid/hooks/useGridCommands.d.ts +3 -0
- package/datagrid/hooks/useGridCommands.js +3 -0
- package/datagrid/hooks/useLoadMainGridPage.js +1 -1
- package/datagrid/hooks/useMainGridCommands.d.ts +1 -13
- package/datagrid/hooks/useMainGridCommands.js +38 -26
- package/datagrid/hooks/useOpenRecord.d.ts +1 -0
- package/datagrid/hooks/useOpenRecord.js +34 -0
- package/datagrid/hooks/useSubGridCommands.js +25 -65
- package/defaults.d.ts +2 -0
- package/defaults.js +5 -0
- package/dialog/hooks/useCloseDialog.js +17 -15
- package/dialog/hooks/useOpenDialog.js +2 -4
- package/form/FormValidationStringContext.d.ts +1 -0
- package/form/FormValidationStringContext.js +1 -0
- package/hooks/index.d.ts +1 -0
- package/hooks/index.js +3 -0
- package/hooks/useDebouncedValue.js +0 -1
- package/hooks/useElementLayout.js +1 -1
- package/hooks/useIsMobile.js +0 -1
- package/hooks/useItemsWithKey.d.ts +7 -0
- package/hooks/useItemsWithKey.js +13 -0
- package/hooks/useSystemColorScheme.d.ts +1 -1
- package/hooks/useSystemColorScheme.js +0 -1
- package/insights/InsightsProvider.d.ts +8 -0
- package/insights/InsightsProvider.js +27 -0
- package/locale/LocaleProvider.d.ts +2 -1
- package/locale/LocaleProvider.js +3 -3
- package/locale/index.d.ts +1 -0
- package/locale/index.js +1 -0
- package/locale/useCurrencySymbol.d.ts +1 -0
- package/locale/useCurrencySymbol.js +13 -0
- package/locale/utils.d.ts +5 -0
- package/locale/utils.js +7 -0
- package/metadata/MetadataProvider.d.ts +8 -4
- package/metadata/MetadataProvider.js +23 -16
- package/metadata/hooks/useExperienceViewCommands.js +7 -1
- package/metadata/hooks/useExperienceViewSubgridCommands.js +7 -1
- package/metadata/hooks/useMetadata.d.ts +2 -4
- package/metadata/hooks/useMetadata.js +2 -6
- package/metadata/hooks/useSchema.d.ts +1 -1
- package/metadata/hooks/useSchema.js +5 -2
- package/mutable/context.js +1 -1
- package/mutable/utils.js +5 -12
- package/navigation/hooks/index.d.ts +1 -0
- package/{appearance → navigation}/hooks/index.js +1 -1
- package/navigation/hooks/useOpenForm.d.ts +2 -4
- package/navigation/hooks/useOpenForm.js +11 -3
- package/navigation/index.d.ts +1 -0
- package/{appearance → navigation}/index.js +0 -3
- package/package.json +6 -2
- package/recordset/RecordSetProvider.js +1 -1
- package/recordset/hooks/useRecordSetResult.js +1 -1
- package/route/RouteProvider.d.ts +2 -2
- package/route/RouteProvider.js +4 -1
- package/store/ComponentStore.d.ts +1 -1
- package/store/ComponentStore.js +5 -9
- package/store/SchemaExperienceStore.d.ts +3 -3
- package/toast-notification/hooks/useCloseToastNotification.js +17 -15
- package/toast-notification/hooks/useOpenToastNotification.js +2 -4
- package/transport/RestDataService/index.d.ts +1 -1
- package/transport/RestDataService/index.js +17 -16
- package/transport/context.d.ts +3 -1
- package/transport/context.js +16 -1
- package/transport/hooks/index.d.ts +1 -0
- package/transport/hooks/index.js +1 -0
- package/transport/hooks/useFileService.d.ts +1 -0
- package/transport/hooks/useFileService.js +12 -0
- package/transport/hooks/useRetriveRecords.d.ts +32 -0
- package/transport/hooks/useRetriveRecords.js +120 -0
- package/utils/color.d.ts +1 -0
- package/utils/color.js +14 -0
- package/utils/getAttributeFormattedValue.d.ts +3 -1
- package/utils/getAttributeFormattedValue.js +108 -54
- package/appearance/context.d.ts +0 -7
- package/appearance/context.js +0 -5
- package/appearance/hooks/index.d.ts +0 -1
- package/appearance/hooks/useAppearanceContext.d.ts +0 -1
- package/appearance/hooks/useAppearanceContext.js +0 -12
- package/appearance/index.d.ts +0 -2
- package/builders/CommandBuilder.d.ts +0 -176
- package/builders/CommandBuilder.js +0 -474
- package/locale/types.d.ts +0 -2
- /package/{locale → board}/types.js +0 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ColumnCondition, SortingState, View } from '@headless-adminapp/core/experience/view';
|
|
2
|
+
import { InferredSchemaType, Schema, SchemaAttributes } from '@headless-adminapp/core/schema';
|
|
3
|
+
import { ISchemaStore } from '@headless-adminapp/core/store';
|
|
4
|
+
import { Filter, IDataService } from '@headless-adminapp/core/transport';
|
|
5
|
+
import { TransformedViewColumn } from '../datagrid';
|
|
6
|
+
type ExportFn<S extends SchemaAttributes = SchemaAttributes> = (option: {
|
|
7
|
+
schema: Schema<S>;
|
|
8
|
+
records: unknown[];
|
|
9
|
+
gridColumns: TransformedViewColumn<SchemaAttributes>[];
|
|
10
|
+
schemaStore: ISchemaStore;
|
|
11
|
+
fileName: string;
|
|
12
|
+
}) => Promise<void>;
|
|
13
|
+
export declare const exportRecordsCSV: ExportFn;
|
|
14
|
+
export declare const exportRecordsXLS: ExportFn;
|
|
15
|
+
export declare function retriveRecords<S extends SchemaAttributes = SchemaAttributes>({ gridColumns, dataService, schema, search, view, extraFilter, columnFilters, schemaStore, sorting, skip, limit, }: {
|
|
16
|
+
gridColumns: TransformedViewColumn<SchemaAttributes>[];
|
|
17
|
+
dataService: IDataService;
|
|
18
|
+
schema: Schema<S>;
|
|
19
|
+
search?: string;
|
|
20
|
+
view: View<S>;
|
|
21
|
+
extraFilter?: Filter;
|
|
22
|
+
columnFilters?: Partial<Record<string, ColumnCondition>>;
|
|
23
|
+
schemaStore: ISchemaStore;
|
|
24
|
+
sorting: SortingState<S>;
|
|
25
|
+
skip: number;
|
|
26
|
+
limit: number;
|
|
27
|
+
}): Promise<import("@headless-adminapp/core/transport").RetriveRecordsResult<InferredSchemaType<S>>>;
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.exportRecordsXLS = exports.exportRecordsCSV = void 0;
|
|
36
|
+
exports.retriveRecords = retriveRecords;
|
|
37
|
+
const utils_1 = require("../datagrid/DataGridProvider/utils");
|
|
38
|
+
const utils_2 = require("../utils");
|
|
39
|
+
const getHeaders = (schema, gridColumns, schemaStore) => {
|
|
40
|
+
const headers = gridColumns.map((column) => {
|
|
41
|
+
var _a, _b, _c;
|
|
42
|
+
if (column.name.indexOf('.') !== -1) {
|
|
43
|
+
const [lookup, field] = column.name.split('.');
|
|
44
|
+
const entity = schema.attributes[lookup].entity;
|
|
45
|
+
const lookupSchema = schemaStore.getSchema(entity);
|
|
46
|
+
return `${(_a = lookupSchema.attributes[field]) === null || _a === void 0 ? void 0 : _a.label} (${(_b = schema.attributes[lookup]) === null || _b === void 0 ? void 0 : _b.label})`;
|
|
47
|
+
}
|
|
48
|
+
return (_c = schema.attributes[column.name]) === null || _c === void 0 ? void 0 : _c.label;
|
|
49
|
+
});
|
|
50
|
+
return headers;
|
|
51
|
+
};
|
|
52
|
+
function getAttribute({ column, schema, schemaStore, }) {
|
|
53
|
+
let attribute;
|
|
54
|
+
if (column.expandedKey) {
|
|
55
|
+
const lookup = column.name;
|
|
56
|
+
const field = column.expandedKey;
|
|
57
|
+
const entity = schema.attributes[lookup].entity;
|
|
58
|
+
const lookupSchema = schemaStore.getSchema(entity);
|
|
59
|
+
attribute = lookupSchema.attributes[field];
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
attribute = schema.attributes[column.name];
|
|
63
|
+
}
|
|
64
|
+
return attribute;
|
|
65
|
+
}
|
|
66
|
+
function extractAttributeData({ column, record, schema, schemaStore, }) {
|
|
67
|
+
var _a, _b;
|
|
68
|
+
const attribute = getAttribute({ column, schema, schemaStore });
|
|
69
|
+
let value;
|
|
70
|
+
if (column.expandedKey) {
|
|
71
|
+
const lookup = column.name;
|
|
72
|
+
const field = column.expandedKey;
|
|
73
|
+
value = (_b = (_a = record.$expand) === null || _a === void 0 ? void 0 : _a[lookup]) === null || _b === void 0 ? void 0 : _b[field];
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
value = record[column.name];
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
attribute,
|
|
80
|
+
value,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
const exportRecordsCSV = (_a) => __awaiter(void 0, [_a], void 0, function* ({ schema, records, gridColumns, schemaStore, fileName, }) {
|
|
84
|
+
const csvDownload = yield Promise.resolve().then(() => __importStar(require('json-to-csv-export')));
|
|
85
|
+
const headers = getHeaders(schema, gridColumns, schemaStore);
|
|
86
|
+
const cellData = records.map((record) => {
|
|
87
|
+
return gridColumns.map((column) => {
|
|
88
|
+
var _a, _b;
|
|
89
|
+
const { attribute, value } = extractAttributeData({
|
|
90
|
+
column,
|
|
91
|
+
record,
|
|
92
|
+
schema,
|
|
93
|
+
schemaStore,
|
|
94
|
+
});
|
|
95
|
+
if (attribute.type === 'money' || attribute.type === 'number') {
|
|
96
|
+
return (_a = value === null || value === void 0 ? void 0 : value.toString()) !== null && _a !== void 0 ? _a : '';
|
|
97
|
+
}
|
|
98
|
+
return (_b = (0, utils_2.getAttributeFormattedValue)(attribute, value)) !== null && _b !== void 0 ? _b : '';
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
csvDownload.default({
|
|
102
|
+
headers,
|
|
103
|
+
data: cellData,
|
|
104
|
+
delimiter: ',',
|
|
105
|
+
filename: fileName,
|
|
106
|
+
});
|
|
107
|
+
});
|
|
108
|
+
exports.exportRecordsCSV = exportRecordsCSV;
|
|
109
|
+
const exportRecordsXLS = (_a) => __awaiter(void 0, [_a], void 0, function* ({ fileName, gridColumns, records, schema, schemaStore, }) {
|
|
110
|
+
const ExcelJS = yield Promise.resolve().then(() => __importStar(require('exceljs')));
|
|
111
|
+
const headers = getHeaders(schema, gridColumns, schemaStore);
|
|
112
|
+
const cellData = records.map((item) => {
|
|
113
|
+
return gridColumns.map((column) => {
|
|
114
|
+
const { attribute, value } = extractAttributeData({
|
|
115
|
+
column,
|
|
116
|
+
record: item,
|
|
117
|
+
schema,
|
|
118
|
+
schemaStore,
|
|
119
|
+
});
|
|
120
|
+
if (!value) {
|
|
121
|
+
return '';
|
|
122
|
+
}
|
|
123
|
+
switch (attribute === null || attribute === void 0 ? void 0 : attribute.type) {
|
|
124
|
+
case 'money':
|
|
125
|
+
case 'number':
|
|
126
|
+
return value;
|
|
127
|
+
case 'date':
|
|
128
|
+
return value ? new Date(value) : undefined;
|
|
129
|
+
default:
|
|
130
|
+
return (0, utils_2.getAttributeFormattedValue)(attribute, value);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
const workbook = new ExcelJS.Workbook();
|
|
135
|
+
const worksheet = workbook.addWorksheet('Sheet1');
|
|
136
|
+
worksheet.addRow(headers);
|
|
137
|
+
const headerRow = worksheet.getRow(1);
|
|
138
|
+
headerRow.font = { bold: true };
|
|
139
|
+
cellData.forEach((row) => {
|
|
140
|
+
worksheet.addRow(row);
|
|
141
|
+
});
|
|
142
|
+
gridColumns.forEach((column, index) => {
|
|
143
|
+
const attribute = getAttribute({ column, schema, schemaStore });
|
|
144
|
+
const sheetColumn = worksheet.getColumn(index + 1);
|
|
145
|
+
let formatFn = (value) => { var _a; return (_a = (0, utils_2.getAttributeFormattedValue)(attribute, value)) !== null && _a !== void 0 ? _a : ''; };
|
|
146
|
+
if ((attribute === null || attribute === void 0 ? void 0 : attribute.type) === 'money') {
|
|
147
|
+
sheetColumn.numFmt = '"₹" #,##0.00';
|
|
148
|
+
}
|
|
149
|
+
let maxLength = 0;
|
|
150
|
+
sheetColumn.eachCell((cell) => {
|
|
151
|
+
const length = formatFn(cell.value).length;
|
|
152
|
+
if (length > maxLength) {
|
|
153
|
+
maxLength = length;
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
sheetColumn.width = Math.max(maxLength, 10) * 1.2;
|
|
157
|
+
});
|
|
158
|
+
// Generate the Excel file
|
|
159
|
+
const buffer = yield workbook.xlsx.writeBuffer();
|
|
160
|
+
const blob = new Blob([buffer], {
|
|
161
|
+
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
162
|
+
});
|
|
163
|
+
const link = document.createElement('a');
|
|
164
|
+
link.href = window.URL.createObjectURL(blob);
|
|
165
|
+
link.download = fileName;
|
|
166
|
+
link.click();
|
|
167
|
+
});
|
|
168
|
+
exports.exportRecordsXLS = exportRecordsXLS;
|
|
169
|
+
function retriveRecords(_a) {
|
|
170
|
+
return __awaiter(this, arguments, void 0, function* ({ gridColumns, dataService, schema, search, view, extraFilter, columnFilters, schemaStore, sorting, skip, limit, }) {
|
|
171
|
+
const expand = (0, utils_1.collectExpandedKeys)(gridColumns);
|
|
172
|
+
const columns = Array.from(new Set([...gridColumns.filter((x) => !x.expandedKey).map((x) => x.name)]));
|
|
173
|
+
const result = yield dataService.retriveRecords({
|
|
174
|
+
logicalName: schema.logicalName,
|
|
175
|
+
search,
|
|
176
|
+
columns: columns,
|
|
177
|
+
expand,
|
|
178
|
+
filter: (0, utils_1.mergeConditions)(schema, view.experience.filter, extraFilter, columnFilters, schemaStore),
|
|
179
|
+
skip,
|
|
180
|
+
limit,
|
|
181
|
+
sort: sorting,
|
|
182
|
+
});
|
|
183
|
+
return result;
|
|
184
|
+
});
|
|
185
|
+
}
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useUtility = useUtility;
|
|
4
4
|
exports.useBaseCommandHandlerContext = useBaseCommandHandlerContext;
|
|
5
|
+
const navigation_1 = require("@headless-adminapp/app/navigation");
|
|
5
6
|
const react_query_1 = require("@tanstack/react-query");
|
|
7
|
+
const react_1 = require("react");
|
|
6
8
|
const hooks_1 = require("../../dialog/hooks");
|
|
7
9
|
const locale_1 = require("../../locale");
|
|
8
10
|
const hooks_2 = require("../../metadata/hooks");
|
|
@@ -16,7 +18,7 @@ function useUtility() {
|
|
|
16
18
|
const openErrorDialog = (0, hooks_1.useOpenErrorDialog)();
|
|
17
19
|
const openPromptDialog = (0, hooks_1.useOpenPromptDialog)();
|
|
18
20
|
const openToastNotification = (0, useOpenToastNotification_1.useOpenToastNotification)();
|
|
19
|
-
return {
|
|
21
|
+
return (0, react_1.useMemo)(() => ({
|
|
20
22
|
hideProgressIndicator,
|
|
21
23
|
showProgressIndicator,
|
|
22
24
|
openAlertDialog,
|
|
@@ -24,7 +26,21 @@ function useUtility() {
|
|
|
24
26
|
openErrorDialog,
|
|
25
27
|
openPromptDialog,
|
|
26
28
|
showNotification: openToastNotification,
|
|
27
|
-
}
|
|
29
|
+
}), [
|
|
30
|
+
hideProgressIndicator,
|
|
31
|
+
openAlertDialog,
|
|
32
|
+
openConfirmDialog,
|
|
33
|
+
openErrorDialog,
|
|
34
|
+
openPromptDialog,
|
|
35
|
+
openToastNotification,
|
|
36
|
+
showProgressIndicator,
|
|
37
|
+
]);
|
|
38
|
+
}
|
|
39
|
+
function useNavigation() {
|
|
40
|
+
const openForm = (0, navigation_1.useOpenForm)();
|
|
41
|
+
return (0, react_1.useMemo)(() => ({
|
|
42
|
+
openForm,
|
|
43
|
+
}), [openForm]);
|
|
28
44
|
}
|
|
29
45
|
function useBaseCommandHandlerContext() {
|
|
30
46
|
const dataService = (0, transport_1.useDataService)();
|
|
@@ -32,11 +48,13 @@ function useBaseCommandHandlerContext() {
|
|
|
32
48
|
const stores = (0, hooks_2.useMetadata)();
|
|
33
49
|
const utility = useUtility();
|
|
34
50
|
const locale = (0, locale_1.useLocale)();
|
|
35
|
-
|
|
51
|
+
const navigation = useNavigation();
|
|
52
|
+
return (0, react_1.useMemo)(() => ({
|
|
36
53
|
dataService,
|
|
37
54
|
queryClient,
|
|
38
55
|
utility,
|
|
39
56
|
stores,
|
|
40
57
|
locale,
|
|
41
|
-
|
|
58
|
+
navigation,
|
|
59
|
+
}), [dataService, queryClient, stores, utility, locale, navigation]);
|
|
42
60
|
}
|
|
@@ -4,4 +4,4 @@ import { CommandItemExperienceSelector, CommandItemState } from '../types';
|
|
|
4
4
|
* @description Transforms the command configuration into a format that can be used by the CommandBar component
|
|
5
5
|
* and apply the necessary conditions to the commands (disabled, hidden, etc.)
|
|
6
6
|
*/
|
|
7
|
-
export declare function useCommands<HandlerContext>(commands: CommandItemExperience<HandlerContext>[][], handlerContext: HandlerContext, selector?: CommandItemExperienceSelector<HandlerContext>): CommandItemState[][];
|
|
7
|
+
export declare function useCommands<HandlerContext>(commands: CommandItemExperience<HandlerContext>[][] | undefined, handlerContext: HandlerContext, selector?: CommandItemExperienceSelector<HandlerContext>): CommandItemState[][];
|
|
@@ -11,6 +11,6 @@ function useCommands(commands, handlerContext, selector) {
|
|
|
11
11
|
const selectorRef = (0, react_1.useRef)(selector);
|
|
12
12
|
selectorRef.current = selector;
|
|
13
13
|
return (0, react_1.useMemo)(() => {
|
|
14
|
-
return (0, utils_1.transformCommadnGroups)(commands, handlerContext, selectorRef.current);
|
|
14
|
+
return (0, utils_1.transformCommadnGroups)(commands !== null && commands !== void 0 ? commands : [], handlerContext, selectorRef.current);
|
|
15
15
|
}, [commands, handlerContext]);
|
|
16
16
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FC, PropsWithChildren } from 'react';
|
|
2
|
+
interface ScrollbarWithMoreDataRequest {
|
|
3
|
+
data: any;
|
|
4
|
+
hasMore: boolean;
|
|
5
|
+
onRequestMore: () => void;
|
|
6
|
+
rtl?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare const ScrollbarWithMoreDataRequest: FC<PropsWithChildren<ScrollbarWithMoreDataRequest>>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ScrollbarWithMoreDataRequest = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const ScrollView_1 = require("../ScrollView");
|
|
7
|
+
function getReaminingSpace(div) {
|
|
8
|
+
return div.scrollHeight - div.scrollTop - div.clientHeight;
|
|
9
|
+
}
|
|
10
|
+
const ScrollbarWithMoreDataRequest = ({ data, onRequestMore, hasMore, children, rtl }) => {
|
|
11
|
+
const divRef = (0, react_1.useRef)(null);
|
|
12
|
+
const onRequestMoreRef = (0, react_1.useRef)(onRequestMore);
|
|
13
|
+
onRequestMoreRef.current = onRequestMore;
|
|
14
|
+
(0, react_1.useEffect)(() => {
|
|
15
|
+
var _a;
|
|
16
|
+
const div = (_a = divRef.current) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
17
|
+
if (!div) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const remainingSpace = getReaminingSpace(div);
|
|
21
|
+
if (remainingSpace <= 0 && hasMore) {
|
|
22
|
+
onRequestMoreRef.current();
|
|
23
|
+
}
|
|
24
|
+
}, [data, hasMore]);
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)(ScrollView_1.ScrollView, { autoHide: true, rtl: rtl, onScroll: (e) => {
|
|
26
|
+
const div = e.target;
|
|
27
|
+
const remainingSpace = getReaminingSpace(div);
|
|
28
|
+
if (remainingSpace <= 0 && hasMore) {
|
|
29
|
+
onRequestMoreRef.current();
|
|
30
|
+
}
|
|
31
|
+
}, children: (0, jsx_runtime_1.jsx)("div", { ref: divRef, children: children }) }));
|
|
32
|
+
};
|
|
33
|
+
exports.ScrollbarWithMoreDataRequest = ScrollbarWithMoreDataRequest;
|
|
@@ -28,10 +28,10 @@ function getControls(form) {
|
|
|
28
28
|
return controls;
|
|
29
29
|
}
|
|
30
30
|
function getColumns(form) {
|
|
31
|
-
var _a;
|
|
31
|
+
var _a, _b;
|
|
32
32
|
const columns = Array.from(new Set([
|
|
33
33
|
...((_a = form.experience.includeAttributes) !== null && _a !== void 0 ? _a : []),
|
|
34
|
-
...form.experience.headerControls,
|
|
34
|
+
...((_b = form.experience.headerControls) !== null && _b !== void 0 ? _b : []),
|
|
35
35
|
...getControls(form)
|
|
36
36
|
.filter((control) => control.type === 'standard')
|
|
37
37
|
.map((control) => control.attributeName),
|
|
@@ -39,7 +39,7 @@ function getColumns(form) {
|
|
|
39
39
|
return columns;
|
|
40
40
|
}
|
|
41
41
|
function getRecord(_a) {
|
|
42
|
-
return __awaiter(this, arguments, void 0, function* ({ recordId, dataService, form, schema, columns,
|
|
42
|
+
return __awaiter(this, arguments, void 0, function* ({ recordId, dataService, form, schema, columns, schemaStore, }) {
|
|
43
43
|
var _b;
|
|
44
44
|
let record = null;
|
|
45
45
|
try {
|
|
@@ -60,7 +60,7 @@ function getRecord(_a) {
|
|
|
60
60
|
if (control.type !== 'editablegrid') {
|
|
61
61
|
continue;
|
|
62
62
|
}
|
|
63
|
-
const controlSchema = getSchema(control.logicalName);
|
|
63
|
+
const controlSchema = schemaStore.getSchema(control.logicalName);
|
|
64
64
|
const records = yield dataService.retriveRecords({
|
|
65
65
|
logicalName: controlSchema.logicalName,
|
|
66
66
|
filter: {
|
|
@@ -97,7 +97,7 @@ function DataResolver() {
|
|
|
97
97
|
const form = (0, hooks_2.useSelectedForm)();
|
|
98
98
|
const dataService = (0, transport_2.useDataService)();
|
|
99
99
|
const recordId = (0, hooks_2.useRecordId)();
|
|
100
|
-
const {
|
|
100
|
+
const { schemaStore } = (0, hooks_1.useMetadata)();
|
|
101
101
|
const setState = (0, mutable_1.useContextSetValue)(context_1.DataFormContext);
|
|
102
102
|
const columns = (0, react_1.useMemo)(() => getColumns(form), [form]);
|
|
103
103
|
const queryKey = (0, react_1.useMemo)(() => ['data', 'retriveRecord', schema.logicalName, recordId, columns], [columns, recordId, schema.logicalName]);
|
|
@@ -113,7 +113,7 @@ function DataResolver() {
|
|
|
113
113
|
form,
|
|
114
114
|
recordId,
|
|
115
115
|
schema,
|
|
116
|
-
|
|
116
|
+
schemaStore,
|
|
117
117
|
});
|
|
118
118
|
return record;
|
|
119
119
|
}),
|
|
@@ -6,6 +6,7 @@ const mutable_1 = require("../../mutable");
|
|
|
6
6
|
const context_1 = require("../context");
|
|
7
7
|
const hooks_1 = require("../hooks");
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
|
+
const defaultParameters_1 = require("../utils/defaultParameters");
|
|
9
10
|
function InitialValueResolver() {
|
|
10
11
|
const formConfig = (0, hooks_1.useSelectedForm)();
|
|
11
12
|
const schema = (0, hooks_1.useDataFormSchema)();
|
|
@@ -13,14 +14,15 @@ function InitialValueResolver() {
|
|
|
13
14
|
const record = (0, mutable_1.useContextSelector)(context_1.DataFormContext, (state) => state.record);
|
|
14
15
|
const formInstance = (0, hooks_1.useFormInstance)();
|
|
15
16
|
const initialValues = (0, react_1.useMemo)(() => {
|
|
17
|
+
var _a;
|
|
18
|
+
const defaultParameters = (_a = (0, defaultParameters_1.getFormDefaultParameters)(schema)) !== null && _a !== void 0 ? _a : {};
|
|
16
19
|
return (0, utils_1.getInitialValues)({
|
|
17
20
|
cloneRecord: undefined,
|
|
18
21
|
form: formConfig,
|
|
19
22
|
record: record,
|
|
20
23
|
recordId: recordId,
|
|
21
24
|
schema: schema,
|
|
22
|
-
defaultParameters
|
|
23
|
-
// defaultParameters,
|
|
25
|
+
defaultParameters,
|
|
24
26
|
});
|
|
25
27
|
}, [formConfig, record, recordId, schema]);
|
|
26
28
|
const setValue = (0, mutable_1.useContextSetValue)(context_1.DataFormContext);
|
|
@@ -23,7 +23,7 @@ const DataResolver_1 = require("./DataResolver");
|
|
|
23
23
|
const InitialValueResolver_1 = require("./InitialValueResolver");
|
|
24
24
|
const ReadonlyInfoResolver_1 = require("./ReadonlyInfoResolver");
|
|
25
25
|
function DataFormProvider(props) {
|
|
26
|
-
const {
|
|
26
|
+
const { schemaStore } = (0, useMetadata_1.useMetadata)();
|
|
27
27
|
const { language } = (0, useLocale_1.useLocale)();
|
|
28
28
|
const formValidationStrings = (0, FormValidationStringContext_1.useFormValidationStrings)();
|
|
29
29
|
const [formReadOnly, setFormReadOnly] = (0, react_1.useState)(false); // A trick to provide readOnly info to formInstance
|
|
@@ -32,7 +32,7 @@ function DataFormProvider(props) {
|
|
|
32
32
|
defaultValues: {},
|
|
33
33
|
resolver: (0, utils_1.formValidator)({
|
|
34
34
|
form: props.form,
|
|
35
|
-
|
|
35
|
+
schemaStore,
|
|
36
36
|
language,
|
|
37
37
|
schema: props.schema,
|
|
38
38
|
strings: formValidationStrings,
|
|
@@ -65,7 +65,7 @@ function DataFormProvider(props) {
|
|
|
65
65
|
props.schema,
|
|
66
66
|
props.recordId,
|
|
67
67
|
contextValue,
|
|
68
|
-
|
|
68
|
+
schemaStore,
|
|
69
69
|
props.commands,
|
|
70
70
|
]);
|
|
71
71
|
return ((0, jsx_runtime_1.jsx)(context_1.DataFormContext.Provider, { value: contextValue, children: (0, jsx_runtime_1.jsxs)(react_hook_form_1.FormProvider, Object.assign({}, formInstance, { children: [(0, jsx_runtime_1.jsx)(DataResolver_1.DataResolver, {}), (0, jsx_runtime_1.jsx)(InitialValueResolver_1.InitialValueResolver, {}), (0, jsx_runtime_1.jsx)(ReadonlyInfoResolver_1.ReadonlyInfoResolver, { setFormReadOnly: setFormReadOnly }), props.children] })) }));
|
package/dataform/hooks/index.js
CHANGED
|
@@ -26,3 +26,4 @@ __exportStar(require("./useRecordId"), exports);
|
|
|
26
26
|
__exportStar(require("./useRecordTitle"), exports);
|
|
27
27
|
__exportStar(require("./useSelectedForm"), exports);
|
|
28
28
|
__exportStar(require("./useLoadFormGridPage"), exports);
|
|
29
|
+
__exportStar(require("./useProcessFlowSteps"), exports);
|
|
@@ -17,6 +17,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
19
|
exports.useFormSave = useFormSave;
|
|
20
|
+
// Wrapper - Loader, response message
|
|
21
|
+
// Core - Extract modified fields, prepare operations, perform operations
|
|
22
|
+
const route_1 = require("@headless-adminapp/app/route");
|
|
20
23
|
const react_query_1 = require("@tanstack/react-query");
|
|
21
24
|
const react_1 = require("react");
|
|
22
25
|
const react_hook_form_1 = require("react-hook-form");
|
|
@@ -34,7 +37,7 @@ function useFormSave() {
|
|
|
34
37
|
const form = (0, useSelectedForm_1.useSelectedForm)();
|
|
35
38
|
const formInstance = (0, react_hook_form_1.useFormContext)();
|
|
36
39
|
const record = (0, useFormRecord_1.useFormRecord)();
|
|
37
|
-
const {
|
|
40
|
+
const { schemaStore } = (0, useMetadata_1.useMetadata)();
|
|
38
41
|
const schema = (0, useFormSchema_1.useDataFormSchema)();
|
|
39
42
|
const initialValues = (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.initialValues);
|
|
40
43
|
const refresh = (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.refresh);
|
|
@@ -42,6 +45,7 @@ function useFormSave() {
|
|
|
42
45
|
const { showProgressIndicator, hideProgressIndicator } = (0, useProgressIndicator_1.useProgressIndicator)();
|
|
43
46
|
const openToastNotification = (0, useOpenToastNotification_1.useOpenToastNotification)();
|
|
44
47
|
const client = (0, react_query_1.useQueryClient)();
|
|
48
|
+
const router = (0, route_1.useRouter)();
|
|
45
49
|
function showMessageAfterSave({ isCreatedMode }) {
|
|
46
50
|
// Show notification
|
|
47
51
|
if (!isCreatedMode) {
|
|
@@ -76,7 +80,7 @@ function useFormSave() {
|
|
|
76
80
|
initialValues: initialValues,
|
|
77
81
|
dataService,
|
|
78
82
|
schema: schema,
|
|
79
|
-
|
|
83
|
+
schemaStore,
|
|
80
84
|
});
|
|
81
85
|
if (!result.success) {
|
|
82
86
|
openToastNotification({
|
|
@@ -97,6 +101,9 @@ function useFormSave() {
|
|
|
97
101
|
yield client.invalidateQueries({
|
|
98
102
|
queryKey: ['data', 'retriveRecord'],
|
|
99
103
|
});
|
|
104
|
+
if (mode === 'saveandclose') {
|
|
105
|
+
router.back();
|
|
106
|
+
}
|
|
100
107
|
}
|
|
101
108
|
yield client.invalidateQueries({
|
|
102
109
|
queryKey: ['data', 'retriveRecords'],
|
|
@@ -10,6 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.useLoadFormGridPage = useLoadFormGridPage;
|
|
13
|
+
const app_1 = require("@headless-adminapp/app/app");
|
|
13
14
|
const react_query_1 = require("@tanstack/react-query");
|
|
14
15
|
const hooks_1 = require("../../metadata/hooks");
|
|
15
16
|
function useLoadFormGridPage(logicalName, formId) {
|
|
@@ -22,10 +23,15 @@ function useLoadFormGridPage(logicalName, formId) {
|
|
|
22
23
|
}),
|
|
23
24
|
placeholderData: react_query_1.keepPreviousData,
|
|
24
25
|
});
|
|
26
|
+
const { app: { formCommands }, } = (0, app_1.useAppContext)();
|
|
25
27
|
const { data: commands } = (0, react_query_1.useQuery)({
|
|
26
28
|
queryKey: ['experience-schema-form-commands', logicalName],
|
|
27
29
|
queryFn: () => __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
|
|
30
|
+
let commands = yield experienceStore.getFormCommands(logicalName);
|
|
31
|
+
if (!commands) {
|
|
32
|
+
commands = formCommands;
|
|
33
|
+
}
|
|
34
|
+
return commands !== null && commands !== void 0 ? commands : [];
|
|
29
35
|
}),
|
|
30
36
|
initialData: [],
|
|
31
37
|
});
|
|
@@ -34,7 +40,7 @@ function useLoadFormGridPage(logicalName, formId) {
|
|
|
34
40
|
loading: false,
|
|
35
41
|
error: true,
|
|
36
42
|
title: 'Schema not found',
|
|
37
|
-
message:
|
|
43
|
+
message: `The schema "${logicalName}" was not found`,
|
|
38
44
|
};
|
|
39
45
|
}
|
|
40
46
|
if (!form) {
|
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
import { EntityFormCommandContext } from '@headless-adminapp/core/experience/form';
|
|
2
2
|
import { CommandItemState } from '../../command';
|
|
3
|
-
export declare function useFormControlContext():
|
|
4
|
-
data: any;
|
|
5
|
-
logicalName: string;
|
|
6
|
-
schema: import("@headless-adminapp/core/schema").Schema<import("@headless-adminapp/core/schema").SchemaAttributes>;
|
|
7
|
-
form: import("@headless-adminapp/core/experience/form").Form<import("@headless-adminapp/core/schema").SchemaAttributes>;
|
|
8
|
-
formId: string;
|
|
9
|
-
originalData: import("@headless-adminapp/core/transport").Data<import("@headless-adminapp/core/schema").InferredSchemaType<import("@headless-adminapp/core/schema").SchemaAttributes>> | null;
|
|
10
|
-
recordId: string | number;
|
|
11
|
-
refresh: () => Promise<void>;
|
|
12
|
-
save: (mode?: import("@headless-adminapp/core/experience/form").SaveMode) => Promise<void>;
|
|
13
|
-
readonly: boolean | undefined;
|
|
14
|
-
};
|
|
3
|
+
export declare function useFormControlContext(): EntityFormCommandContext['primaryControl'];
|
|
15
4
|
export declare function useMainFormCommandHandlerContext(): EntityFormCommandContext;
|
|
16
5
|
export declare function useMainFormCommands(): CommandItemState[][];
|
|
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.useFormControlContext = useFormControlContext;
|
|
4
4
|
exports.useMainFormCommandHandlerContext = useMainFormCommandHandlerContext;
|
|
5
5
|
exports.useMainFormCommands = useMainFormCommands;
|
|
6
|
+
const route_1 = require("@headless-adminapp/app/route");
|
|
7
|
+
const react_1 = require("react");
|
|
6
8
|
const command_1 = require("../../command");
|
|
7
9
|
const context_1 = require("../../mutable/context");
|
|
8
10
|
const context_2 = require("../context");
|
|
@@ -13,6 +15,7 @@ const useFormSave_1 = require("./useFormSave");
|
|
|
13
15
|
const useFormSchema_1 = require("./useFormSchema");
|
|
14
16
|
const useRecordId_1 = require("./useRecordId");
|
|
15
17
|
function useFormControlContext() {
|
|
18
|
+
var _a;
|
|
16
19
|
const schema = (0, useFormSchema_1.useDataFormSchema)();
|
|
17
20
|
const form = (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.form);
|
|
18
21
|
const originalData = (0, useFormRecord_1.useFormRecord)();
|
|
@@ -20,8 +23,12 @@ function useFormControlContext() {
|
|
|
20
23
|
const save = (0, useFormSave_1.useFormSave)();
|
|
21
24
|
const refresh = (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.refresh);
|
|
22
25
|
const formInstance = (0, useFormInstance_1.useFormInstance)();
|
|
23
|
-
const readonly = (0, useFormIsReadonly_1.useFormIsReadonly)();
|
|
26
|
+
const readonly = (_a = (0, useFormIsReadonly_1.useFormIsReadonly)()) !== null && _a !== void 0 ? _a : false;
|
|
24
27
|
const data = formInstance.watch();
|
|
28
|
+
const router = (0, route_1.useRouter)();
|
|
29
|
+
const close = (0, react_1.useCallback)(() => {
|
|
30
|
+
router.back();
|
|
31
|
+
}, [router]);
|
|
25
32
|
return {
|
|
26
33
|
data,
|
|
27
34
|
logicalName: schema.logicalName,
|
|
@@ -33,6 +40,7 @@ function useFormControlContext() {
|
|
|
33
40
|
refresh,
|
|
34
41
|
save,
|
|
35
42
|
readonly,
|
|
43
|
+
close,
|
|
36
44
|
};
|
|
37
45
|
}
|
|
38
46
|
function useMainFormCommandHandlerContext() {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useProcessFlowSteps(): import("@headless-adminapp/core/experience/form/ProcessFlowInfo").ProcessFlowStep[] | null | undefined;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useProcessFlowSteps = useProcessFlowSteps;
|
|
4
|
+
const command_1 = require("@headless-adminapp/app/command");
|
|
5
|
+
const context_1 = require("../../mutable/context");
|
|
6
|
+
const context_2 = require("../context");
|
|
7
|
+
const useFormInstance_1 = require("./useFormInstance");
|
|
8
|
+
const useFormIsReadonly_1 = require("./useFormIsReadonly");
|
|
9
|
+
const useFormRecord_1 = require("./useFormRecord");
|
|
10
|
+
const useFormSchema_1 = require("./useFormSchema");
|
|
11
|
+
const useRecordId_1 = require("./useRecordId");
|
|
12
|
+
const useSelectedForm_1 = require("./useSelectedForm");
|
|
13
|
+
function useFormControlContext() {
|
|
14
|
+
var _a;
|
|
15
|
+
const schema = (0, useFormSchema_1.useDataFormSchema)();
|
|
16
|
+
const form = (0, context_1.useContextSelector)(context_2.DataFormContext, (state) => state.form);
|
|
17
|
+
const originalData = (0, useFormRecord_1.useFormRecord)();
|
|
18
|
+
const recordId = (0, useRecordId_1.useRecordId)();
|
|
19
|
+
const formInstance = (0, useFormInstance_1.useFormInstance)();
|
|
20
|
+
const readonly = (_a = (0, useFormIsReadonly_1.useFormIsReadonly)()) !== null && _a !== void 0 ? _a : false;
|
|
21
|
+
const data = formInstance.watch();
|
|
22
|
+
return {
|
|
23
|
+
data,
|
|
24
|
+
logicalName: schema.logicalName,
|
|
25
|
+
schema,
|
|
26
|
+
form,
|
|
27
|
+
formId: form.id,
|
|
28
|
+
originalData: originalData !== null && originalData !== void 0 ? originalData : null,
|
|
29
|
+
recordId,
|
|
30
|
+
readonly,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
function useProcessFlowInfoContext() {
|
|
34
|
+
const primaryControl = useFormControlContext();
|
|
35
|
+
const baseHandlerContext = (0, command_1.useBaseCommandHandlerContext)();
|
|
36
|
+
return Object.assign(Object.assign({}, baseHandlerContext), { primaryControl });
|
|
37
|
+
}
|
|
38
|
+
function useProcessFlowSteps() {
|
|
39
|
+
var _a;
|
|
40
|
+
const formConfig = (0, useSelectedForm_1.useSelectedForm)();
|
|
41
|
+
const context = useProcessFlowInfoContext();
|
|
42
|
+
const steps = (_a = formConfig.experience.processFlow) === null || _a === void 0 ? void 0 : _a.getSteps(context);
|
|
43
|
+
return steps;
|
|
44
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function useRecordTitle():
|
|
1
|
+
export declare function useRecordTitle(): any;
|
|
@@ -5,11 +5,18 @@ const useFormInstance_1 = require("./useFormInstance");
|
|
|
5
5
|
const useFormSchema_1 = require("./useFormSchema");
|
|
6
6
|
const useRecordId_1 = require("./useRecordId");
|
|
7
7
|
function useRecordTitle() {
|
|
8
|
-
var _a;
|
|
9
8
|
const formInstance = (0, useFormInstance_1.useFormInstance)();
|
|
10
9
|
const schema = (0, useFormSchema_1.useDataFormSchema)();
|
|
11
10
|
const recordId = (0, useRecordId_1.useRecordId)();
|
|
12
|
-
|
|
11
|
+
let primaryAttributeValue = formInstance.watch(schema.primaryAttribute);
|
|
12
|
+
const primaryAttribute = schema.attributes[schema.primaryAttribute];
|
|
13
|
+
if ((primaryAttribute === null || primaryAttribute === void 0 ? void 0 : primaryAttribute.type) === 'lookup') {
|
|
14
|
+
// Handle lookup attribute as primary
|
|
15
|
+
primaryAttributeValue = primaryAttributeValue === null || primaryAttributeValue === void 0 ? void 0 : primaryAttributeValue.name;
|
|
16
|
+
}
|
|
17
|
+
if (primaryAttributeValue && typeof primaryAttributeValue !== 'string') {
|
|
18
|
+
return String(primaryAttributeValue);
|
|
19
|
+
}
|
|
13
20
|
if (primaryAttributeValue) {
|
|
14
21
|
return primaryAttributeValue;
|
|
15
22
|
}
|