@mcurros2/microm 1.1.446-0 → 1.1.448-0
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +79 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -7376,13 +7376,16 @@ $parcel$export(module.exports, "useHierarchyKeys", function () { return $7f5304f
|
|
|
7376
7376
|
|
|
7377
7377
|
parcelRequire("2eyXi");
|
|
7378
7378
|
var $2cfmO = parcelRequire("2cfmO");
|
|
7379
|
-
const $7f5304fd68d04ed6$var$
|
|
7379
|
+
const $7f5304fd68d04ed6$var$resolveHierarchyValues = (formAPI, hierarchy)=>{
|
|
7380
|
+
return hierarchy.map((name)=>Object.prototype.hasOwnProperty.call(formAPI.form.values, name) ? formAPI.form.values[name] : formAPI.entity.def.columns[name]?.value ?? '');
|
|
7381
|
+
};
|
|
7382
|
+
const $7f5304fd68d04ed6$var$generateParentKeysArray = (hierarchy, mappedHierarchy, hierarchyValues, changedIndex)=>{
|
|
7380
7383
|
return hierarchy.map((_, index)=>{
|
|
7381
7384
|
const parentKeys = {};
|
|
7382
7385
|
for(let i = 0; i <= index; i++){
|
|
7383
7386
|
const formValueName = hierarchy[i];
|
|
7384
7387
|
const mappedName = mappedHierarchy?.[i] || formValueName;
|
|
7385
|
-
parentKeys[mappedName] = changedIndex !== undefined && i > changedIndex ? '' :
|
|
7388
|
+
parentKeys[mappedName] = changedIndex !== undefined && i > changedIndex ? '' : hierarchyValues[i];
|
|
7386
7389
|
}
|
|
7387
7390
|
return parentKeys;
|
|
7388
7391
|
});
|
|
@@ -7397,9 +7400,10 @@ const $7f5304fd68d04ed6$var$areStringArraysEqual = (left, right)=>{
|
|
|
7397
7400
|
};
|
|
7398
7401
|
function $7f5304fd68d04ed6$export$1dc6a021c60990b5(props) {
|
|
7399
7402
|
const { formAPI: formAPI, hierarchy: hierarchy, mappedHierarchy: mappedHierarchy } = props;
|
|
7403
|
+
const currentHierarchyValues = $7f5304fd68d04ed6$var$resolveHierarchyValues(formAPI, hierarchy);
|
|
7400
7404
|
const [hierarchyState, setHierarchyState] = (0, $b4te3$react.useState)(()=>({
|
|
7401
|
-
parentKeysArray: $7f5304fd68d04ed6$var$generateParentKeysArray(hierarchy, mappedHierarchy,
|
|
7402
|
-
hierarchyValues:
|
|
7405
|
+
parentKeysArray: $7f5304fd68d04ed6$var$generateParentKeysArray(hierarchy, mappedHierarchy, currentHierarchyValues),
|
|
7406
|
+
hierarchyValues: currentHierarchyValues,
|
|
7403
7407
|
hierarchy: [
|
|
7404
7408
|
...hierarchy
|
|
7405
7409
|
],
|
|
@@ -7408,7 +7412,6 @@ function $7f5304fd68d04ed6$export$1dc6a021c60990b5(props) {
|
|
|
7408
7412
|
] : undefined,
|
|
7409
7413
|
changeRevision: 0
|
|
7410
7414
|
}));
|
|
7411
|
-
const currentHierarchyValues = hierarchy.map((name)=>formAPI.form.values[name]);
|
|
7412
7415
|
const isGetLoading = formAPI.status.operationType === 'get' && formAPI.status.loading === true;
|
|
7413
7416
|
const isExistingRecordMode = formAPI.formMode === 'edit' || formAPI.formMode === 'view';
|
|
7414
7417
|
const isNewCompletedGet = isExistingRecordMode && formAPI.status.operationType === 'get' && formAPI.status.loading === false && hierarchyState.processedGetStatus !== formAPI.status;
|
|
@@ -7422,7 +7425,7 @@ function $7f5304fd68d04ed6$export$1dc6a021c60990b5(props) {
|
|
|
7422
7425
|
let resolvedHierarchyState = hierarchyState;
|
|
7423
7426
|
if (!isGetLoading) {
|
|
7424
7427
|
const changedIndex = isNewCompletedGet || hierarchyConfigurationChanged ? undefined : detectedChangedIndex === -1 ? hierarchyState.changedIndex : detectedChangedIndex;
|
|
7425
|
-
const newParentKeysArray = $7f5304fd68d04ed6$var$generateParentKeysArray(hierarchy, mappedHierarchy,
|
|
7428
|
+
const newParentKeysArray = $7f5304fd68d04ed6$var$generateParentKeysArray(hierarchy, mappedHierarchy, currentHierarchyValues, changedIndex);
|
|
7426
7429
|
const parentKeysChanged = !$7f5304fd68d04ed6$var$areParentKeysArraysEqual(hierarchyState.parentKeysArray, newParentKeysArray);
|
|
7427
7430
|
const hierarchyChanged = isNewCompletedGet || hierarchyConfigurationChanged || detectedChangedIndex !== -1;
|
|
7428
7431
|
if (parentKeysChanged || hierarchyChanged) {
|
|
@@ -36212,6 +36215,8 @@ var $4H7ea = parcelRequire("4H7ea");
|
|
|
36212
36215
|
var $iKzSR = parcelRequire("iKzSR");
|
|
36213
36216
|
parcelRequire("17D0Z");
|
|
36214
36217
|
var $42GxC = parcelRequire("42GxC");
|
|
36218
|
+
|
|
36219
|
+
var $hUJzP = parcelRequire("hUJzP");
|
|
36215
36220
|
const $d296e9f4d3930bfd$export$4db9dd7eda56bf7b = ({ entityForm: entityForm, entity: entity, lookupDefName: lookupDefName, column: column, parentKeys: parentKeys, required: required, HTMLDescriptionRef: HTMLDescriptionRef, enableAdd: enableAdd, enableEdit: enableEdit, enableDelete: enableDelete, enableView: enableView, transform: transform })=>{
|
|
36216
36221
|
const [status, setStatus] = (0, $b4te3$react.useState)({});
|
|
36217
36222
|
const [previousLookupResult, setPreviousLookupResult] = (0, $b4te3$react.useState)();
|
|
@@ -36220,6 +36225,9 @@ const $d296e9f4d3930bfd$export$4db9dd7eda56bf7b = ({ entityForm: entityForm, ent
|
|
|
36220
36225
|
const lookupEntity = (0, $b4te3$react.useRef)();
|
|
36221
36226
|
const viewName = (0, $b4te3$react.useRef)('');
|
|
36222
36227
|
const lookupDef = (0, $b4te3$react.useRef)();
|
|
36228
|
+
const lookupKeyColumn = (0, $b4te3$react.useRef)();
|
|
36229
|
+
const lookupConfigurationError = (0, $b4te3$react.useRef)();
|
|
36230
|
+
const loggedConfigurationError = (0, $b4te3$react.useRef)();
|
|
36223
36231
|
const isLooking = (0, $b4te3$react.useRef)(false);
|
|
36224
36232
|
const lastFocusedElement = (0, $b4te3$react.useRef)();
|
|
36225
36233
|
const lastValidLookup = (0, $b4te3$react.useRef)();
|
|
@@ -36235,7 +36243,16 @@ const $d296e9f4d3930bfd$export$4db9dd7eda56bf7b = ({ entityForm: entityForm, ent
|
|
|
36235
36243
|
error: false,
|
|
36236
36244
|
updateParentKeys: true
|
|
36237
36245
|
});
|
|
36238
|
-
const mappedKeyColumnName =
|
|
36246
|
+
const mappedKeyColumnName = lookupKeyColumn.current;
|
|
36247
|
+
if (!mappedKeyColumnName) return Promise.resolve({
|
|
36248
|
+
columnName: bindingColumn,
|
|
36249
|
+
key: keyValue,
|
|
36250
|
+
description: '',
|
|
36251
|
+
cancel: false,
|
|
36252
|
+
error: true,
|
|
36253
|
+
updateParentKeys: false,
|
|
36254
|
+
errorDescription: lookupConfigurationError.current ?? `Lookup '${currentLookupDef.name}' key column is not initialized.`
|
|
36255
|
+
});
|
|
36239
36256
|
const prepareLookupValues = (lookupKey)=>{
|
|
36240
36257
|
// Parent keys provide the lookup context, but the explicit typed or selected
|
|
36241
36258
|
// key must win when both sources contain the binding column.
|
|
@@ -36248,7 +36265,7 @@ const $d296e9f4d3930bfd$export$4db9dd7eda56bf7b = ({ entityForm: entityForm, ent
|
|
|
36248
36265
|
};
|
|
36249
36266
|
prepareLookupValues(keyValue);
|
|
36250
36267
|
if (parentKeys) currentLookupEntity.parentKeys = parentKeys;
|
|
36251
|
-
return new Promise(async (resolve
|
|
36268
|
+
return new Promise(async (resolve)=>{
|
|
36252
36269
|
const doLookup = async (lookupKey = keyValue)=>{
|
|
36253
36270
|
const requestValues = prepareLookupValues(lookupKey);
|
|
36254
36271
|
const cached = lastValidLookup.current;
|
|
@@ -36304,7 +36321,20 @@ const $d296e9f4d3930bfd$export$4db9dd7eda56bf7b = ({ entityForm: entityForm, ent
|
|
|
36304
36321
|
const onOK = async (selectedKeys)=>{
|
|
36305
36322
|
//console.log(`OnOK force: ${force} isLooking ${isLooking.current}`);
|
|
36306
36323
|
if (selectedKeys.length > 0) {
|
|
36307
|
-
|
|
36324
|
+
if (!Object.prototype.hasOwnProperty.call(selectedKeys[0], mappedKeyColumnName)) {
|
|
36325
|
+
const errorDescription = `Lookup '${currentLookupDef.name}' selection does not contain the inferred key column '${mappedKeyColumnName}'.`;
|
|
36326
|
+
console.error(errorDescription);
|
|
36327
|
+
resolve({
|
|
36328
|
+
columnName: bindingColumn,
|
|
36329
|
+
key: keyValue,
|
|
36330
|
+
description: '',
|
|
36331
|
+
cancel: false,
|
|
36332
|
+
error: true,
|
|
36333
|
+
updateParentKeys: false,
|
|
36334
|
+
errorDescription: errorDescription
|
|
36335
|
+
});
|
|
36336
|
+
return;
|
|
36337
|
+
}
|
|
36308
36338
|
const selectedKeyValue = selectedKeys[0][mappedKeyColumnName];
|
|
36309
36339
|
entityForm.form.setFieldValue(column, selectedKeyValue);
|
|
36310
36340
|
//lookupEntity.current!.def.columns[bindingColumn].value = selectedKeys[0][bindingColumn];
|
|
@@ -36485,7 +36515,15 @@ const $d296e9f4d3930bfd$export$4db9dd7eda56bf7b = ({ entityForm: entityForm, ent
|
|
|
36485
36515
|
lookupEntity.current = lookupDef.current.entityConstructor(entity.API.client, parentKeys);
|
|
36486
36516
|
const stdview = lookupEntity.current.def.standardView() ?? '';
|
|
36487
36517
|
viewName.current = lookupDef.current.view ? lookupDef.current.view : stdview;
|
|
36518
|
+
const keyColumnResolution = (0, $hUJzP.resolveLookupKeyColumn)(lookupDef.current, lookupEntity.current, viewName.current, column);
|
|
36519
|
+
lookupKeyColumn.current = keyColumnResolution.columnName;
|
|
36520
|
+
lookupConfigurationError.current = keyColumnResolution.error;
|
|
36521
|
+
if (keyColumnResolution.error && loggedConfigurationError.current !== keyColumnResolution.error) {
|
|
36522
|
+
console.error(keyColumnResolution.error);
|
|
36523
|
+
loggedConfigurationError.current = keyColumnResolution.error;
|
|
36524
|
+
} else if (!keyColumnResolution.error) loggedConfigurationError.current = undefined;
|
|
36488
36525
|
}, [
|
|
36526
|
+
column,
|
|
36489
36527
|
entity,
|
|
36490
36528
|
lookupDefName,
|
|
36491
36529
|
parentKeys
|
|
@@ -36531,6 +36569,38 @@ const $d296e9f4d3930bfd$export$4db9dd7eda56bf7b = ({ entityForm: entityForm, ent
|
|
|
36531
36569
|
};
|
|
36532
36570
|
|
|
36533
36571
|
});
|
|
36572
|
+
parcelRegister("hUJzP", function(module, exports) {
|
|
36573
|
+
|
|
36574
|
+
$parcel$export(module.exports, "resolveLookupKeyColumn", function () { return $e54a93aeccdd45e1$export$d6c095cc4cfabd61; });
|
|
36575
|
+
function $e54a93aeccdd45e1$export$d6c095cc4cfabd61(lookupDef, lookupEntity, viewName, bindingColumn) {
|
|
36576
|
+
const validateColumn = (columnName, source)=>{
|
|
36577
|
+
if (lookupEntity.def.columns[columnName]) return {
|
|
36578
|
+
columnName: columnName
|
|
36579
|
+
};
|
|
36580
|
+
return {
|
|
36581
|
+
error: `Lookup '${lookupDef.name}' ${source} resolves to column '${columnName}', but that column does not exist in lookup entity '${lookupEntity.def.name}'.`
|
|
36582
|
+
};
|
|
36583
|
+
};
|
|
36584
|
+
if (lookupDef.bindingColumnKey) return validateColumn(lookupDef.bindingColumnKey, 'bindingColumnKey');
|
|
36585
|
+
const view = lookupEntity.def.views[viewName];
|
|
36586
|
+
if (view) {
|
|
36587
|
+
const keyIndex = lookupDef.viewMapping?.keyIndex ?? 0;
|
|
36588
|
+
const mappedColumns = Object.entries(view.keyMappings).filter(([, resultIndex])=>resultIndex === keyIndex).map(([columnName])=>columnName);
|
|
36589
|
+
if (mappedColumns.length === 1) return validateColumn(mappedColumns[0], `view '${viewName}' key mapping at result index ${keyIndex}`);
|
|
36590
|
+
if (mappedColumns.length > 1) return {
|
|
36591
|
+
error: `Lookup '${lookupDef.name}' view '${viewName}' has multiple key mappings at result index ${keyIndex}. Configure bindingColumnKey explicitly.`
|
|
36592
|
+
};
|
|
36593
|
+
}
|
|
36594
|
+
if (lookupEntity.def.columns[bindingColumn]) return {
|
|
36595
|
+
columnName: bindingColumn
|
|
36596
|
+
};
|
|
36597
|
+
return {
|
|
36598
|
+
error: view ? `Lookup '${lookupDef.name}' cannot infer its key column: view '${viewName}' has no key mapping for result index ${lookupDef.viewMapping?.keyIndex ?? 0}, and lookup entity '${lookupEntity.def.name}' has no column named '${bindingColumn}'.` : `Lookup '${lookupDef.name}' cannot infer its key column: view '${viewName}' was not found in lookup entity '${lookupEntity.def.name}', and the entity has no column named '${bindingColumn}'.`
|
|
36599
|
+
};
|
|
36600
|
+
}
|
|
36601
|
+
|
|
36602
|
+
});
|
|
36603
|
+
|
|
36534
36604
|
|
|
36535
36605
|
|
|
36536
36606
|
|