@reltio/components 1.4.2253 → 1.4.2254

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 (77) hide show
  1. package/ConfigureColumnsPopup/ConfigureColumnsPopup.d.ts +3 -3
  2. package/ConfigureColumnsPopup/ConfigureColumnsPopup.js +5 -5
  3. package/SelectionPopup/SelectionPopup.d.ts +4 -4
  4. package/SelectionPopup/SelectionPopup.js +4 -3
  5. package/SelectionPopup/SelectionPopup.spec.js +2 -2
  6. package/cjs/ConfigureColumnsPopup/ConfigureColumnsPopup.d.ts +3 -3
  7. package/cjs/ConfigureColumnsPopup/ConfigureColumnsPopup.js +5 -5
  8. package/cjs/SelectionPopup/SelectionPopup.d.ts +4 -4
  9. package/cjs/SelectionPopup/SelectionPopup.js +4 -3
  10. package/cjs/SelectionPopup/SelectionPopup.spec.js +2 -2
  11. package/cjs/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/EntityChangesGroup.js +22 -6
  12. package/cjs/features/workflow/ChangeRequestEditor/helpers/addedAttributes.js +5 -2
  13. package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.js +29 -13
  14. package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.test-data.d.ts +41 -0
  15. package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.test-data.js +161 -0
  16. package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.test.js +52 -0
  17. package/cjs/features/workflow/ChangeRequestEditor/helpers/helpers.d.ts +1 -1
  18. package/cjs/features/workflow/ChangeRequestEditor/helpers/helpers.js +2 -4
  19. package/cjs/features/workflow/ReviewDCRDialog/ReviewDCRDialog.d.ts +2 -1
  20. package/cjs/features/workflow/ReviewDCRDialog/ReviewDCRDialog.js +37 -3
  21. package/cjs/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +2 -2
  22. package/cjs/features/workflow/contexts/AddedAttributesContext/index.d.ts +1 -0
  23. package/cjs/features/workflow/contexts/AddedAttributesContext/index.js +8 -3
  24. package/cjs/features/workflow/contexts/ChangeRequestEditorContext/index.d.ts +1 -0
  25. package/cjs/features/workflow/contexts/ChangeRequestEditorContext/index.js +8 -2
  26. package/cjs/features/workflow/helpers/attributes.js +5 -4
  27. package/cjs/features/workflow/helpers/attributes.test.js +55 -0
  28. package/cjs/features/workflow/helpers/common.d.ts +2 -1
  29. package/cjs/features/workflow/helpers/common.js +5 -1
  30. package/cjs/features/workflow/helpers/dcr.js +2 -1
  31. package/cjs/features/workflow/helpers/dcr.test.js +47 -0
  32. package/cjs/features/workflow/helpers/merge.js +1 -1
  33. package/cjs/features/workflow/helpers/merge.test.js +34 -0
  34. package/cjs/features/workflow/helpers/metadata.test-data.js +9 -0
  35. package/cjs/features/workflow/helpers/validation.js +3 -2
  36. package/cjs/features/workflow/helpers/validation.test-data.d.ts +1 -0
  37. package/cjs/features/workflow/helpers/validation.test-data.js +34 -1
  38. package/cjs/features/workflow/helpers/validation.test.js +10 -0
  39. package/cjs/features/workflow/hooks/useChangeRequest.d.ts +1 -0
  40. package/cjs/features/workflow/hooks/useChangeRequest.js +8 -5
  41. package/cjs/features/workflow/hooks/useChangeRequest.test.js +11 -5
  42. package/cjs/features/workflow/hooks/useWorkflowActions.d.ts +2 -1
  43. package/cjs/features/workflow/hooks/useWorkflowActions.js +8 -3
  44. package/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/EntityChangesGroup.js +23 -7
  45. package/features/workflow/ChangeRequestEditor/helpers/addedAttributes.js +5 -2
  46. package/features/workflow/ChangeRequestEditor/helpers/changesList.js +29 -13
  47. package/features/workflow/ChangeRequestEditor/helpers/changesList.test-data.d.ts +41 -0
  48. package/features/workflow/ChangeRequestEditor/helpers/changesList.test-data.js +153 -0
  49. package/features/workflow/ChangeRequestEditor/helpers/changesList.test.js +52 -0
  50. package/features/workflow/ChangeRequestEditor/helpers/helpers.d.ts +1 -1
  51. package/features/workflow/ChangeRequestEditor/helpers/helpers.js +1 -3
  52. package/features/workflow/ReviewDCRDialog/ReviewDCRDialog.d.ts +2 -1
  53. package/features/workflow/ReviewDCRDialog/ReviewDCRDialog.js +14 -3
  54. package/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +2 -2
  55. package/features/workflow/contexts/AddedAttributesContext/index.d.ts +1 -0
  56. package/features/workflow/contexts/AddedAttributesContext/index.js +8 -3
  57. package/features/workflow/contexts/ChangeRequestEditorContext/index.d.ts +1 -0
  58. package/features/workflow/contexts/ChangeRequestEditorContext/index.js +8 -2
  59. package/features/workflow/helpers/attributes.js +5 -4
  60. package/features/workflow/helpers/attributes.test.js +55 -0
  61. package/features/workflow/helpers/common.d.ts +2 -1
  62. package/features/workflow/helpers/common.js +3 -0
  63. package/features/workflow/helpers/dcr.js +2 -1
  64. package/features/workflow/helpers/dcr.test.js +47 -0
  65. package/features/workflow/helpers/merge.js +2 -2
  66. package/features/workflow/helpers/merge.test.js +34 -0
  67. package/features/workflow/helpers/metadata.test-data.js +9 -0
  68. package/features/workflow/helpers/validation.js +3 -2
  69. package/features/workflow/helpers/validation.test-data.d.ts +1 -0
  70. package/features/workflow/helpers/validation.test-data.js +32 -0
  71. package/features/workflow/helpers/validation.test.js +11 -1
  72. package/features/workflow/hooks/useChangeRequest.d.ts +1 -0
  73. package/features/workflow/hooks/useChangeRequest.js +8 -5
  74. package/features/workflow/hooks/useChangeRequest.test.js +11 -5
  75. package/features/workflow/hooks/useWorkflowActions.d.ts +2 -1
  76. package/features/workflow/hooks/useWorkflowActions.js +8 -3
  77. package/package.json +1 -1
@@ -215,6 +215,16 @@ describe('getValidationErrors', function () {
215
215
  }
216
216
  ]);
217
217
  });
218
+ it('should not report a missing required boolean attribute when its value is primitive false', function () {
219
+ var metadata = (0, metadata_test_data_1.getMetadata)();
220
+ var result = (0, validation_1.getValidationErrors)({
221
+ changes: (0, validation_test_data_1.getChangesWithBooleanPrimitiveValue)(),
222
+ userChanges: [],
223
+ entitiesOrRelations: (0, validation_test_data_1.getEntitiesOrRelations)(),
224
+ metadata: metadata
225
+ });
226
+ expect(result).toEqual([]);
227
+ });
218
228
  it('should validate required attributes in new entity', function () {
219
229
  var metadata = (0, metadata_test_data_1.getMetadata)();
220
230
  var result = (0, validation_1.getValidationErrors)({
@@ -2,4 +2,5 @@ import { ChangeRequest, GroupedObjectsInfo } from '@reltio/mdm-sdk';
2
2
  export declare const useChangeRequest: (dcrUri: string) => {
3
3
  dcr: ChangeRequest;
4
4
  groupedObjects: GroupedObjectsInfo[];
5
+ reloadDcr: () => void;
5
6
  };
@@ -28,8 +28,8 @@ var useChangeRequest = function (dcrUri) {
28
28
  }
29
29
  return safePromise((0, mdm_sdk_1.getEntitiesByUris)(entityUris, { searchOptions: 'ovOnly', defaultMaxValues: 1 }));
30
30
  }, []); // eslint-disable-line
31
- (0, react_1.useEffect)(function () {
32
- (0, mdm_sdk_1.getDataChangeRequest)(dcrUri)
31
+ var loadDcr = (0, react_1.useCallback)(function () {
32
+ safePromise((0, mdm_sdk_1.getDataChangeRequest)(dcrUri))
33
33
  .then(function (dcr) {
34
34
  var changes = dcr.changes, objectsInfo = dcr.objectsInfo;
35
35
  var objectsWithChanges = (0, dcr_1.extractObjectsFromChangeRequest)(changes, objectsInfo);
@@ -40,7 +40,7 @@ var useChangeRequest = function (dcrUri) {
40
40
  requestEntities(entityUris)
41
41
  .then(function (entities) {
42
42
  var relationsObjectsWithRequestedEntities = relationsObjectsWithoutEntity.map(function (relationsObject, index) {
43
- return __assign(__assign({}, relationsObject), { entity: entities[index] });
43
+ return __assign(__assign({}, relationsObject), { entity: __assign(__assign({}, entities[index]), { isExist: true }) });
44
44
  });
45
45
  (0, ramda_1.pipe)(ramda_1.flatten, (0, ramda_1.reduce)(dcr_1.concatEntityRelationsObjects, {}), ramda_1.values, setGroupedObjects)([
46
46
  entityObjectsWithRelations,
@@ -52,7 +52,10 @@ var useChangeRequest = function (dcrUri) {
52
52
  setDcr(dcr);
53
53
  })
54
54
  .catch(errors_1.showErrorMessage);
55
- }, [dcrUri, requestEntities]);
56
- return { dcr: dcr, groupedObjects: groupedObjects };
55
+ }, [dcrUri, requestEntities, safePromise]);
56
+ (0, react_1.useEffect)(function () {
57
+ loadDcr();
58
+ }, [loadDcr]);
59
+ return { dcr: dcr, groupedObjects: groupedObjects, reloadDcr: loadDcr };
57
60
  };
58
61
  exports.useChangeRequest = useChangeRequest;
@@ -129,7 +129,8 @@ describe('useChangeRequest tests', function () {
129
129
  expect(mdm_sdk_1.getEntitiesByUris).not.toHaveBeenCalled();
130
130
  expect(result.current).toEqual({
131
131
  dcr: null,
132
- groupedObjects: []
132
+ groupedObjects: [],
133
+ reloadDcr: expect.any(Function)
133
134
  });
134
135
  });
135
136
  it('should return empty parameters if dcrUri is undefined', function () {
@@ -138,7 +139,8 @@ describe('useChangeRequest tests', function () {
138
139
  expect(mdm_sdk_1.getEntitiesByUris).not.toHaveBeenCalled();
139
140
  expect(result.current).toEqual({
140
141
  dcr: null,
141
- groupedObjects: []
142
+ groupedObjects: [],
143
+ reloadDcr: expect.any(Function)
142
144
  });
143
145
  });
144
146
  it('should go to error message in case of getDataChangeRequest error', function () { return __awaiter(void 0, void 0, void 0, function () {
@@ -161,7 +163,8 @@ describe('useChangeRequest tests', function () {
161
163
  });
162
164
  expect(result.current).toEqual({
163
165
  dcr: null,
164
- groupedObjects: []
166
+ groupedObjects: [],
167
+ reloadDcr: expect.any(Function)
165
168
  });
166
169
  return [2 /*return*/];
167
170
  }
@@ -200,7 +203,8 @@ describe('useChangeRequest tests', function () {
200
203
  });
201
204
  expect(result.current).toEqual({
202
205
  dcr: dcr,
203
- groupedObjects: []
206
+ groupedObjects: [],
207
+ reloadDcr: expect.any(Function)
204
208
  });
205
209
  return [2 /*return*/];
206
210
  }
@@ -236,6 +240,7 @@ describe('useChangeRequest tests', function () {
236
240
  expect(ErrorPopup_1.ErrorPopup.addError).not.toHaveBeenCalled();
237
241
  expect(result.current).toEqual({
238
242
  dcr: dcr,
243
+ reloadDcr: expect.any(Function),
239
244
  groupedObjects: [
240
245
  {
241
246
  entity: {
@@ -269,7 +274,8 @@ describe('useChangeRequest tests', function () {
269
274
  },
270
275
  {
271
276
  entity: {
272
- uri: 'entities/151gdPs5'
277
+ uri: 'entities/151gdPs5',
278
+ isExist: true
273
279
  },
274
280
  relations: [
275
281
  {
@@ -4,9 +4,10 @@ type Task = Partial<Pick<WorkflowTaskData, 'taskId' | 'possibleActions' | 'assig
4
4
  type Props = {
5
5
  task: Task;
6
6
  onActionSuccess?: (action: string) => void;
7
+ onError?: () => void;
7
8
  beforeAction?: () => Promise<BeforeActionOutcome>;
8
9
  };
9
- export declare const useWorkflowActions: ({ task, onActionSuccess, beforeAction }: Props) => {
10
+ export declare const useWorkflowActions: ({ task, onActionSuccess, onError, beforeAction }: Props) => {
10
11
  actions: TaskAction[];
11
12
  actionRequestIsInProgress: boolean;
12
13
  };
@@ -46,7 +46,7 @@ var MdmModuleContext_1 = require("../../../contexts/MdmModuleContext");
46
46
  var CommentDialogContext_1 = require("../../../contexts/CommentDialogContext");
47
47
  var errors_2 = require("../../../helpers/errors");
48
48
  var useWorkflowActions = function (_a) {
49
- var task = _a.task, onActionSuccess = _a.onActionSuccess, beforeAction = _a.beforeAction;
49
+ var task = _a.task, onActionSuccess = _a.onActionSuccess, onError = _a.onError, beforeAction = _a.beforeAction;
50
50
  var _b = task !== null && task !== void 0 ? task : {}, possibleActions = _b.possibleActions, assignee = _b.assignee, taskId = _b.taskId, isOpen = _b.isOpen;
51
51
  var workflowTasks = (0, react_1.useContext)(WorkflowTasksContext_1.WorkflowTasksContext);
52
52
  var workflowPath = (0, MdmModuleContext_1.useMdmWorkflowPath)();
@@ -85,6 +85,7 @@ var useWorkflowActions = function (_a) {
85
85
  if (!outcome.proceed) {
86
86
  if (outcome.error) {
87
87
  (0, errors_2.showDefaultErrorMessage)(outcome.error);
88
+ onError === null || onError === void 0 ? void 0 : onError();
88
89
  }
89
90
  setActionRequestIsInProgress(false);
90
91
  return [2 /*return*/];
@@ -93,6 +94,7 @@ var useWorkflowActions = function (_a) {
93
94
  case 5:
94
95
  error_1 = _a.sent();
95
96
  (0, errors_2.showDefaultErrorMessage)(error_1);
97
+ onError === null || onError === void 0 ? void 0 : onError();
96
98
  setActionRequestIsInProgress(false);
97
99
  return [2 /*return*/];
98
100
  case 6:
@@ -107,7 +109,10 @@ var useWorkflowActions = function (_a) {
107
109
  .then(function () {
108
110
  handleActionSuccess === null || handleActionSuccess === void 0 ? void 0 : handleActionSuccess(action);
109
111
  })
110
- .catch(errors_1.showWorkflowError)
112
+ .catch(function (error) {
113
+ (0, errors_1.showWorkflowError)(error);
114
+ onError === null || onError === void 0 ? void 0 : onError();
115
+ })
111
116
  .finally(function () {
112
117
  setActionRequestIsInProgress(false);
113
118
  });
@@ -116,7 +121,7 @@ var useWorkflowActions = function (_a) {
116
121
  }
117
122
  });
118
123
  }); };
119
- }, [workflowPath, taskId, environment, tenant, handleActionSuccess, showCommentDialog, beforeAction]);
124
+ }, [workflowPath, taskId, environment, tenant, handleActionSuccess, showCommentDialog, beforeAction, onError]);
120
125
  var actions = (0, react_1.useMemo)(function () {
121
126
  return username === assignee && (0, common_1.isOpenTask)(isOpen)
122
127
  ? (possibleActions || []).map(function (_a) {
@@ -16,7 +16,7 @@ import { getDCRUri } from '../../../helpers/common';
16
16
  import { getAvailableAttributeTypesForEntity, getAvailableAttributeTypesForRelation, getAvailableSubAttributesForNestedOrReference } from '../../../helpers/moreAttributesScope';
17
17
  import { isDiffChange, isRelationRow, isNestedOrReferenceParent } from '../../helpers/helpers';
18
18
  import { prepareChangesList } from '../../helpers/changesList';
19
- import { extractChangeOverrides, getAddedId, getObjectIdFromLineId, getParentAddedId, getParentChangeOverrides, getParentLineId, isRootAddedAttribute } from '../../helpers/addedAttributes';
19
+ import { extractChangeOverrides, getAddedId, getParentAddedId, getParentChangeOverrides, getParentLineId, isRootAddedAttribute } from '../../helpers/addedAttributes';
20
20
  import { extractLineIds } from '../../../helpers/merge';
21
21
  import { useDcrReviewAllowAddAttributes } from '../../hooks/useDcrReviewAllowAddAttributes';
22
22
  import { MoreAttributesEditor } from '../editors';
@@ -35,6 +35,22 @@ export var EntityChangesGroup = function (_a) {
35
35
  relationsInfo: relationsInfo
36
36
  });
37
37
  var changesList = useMemo(function () { return prepareChangesList(rawChangesList); }, [rawChangesList]);
38
+ var objectUriByChangeIndex = useMemo(function () {
39
+ var _a, _b;
40
+ var result = [];
41
+ var currentObjectUri = entityInfo.uri;
42
+ for (var _i = 0, changesList_1 = changesList; _i < changesList_1.length; _i++) {
43
+ var item = changesList_1[_i];
44
+ if (!isDiffChange(item)) {
45
+ currentObjectUri = entityInfo.uri;
46
+ }
47
+ else if (isRelationRow(item)) {
48
+ currentObjectUri = (_b = (_a = item.attributeValue) === null || _a === void 0 ? void 0 : _a.uri) !== null && _b !== void 0 ? _b : entityInfo.uri;
49
+ }
50
+ result.push(currentObjectUri);
51
+ }
52
+ return result;
53
+ }, [changesList, entityInfo.uri]);
38
54
  var entityAttributeTypes = useMemo(function () {
39
55
  if (!isNil(entityInfo.isExist)) {
40
56
  return getAvailableAttributeTypesForEntity(metadata, entityInfo.type);
@@ -64,7 +80,7 @@ export var EntityChangesGroup = function (_a) {
64
80
  highlight(addedIds);
65
81
  };
66
82
  }, [addAddedAttributes, highlight]);
67
- var handleAddNestedAttributes = useCallback(function (change) { return function (attributeTypes) {
83
+ var handleAddNestedAttributes = useCallback(function (change, objectUri) { return function (attributeTypes) {
68
84
  var _a, _b, _c, _d, _e;
69
85
  var parentUri = (_a = change.attributeType) === null || _a === void 0 ? void 0 : _a.uri;
70
86
  var parentAttrs = attributeTypes.filter(function (attr) { return attr.uri === parentUri; });
@@ -76,7 +92,7 @@ export var EntityChangesGroup = function (_a) {
76
92
  var addedId = getAddedId(change);
77
93
  if (lineId && isRootAddedAttribute(lineId)) {
78
94
  handleAddAttributes({
79
- objectUri: getObjectIdFromLineId(lineId),
95
+ objectUri: objectUri,
80
96
  changeOverrides: siblingOverrides
81
97
  })(parentAttrs);
82
98
  }
@@ -89,7 +105,7 @@ export var EntityChangesGroup = function (_a) {
89
105
  }
90
106
  else {
91
107
  handleAddAttributes({
92
- objectUri: entityInfo.uri,
108
+ objectUri: objectUri,
93
109
  changeOverrides: siblingOverrides
94
110
  })(parentAttrs);
95
111
  }
@@ -102,12 +118,12 @@ export var EntityChangesGroup = function (_a) {
102
118
  }
103
119
  else {
104
120
  handleAddAttributes({
105
- objectUri: entityInfo.uri,
121
+ objectUri: objectUri,
106
122
  changeOverrides: childOverrides
107
123
  })(subAttrs);
108
124
  }
109
125
  }
110
- }; }, [handleAddAttributes, entityInfo.uri]);
126
+ }; }, [handleAddAttributes]);
111
127
  return (React.createElement(AttributesChangesContext.Provider, { value: objectsInfo },
112
128
  React.createElement(Accordion, { className: styles.entityGroup, defaultExpanded: true, "data-reltio-id": "entity-changes-group" },
113
129
  React.createElement(AccordionSummary, { expandIcon: React.createElement(ExpandMoreIcon, null), className: styles.entityHeader, classes: {
@@ -134,6 +150,6 @@ export var EntityChangesGroup = function (_a) {
134
150
  objectUri: (_e = item === null || item === void 0 ? void 0 : item.attributeValue) === null || _e === void 0 ? void 0 : _e.uri,
135
151
  parentLineId: (_f = item.lineIds) === null || _f === void 0 ? void 0 : _f[0]
136
152
  }) })),
137
- allowAddAttributes && isNestedOrReferenceParent(item) && (React.createElement(MoreAttributesEditor, { data: nestedAttrs, change: item, parent: item.attributeType, onApply: handleAddNestedAttributes(item) }))));
153
+ allowAddAttributes && isNestedOrReferenceParent(item) && (React.createElement(MoreAttributesEditor, { data: nestedAttrs, change: item, parent: item.attributeType, onApply: handleAddNestedAttributes(item, objectUriByChangeIndex[index]) }))));
138
154
  })))));
139
155
  };
@@ -52,10 +52,13 @@ export var getParentChangeOverrides = function (change) {
52
52
  if (change.refAttributeType) {
53
53
  var parts = change.refAttributeType.split('/');
54
54
  if (parts.length > 2) {
55
- result.refAttributeType = parts.slice(0, -2).join('/');
55
+ var parentRefAttributeType = parts.slice(0, -2).join('/');
56
+ if (parentRefAttributeType.includes('/attributes/')) {
57
+ result.refAttributeType = parentRefAttributeType;
58
+ }
56
59
  }
57
60
  }
58
- if (change.refObjectURI) {
61
+ if (result.refAttributeType && change.refObjectURI) {
59
62
  result.refObjectURI = change.refObjectURI;
60
63
  }
61
64
  return Object.keys(result).length > 0 ? result : undefined;
@@ -9,6 +9,15 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
+ if (ar || !(i in from)) {
15
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
+ ar[i] = from[i];
17
+ }
18
+ }
19
+ return to.concat(ar || Array.prototype.slice.call(from));
20
+ };
12
21
  import { DCROperationTypes, isComplexAttribute, isImage, isRoleAttrType, isTagAttrType } from '@reltio/mdm-sdk';
13
22
  import { getOperationType } from '../../helpers/common';
14
23
  import { isDiffChange } from './helpers';
@@ -127,23 +136,30 @@ var extractPathFromInnerChange = function (attributeValue) {
127
136
  return __assign(__assign({ attributePath: inner.attributePath }, (inner.refAttributeType && { refAttributeType: inner.refAttributeType })), (inner.refObjectURI && { refObjectURI: inner.refObjectURI }));
128
137
  };
129
138
  var fillParentPaths = function (items) {
130
- return items.map(function (item, index) {
131
- var _a, _b;
139
+ var _a, _b;
140
+ var result = __spreadArray([], items, true);
141
+ for (var index = result.length - 1; index >= 0; index--) {
142
+ var item = result[index];
132
143
  if (!isDiffChange(item) || !isComplexAttribute(item.attributeType) || item.attributePath)
133
- return item;
144
+ continue;
134
145
  var innerPath = extractPathFromInnerChange(item.attributeValue);
135
- if (innerPath)
136
- return __assign(__assign({}, item), innerPath);
137
- var name = (_a = item.attributeType) === null || _a === void 0 ? void 0 : _a.name;
146
+ if (innerPath) {
147
+ result[index] = __assign(__assign({}, item), innerPath);
148
+ continue;
149
+ }
150
+ var name_1 = (_a = item.attributeType) === null || _a === void 0 ? void 0 : _a.name;
138
151
  var instanceId = (_b = item.attributeValue) === null || _b === void 0 ? void 0 : _b.id;
139
- if (!name || !instanceId)
140
- return item;
141
- var descendant = findDescendantWithPath(items, index, item.level);
152
+ if (!name_1 || !instanceId)
153
+ continue;
154
+ var descendant = findDescendantWithPath(result, index, item.level);
142
155
  if (!descendant)
143
- return item;
144
- var parentPath = deriveParentPath(descendant, name, instanceId);
145
- return parentPath ? __assign(__assign({}, item), parentPath) : item;
146
- });
156
+ continue;
157
+ var parentPath = deriveParentPath(descendant, name_1, instanceId);
158
+ if (parentPath) {
159
+ result[index] = __assign(__assign({}, item), parentPath);
160
+ }
161
+ }
162
+ return result;
147
163
  };
148
164
  export var prepareChangesList = function (rawChangesList) {
149
165
  var withPaths = fillParentPaths(rawChangesList);
@@ -0,0 +1,41 @@
1
+ import { DCRTypes, type AttributeType } from '@reltio/mdm-sdk';
2
+ import type { Diff } from '../../types';
3
+ export declare const referenceAttributeType: AttributeType;
4
+ export declare const referenceAttributeValue: {
5
+ id: string;
6
+ value: {
7
+ RefFirstLevelNested: {
8
+ id: string;
9
+ value: {
10
+ FirstLevelNestedSub2: {
11
+ id: string;
12
+ value: {
13
+ id: string;
14
+ refObjectURI: string;
15
+ type: DCRTypes;
16
+ objectType: string;
17
+ attributePath: string;
18
+ oldValue: {
19
+ value: string;
20
+ lineIds: string[];
21
+ };
22
+ newValue: {
23
+ value: string;
24
+ lineIds: string[];
25
+ };
26
+ attributeType: string;
27
+ refAttributeType: string;
28
+ lineIds: string[];
29
+ };
30
+ }[];
31
+ };
32
+ }[];
33
+ };
34
+ refObjectURI: string;
35
+ };
36
+ export declare const affiliationsChangeRow: Diff;
37
+ export declare const deepNestedParentFromChildChanges: () => Diff[];
38
+ export declare const deepNestedInnerChangeRow: () => Diff[];
39
+ export declare const addressDeepNestedThreeLevelChanges: () => Diff[];
40
+ export declare const addressDeepNestedRefPropagationChanges: () => Diff[];
41
+ export declare const deepNestedRowWithExistingPath: () => Diff[];
@@ -0,0 +1,153 @@
1
+ import { DCROperationTypes, DCRTypes } from '@reltio/mdm-sdk';
2
+ export var referenceAttributeType = {
3
+ uri: 'configuration/entityTypes/HCP/attributes/Affiliations',
4
+ name: 'Affiliations',
5
+ label: 'HCP to HCA Affiliations',
6
+ type: 'Reference',
7
+ referencedEntityTypeURI: 'configuration/entityTypes/HCA',
8
+ relationshipTypeURI: 'configuration/relationTypes/HCPtoHCA'
9
+ };
10
+ export var referenceAttributeValue = {
11
+ id: '0HocGCj',
12
+ value: {
13
+ RefFirstLevelNested: [
14
+ {
15
+ id: '2Cf73Q29',
16
+ value: {
17
+ FirstLevelNestedSub2: [
18
+ {
19
+ id: '2ph3wL7h',
20
+ value: {
21
+ id: '0aDhfxd',
22
+ refObjectURI: 'relations/0HocGCj',
23
+ type: DCRTypes.UPDATE_ATTRIBUTE,
24
+ objectType: 'configuration/entityTypes/HCP',
25
+ attributePath: 'RefFirstLevelNested/2Cf73Q29/FirstLevelNestedSub2/2ph3wL7h',
26
+ oldValue: { value: '555756', lineIds: ['BAliEK2/0aDhfxd/oldValue'] },
27
+ newValue: { value: '5557563462', lineIds: ['BAliEK2/0aDhfxd/newValue'] },
28
+ attributeType: 'configuration/relationTypes/HCPtoHCA/attributes/RefFirstLevelNested/attributes/FirstLevelNestedSub2',
29
+ refAttributeType: 'configuration/entityTypes/HCP/attributes/Affiliations/attributes/RefFirstLevelNested/attributes/FirstLevelNestedSub2',
30
+ lineIds: ['BAliEK2/0aDhfxd']
31
+ }
32
+ }
33
+ ]
34
+ }
35
+ }
36
+ ]
37
+ },
38
+ refObjectURI: 'relations/0HocGCj'
39
+ };
40
+ export var affiliationsChangeRow = {
41
+ level: 0,
42
+ label: 'HCP to HCA Affiliations',
43
+ attributeType: referenceAttributeType,
44
+ attributeValue: referenceAttributeValue,
45
+ operation: DCROperationTypes.EDITED,
46
+ isReferenceSubAttribute: false
47
+ };
48
+ var nestedAttributeType = function (name) {
49
+ return ({
50
+ uri: "configuration/entityTypes/HCP/attributes/".concat(name),
51
+ name: name,
52
+ label: name,
53
+ type: 'Nested'
54
+ });
55
+ };
56
+ var firstLevelNestedSub2FloatType = {
57
+ uri: 'configuration/relationTypes/HCPtoHCA/attributes/RefFirstLevelNested/attributes/FirstLevelNestedSub2',
58
+ name: 'FirstLevelNestedSub2',
59
+ label: 'float',
60
+ type: 'Float'
61
+ };
62
+ export var deepNestedParentFromChildChanges = function () { return [
63
+ {
64
+ level: 1,
65
+ label: 'DeepNested',
66
+ attributeType: nestedAttributeType('DeepNested'),
67
+ attributeValue: { id: '2ph3uHFx', value: { FirstLevelNestedSub2: [] } },
68
+ operation: DCROperationTypes.EDITED,
69
+ isReferenceSubAttribute: false
70
+ },
71
+ {
72
+ level: 2,
73
+ label: 'FirstLevelNestedSub2',
74
+ attributeType: firstLevelNestedSub2FloatType,
75
+ attributePath: 'DeepNested/2ph3uHFx/FirstLevelNestedSub2/2ph3uPmT',
76
+ operation: DCROperationTypes.EDITED,
77
+ isReferenceSubAttribute: false
78
+ }
79
+ ]; };
80
+ export var deepNestedInnerChangeRow = function () { return [
81
+ {
82
+ level: 1,
83
+ label: 'DeepNested',
84
+ attributeType: nestedAttributeType('DeepNested'),
85
+ attributeValue: {
86
+ id: '4FcgXO5o',
87
+ value: {
88
+ attributePath: 'DeepNested/4FcgXO5o/SecondLevelNested',
89
+ refAttributeType: 'configuration/entityTypes/HCP/attributes/Address/attributes/DeepNested/attributes/SecondLevelNested',
90
+ refObjectURI: 'relations/0LbuUWU'
91
+ }
92
+ },
93
+ operation: DCROperationTypes.EDITED,
94
+ isReferenceSubAttribute: false
95
+ }
96
+ ]; };
97
+ export var addressDeepNestedThreeLevelChanges = function () { return [
98
+ {
99
+ level: 1,
100
+ label: 'DeepNested',
101
+ attributeType: nestedAttributeType('DeepNested'),
102
+ attributeValue: { id: '4FcgXO5o', value: { SecondLevelNested: [] } },
103
+ operation: DCROperationTypes.EDITED,
104
+ isReferenceSubAttribute: false
105
+ },
106
+ {
107
+ level: 2,
108
+ label: 'SecondLevelNested',
109
+ attributeType: nestedAttributeType('SecondLevelNested'),
110
+ attributeValue: { id: '2v13QcOX', value: { FirstLevelNestedSubatr3: [] } },
111
+ operation: DCROperationTypes.EDITED,
112
+ isReferenceSubAttribute: false
113
+ },
114
+ {
115
+ level: 3,
116
+ label: 'FirstLevelNestedSubatr3',
117
+ attributeType: nestedAttributeType('FirstLevelNestedSubatr3'),
118
+ attributePath: 'DeepNested/4FcgXO5o/SecondLevelNested/2v13QcOX/FirstLevelNestedSubatr3/2v13Qgen',
119
+ operation: DCROperationTypes.EDITED,
120
+ isReferenceSubAttribute: false
121
+ }
122
+ ]; };
123
+ export var addressDeepNestedRefPropagationChanges = function () { return [
124
+ {
125
+ level: 1,
126
+ label: 'DeepNested',
127
+ attributeType: nestedAttributeType('DeepNested'),
128
+ attributeValue: { id: '2ph3uHFx', value: { FirstLevelNestedSub2: [] } },
129
+ operation: DCROperationTypes.EDITED,
130
+ isReferenceSubAttribute: false
131
+ },
132
+ {
133
+ level: 2,
134
+ label: 'FirstLevelNestedSub2',
135
+ attributeType: firstLevelNestedSub2FloatType,
136
+ attributePath: 'DeepNested/2ph3uHFx/FirstLevelNestedSub2/2ph3uPmT',
137
+ refAttributeType: 'configuration/entityTypes/HCP/attributes/Address/attributes/DeepNested/attributes/FirstLevelNestedSub2',
138
+ refObjectURI: 'relations/0LbuUWU',
139
+ operation: DCROperationTypes.EDITED,
140
+ isReferenceSubAttribute: false
141
+ }
142
+ ]; };
143
+ export var deepNestedRowWithExistingPath = function () { return [
144
+ {
145
+ level: 1,
146
+ label: 'DeepNested',
147
+ attributeType: nestedAttributeType('DeepNested'),
148
+ attributeValue: { id: '2ph3uHFx', value: { FirstLevelNestedSub2: [] } },
149
+ attributePath: 'DeepNested/2ph3uHFx',
150
+ operation: DCROperationTypes.EDITED,
151
+ isReferenceSubAttribute: false
152
+ }
153
+ ]; };
@@ -9,8 +9,18 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
13
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
14
+ if (ar || !(i in from)) {
15
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
16
+ ar[i] = from[i];
17
+ }
18
+ }
19
+ return to.concat(ar || Array.prototype.slice.call(from));
20
+ };
12
21
  import { DataTypes, DCROperationTypes } from '@reltio/mdm-sdk';
13
22
  import { prepareChangesList } from './changesList';
23
+ import { addressDeepNestedRefPropagationChanges, addressDeepNestedThreeLevelChanges, affiliationsChangeRow, deepNestedInnerChangeRow, deepNestedParentFromChildChanges, deepNestedRowWithExistingPath } from './changesList.test-data';
14
24
  var createDiff = function (overrides) {
15
25
  if (overrides === void 0) { overrides = {}; }
16
26
  return (__assign({ level: 0, label: 'Test', attributeType: {
@@ -198,4 +208,46 @@ describe('prepareChangesList', function () {
198
208
  expect((_b = result[1].displayOptions) === null || _b === void 0 ? void 0 : _b.hasSameAttributeSiblings).toBe(false);
199
209
  });
200
210
  });
211
+ describe('fillParentPaths', function () {
212
+ it('fills parent without attributePath from descendant when value is not inner DCR change', function () {
213
+ var result = prepareChangesList(deepNestedParentFromChildChanges());
214
+ expect(result[0].attributePath).toBe('DeepNested/2ph3uHFx');
215
+ });
216
+ it('fills nested-in-nested parents without paths when only leaf has attributePath (reverse pass)', function () {
217
+ var result = prepareChangesList(addressDeepNestedThreeLevelChanges());
218
+ expect(result[0].attributePath).toBe('DeepNested/4FcgXO5o');
219
+ expect(result[1].attributePath).toBe('DeepNested/4FcgXO5o/SecondLevelNested/2v13QcOX');
220
+ });
221
+ it('fills path from attributeValue.value when inner change carries attributePath', function () {
222
+ var result = prepareChangesList(deepNestedInnerChangeRow());
223
+ expect(result[0].attributePath).toBe('DeepNested/4FcgXO5o/SecondLevelNested');
224
+ expect(result[0].refAttributeType).toBe('configuration/entityTypes/HCP/attributes/Address/attributes/DeepNested/attributes/SecondLevelNested');
225
+ expect(result[0].refObjectURI).toBe('relations/0LbuUWU');
226
+ });
227
+ it('fills parent path and ref fields via descendant when inner change path is absent', function () {
228
+ var result = prepareChangesList(addressDeepNestedRefPropagationChanges());
229
+ expect(result[0].attributePath).toBe('DeepNested/2ph3uHFx');
230
+ expect(result[0].refAttributeType).toBe('configuration/entityTypes/HCP/attributes/Address/attributes/DeepNested');
231
+ expect(result[0].refObjectURI).toBe('relations/0LbuUWU');
232
+ });
233
+ it('does not change attributePath when already set on complex row', function () {
234
+ var result = prepareChangesList(deepNestedRowWithExistingPath());
235
+ expect(result[0].attributePath).toBe('DeepNested/2ph3uHFx');
236
+ });
237
+ it('leaves reference row paths unset and still fills following nested rows', function () {
238
+ var _a, _b, _c;
239
+ var affOnly = prepareChangesList([affiliationsChangeRow]);
240
+ expect(affOnly).toHaveLength(1);
241
+ var aff = affOnly[0];
242
+ expect(aff.attributePath).toBeUndefined();
243
+ expect((_a = aff.displayOptions) === null || _a === void 0 ? void 0 : _a.showLabel).toBe(false);
244
+ expect((_b = aff.displayOptions) === null || _b === void 0 ? void 0 : _b.showAddButton).toBe(false);
245
+ expect((_c = aff.displayOptions) === null || _c === void 0 ? void 0 : _c.hasSameAttributeSiblings).toBe(false);
246
+ var combined = prepareChangesList(__spreadArray([affiliationsChangeRow], deepNestedParentFromChildChanges(), true));
247
+ expect(combined).toHaveLength(3);
248
+ expect(combined[0].attributePath).toBeUndefined();
249
+ expect(combined[1].attributePath).toBe('DeepNested/2ph3uHFx');
250
+ expect(combined[0].operation).toBe(DCROperationTypes.EDITED);
251
+ });
252
+ });
201
253
  });
@@ -1,6 +1,6 @@
1
1
  import { type DCRChanges, type EnrichedDCRChanges, type GroupedObjectsInfo, type Metadata, type SimpleAttributeValue, type TEntityType } from '@reltio/mdm-sdk';
2
- export declare const isSimpleAttributeValue: (value: unknown) => value is SimpleAttributeValue;
3
2
  import type { Diff, Title } from '../../types';
3
+ export declare const isSimpleAttributeValue: (value: unknown) => value is SimpleAttributeValue;
4
4
  export declare const isEditableChange: (change: Diff, entityInfo: GroupedObjectsInfo["entity"]) => boolean;
5
5
  export declare const addLineIdToValue: (data: DCRChanges | EnrichedDCRChanges) => EnrichedDCRChanges;
6
6
  export declare const isDiffChange: (change: Diff | Title) => change is Diff;
@@ -11,6 +11,7 @@ var __assign = (this && this.__assign) || function () {
11
11
  };
12
12
  import { clone, has, isNil } from 'ramda';
13
13
  import { DCROperationTypes, DCRTypes, isComplexAttribute, isImage, isRelationTypeUri, MetadataPermissions, checkMetadataPermission, isRoleAttrType, isTagAttrType, checkSubAttributesPermissions } from '@reltio/mdm-sdk';
14
+ import { isPrimitiveValue } from '../../helpers/common';
14
15
  export var isSimpleAttributeValue = function (value) {
15
16
  return value !== null && typeof value === 'object' && 'value' in value;
16
17
  };
@@ -24,9 +25,6 @@ export var isEditableChange = function (change, entityInfo) {
24
25
  !isRelationTypeUri(currentAttributeTypeUri);
25
26
  return !!currentAttributeTypeUri && !isExistingReferenceEntityChange && !isNil(change.newValue);
26
27
  };
27
- var isPrimitiveValue = function (value) {
28
- return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';
29
- };
30
28
  var addLineIdRecursively = function (value, basePath) {
31
29
  if (value == null)
32
30
  return value;
@@ -6,6 +6,7 @@ type Props = {
6
6
  dcr: ChangeRequest;
7
7
  task: WorkflowTaskData;
8
8
  groupedObjects: GroupedObjectsInfo[];
9
+ onReloadDcr?: () => void;
9
10
  };
10
- export declare const ReviewDCRDialog: ({ open, onClose, dcr, task, groupedObjects }: Props) => React.JSX.Element;
11
+ export declare const ReviewDCRDialog: ({ open, onClose, dcr, task, groupedObjects, onReloadDcr }: Props) => React.JSX.Element;
11
12
  export {};