udp-stencil-component-library 26.2.0-beta.0 → 26.2.0-beta.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/dist/cjs/ag-grid-base_63.cjs.entry.js +7 -7
- package/dist/cjs/api-method-instance-grid.cjs.entry.js +7 -2
- package/dist/cjs/{apiMethodInstance-B_zfUIFl.js → apiMethodInstance-DymTfku4.js} +1 -1
- package/dist/cjs/{configureUdpColumnMods-MGNO-bXn.js → configureUdpColumnMods-DtsJ11YI.js} +17 -2
- package/dist/cjs/index.cjs.js +3 -2
- package/dist/cjs/lookupHelper-fokGJbeb.js +86 -0
- package/dist/cjs/search-method-grid.cjs.entry.js +2 -69
- package/dist/collection/components/grid/new-grid/helperFunctions/configureUdpColumnMods.js +16 -2
- package/dist/collection/components/grid/new-grid/helperFunctions/lookupHelper.js +54 -47
- package/dist/components/ag-grid-base2.js +1 -1
- package/dist/components/configureUdpColumnMods.js +1 -1
- package/dist/components/search-method-grid2.js +1 -1
- package/dist/docs.json +1 -1
- package/dist/esm/ag-grid-base_63.entry.js +2 -2
- package/dist/esm/api-method-instance-grid.entry.js +7 -2
- package/dist/esm/{apiMethodInstance-WU8uISWJ.js → apiMethodInstance-BVrO2muA.js} +1 -1
- package/dist/esm/{configureUdpColumnMods-UsX5iItH.js → configureUdpColumnMods-CKOL0XD9.js} +17 -2
- package/dist/esm/index.js +3 -2
- package/dist/esm/lookupHelper-C0n7Ube1.js +81 -0
- package/dist/esm/search-method-grid.entry.js +2 -69
- package/dist/stencil-library/ag-grid-base_63.entry.js +1 -1
- package/dist/stencil-library/api-method-instance-grid.entry.js +1 -1
- package/dist/stencil-library/{apiMethodInstance-WU8uISWJ.js → apiMethodInstance-BVrO2muA.js} +1 -1
- package/dist/stencil-library/configureUdpColumnMods-CKOL0XD9.js +1 -0
- package/dist/stencil-library/index.esm.js +1 -1
- package/dist/stencil-library/lookupHelper-C0n7Ube1.js +1 -0
- package/dist/stencil-library/search-method-grid.entry.js +1 -1
- package/dist/types/components/grid/new-grid/helperFunctions/lookupHelper.d.ts +7 -0
- package/package.json +1 -1
- package/dist/cjs/getCurrentApiCatalogId-D7xHCEzs.js +0 -7
- package/dist/esm/getCurrentApiCatalogId-DeurXd9l.js +0 -5
- package/dist/stencil-library/configureUdpColumnMods-UsX5iItH.js +0 -1
- package/dist/stencil-library/getCurrentApiCatalogId-DeurXd9l.js +0 -1
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
var index = require('./index-G1ccGqOs.js');
|
|
4
4
|
var agGridEnterpriseV33 = require('ag-grid-enterprise-v33');
|
|
5
5
|
var apiUtils = require('./apiUtils-ELzOoTQ0.js');
|
|
6
|
-
var
|
|
6
|
+
var lookupHelper = require('./lookupHelper-fokGJbeb.js');
|
|
7
7
|
var tenantUtils = require('./tenantUtils-BCKSE0vq.js');
|
|
8
8
|
var statusRenderer = require('./status-renderer-9CQ-hhq8.js');
|
|
9
|
-
var configureUdpColumnMods = require('./configureUdpColumnMods-
|
|
9
|
+
var configureUdpColumnMods = require('./configureUdpColumnMods-DtsJ11YI.js');
|
|
10
10
|
var lodashEs = require('lodash-es');
|
|
11
11
|
var makeApiCall = require('./makeApiCall-CFfg9gI0.js');
|
|
12
12
|
var configService = require('./configService-BqiLnW8G.js');
|
|
@@ -624,7 +624,7 @@ class SavedViews {
|
|
|
624
624
|
},
|
|
625
625
|
];
|
|
626
626
|
try {
|
|
627
|
-
await apiUtils.updateViewAndConfigurations(view.gridViewId, getUserId(), context === null || context === void 0 ? void 0 : context.gridId,
|
|
627
|
+
await apiUtils.updateViewAndConfigurations(view.gridViewId, getUserId(), context === null || context === void 0 ? void 0 : context.gridId, lookupHelper.getCurrentApiCatalogId(), view.name, saveState, view.isDefault ? 1 : 0, context === null || context === void 0 ? void 0 : context.entityName, (_a = view.gridViewVisibilityTypeId) !== null && _a !== void 0 ? _a : 1, () => null);
|
|
628
628
|
await this.fetchViews();
|
|
629
629
|
const updated = this.filteredViews.find(v => v.gridViewId === view.gridViewId);
|
|
630
630
|
if (updated)
|
|
@@ -786,7 +786,7 @@ class SavedViews {
|
|
|
786
786
|
},
|
|
787
787
|
];
|
|
788
788
|
try {
|
|
789
|
-
await apiUtils.saveView(getUserId(), context === null || context === void 0 ? void 0 : context.gridId,
|
|
789
|
+
await apiUtils.saveView(getUserId(), context === null || context === void 0 ? void 0 : context.gridId, lookupHelper.getCurrentApiCatalogId(), name, context === null || context === void 0 ? void 0 : context.entityName, saveState, visibilityTypeId, 0, // not set as default
|
|
790
790
|
() => null);
|
|
791
791
|
await this.fetchViews();
|
|
792
792
|
const newView = this.filteredViews.find(v => v.name === name);
|
|
@@ -806,7 +806,7 @@ class SavedViews {
|
|
|
806
806
|
this.refresh();
|
|
807
807
|
const context = this.api.getGridOption('context');
|
|
808
808
|
try {
|
|
809
|
-
await apiUtils.updateView(view.gridViewId, getUserId(), context === null || context === void 0 ? void 0 : context.gridId,
|
|
809
|
+
await apiUtils.updateView(view.gridViewId, getUserId(), context === null || context === void 0 ? void 0 : context.gridId, lookupHelper.getCurrentApiCatalogId(), name, view.isDefault ? 1 : 0, context === null || context === void 0 ? void 0 : context.entityName, visibilityTypeId, () => null);
|
|
810
810
|
await this.fetchViews();
|
|
811
811
|
}
|
|
812
812
|
catch (err) {
|
|
@@ -824,12 +824,12 @@ class SavedViews {
|
|
|
824
824
|
const context = this.api.getGridOption('context');
|
|
825
825
|
const isCurrentlyDefault = view.isDefault;
|
|
826
826
|
try {
|
|
827
|
-
await apiUtils.updateView(view.gridViewId, getUserId(), context === null || context === void 0 ? void 0 : context.gridId,
|
|
827
|
+
await apiUtils.updateView(view.gridViewId, getUserId(), context === null || context === void 0 ? void 0 : context.gridId, lookupHelper.getCurrentApiCatalogId(), view.name, isCurrentlyDefault ? 0 : 1, context === null || context === void 0 ? void 0 : context.entityName, (_a = view.gridViewVisibilityTypeId) !== null && _a !== void 0 ? _a : 1, () => null);
|
|
828
828
|
if (!isCurrentlyDefault) {
|
|
829
829
|
// Unset the previous default if there was one
|
|
830
830
|
const currentDefault = this.filteredViews.find(v => v.isDefault);
|
|
831
831
|
if (currentDefault) {
|
|
832
|
-
await apiUtils.updateView(currentDefault.gridViewId, getUserId(), context === null || context === void 0 ? void 0 : context.gridId,
|
|
832
|
+
await apiUtils.updateView(currentDefault.gridViewId, getUserId(), context === null || context === void 0 ? void 0 : context.gridId, lookupHelper.getCurrentApiCatalogId(), currentDefault.name, 0, context === null || context === void 0 ? void 0 : context.entityName, (_b = currentDefault.gridViewVisibilityTypeId) !== null && _b !== void 0 ? _b : 1, () => null).catch(err => console.log(err));
|
|
833
833
|
}
|
|
834
834
|
}
|
|
835
835
|
await this.fetchViews();
|
|
@@ -4,10 +4,15 @@ var index = require('./index-G1ccGqOs.js');
|
|
|
4
4
|
var makeApiCall = require('./makeApiCall-CFfg9gI0.js');
|
|
5
5
|
var searchObject = require('./searchObject-DeDFFGcx.js');
|
|
6
6
|
var lodashEs = require('lodash-es');
|
|
7
|
-
var apiMethodInstance = require('./apiMethodInstance-
|
|
7
|
+
var apiMethodInstance = require('./apiMethodInstance-DymTfku4.js');
|
|
8
8
|
var configService = require('./configService-BqiLnW8G.js');
|
|
9
9
|
require('axios');
|
|
10
|
-
require('./configureUdpColumnMods-
|
|
10
|
+
require('./configureUdpColumnMods-DtsJ11YI.js');
|
|
11
|
+
require('./lookupHelper-fokGJbeb.js');
|
|
12
|
+
require('./apiUtils-ELzOoTQ0.js');
|
|
13
|
+
require('deep-equal');
|
|
14
|
+
require('@stencil/store');
|
|
15
|
+
require('./tenantUtils-BCKSE0vq.js');
|
|
11
16
|
|
|
12
17
|
function mergeSearchObjects(baseSearchObject, searchObjectOverrides) {
|
|
13
18
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var configureUdpColumnMods = require('./configureUdpColumnMods-
|
|
3
|
+
var configureUdpColumnMods = require('./configureUdpColumnMods-DtsJ11YI.js');
|
|
4
4
|
|
|
5
5
|
function mapDotNetTypeToAgGridType(type) {
|
|
6
6
|
const normalized = type.replace(/\?$/, '').trim().toLowerCase();
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var lookupHelper = require('./lookupHelper-fokGJbeb.js');
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Finds an existing 'actions' column in an array of ColDefs and applies
|
|
5
7
|
* a dynamic fixed width and right pinning.
|
|
@@ -28,9 +30,22 @@ function configureUdpColumnMods(columnDefs, disableColumnFiltering = false) {
|
|
|
28
30
|
// Return a new object with the original properties plus our overrides
|
|
29
31
|
return Object.assign(Object.assign({}, colDef), { pinned: 'right', width: calculatedWidth, minWidth: calculatedWidth, maxWidth: calculatedWidth, sortable: false, filter: false, suppressHeaderMenuButton: true, suppressMovable: true });
|
|
30
32
|
}
|
|
31
|
-
//
|
|
33
|
+
// Lookup columns: display the resolved label, but filter against the underlying key.
|
|
34
|
+
// The set filter values + dropdown labels come from the cached lookup table, so the
|
|
35
|
+
// filter model holds keys (server-side IN clause works unchanged). Sort is left off
|
|
36
|
+
// because the backend can only order by the stored key, not the resolved label.
|
|
32
37
|
if ((_e = colDef === null || colDef === void 0 ? void 0 : colDef.context) === null || _e === void 0 ? void 0 : _e.lookupId) {
|
|
33
|
-
|
|
38
|
+
const lookupId = colDef.context.lookupId;
|
|
39
|
+
const field = colDef.field;
|
|
40
|
+
return Object.assign(Object.assign({}, colDef), { valueGetter: (params) => params.data[field + 'LookupValue'], filterValueGetter: (params) => { var _a; return (_a = params.data) === null || _a === void 0 ? void 0 : _a[field]; }, filter: 'agSetColumnFilter', filterParams: Object.assign({ values: (params) => {
|
|
41
|
+
lookupHelper.getLookupTable(lookupId).then(table => {
|
|
42
|
+
params.success(Array.from(table.valueMap.keys()));
|
|
43
|
+
});
|
|
44
|
+
}, valueFormatter: (params) => {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
const key = params.value == null ? '' : String(params.value);
|
|
47
|
+
return (_b = (_a = lookupHelper.getLookupTableSync(lookupId)) === null || _a === void 0 ? void 0 : _a.valueMap.get(key)) !== null && _b !== void 0 ? _b : key;
|
|
48
|
+
} }, colDef.filterParams), sortable: false });
|
|
34
49
|
}
|
|
35
50
|
if (disableColumnFiltering) {
|
|
36
51
|
return Object.assign(Object.assign({}, colDef), { filter: false });
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -8,7 +8,7 @@ var SearchBuilder = require('./SearchBuilder-BsB_257b.js');
|
|
|
8
8
|
var searchObject = require('./searchObject-DeDFFGcx.js');
|
|
9
9
|
var catalogTree = require('./catalogTree-CnzW15ah.js');
|
|
10
10
|
var configService = require('./configService-BqiLnW8G.js');
|
|
11
|
-
var apiMethodInstance = require('./apiMethodInstance-
|
|
11
|
+
var apiMethodInstance = require('./apiMethodInstance-DymTfku4.js');
|
|
12
12
|
var webComponents = require('@fluentui/web-components');
|
|
13
13
|
var tokens = require('@fluentui/tokens');
|
|
14
14
|
var agGridEnterpriseV33 = require('ag-grid-enterprise-v33');
|
|
@@ -17,7 +17,8 @@ require('./apiUtils-ELzOoTQ0.js');
|
|
|
17
17
|
require('deep-equal');
|
|
18
18
|
require('./makeApiCall-CFfg9gI0.js');
|
|
19
19
|
require('./tenantUtils-BCKSE0vq.js');
|
|
20
|
-
require('./configureUdpColumnMods-
|
|
20
|
+
require('./configureUdpColumnMods-DtsJ11YI.js');
|
|
21
|
+
require('./lookupHelper-fokGJbeb.js');
|
|
21
22
|
|
|
22
23
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
23
24
|
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var apiUtils = require('./apiUtils-ELzOoTQ0.js');
|
|
4
|
+
|
|
5
|
+
function getCurrentApiCatalogId() {
|
|
6
|
+
return sessionStorage.getItem('current-api-catalog-id');
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const resolvedLookups = new Map();
|
|
10
|
+
const pendingLookups = new Map();
|
|
11
|
+
async function getLookupTable(lookupId) {
|
|
12
|
+
const cached = resolvedLookups.get(lookupId);
|
|
13
|
+
if (cached)
|
|
14
|
+
return cached;
|
|
15
|
+
const inFlight = pendingLookups.get(lookupId);
|
|
16
|
+
if (inFlight)
|
|
17
|
+
return inFlight;
|
|
18
|
+
const promise = (async () => {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
const lookupApiMethodId = (_b = (_a = (await apiUtils.getPromotedLookupMethod(getCurrentApiCatalogId()))) === null || _a === void 0 ? void 0 : _a.unityBaseGetDataMethod) === null || _b === void 0 ? void 0 : _b.apiMethodId;
|
|
21
|
+
const empty = { keyName: '', valueName: '', valueMap: new Map() };
|
|
22
|
+
if (!lookupApiMethodId)
|
|
23
|
+
return empty;
|
|
24
|
+
try {
|
|
25
|
+
const response = await apiUtils.executeQueryWithParameters({ data: { id: lookupId } }, lookupApiMethodId);
|
|
26
|
+
const { keyName, valueName, data } = response !== null && response !== void 0 ? response : {};
|
|
27
|
+
if (!data || !keyName || !valueName)
|
|
28
|
+
return empty;
|
|
29
|
+
const valueMap = new Map(data.map((item) => [String(item[keyName]), item[valueName]]));
|
|
30
|
+
const table = { keyName, valueName, valueMap };
|
|
31
|
+
resolvedLookups.set(lookupId, table);
|
|
32
|
+
return table;
|
|
33
|
+
}
|
|
34
|
+
catch (_c) {
|
|
35
|
+
return empty;
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
pendingLookups.delete(lookupId);
|
|
39
|
+
}
|
|
40
|
+
})();
|
|
41
|
+
pendingLookups.set(lookupId, promise);
|
|
42
|
+
return promise;
|
|
43
|
+
}
|
|
44
|
+
function getLookupTableSync(lookupId) {
|
|
45
|
+
return resolvedLookups.get(lookupId);
|
|
46
|
+
}
|
|
47
|
+
async function processLookupsInData(rowData, columnDefs) {
|
|
48
|
+
if (!(rowData === null || rowData === void 0 ? void 0 : rowData.length)) {
|
|
49
|
+
return rowData;
|
|
50
|
+
}
|
|
51
|
+
const lookupsByField = new Map();
|
|
52
|
+
const uniqueLookupIds = new Set();
|
|
53
|
+
columnDefs.forEach(col => {
|
|
54
|
+
var _a;
|
|
55
|
+
const lookupId = (_a = col === null || col === void 0 ? void 0 : col.context) === null || _a === void 0 ? void 0 : _a.lookupId;
|
|
56
|
+
if (lookupId && typeof lookupId === 'string' && col.field) {
|
|
57
|
+
lookupsByField.set(col.field, lookupId);
|
|
58
|
+
uniqueLookupIds.add(lookupId);
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
if (uniqueLookupIds.size === 0) {
|
|
62
|
+
return rowData;
|
|
63
|
+
}
|
|
64
|
+
await Promise.all(Array.from(uniqueLookupIds).map(id => getLookupTable(id)));
|
|
65
|
+
return rowData.map(row => {
|
|
66
|
+
var _a;
|
|
67
|
+
const newRow = Object.assign({}, row);
|
|
68
|
+
for (const [field, lookupId] of lookupsByField.entries()) {
|
|
69
|
+
if (newRow[field] === null || newRow[field] === undefined)
|
|
70
|
+
continue;
|
|
71
|
+
const valueMap = (_a = resolvedLookups.get(lookupId)) === null || _a === void 0 ? void 0 : _a.valueMap;
|
|
72
|
+
if (!valueMap)
|
|
73
|
+
continue;
|
|
74
|
+
const key = String(newRow[field]);
|
|
75
|
+
if (valueMap.has(key)) {
|
|
76
|
+
newRow[field + 'LookupValue'] = valueMap.get(key);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return newRow;
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
exports.getCurrentApiCatalogId = getCurrentApiCatalogId;
|
|
84
|
+
exports.getLookupTable = getLookupTable;
|
|
85
|
+
exports.getLookupTableSync = getLookupTableSync;
|
|
86
|
+
exports.processLookupsInData = processLookupsInData;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var index = require('./index-G1ccGqOs.js');
|
|
4
4
|
var apiUtils = require('./apiUtils-ELzOoTQ0.js');
|
|
5
5
|
var searchObject = require('./searchObject-DeDFFGcx.js');
|
|
6
|
-
var
|
|
6
|
+
var lookupHelper = require('./lookupHelper-fokGJbeb.js');
|
|
7
7
|
var makeApiCall = require('./makeApiCall-CFfg9gI0.js');
|
|
8
8
|
var configService = require('./configService-BqiLnW8G.js');
|
|
9
9
|
var isEqual = require('lodash-es/isEqual');
|
|
@@ -16,73 +16,6 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
|
16
16
|
|
|
17
17
|
var isEqual__default = /*#__PURE__*/_interopDefault(isEqual);
|
|
18
18
|
|
|
19
|
-
async function processLookupsInData(rowData, columnDefs) {
|
|
20
|
-
var _a, _b;
|
|
21
|
-
if (!(rowData === null || rowData === void 0 ? void 0 : rowData.length)) {
|
|
22
|
-
return rowData;
|
|
23
|
-
}
|
|
24
|
-
// Step 1: Build a map of lookups needed (simpler now)
|
|
25
|
-
const lookupsToFetch = new Map();
|
|
26
|
-
columnDefs.forEach(col => {
|
|
27
|
-
var _a;
|
|
28
|
-
const lookupId = (_a = col === null || col === void 0 ? void 0 : col.context) === null || _a === void 0 ? void 0 : _a.lookupId;
|
|
29
|
-
if (lookupId && typeof lookupId === 'string' && col.field) {
|
|
30
|
-
const existing = lookupsToFetch.get(lookupId);
|
|
31
|
-
if (existing) {
|
|
32
|
-
// If this lookupId is already tracked, add the new field to its list
|
|
33
|
-
existing.columnFields.push(col.field);
|
|
34
|
-
}
|
|
35
|
-
else {
|
|
36
|
-
// Otherwise, create a new entry for this lookupId
|
|
37
|
-
lookupsToFetch.set(lookupId, { columnFields: [col.field] });
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
if (lookupsToFetch.size === 0) {
|
|
42
|
-
return rowData;
|
|
43
|
-
}
|
|
44
|
-
// Step 2: Fetch the method ID and then the lookup data
|
|
45
|
-
const lookupApiMethodId = (_b = (_a = (await apiUtils.getPromotedLookupMethod(getCurrentApiCatalogId.getCurrentApiCatalogId()))) === null || _a === void 0 ? void 0 : _a.unityBaseGetDataMethod) === null || _b === void 0 ? void 0 : _b.apiMethodId;
|
|
46
|
-
if (!lookupApiMethodId) {
|
|
47
|
-
return rowData;
|
|
48
|
-
}
|
|
49
|
-
const lookupPromises = Array.from(lookupsToFetch.keys()).map(lookupId => {
|
|
50
|
-
// 2. If not in cache, make the API call.
|
|
51
|
-
return apiUtils.executeQueryWithParameters({ data: { id: lookupId } }, lookupApiMethodId)
|
|
52
|
-
.then(response => {
|
|
53
|
-
return Object.assign({ lookupId }, response);
|
|
54
|
-
})
|
|
55
|
-
.catch(() => ({ lookupId, data: [] }));
|
|
56
|
-
});
|
|
57
|
-
const lookupResults = await Promise.all(lookupPromises);
|
|
58
|
-
// Step 3: Create a fast-access map using the keyName and valueName from the response
|
|
59
|
-
const lookupsMap = new Map();
|
|
60
|
-
lookupResults.forEach(result => {
|
|
61
|
-
const config = lookupsToFetch.get(result.lookupId);
|
|
62
|
-
const keyName = result.keyName;
|
|
63
|
-
const valueName = result.valueName;
|
|
64
|
-
if (result.data && keyName && valueName) {
|
|
65
|
-
const valueMap = new Map(result.data.map(item => [String(item[keyName]), item[valueName]]));
|
|
66
|
-
for (const field of config.columnFields) {
|
|
67
|
-
lookupsMap.set(field, valueMap);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
// Step 4: Map the original rowData (unchanged)
|
|
72
|
-
return rowData.map(row => {
|
|
73
|
-
const newRow = Object.assign({}, row);
|
|
74
|
-
for (const [field, valueMap] of lookupsMap.entries()) {
|
|
75
|
-
if (newRow[field] !== null && newRow[field] !== undefined) {
|
|
76
|
-
const key = String(newRow[field]);
|
|
77
|
-
if (valueMap.has(key)) {
|
|
78
|
-
newRow[field + 'LookupValue'] = valueMap.get(key);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
return newRow;
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
19
|
const FilterOperators = {
|
|
87
20
|
equals: searchObject.SearchOperators.EQUALS,
|
|
88
21
|
contains: searchObject.SearchOperators.LIKE,
|
|
@@ -321,7 +254,7 @@ const createSearchMethodDataSource = (options) => {
|
|
|
321
254
|
}
|
|
322
255
|
else {
|
|
323
256
|
const columnDefs = params.api.getColumnDefs();
|
|
324
|
-
finalRowData = await processLookupsInData(response.pageList, columnDefs);
|
|
257
|
+
finalRowData = await lookupHelper.processLookupsInData(response.pageList, columnDefs);
|
|
325
258
|
}
|
|
326
259
|
params.success({
|
|
327
260
|
rowData: finalRowData,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getLookupTable, getLookupTableSync } from "./lookupHelper";
|
|
1
2
|
/**
|
|
2
3
|
* Finds an existing 'actions' column in an array of ColDefs and applies
|
|
3
4
|
* a dynamic fixed width and right pinning.
|
|
@@ -26,9 +27,22 @@ export function configureUdpColumnMods(columnDefs, disableColumnFiltering = fals
|
|
|
26
27
|
// Return a new object with the original properties plus our overrides
|
|
27
28
|
return Object.assign(Object.assign({}, colDef), { pinned: 'right', width: calculatedWidth, minWidth: calculatedWidth, maxWidth: calculatedWidth, sortable: false, filter: false, suppressHeaderMenuButton: true, suppressMovable: true });
|
|
28
29
|
}
|
|
29
|
-
//
|
|
30
|
+
// Lookup columns: display the resolved label, but filter against the underlying key.
|
|
31
|
+
// The set filter values + dropdown labels come from the cached lookup table, so the
|
|
32
|
+
// filter model holds keys (server-side IN clause works unchanged). Sort is left off
|
|
33
|
+
// because the backend can only order by the stored key, not the resolved label.
|
|
30
34
|
if ((_e = colDef === null || colDef === void 0 ? void 0 : colDef.context) === null || _e === void 0 ? void 0 : _e.lookupId) {
|
|
31
|
-
|
|
35
|
+
const lookupId = colDef.context.lookupId;
|
|
36
|
+
const field = colDef.field;
|
|
37
|
+
return Object.assign(Object.assign({}, colDef), { valueGetter: (params) => params.data[field + 'LookupValue'], filterValueGetter: (params) => { var _a; return (_a = params.data) === null || _a === void 0 ? void 0 : _a[field]; }, filter: 'agSetColumnFilter', filterParams: Object.assign({ values: (params) => {
|
|
38
|
+
getLookupTable(lookupId).then(table => {
|
|
39
|
+
params.success(Array.from(table.valueMap.keys()));
|
|
40
|
+
});
|
|
41
|
+
}, valueFormatter: (params) => {
|
|
42
|
+
var _a, _b;
|
|
43
|
+
const key = params.value == null ? '' : String(params.value);
|
|
44
|
+
return (_b = (_a = getLookupTableSync(lookupId)) === null || _a === void 0 ? void 0 : _a.valueMap.get(key)) !== null && _b !== void 0 ? _b : key;
|
|
45
|
+
} }, colDef.filterParams), sortable: false });
|
|
32
46
|
}
|
|
33
47
|
if (disableColumnFiltering) {
|
|
34
48
|
return Object.assign(Object.assign({}, colDef), { filter: false });
|
|
@@ -1,66 +1,73 @@
|
|
|
1
1
|
import { executeQueryWithParameters, getPromotedLookupMethod, } from "../../../../udp-utilities/api-udp/apiUtils";
|
|
2
2
|
import { getCurrentApiCatalogId } from "../../../../udp-utilities/catalog/getCurrentApiCatalogId";
|
|
3
|
+
const resolvedLookups = new Map();
|
|
4
|
+
const pendingLookups = new Map();
|
|
5
|
+
export async function getLookupTable(lookupId) {
|
|
6
|
+
const cached = resolvedLookups.get(lookupId);
|
|
7
|
+
if (cached)
|
|
8
|
+
return cached;
|
|
9
|
+
const inFlight = pendingLookups.get(lookupId);
|
|
10
|
+
if (inFlight)
|
|
11
|
+
return inFlight;
|
|
12
|
+
const promise = (async () => {
|
|
13
|
+
var _a, _b;
|
|
14
|
+
const lookupApiMethodId = (_b = (_a = (await getPromotedLookupMethod(getCurrentApiCatalogId()))) === null || _a === void 0 ? void 0 : _a.unityBaseGetDataMethod) === null || _b === void 0 ? void 0 : _b.apiMethodId;
|
|
15
|
+
const empty = { keyName: '', valueName: '', valueMap: new Map() };
|
|
16
|
+
if (!lookupApiMethodId)
|
|
17
|
+
return empty;
|
|
18
|
+
try {
|
|
19
|
+
const response = await executeQueryWithParameters({ data: { id: lookupId } }, lookupApiMethodId);
|
|
20
|
+
const { keyName, valueName, data } = response !== null && response !== void 0 ? response : {};
|
|
21
|
+
if (!data || !keyName || !valueName)
|
|
22
|
+
return empty;
|
|
23
|
+
const valueMap = new Map(data.map((item) => [String(item[keyName]), item[valueName]]));
|
|
24
|
+
const table = { keyName, valueName, valueMap };
|
|
25
|
+
resolvedLookups.set(lookupId, table);
|
|
26
|
+
return table;
|
|
27
|
+
}
|
|
28
|
+
catch (_c) {
|
|
29
|
+
return empty;
|
|
30
|
+
}
|
|
31
|
+
finally {
|
|
32
|
+
pendingLookups.delete(lookupId);
|
|
33
|
+
}
|
|
34
|
+
})();
|
|
35
|
+
pendingLookups.set(lookupId, promise);
|
|
36
|
+
return promise;
|
|
37
|
+
}
|
|
38
|
+
export function getLookupTableSync(lookupId) {
|
|
39
|
+
return resolvedLookups.get(lookupId);
|
|
40
|
+
}
|
|
3
41
|
export async function processLookupsInData(rowData, columnDefs) {
|
|
4
|
-
var _a, _b;
|
|
5
42
|
if (!(rowData === null || rowData === void 0 ? void 0 : rowData.length)) {
|
|
6
43
|
return rowData;
|
|
7
44
|
}
|
|
8
|
-
|
|
9
|
-
const
|
|
45
|
+
const lookupsByField = new Map();
|
|
46
|
+
const uniqueLookupIds = new Set();
|
|
10
47
|
columnDefs.forEach(col => {
|
|
11
48
|
var _a;
|
|
12
49
|
const lookupId = (_a = col === null || col === void 0 ? void 0 : col.context) === null || _a === void 0 ? void 0 : _a.lookupId;
|
|
13
50
|
if (lookupId && typeof lookupId === 'string' && col.field) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
// If this lookupId is already tracked, add the new field to its list
|
|
17
|
-
existing.columnFields.push(col.field);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
// Otherwise, create a new entry for this lookupId
|
|
21
|
-
lookupsToFetch.set(lookupId, { columnFields: [col.field] });
|
|
22
|
-
}
|
|
51
|
+
lookupsByField.set(col.field, lookupId);
|
|
52
|
+
uniqueLookupIds.add(lookupId);
|
|
23
53
|
}
|
|
24
54
|
});
|
|
25
|
-
if (
|
|
55
|
+
if (uniqueLookupIds.size === 0) {
|
|
26
56
|
return rowData;
|
|
27
57
|
}
|
|
28
|
-
|
|
29
|
-
const lookupApiMethodId = (_b = (_a = (await getPromotedLookupMethod(getCurrentApiCatalogId()))) === null || _a === void 0 ? void 0 : _a.unityBaseGetDataMethod) === null || _b === void 0 ? void 0 : _b.apiMethodId;
|
|
30
|
-
if (!lookupApiMethodId) {
|
|
31
|
-
return rowData;
|
|
32
|
-
}
|
|
33
|
-
const lookupPromises = Array.from(lookupsToFetch.keys()).map(lookupId => {
|
|
34
|
-
// 2. If not in cache, make the API call.
|
|
35
|
-
return executeQueryWithParameters({ data: { id: lookupId } }, lookupApiMethodId)
|
|
36
|
-
.then(response => {
|
|
37
|
-
return Object.assign({ lookupId }, response);
|
|
38
|
-
})
|
|
39
|
-
.catch(() => ({ lookupId, data: [] }));
|
|
40
|
-
});
|
|
41
|
-
const lookupResults = await Promise.all(lookupPromises);
|
|
42
|
-
// Step 3: Create a fast-access map using the keyName and valueName from the response
|
|
43
|
-
const lookupsMap = new Map();
|
|
44
|
-
lookupResults.forEach(result => {
|
|
45
|
-
const config = lookupsToFetch.get(result.lookupId);
|
|
46
|
-
const keyName = result.keyName;
|
|
47
|
-
const valueName = result.valueName;
|
|
48
|
-
if (result.data && keyName && valueName) {
|
|
49
|
-
const valueMap = new Map(result.data.map(item => [String(item[keyName]), item[valueName]]));
|
|
50
|
-
for (const field of config.columnFields) {
|
|
51
|
-
lookupsMap.set(field, valueMap);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
// Step 4: Map the original rowData (unchanged)
|
|
58
|
+
await Promise.all(Array.from(uniqueLookupIds).map(id => getLookupTable(id)));
|
|
56
59
|
return rowData.map(row => {
|
|
60
|
+
var _a;
|
|
57
61
|
const newRow = Object.assign({}, row);
|
|
58
|
-
for (const [field,
|
|
59
|
-
if (newRow[field]
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
for (const [field, lookupId] of lookupsByField.entries()) {
|
|
63
|
+
if (newRow[field] === null || newRow[field] === undefined)
|
|
64
|
+
continue;
|
|
65
|
+
const valueMap = (_a = resolvedLookups.get(lookupId)) === null || _a === void 0 ? void 0 : _a.valueMap;
|
|
66
|
+
if (!valueMap)
|
|
67
|
+
continue;
|
|
68
|
+
const key = String(newRow[field]);
|
|
69
|
+
if (valueMap.has(key)) {
|
|
70
|
+
newRow[field + 'LookupValue'] = valueMap.get(key);
|
|
64
71
|
}
|
|
65
72
|
}
|
|
66
73
|
return newRow;
|