@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
@@ -1,8 +1,9 @@
1
- import React from 'react';
1
+ import React, { useCallback } from 'react';
2
2
  import Dialog from '@mui/material/Dialog';
3
3
  import DialogTitle from '@mui/material/DialogTitle';
4
4
  import DialogContent from '@mui/material/DialogContent';
5
5
  import Typography from '@mui/material/Typography';
6
+ import { useContextSelector } from '@fluentui/react-context-selector';
6
7
  import { SmallIconButtonWithTooltip } from '../../../SmallIconButton';
7
8
  import CloseIcon from '@mui/icons-material/Close';
8
9
  import i18n from 'ui-i18n';
@@ -19,13 +20,22 @@ import { DCRSummaryInfo } from './components/DCRSummaryInfo/DCRSummaryInfo';
19
20
  import { ChangeRequestEditor } from '../ChangeRequestEditor';
20
21
  import { useApplyDcrChanges } from '../hooks/useApplyDcrChanges';
21
22
  import { DCRErrorsPanel } from './DCRErrorsPanel/DCRErrorsPanel';
23
+ import { AddedAttributesContext } from '../contexts/AddedAttributesContext';
24
+ import { ChangeRequestEditorContext } from '../contexts/ChangeRequestEditorContext';
22
25
  import styles from './ReviewDCRDialog.module.css';
23
26
  export var ReviewDCRDialog = function (_a) {
24
- var open = _a.open, onClose = _a.onClose, dcr = _a.dcr, task = _a.task, groupedObjects = _a.groupedObjects;
27
+ var open = _a.open, onClose = _a.onClose, dcr = _a.dcr, task = _a.task, groupedObjects = _a.groupedObjects, onReloadDcr = _a.onReloadDcr;
25
28
  var entity = useMdmEntity();
26
29
  var checkWorkflowPermission = useWorkflowCheckPermission();
27
30
  var canViewComments = checkWorkflowPermission('VIEW_PROCESS_INSTANCE_COMMENTS');
28
31
  var applyDcrChanges = useApplyDcrChanges(dcr);
32
+ var resetAddedAttributes = useContextSelector(AddedAttributesContext, function (ctx) { return ctx.resetState; });
33
+ var resetEditorState = useContextSelector(ChangeRequestEditorContext, function (ctx) { return ctx.resetState; });
34
+ var handleError = useCallback(function () {
35
+ resetAddedAttributes();
36
+ resetEditorState();
37
+ onReloadDcr === null || onReloadDcr === void 0 ? void 0 : onReloadDcr();
38
+ }, [resetAddedAttributes, resetEditorState, onReloadDcr]);
29
39
  var _b = useWorkflowActions({
30
40
  task: {
31
41
  taskId: task.taskId,
@@ -33,7 +43,8 @@ export var ReviewDCRDialog = function (_a) {
33
43
  assignee: task.assignee,
34
44
  isOpen: task.isOpen
35
45
  },
36
- beforeAction: applyDcrChanges
46
+ beforeAction: applyDcrChanges,
47
+ onError: handleError
37
48
  }), workflowActions = _b.actions, actionRequestIsInProgress = _b.actionRequestIsInProgress;
38
49
  return (React.createElement(Dialog, { open: open, onClose: onClose, fullScreen: true },
39
50
  React.createElement(DialogTitle, { className: styles.dialogTitle },
@@ -26,7 +26,7 @@ export var DataChangeRequestTaskCard = function (_a) {
26
26
  var _b = useState(false), isReviewDCRDialogOpen = _b[0], setIsReviewDCRDialogOpen = _b[1];
27
27
  var objectURIs = task.objectURIs, assignee = task.assignee;
28
28
  var dcrUri = getDCRUri(objectURIs);
29
- var _c = useChangeRequest(dcrUri), dcr = _c.dcr, groupedObjects = _c.groupedObjects;
29
+ var _c = useChangeRequest(dcrUri), dcr = _c.dcr, groupedObjects = _c.groupedObjects, reloadDcr = _c.reloadDcr;
30
30
  var handleReviewDCR = useCallback(function () {
31
31
  setIsReviewDCRDialogOpen(true);
32
32
  }, []);
@@ -44,5 +44,5 @@ export var DataChangeRequestTaskCard = function (_a) {
44
44
  React.createElement(ChangeRequestEditorProvider, null,
45
45
  React.createElement(ScrollToElementProvider, null,
46
46
  React.createElement(ScrollToAddedAttributeProvider, null,
47
- React.createElement(ReviewDCRDialog, { open: isReviewDCRDialogOpen, onClose: handleCloseReviewDCRDialog, dcr: dcr, groupedObjects: groupedObjects, task: task }))))))));
47
+ React.createElement(ReviewDCRDialog, { open: isReviewDCRDialogOpen, onClose: handleCloseReviewDCRDialog, dcr: dcr, groupedObjects: groupedObjects, task: task, onReloadDcr: reloadDcr }))))))));
48
48
  };
@@ -32,6 +32,7 @@ export type AddedAttributesContextType = {
32
32
  }) => string[];
33
33
  removeAddedAttribute: (id: string) => void;
34
34
  updateAddedAttributeRefEntity: (id: string, refEntity: ConnectionEntity) => void;
35
+ resetState: () => void;
35
36
  };
36
37
  export declare const AddedAttributesContext: import("@fluentui/react-context-selector").Context<AddedAttributesContextType>;
37
38
  export declare const AddedAttributesProvider: ({ children }: {
@@ -30,7 +30,8 @@ export var AddedAttributesContext = createContext({
30
30
  getAddedAttributes: undefined,
31
31
  addAddedAttributes: undefined,
32
32
  removeAddedAttribute: undefined,
33
- updateAddedAttributeRefEntity: undefined
33
+ updateAddedAttributeRefEntity: undefined,
34
+ resetState: undefined
34
35
  });
35
36
  var getInitialAttributeValue = function (attrType) {
36
37
  if (isComplexAttribute(attrType) || isImage(attrType))
@@ -115,11 +116,15 @@ export var AddedAttributesProvider = function (_a) {
115
116
  var updateAddedAttributeRefEntity = useCallback(function (id, refEntity) {
116
117
  setState(function (prev) { return prev.map(function (attr) { return (attr.id === id ? __assign(__assign({}, attr), { refEntity: refEntity }) : attr); }); });
117
118
  }, []);
119
+ var resetState = useCallback(function () {
120
+ setState([]);
121
+ }, []);
118
122
  var value = useMemo(function () { return ({
119
123
  getAddedAttributes: getAddedAttributes,
120
124
  addAddedAttributes: addAddedAttributes,
121
125
  removeAddedAttribute: removeAddedAttribute,
122
- updateAddedAttributeRefEntity: updateAddedAttributeRefEntity
123
- }); }, [getAddedAttributes, addAddedAttributes, removeAddedAttribute, updateAddedAttributeRefEntity]);
126
+ updateAddedAttributeRefEntity: updateAddedAttributeRefEntity,
127
+ resetState: resetState
128
+ }); }, [getAddedAttributes, addAddedAttributes, removeAddedAttribute, updateAddedAttributeRefEntity, resetState]);
124
129
  return React.createElement(AddedAttributesContext.Provider, { value: value }, children);
125
130
  };
@@ -27,6 +27,7 @@ export type ChangeRequestEditorContextType = {
27
27
  error: AttributeError;
28
28
  lineIds: string[];
29
29
  }[];
30
+ resetState: () => void;
30
31
  };
31
32
  export declare const ChangeRequestEditorContext: import("@fluentui/react-context-selector").Context<ChangeRequestEditorContextType>;
32
33
  export declare const ChangeRequestEditorProvider: ({ children }: {
@@ -14,7 +14,8 @@ export var ChangeRequestEditorContext = createContext({
14
14
  getAllChanges: undefined,
15
15
  setErrors: undefined,
16
16
  getErrorByLineId: undefined,
17
- getErrors: undefined
17
+ getErrors: undefined,
18
+ resetState: undefined
18
19
  });
19
20
  var emptyArray = [];
20
21
  var removeLineDataFromMap = function (map, lineIds) {
@@ -134,6 +135,10 @@ export var ChangeRequestEditorProvider = function (_a) {
134
135
  var getErrors = useCallback(function () {
135
136
  return errors;
136
137
  }, [errors]);
138
+ var resetState = useCallback(function () {
139
+ setLineDataMap(new Map());
140
+ setErrors([]);
141
+ }, []);
137
142
  var contextValue = {
138
143
  updateChange: updateChange,
139
144
  getLineData: getLineData,
@@ -147,7 +152,8 @@ export var ChangeRequestEditorProvider = function (_a) {
147
152
  getAllChanges: getAllChanges,
148
153
  setErrors: setErrors,
149
154
  getErrorByLineId: getErrorByLineId,
150
- getErrors: getErrors
155
+ getErrors: getErrors,
156
+ resetState: resetState
151
157
  };
152
158
  return React.createElement(ChangeRequestEditorContext.Provider, { value: contextValue }, children);
153
159
  };
@@ -54,7 +54,7 @@ var dcrAttributesFactory = function (metadata, attributeType, attributeValue, le
54
54
  switch (attributeType.type) {
55
55
  case DataTypes.TYPE_NESTED:
56
56
  case DataTypes.TYPE_IMAGE:
57
- return getNestedAttributeChange(metadata, attributeType, attributeValue, level);
57
+ return getNestedAttributeChange(metadata, attributeType, attributeValue, level, isReferenceSubAttribute);
58
58
  case DataTypes.TYPE_REFERENCE:
59
59
  return getReferenceAttributeChange(metadata, attributeType, attributeValue, level);
60
60
  default: {
@@ -74,14 +74,15 @@ var extractAddedId = function (attributeValue) {
74
74
  var innerChange = attributeValue.value;
75
75
  return ((_d = (_b = (_a = innerChange === null || innerChange === void 0 ? void 0 : innerChange.newValue) === null || _a === void 0 ? void 0 : _a.addedId) !== null && _b !== void 0 ? _b : (_c = attributeValue.newValue) === null || _c === void 0 ? void 0 : _c.addedId) !== null && _d !== void 0 ? _d : attributeValue.addedId);
76
76
  };
77
- var getNestedAttributeChange = function (metadata, attributeType, attributeValue, level) {
77
+ var getNestedAttributeChange = function (metadata, attributeType, attributeValue, level, isReferenceSubAttribute) {
78
+ if (isReferenceSubAttribute === void 0) { isReferenceSubAttribute = false; }
78
79
  var attributeTypeList = getAttributeTypeSubAttributes({}, attributeType);
79
80
  var label = getLabel((attributeType === null || attributeType === void 0 ? void 0 : attributeType.label) || (attributeType === null || attributeType === void 0 ? void 0 : attributeType.name));
80
81
  var lineIds = extractLineIds(attributeValue);
81
82
  var addedId = extractAddedId(attributeValue);
82
83
  return [
83
- __assign({ level: level, label: label, attributeType: attributeType, attributeValue: attributeValue, lineIds: lineIds }, (addedId && { addedId: addedId })),
84
- getAttributesList(metadata, attributeTypeList, attributeValue.value, level + 1)
84
+ __assign(__assign({ level: level, label: label, attributeType: attributeType, attributeValue: attributeValue, lineIds: lineIds }, (isReferenceSubAttribute && { isReferenceSubAttribute: isReferenceSubAttribute })), (addedId && { addedId: addedId })),
85
+ getAttributesList(metadata, attributeTypeList, attributeValue.value, level + 1, isReferenceSubAttribute)
85
86
  ];
86
87
  };
87
88
  var getReferenceAttributeChange = function (metadata, attributeType, attributeValue, level) {
@@ -123,6 +123,61 @@ describe('attributes helpers tests', function () {
123
123
  }
124
124
  ]);
125
125
  });
126
+ it('should mark a nested attribute and its sub-attributes inside a reference attribute as isReferenceSubAttribute=true', function () {
127
+ var metadata = getMetadata();
128
+ var objectInfo = {
129
+ isExist: true,
130
+ label: 'HCA',
131
+ secondaryLabel: '',
132
+ type: 'configuration/entityTypes/HCA',
133
+ uri: 'entities/1hRTSKE5'
134
+ };
135
+ var changes = {
136
+ Address: [
137
+ {
138
+ value: {
139
+ AdditionalAttributes: [
140
+ {
141
+ value: {
142
+ AttributeType: [
143
+ {
144
+ value: {
145
+ newValue: { value: 'TypeA' },
146
+ type: DCRTypes.INSERT_ATTRIBUTE
147
+ }
148
+ }
149
+ ]
150
+ }
151
+ }
152
+ ]
153
+ }
154
+ }
155
+ ]
156
+ };
157
+ expect(getEntityChanges(metadata, objectInfo, changes)).toEqual([
158
+ {
159
+ attributeType: metadata.entityTypes[0].attributes[4],
160
+ attributeValue: changes.Address[0],
161
+ label: 'Address',
162
+ level: 0
163
+ },
164
+ {
165
+ attributeType: metadata.relationTypes[0].attributes[0],
166
+ attributeValue: changes.Address[0].value.AdditionalAttributes[0],
167
+ label: 'Additional Attributes',
168
+ level: 1,
169
+ isReferenceSubAttribute: true
170
+ },
171
+ {
172
+ attributeType: metadata.relationTypes[0].attributes[0].attributes[0],
173
+ label: 'Attribute Type',
174
+ level: 2,
175
+ newValue: changes.Address[0].value.AdditionalAttributes[0].value.AttributeType[0].value.newValue,
176
+ operation: DCROperationTypes.ADDED,
177
+ isReferenceSubAttribute: true
178
+ }
179
+ ]);
180
+ });
126
181
  describe('getRelationsChanges behaviour', function () {
127
182
  var relationInfo = {
128
183
  endObjectLabel: '',
@@ -1,4 +1,5 @@
1
- import { AttributeType, DCRAttributeValue, DCRObjectsInfo, DCROperationTypes, DCRValue, Metadata, WorkflowDefinition, WorkflowTaskData } from '@reltio/mdm-sdk';
1
+ import { AttributeType, DCRAttributeValue, DCRObjectsInfo, DCROperationTypes, DCRValue, Metadata, PrimitiveValue, WorkflowDefinition, WorkflowTaskData } from '@reltio/mdm-sdk';
2
+ export declare const isPrimitiveValue: (value: unknown) => value is PrimitiveValue;
2
3
  export declare const getOperationType: (type: string, newPinOrIgnoreValue?: boolean) => DCROperationTypes;
3
4
  export declare const getOperationLabel: (operation: DCROperationTypes) => string;
4
5
  export declare const getAttributeDescription: (attrType: AttributeType, value: DCRAttributeValue, currentEntityUri: string, objectsInfo?: DCRObjectsInfo) => {
@@ -1,6 +1,9 @@
1
1
  import { allPass, always, equals, evolve, filter, has, identity, isNil, length, nth, pipe, prop, propEq, split, startsWith, unless, when } from 'ramda';
2
2
  import i18n from 'ui-i18n';
3
3
  import { DataTypes, DCROperationTypes, DCRTypes, EntityAttrTypes, getAttrDataTypeDefinition, getRoleLabel, isUrl } from '@reltio/mdm-sdk';
4
+ export var isPrimitiveValue = function (value) {
5
+ return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';
6
+ };
4
7
  export var getOperationType = function (type, newPinOrIgnoreValue) {
5
8
  switch (type) {
6
9
  case DCRTypes.CREATE_RELATIONSHIP:
@@ -21,6 +21,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
21
21
  import { createEntryDeleteAttribute, DCRTypes, EventType, findAttributeTypeByUri, getReferencedEntityTypeUriFromAttrType, isEmptyValue, isEntityUri, isNested, isRelationTypeUri, isRelationUri } from '@reltio/mdm-sdk';
22
22
  import { allPass, append, assocPath, concat, curry, dissocPath, equals, filter, flatten, fromPairs, groupBy, has, hasPath, isEmpty, isNil, keys, map, partition, path, pathOr, pipe, pluck, prop, propOr, toPairs, values, uniq, uniqBy, when } from 'ramda';
23
23
  import { ADDED_CHANGE_ID_PREFIX } from '../contexts/AddedAttributesContext';
24
+ import { isPrimitiveValue } from './common';
24
25
  var isAddedChange = function (changeId) { return changeId === null || changeId === void 0 ? void 0 : changeId.startsWith(ADDED_CHANGE_ID_PREFIX); };
25
26
  var normalizeReferenceValueForApi = function (val, change, metadata) {
26
27
  var attrType = findAttributeTypeByUri(metadata, change.attributeType);
@@ -101,7 +102,7 @@ export var isCreateEntityOperation = function (dcr) {
101
102
  return dcr.type === DCRTypes.CREATE_ENTITY;
102
103
  };
103
104
  var cleanValueRecursively = function (value) {
104
- if (isNil(value) || typeof value === 'string' || isEmpty(value)) {
105
+ if (isNil(value) || isPrimitiveValue(value) || isEmpty(value)) {
105
106
  return value;
106
107
  }
107
108
  var cleanedProperties = map(function (propertyValues) {
@@ -280,6 +280,53 @@ describe('dcr helpers tests', function () {
280
280
  ]
281
281
  } }));
282
282
  });
283
+ it('should preserve primitive boolean defaultValue for added attribute when no lineData exists', function () {
284
+ var changes = {
285
+ 'entities/456': [
286
+ {
287
+ id: 'added|bool1',
288
+ type: DCRTypes.INSERT_ATTRIBUTE,
289
+ attributePath: 'PrimaryAffiliationIndicator',
290
+ attributeType: 'configuration/entityTypes/HCP/attributes/PrimaryAffiliationIndicator',
291
+ newValue: { value: false }
292
+ }
293
+ ]
294
+ };
295
+ var result = buildDCRSavePlan(changes, noLineData, emptyMetadata);
296
+ expect(result).toEqual(__assign(__assign({}, emptyPlan), { insertEntityAttributes: {
297
+ 'entities/456': [
298
+ {
299
+ type: 'INSERT_ATTRIBUTE',
300
+ uri: 'entities/456/attributes/PrimaryAffiliationIndicator',
301
+ newValue: [{ value: false }]
302
+ }
303
+ ]
304
+ } }));
305
+ });
306
+ it('should send user-edited boolean value for added attribute', function () {
307
+ var changes = {
308
+ 'entities/456': [
309
+ {
310
+ id: 'added|bool2',
311
+ type: DCRTypes.INSERT_ATTRIBUTE,
312
+ attributePath: 'PrimaryAffiliationIndicator',
313
+ attributeType: 'configuration/entityTypes/HCP/attributes/PrimaryAffiliationIndicator',
314
+ newValue: { value: false }
315
+ }
316
+ ]
317
+ };
318
+ var lineData = [['456/added|bool2/newValue', { value: { value: 'true' } }]];
319
+ var result = buildDCRSavePlan(changes, function (changeId) { return (changeId === 'added|bool2' ? lineData : []); }, emptyMetadata);
320
+ expect(result).toEqual(__assign(__assign({}, emptyPlan), { insertEntityAttributes: {
321
+ 'entities/456': [
322
+ {
323
+ type: 'INSERT_ATTRIBUTE',
324
+ uri: 'entities/456/attributes/PrimaryAffiliationIndicator',
325
+ newValue: [{ value: 'true' }]
326
+ }
327
+ ]
328
+ } }));
329
+ });
283
330
  it('should preserve lookup sub-attribute with lookupCode inside nested parent', function () {
284
331
  var metadata = {
285
332
  entityTypes: [
@@ -10,7 +10,7 @@ var __assign = (this && this.__assign) || function () {
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
12
  import { both, concat, curry, difference, flatten, isNil, omit, path, pathEq, pick, pipe, propEq, propOr, reduce } from 'ramda';
13
- import { DCRTypes, EntityAttrTypes, generateTempUri, getRoleLabel, isEmptyValue } from '@reltio/mdm-sdk';
13
+ import { DCRTypes, EntityAttrTypes, generateTempUri, isEmptyValue } from '@reltio/mdm-sdk';
14
14
  import { getEntityChanges, getRelationChanges } from './attributes';
15
15
  var ATTRIBUTE_DELIMITER = '/';
16
16
  var SPECIAL_ATTRIBUTES_NAMES = [
@@ -166,7 +166,7 @@ var createEntityOrRelation = function (metadata, value) {
166
166
  newObject[EntityAttrTypes.roles.name] = [
167
167
  {
168
168
  type: DCRTypes.INSERT_ATTRIBUTE,
169
- newValue: __assign({ value: addedId ? [] : roles.map(getRoleLabel(metadata)), lineIds: lineIds && ["".concat(lineIds[0], "/").concat(EntityAttrTypes.roles.name)] }, (addedId && { addedId: addedId }))
169
+ newValue: __assign({ value: addedId ? [] : roles, lineIds: lineIds && ["".concat(lineIds[0], "/").concat(EntityAttrTypes.roles.name)] }, (addedId && { addedId: addedId }))
170
170
  }
171
171
  ];
172
172
  }
@@ -389,4 +389,38 @@ describe('mergeChanges tests', function () {
389
389
  var mergedChanges = mergeChanges(metadata, changes, objectInfo, [])[0];
390
390
  expect((_c = (_b = mergedChanges[0]) === null || _b === void 0 ? void 0 : _b.newValue) === null || _c === void 0 ? void 0 : _c.lineIds).toEqual(['line-2', 'line-4']);
391
391
  });
392
+ it('should keep role URIs in CREATE_ENTITY changes without mapping to labels', function () {
393
+ var _a;
394
+ var _b;
395
+ var metadata = getMetadata();
396
+ var roleUris = [
397
+ 'configuration/roles/DirectorofNursing',
398
+ 'configuration/roles/MedicalAssistant',
399
+ 'configuration/roles/LabDirectors'
400
+ ];
401
+ var changes = (_a = {},
402
+ _a[entityUri] = [
403
+ {
404
+ id: 'create1',
405
+ type: DCRTypes.CREATE_ENTITY,
406
+ objectType: 'configuration/entityTypes/HCA',
407
+ newValue: {
408
+ uri: entityUri,
409
+ type: 'configuration/entityTypes/HCA',
410
+ attributes: {
411
+ ActivationDate: [{ value: '2024-01-01' }]
412
+ },
413
+ roles: roleUris,
414
+ crosswalks: [{ type: 'configuration/sources/Reltio', value: '1hRTSKE5', dataProvider: true }],
415
+ analyticsAttributes: {}
416
+ }
417
+ }
418
+ ],
419
+ _a);
420
+ var entityChanges = mergeChanges(metadata, changes, objectInfo, [])[0];
421
+ var rolesDiff = entityChanges.find(function (d) { var _a; return ((_a = d.attributeType) === null || _a === void 0 ? void 0 : _a.uri) === EntityAttrTypes.roles.uri; });
422
+ expect(rolesDiff).toBeDefined();
423
+ var rolesNewValue = (_b = rolesDiff.newValue) === null || _b === void 0 ? void 0 : _b.value;
424
+ expect(rolesNewValue).toEqual(roleUris);
425
+ });
392
426
  });
@@ -261,5 +261,14 @@ export var getMetadata = function () { return ({
261
261
  }
262
262
  ]
263
263
  }
264
+ ],
265
+ roles: [
266
+ {
267
+ uri: 'configuration/roles/DirectorofNursing',
268
+ label: 'Director of Nursing',
269
+ description: 'Director of Nursing'
270
+ },
271
+ { uri: 'configuration/roles/MedicalAssistant', label: 'Medical Assistant', description: 'Medical Assistant' },
272
+ { uri: 'configuration/roles/LabDirectors', label: 'Lab Directors', description: 'Lab Directors' }
264
273
  ]
265
274
  }); };
@@ -21,6 +21,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
21
21
  import { clone } from 'ramda';
22
22
  import i18n from 'ui-i18n';
23
23
  import { findAttributeTypeByUri, DCRTypes, getRequiredAttributeTypesByTypeUri, buildError, ErrorType, getParentUri, findAttributeValuesByTypeUri, isEmptyValue, isOv, isIgnored, ErrorSource, evaluateErrorPath, isReference } from '@reltio/mdm-sdk';
24
+ import { isPrimitiveValue } from './common';
24
25
  var ALLOWED_CHANGE_TYPES = [
25
26
  DCRTypes.UPDATE_ATTRIBUTE,
26
27
  DCRTypes.INSERT_ATTRIBUTE,
@@ -256,7 +257,7 @@ var validateRequiredComplexAttributes = function (_a) {
256
257
  return [];
257
258
  }
258
259
  var valueHolder = change.type === DCRTypes.CREATE_ENTITY || change.type === DCRTypes.CREATE_RELATIONSHIP ? 'attributes' : 'value';
259
- var rootAttributeTypeUri = change.refAttributeType || change.attributeType || change.objectType;
260
+ var rootAttributeTypeUri = change.attributeType || change.refAttributeType || change.objectType;
260
261
  if (!rootAttributeTypeUri) {
261
262
  return [];
262
263
  }
@@ -286,7 +287,7 @@ var validateRequiredComplexAttributes = function (_a) {
286
287
  var errors = [];
287
288
  var visitValue = function (value, path) {
288
289
  var isRejected = checkIsChangeRejected(path.slice(0, -1).join('/'));
289
- if (typeof value === 'string') {
290
+ if (isPrimitiveValue(value)) {
290
291
  return !isRejected;
291
292
  }
292
293
  if (isRejected) {
@@ -10,5 +10,6 @@ export declare const getUserChanges: () => UserChange[];
10
10
  export declare const getUserChangesRejectSubnestedAttributes: () => UserChange[];
11
11
  export declare const getUserChangesRejectSubnestedRelationAttributes: () => UserChange[];
12
12
  export declare const getUserChangesSubnestedEmpty: () => UserChange[];
13
+ export declare const getChangesWithBooleanPrimitiveValue: () => DCRChanges;
13
14
  export declare const getUserChangesNewEntity: () => UserChange[];
14
15
  export {};
@@ -478,6 +478,38 @@ export var getUserChangesSubnestedEmpty = function () { return [
478
478
  }
479
479
  }
480
480
  ]; };
481
+ export var getChangesWithBooleanPrimitiveValue = function () { return ({
482
+ 'entities/entityUri1': [
483
+ {
484
+ id: '0SBn7Oa',
485
+ type: DCRTypes.INSERT_ATTRIBUTE,
486
+ createdTime: 1761922840650,
487
+ createdBy: 'ivan.kositsin',
488
+ objectType: 'configuration/entityTypes/HCP',
489
+ attributePath: 'Specialities',
490
+ newValue: {
491
+ value: {
492
+ SpecialityStatus: [
493
+ {
494
+ value: 'ACTIVE'
495
+ }
496
+ ],
497
+ PrimarySpecialityInd: [
498
+ {
499
+ value: false
500
+ }
501
+ ]
502
+ }
503
+ },
504
+ crosswalk: {
505
+ type: 'configuration/sources/Reltio',
506
+ value: 'entityUri1'
507
+ },
508
+ newPinOrIgnoreValue: false,
509
+ attributeType: 'configuration/entityTypes/HCP/attributes/Specialities'
510
+ }
511
+ ]
512
+ }); };
481
513
  export var getUserChangesNewEntity = function () { return [
482
514
  {
483
515
  lineId: 'entityUri2/0IEiwoe/newValue/attributes/Name/0',
@@ -1,6 +1,6 @@
1
1
  import { getValidationErrors } from './validation';
2
2
  import { getMetadata } from './metadata.test-data';
3
- import { getChanges, getEntitiesOrRelations, getUserChanges, getUserChangesRejectSubnestedAttributes, getUserChangesRejectSubnestedRelationAttributes, getUserChangesSubnestedEmpty, getUserChangesNewEntity } from './validation.test-data';
3
+ import { getChanges, getChangesWithBooleanPrimitiveValue, getEntitiesOrRelations, getUserChanges, getUserChangesRejectSubnestedAttributes, getUserChangesRejectSubnestedRelationAttributes, getUserChangesSubnestedEmpty, getUserChangesNewEntity } from './validation.test-data';
4
4
  import { findAttributeTypeByUri } from '@reltio/mdm-sdk';
5
5
  describe('getValidationErrors', function () {
6
6
  it('should validate required attributes with user changes', function () {
@@ -213,6 +213,16 @@ describe('getValidationErrors', function () {
213
213
  }
214
214
  ]);
215
215
  });
216
+ it('should not report a missing required boolean attribute when its value is primitive false', function () {
217
+ var metadata = getMetadata();
218
+ var result = getValidationErrors({
219
+ changes: getChangesWithBooleanPrimitiveValue(),
220
+ userChanges: [],
221
+ entitiesOrRelations: getEntitiesOrRelations(),
222
+ metadata: metadata
223
+ });
224
+ expect(result).toEqual([]);
225
+ });
216
226
  it('should validate required attributes in new entity', function () {
217
227
  var metadata = getMetadata();
218
228
  var result = 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
  };
@@ -25,8 +25,8 @@ export var useChangeRequest = function (dcrUri) {
25
25
  }
26
26
  return safePromise(getEntitiesByUris(entityUris, { searchOptions: 'ovOnly', defaultMaxValues: 1 }));
27
27
  }, []); // eslint-disable-line
28
- useEffect(function () {
29
- getDataChangeRequest(dcrUri)
28
+ var loadDcr = useCallback(function () {
29
+ safePromise(getDataChangeRequest(dcrUri))
30
30
  .then(function (dcr) {
31
31
  var changes = dcr.changes, objectsInfo = dcr.objectsInfo;
32
32
  var objectsWithChanges = extractObjectsFromChangeRequest(changes, objectsInfo);
@@ -37,7 +37,7 @@ export var useChangeRequest = function (dcrUri) {
37
37
  requestEntities(entityUris)
38
38
  .then(function (entities) {
39
39
  var relationsObjectsWithRequestedEntities = relationsObjectsWithoutEntity.map(function (relationsObject, index) {
40
- return __assign(__assign({}, relationsObject), { entity: entities[index] });
40
+ return __assign(__assign({}, relationsObject), { entity: __assign(__assign({}, entities[index]), { isExist: true }) });
41
41
  });
42
42
  pipe(flatten, reduce(concatEntityRelationsObjects, {}), values, setGroupedObjects)([
43
43
  entityObjectsWithRelations,
@@ -49,6 +49,9 @@ export var useChangeRequest = function (dcrUri) {
49
49
  setDcr(dcr);
50
50
  })
51
51
  .catch(showErrorMessage);
52
- }, [dcrUri, requestEntities]);
53
- return { dcr: dcr, groupedObjects: groupedObjects };
52
+ }, [dcrUri, requestEntities, safePromise]);
53
+ useEffect(function () {
54
+ loadDcr();
55
+ }, [loadDcr]);
56
+ return { dcr: dcr, groupedObjects: groupedObjects, reloadDcr: loadDcr };
54
57
  };
@@ -127,7 +127,8 @@ describe('useChangeRequest tests', function () {
127
127
  expect(getEntitiesByUris).not.toHaveBeenCalled();
128
128
  expect(result.current).toEqual({
129
129
  dcr: null,
130
- groupedObjects: []
130
+ groupedObjects: [],
131
+ reloadDcr: expect.any(Function)
131
132
  });
132
133
  });
133
134
  it('should return empty parameters if dcrUri is undefined', function () {
@@ -136,7 +137,8 @@ describe('useChangeRequest tests', function () {
136
137
  expect(getEntitiesByUris).not.toHaveBeenCalled();
137
138
  expect(result.current).toEqual({
138
139
  dcr: null,
139
- groupedObjects: []
140
+ groupedObjects: [],
141
+ reloadDcr: expect.any(Function)
140
142
  });
141
143
  });
142
144
  it('should go to error message in case of getDataChangeRequest error', function () { return __awaiter(void 0, void 0, void 0, function () {
@@ -159,7 +161,8 @@ describe('useChangeRequest tests', function () {
159
161
  });
160
162
  expect(result.current).toEqual({
161
163
  dcr: null,
162
- groupedObjects: []
164
+ groupedObjects: [],
165
+ reloadDcr: expect.any(Function)
163
166
  });
164
167
  return [2 /*return*/];
165
168
  }
@@ -198,7 +201,8 @@ describe('useChangeRequest tests', function () {
198
201
  });
199
202
  expect(result.current).toEqual({
200
203
  dcr: dcr,
201
- groupedObjects: []
204
+ groupedObjects: [],
205
+ reloadDcr: expect.any(Function)
202
206
  });
203
207
  return [2 /*return*/];
204
208
  }
@@ -234,6 +238,7 @@ describe('useChangeRequest tests', function () {
234
238
  expect(ErrorPopup.addError).not.toHaveBeenCalled();
235
239
  expect(result.current).toEqual({
236
240
  dcr: dcr,
241
+ reloadDcr: expect.any(Function),
237
242
  groupedObjects: [
238
243
  {
239
244
  entity: {
@@ -267,7 +272,8 @@ describe('useChangeRequest tests', function () {
267
272
  },
268
273
  {
269
274
  entity: {
270
- uri: 'entities/151gdPs5'
275
+ uri: 'entities/151gdPs5',
276
+ isExist: true
271
277
  },
272
278
  relations: [
273
279
  {
@@ -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
  };