@reltio/components 1.4.2253 → 1.4.2255
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/ActivenessDateControl/ActivenessDateControl.d.ts +3 -1
- package/ActivenessDateControl/ActivenessDateControl.js +2 -2
- package/ConfigureColumnsPopup/ConfigureColumnsPopup.d.ts +3 -3
- package/ConfigureColumnsPopup/ConfigureColumnsPopup.js +5 -5
- package/SelectionPopup/SelectionPopup.d.ts +4 -4
- package/SelectionPopup/SelectionPopup.js +4 -3
- package/SelectionPopup/SelectionPopup.spec.js +2 -2
- package/cjs/ActivenessDateControl/ActivenessDateControl.d.ts +3 -1
- package/cjs/ActivenessDateControl/ActivenessDateControl.js +2 -2
- package/cjs/ConfigureColumnsPopup/ConfigureColumnsPopup.d.ts +3 -3
- package/cjs/ConfigureColumnsPopup/ConfigureColumnsPopup.js +5 -5
- package/cjs/SelectionPopup/SelectionPopup.d.ts +4 -4
- package/cjs/SelectionPopup/SelectionPopup.js +4 -3
- package/cjs/SelectionPopup/SelectionPopup.spec.js +2 -2
- package/cjs/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/EntityChangesGroup.js +22 -6
- package/cjs/features/workflow/ChangeRequestEditor/helpers/addedAttributes.js +5 -2
- package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.js +29 -13
- package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.test-data.d.ts +41 -0
- package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.test-data.js +161 -0
- package/cjs/features/workflow/ChangeRequestEditor/helpers/changesList.test.js +52 -0
- package/cjs/features/workflow/ChangeRequestEditor/helpers/helpers.d.ts +1 -1
- package/cjs/features/workflow/ChangeRequestEditor/helpers/helpers.js +2 -4
- package/cjs/features/workflow/ReviewDCRDialog/ReviewDCRDialog.d.ts +2 -1
- package/cjs/features/workflow/ReviewDCRDialog/ReviewDCRDialog.js +37 -3
- package/cjs/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +2 -2
- package/cjs/features/workflow/contexts/AddedAttributesContext/index.d.ts +1 -0
- package/cjs/features/workflow/contexts/AddedAttributesContext/index.js +8 -3
- package/cjs/features/workflow/contexts/ChangeRequestEditorContext/index.d.ts +1 -0
- package/cjs/features/workflow/contexts/ChangeRequestEditorContext/index.js +8 -2
- package/cjs/features/workflow/helpers/attributes.js +5 -4
- package/cjs/features/workflow/helpers/attributes.test.js +55 -0
- package/cjs/features/workflow/helpers/common.d.ts +2 -1
- package/cjs/features/workflow/helpers/common.js +5 -1
- package/cjs/features/workflow/helpers/dcr.js +2 -1
- package/cjs/features/workflow/helpers/dcr.test.js +47 -0
- package/cjs/features/workflow/helpers/merge.js +1 -1
- package/cjs/features/workflow/helpers/merge.test.js +34 -0
- package/cjs/features/workflow/helpers/metadata.test-data.js +9 -0
- package/cjs/features/workflow/helpers/validation.js +3 -2
- package/cjs/features/workflow/helpers/validation.test-data.d.ts +1 -0
- package/cjs/features/workflow/helpers/validation.test-data.js +34 -1
- package/cjs/features/workflow/helpers/validation.test.js +10 -0
- package/cjs/features/workflow/hooks/useChangeRequest.d.ts +1 -0
- package/cjs/features/workflow/hooks/useChangeRequest.js +8 -5
- package/cjs/features/workflow/hooks/useChangeRequest.test.js +11 -5
- package/cjs/features/workflow/hooks/useWorkflowActions.d.ts +2 -1
- package/cjs/features/workflow/hooks/useWorkflowActions.js +8 -3
- package/features/workflow/ChangeRequestEditor/components/EntityChangesGroup/EntityChangesGroup.js +23 -7
- package/features/workflow/ChangeRequestEditor/helpers/addedAttributes.js +5 -2
- package/features/workflow/ChangeRequestEditor/helpers/changesList.js +29 -13
- package/features/workflow/ChangeRequestEditor/helpers/changesList.test-data.d.ts +41 -0
- package/features/workflow/ChangeRequestEditor/helpers/changesList.test-data.js +153 -0
- package/features/workflow/ChangeRequestEditor/helpers/changesList.test.js +52 -0
- package/features/workflow/ChangeRequestEditor/helpers/helpers.d.ts +1 -1
- package/features/workflow/ChangeRequestEditor/helpers/helpers.js +1 -3
- package/features/workflow/ReviewDCRDialog/ReviewDCRDialog.d.ts +2 -1
- package/features/workflow/ReviewDCRDialog/ReviewDCRDialog.js +14 -3
- package/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +2 -2
- package/features/workflow/contexts/AddedAttributesContext/index.d.ts +1 -0
- package/features/workflow/contexts/AddedAttributesContext/index.js +8 -3
- package/features/workflow/contexts/ChangeRequestEditorContext/index.d.ts +1 -0
- package/features/workflow/contexts/ChangeRequestEditorContext/index.js +8 -2
- package/features/workflow/helpers/attributes.js +5 -4
- package/features/workflow/helpers/attributes.test.js +55 -0
- package/features/workflow/helpers/common.d.ts +2 -1
- package/features/workflow/helpers/common.js +3 -0
- package/features/workflow/helpers/dcr.js +2 -1
- package/features/workflow/helpers/dcr.test.js +47 -0
- package/features/workflow/helpers/merge.js +2 -2
- package/features/workflow/helpers/merge.test.js +34 -0
- package/features/workflow/helpers/metadata.test-data.js +9 -0
- package/features/workflow/helpers/validation.js +3 -2
- package/features/workflow/helpers/validation.test-data.d.ts +1 -0
- package/features/workflow/helpers/validation.test-data.js +32 -0
- package/features/workflow/helpers/validation.test.js +11 -1
- package/features/workflow/hooks/useChangeRequest.d.ts +1 -0
- package/features/workflow/hooks/useChangeRequest.js +8 -5
- package/features/workflow/hooks/useChangeRequest.test.js +11 -5
- package/features/workflow/hooks/useWorkflowActions.d.ts +2 -1
- package/features/workflow/hooks/useWorkflowActions.js +8 -3
- package/package.json +2 -2
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.deepNestedRowWithExistingPath = exports.addressDeepNestedRefPropagationChanges = exports.addressDeepNestedThreeLevelChanges = exports.deepNestedInnerChangeRow = exports.deepNestedParentFromChildChanges = exports.affiliationsChangeRow = exports.referenceAttributeValue = exports.referenceAttributeType = void 0;
|
|
4
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
5
|
+
exports.referenceAttributeType = {
|
|
6
|
+
uri: 'configuration/entityTypes/HCP/attributes/Affiliations',
|
|
7
|
+
name: 'Affiliations',
|
|
8
|
+
label: 'HCP to HCA Affiliations',
|
|
9
|
+
type: 'Reference',
|
|
10
|
+
referencedEntityTypeURI: 'configuration/entityTypes/HCA',
|
|
11
|
+
relationshipTypeURI: 'configuration/relationTypes/HCPtoHCA'
|
|
12
|
+
};
|
|
13
|
+
exports.referenceAttributeValue = {
|
|
14
|
+
id: '0HocGCj',
|
|
15
|
+
value: {
|
|
16
|
+
RefFirstLevelNested: [
|
|
17
|
+
{
|
|
18
|
+
id: '2Cf73Q29',
|
|
19
|
+
value: {
|
|
20
|
+
FirstLevelNestedSub2: [
|
|
21
|
+
{
|
|
22
|
+
id: '2ph3wL7h',
|
|
23
|
+
value: {
|
|
24
|
+
id: '0aDhfxd',
|
|
25
|
+
refObjectURI: 'relations/0HocGCj',
|
|
26
|
+
type: mdm_sdk_1.DCRTypes.UPDATE_ATTRIBUTE,
|
|
27
|
+
objectType: 'configuration/entityTypes/HCP',
|
|
28
|
+
attributePath: 'RefFirstLevelNested/2Cf73Q29/FirstLevelNestedSub2/2ph3wL7h',
|
|
29
|
+
oldValue: { value: '555756', lineIds: ['BAliEK2/0aDhfxd/oldValue'] },
|
|
30
|
+
newValue: { value: '5557563462', lineIds: ['BAliEK2/0aDhfxd/newValue'] },
|
|
31
|
+
attributeType: 'configuration/relationTypes/HCPtoHCA/attributes/RefFirstLevelNested/attributes/FirstLevelNestedSub2',
|
|
32
|
+
refAttributeType: 'configuration/entityTypes/HCP/attributes/Affiliations/attributes/RefFirstLevelNested/attributes/FirstLevelNestedSub2',
|
|
33
|
+
lineIds: ['BAliEK2/0aDhfxd']
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
},
|
|
41
|
+
refObjectURI: 'relations/0HocGCj'
|
|
42
|
+
};
|
|
43
|
+
exports.affiliationsChangeRow = {
|
|
44
|
+
level: 0,
|
|
45
|
+
label: 'HCP to HCA Affiliations',
|
|
46
|
+
attributeType: exports.referenceAttributeType,
|
|
47
|
+
attributeValue: exports.referenceAttributeValue,
|
|
48
|
+
operation: mdm_sdk_1.DCROperationTypes.EDITED,
|
|
49
|
+
isReferenceSubAttribute: false
|
|
50
|
+
};
|
|
51
|
+
var nestedAttributeType = function (name) {
|
|
52
|
+
return ({
|
|
53
|
+
uri: "configuration/entityTypes/HCP/attributes/".concat(name),
|
|
54
|
+
name: name,
|
|
55
|
+
label: name,
|
|
56
|
+
type: 'Nested'
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
var firstLevelNestedSub2FloatType = {
|
|
60
|
+
uri: 'configuration/relationTypes/HCPtoHCA/attributes/RefFirstLevelNested/attributes/FirstLevelNestedSub2',
|
|
61
|
+
name: 'FirstLevelNestedSub2',
|
|
62
|
+
label: 'float',
|
|
63
|
+
type: 'Float'
|
|
64
|
+
};
|
|
65
|
+
var deepNestedParentFromChildChanges = function () { return [
|
|
66
|
+
{
|
|
67
|
+
level: 1,
|
|
68
|
+
label: 'DeepNested',
|
|
69
|
+
attributeType: nestedAttributeType('DeepNested'),
|
|
70
|
+
attributeValue: { id: '2ph3uHFx', value: { FirstLevelNestedSub2: [] } },
|
|
71
|
+
operation: mdm_sdk_1.DCROperationTypes.EDITED,
|
|
72
|
+
isReferenceSubAttribute: false
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
level: 2,
|
|
76
|
+
label: 'FirstLevelNestedSub2',
|
|
77
|
+
attributeType: firstLevelNestedSub2FloatType,
|
|
78
|
+
attributePath: 'DeepNested/2ph3uHFx/FirstLevelNestedSub2/2ph3uPmT',
|
|
79
|
+
operation: mdm_sdk_1.DCROperationTypes.EDITED,
|
|
80
|
+
isReferenceSubAttribute: false
|
|
81
|
+
}
|
|
82
|
+
]; };
|
|
83
|
+
exports.deepNestedParentFromChildChanges = deepNestedParentFromChildChanges;
|
|
84
|
+
var deepNestedInnerChangeRow = function () { return [
|
|
85
|
+
{
|
|
86
|
+
level: 1,
|
|
87
|
+
label: 'DeepNested',
|
|
88
|
+
attributeType: nestedAttributeType('DeepNested'),
|
|
89
|
+
attributeValue: {
|
|
90
|
+
id: '4FcgXO5o',
|
|
91
|
+
value: {
|
|
92
|
+
attributePath: 'DeepNested/4FcgXO5o/SecondLevelNested',
|
|
93
|
+
refAttributeType: 'configuration/entityTypes/HCP/attributes/Address/attributes/DeepNested/attributes/SecondLevelNested',
|
|
94
|
+
refObjectURI: 'relations/0LbuUWU'
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
operation: mdm_sdk_1.DCROperationTypes.EDITED,
|
|
98
|
+
isReferenceSubAttribute: false
|
|
99
|
+
}
|
|
100
|
+
]; };
|
|
101
|
+
exports.deepNestedInnerChangeRow = deepNestedInnerChangeRow;
|
|
102
|
+
var addressDeepNestedThreeLevelChanges = function () { return [
|
|
103
|
+
{
|
|
104
|
+
level: 1,
|
|
105
|
+
label: 'DeepNested',
|
|
106
|
+
attributeType: nestedAttributeType('DeepNested'),
|
|
107
|
+
attributeValue: { id: '4FcgXO5o', value: { SecondLevelNested: [] } },
|
|
108
|
+
operation: mdm_sdk_1.DCROperationTypes.EDITED,
|
|
109
|
+
isReferenceSubAttribute: false
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
level: 2,
|
|
113
|
+
label: 'SecondLevelNested',
|
|
114
|
+
attributeType: nestedAttributeType('SecondLevelNested'),
|
|
115
|
+
attributeValue: { id: '2v13QcOX', value: { FirstLevelNestedSubatr3: [] } },
|
|
116
|
+
operation: mdm_sdk_1.DCROperationTypes.EDITED,
|
|
117
|
+
isReferenceSubAttribute: false
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
level: 3,
|
|
121
|
+
label: 'FirstLevelNestedSubatr3',
|
|
122
|
+
attributeType: nestedAttributeType('FirstLevelNestedSubatr3'),
|
|
123
|
+
attributePath: 'DeepNested/4FcgXO5o/SecondLevelNested/2v13QcOX/FirstLevelNestedSubatr3/2v13Qgen',
|
|
124
|
+
operation: mdm_sdk_1.DCROperationTypes.EDITED,
|
|
125
|
+
isReferenceSubAttribute: false
|
|
126
|
+
}
|
|
127
|
+
]; };
|
|
128
|
+
exports.addressDeepNestedThreeLevelChanges = addressDeepNestedThreeLevelChanges;
|
|
129
|
+
var addressDeepNestedRefPropagationChanges = function () { return [
|
|
130
|
+
{
|
|
131
|
+
level: 1,
|
|
132
|
+
label: 'DeepNested',
|
|
133
|
+
attributeType: nestedAttributeType('DeepNested'),
|
|
134
|
+
attributeValue: { id: '2ph3uHFx', value: { FirstLevelNestedSub2: [] } },
|
|
135
|
+
operation: mdm_sdk_1.DCROperationTypes.EDITED,
|
|
136
|
+
isReferenceSubAttribute: false
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
level: 2,
|
|
140
|
+
label: 'FirstLevelNestedSub2',
|
|
141
|
+
attributeType: firstLevelNestedSub2FloatType,
|
|
142
|
+
attributePath: 'DeepNested/2ph3uHFx/FirstLevelNestedSub2/2ph3uPmT',
|
|
143
|
+
refAttributeType: 'configuration/entityTypes/HCP/attributes/Address/attributes/DeepNested/attributes/FirstLevelNestedSub2',
|
|
144
|
+
refObjectURI: 'relations/0LbuUWU',
|
|
145
|
+
operation: mdm_sdk_1.DCROperationTypes.EDITED,
|
|
146
|
+
isReferenceSubAttribute: false
|
|
147
|
+
}
|
|
148
|
+
]; };
|
|
149
|
+
exports.addressDeepNestedRefPropagationChanges = addressDeepNestedRefPropagationChanges;
|
|
150
|
+
var deepNestedRowWithExistingPath = function () { return [
|
|
151
|
+
{
|
|
152
|
+
level: 1,
|
|
153
|
+
label: 'DeepNested',
|
|
154
|
+
attributeType: nestedAttributeType('DeepNested'),
|
|
155
|
+
attributeValue: { id: '2ph3uHFx', value: { FirstLevelNestedSub2: [] } },
|
|
156
|
+
attributePath: 'DeepNested/2ph3uHFx',
|
|
157
|
+
operation: mdm_sdk_1.DCROperationTypes.EDITED,
|
|
158
|
+
isReferenceSubAttribute: false
|
|
159
|
+
}
|
|
160
|
+
]; };
|
|
161
|
+
exports.deepNestedRowWithExistingPath = deepNestedRowWithExistingPath;
|
|
@@ -10,9 +10,19 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
14
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
15
|
+
if (ar || !(i in from)) {
|
|
16
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
17
|
+
ar[i] = from[i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
21
|
+
};
|
|
13
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
23
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
15
24
|
var changesList_1 = require("./changesList");
|
|
25
|
+
var changesList_test_data_1 = require("./changesList.test-data");
|
|
16
26
|
var createDiff = function (overrides) {
|
|
17
27
|
if (overrides === void 0) { overrides = {}; }
|
|
18
28
|
return (__assign({ level: 0, label: 'Test', attributeType: {
|
|
@@ -200,4 +210,46 @@ describe('prepareChangesList', function () {
|
|
|
200
210
|
expect((_b = result[1].displayOptions) === null || _b === void 0 ? void 0 : _b.hasSameAttributeSiblings).toBe(false);
|
|
201
211
|
});
|
|
202
212
|
});
|
|
213
|
+
describe('fillParentPaths', function () {
|
|
214
|
+
it('fills parent without attributePath from descendant when value is not inner DCR change', function () {
|
|
215
|
+
var result = (0, changesList_1.prepareChangesList)((0, changesList_test_data_1.deepNestedParentFromChildChanges)());
|
|
216
|
+
expect(result[0].attributePath).toBe('DeepNested/2ph3uHFx');
|
|
217
|
+
});
|
|
218
|
+
it('fills nested-in-nested parents without paths when only leaf has attributePath (reverse pass)', function () {
|
|
219
|
+
var result = (0, changesList_1.prepareChangesList)((0, changesList_test_data_1.addressDeepNestedThreeLevelChanges)());
|
|
220
|
+
expect(result[0].attributePath).toBe('DeepNested/4FcgXO5o');
|
|
221
|
+
expect(result[1].attributePath).toBe('DeepNested/4FcgXO5o/SecondLevelNested/2v13QcOX');
|
|
222
|
+
});
|
|
223
|
+
it('fills path from attributeValue.value when inner change carries attributePath', function () {
|
|
224
|
+
var result = (0, changesList_1.prepareChangesList)((0, changesList_test_data_1.deepNestedInnerChangeRow)());
|
|
225
|
+
expect(result[0].attributePath).toBe('DeepNested/4FcgXO5o/SecondLevelNested');
|
|
226
|
+
expect(result[0].refAttributeType).toBe('configuration/entityTypes/HCP/attributes/Address/attributes/DeepNested/attributes/SecondLevelNested');
|
|
227
|
+
expect(result[0].refObjectURI).toBe('relations/0LbuUWU');
|
|
228
|
+
});
|
|
229
|
+
it('fills parent path and ref fields via descendant when inner change path is absent', function () {
|
|
230
|
+
var result = (0, changesList_1.prepareChangesList)((0, changesList_test_data_1.addressDeepNestedRefPropagationChanges)());
|
|
231
|
+
expect(result[0].attributePath).toBe('DeepNested/2ph3uHFx');
|
|
232
|
+
expect(result[0].refAttributeType).toBe('configuration/entityTypes/HCP/attributes/Address/attributes/DeepNested');
|
|
233
|
+
expect(result[0].refObjectURI).toBe('relations/0LbuUWU');
|
|
234
|
+
});
|
|
235
|
+
it('does not change attributePath when already set on complex row', function () {
|
|
236
|
+
var result = (0, changesList_1.prepareChangesList)((0, changesList_test_data_1.deepNestedRowWithExistingPath)());
|
|
237
|
+
expect(result[0].attributePath).toBe('DeepNested/2ph3uHFx');
|
|
238
|
+
});
|
|
239
|
+
it('leaves reference row paths unset and still fills following nested rows', function () {
|
|
240
|
+
var _a, _b, _c;
|
|
241
|
+
var affOnly = (0, changesList_1.prepareChangesList)([changesList_test_data_1.affiliationsChangeRow]);
|
|
242
|
+
expect(affOnly).toHaveLength(1);
|
|
243
|
+
var aff = affOnly[0];
|
|
244
|
+
expect(aff.attributePath).toBeUndefined();
|
|
245
|
+
expect((_a = aff.displayOptions) === null || _a === void 0 ? void 0 : _a.showLabel).toBe(false);
|
|
246
|
+
expect((_b = aff.displayOptions) === null || _b === void 0 ? void 0 : _b.showAddButton).toBe(false);
|
|
247
|
+
expect((_c = aff.displayOptions) === null || _c === void 0 ? void 0 : _c.hasSameAttributeSiblings).toBe(false);
|
|
248
|
+
var combined = (0, changesList_1.prepareChangesList)(__spreadArray([changesList_test_data_1.affiliationsChangeRow], (0, changesList_test_data_1.deepNestedParentFromChildChanges)(), true));
|
|
249
|
+
expect(combined).toHaveLength(3);
|
|
250
|
+
expect(combined[0].attributePath).toBeUndefined();
|
|
251
|
+
expect(combined[1].attributePath).toBe('DeepNested/2ph3uHFx');
|
|
252
|
+
expect(combined[0].operation).toBe(mdm_sdk_1.DCROperationTypes.EDITED);
|
|
253
|
+
});
|
|
254
|
+
});
|
|
203
255
|
});
|
|
@@ -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;
|
|
@@ -14,6 +14,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
14
14
|
exports.checkCanInitiateChangeRequest = exports.isNestedOrReferenceParent = exports.isRelationRow = exports.isDiffChange = exports.addLineIdToValue = exports.isEditableChange = exports.isSimpleAttributeValue = void 0;
|
|
15
15
|
var ramda_1 = require("ramda");
|
|
16
16
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
17
|
+
var common_1 = require("../../helpers/common");
|
|
17
18
|
var isSimpleAttributeValue = function (value) {
|
|
18
19
|
return value !== null && typeof value === 'object' && 'value' in value;
|
|
19
20
|
};
|
|
@@ -29,9 +30,6 @@ var isEditableChange = function (change, entityInfo) {
|
|
|
29
30
|
return !!currentAttributeTypeUri && !isExistingReferenceEntityChange && !(0, ramda_1.isNil)(change.newValue);
|
|
30
31
|
};
|
|
31
32
|
exports.isEditableChange = isEditableChange;
|
|
32
|
-
var isPrimitiveValue = function (value) {
|
|
33
|
-
return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';
|
|
34
|
-
};
|
|
35
33
|
var addLineIdRecursively = function (value, basePath) {
|
|
36
34
|
if (value == null)
|
|
37
35
|
return value;
|
|
@@ -76,7 +74,7 @@ var addLineIdToChangeValue = function (container, basePath, type) {
|
|
|
76
74
|
}
|
|
77
75
|
if ((0, exports.isSimpleAttributeValue)(container)) {
|
|
78
76
|
var containerValue = container.value;
|
|
79
|
-
return __assign(__assign({}, container), { lineIds: [basePath], value: isPrimitiveValue(containerValue)
|
|
77
|
+
return __assign(__assign({}, container), { lineIds: [basePath], value: (0, common_1.isPrimitiveValue)(containerValue)
|
|
80
78
|
? containerValue
|
|
81
79
|
: addLineIdRecursively(containerValue, "".concat(basePath, "/value")) });
|
|
82
80
|
}
|
|
@@ -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 {};
|
|
@@ -1,14 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
exports.ReviewDCRDialog = void 0;
|
|
7
|
-
var react_1 =
|
|
30
|
+
var react_1 = __importStar(require("react"));
|
|
8
31
|
var Dialog_1 = __importDefault(require("@mui/material/Dialog"));
|
|
9
32
|
var DialogTitle_1 = __importDefault(require("@mui/material/DialogTitle"));
|
|
10
33
|
var DialogContent_1 = __importDefault(require("@mui/material/DialogContent"));
|
|
11
34
|
var Typography_1 = __importDefault(require("@mui/material/Typography"));
|
|
35
|
+
var react_context_selector_1 = require("@fluentui/react-context-selector");
|
|
12
36
|
var SmallIconButton_1 = require("../../../SmallIconButton");
|
|
13
37
|
var Close_1 = __importDefault(require("@mui/icons-material/Close"));
|
|
14
38
|
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
@@ -25,13 +49,22 @@ var DCRSummaryInfo_1 = require("./components/DCRSummaryInfo/DCRSummaryInfo");
|
|
|
25
49
|
var ChangeRequestEditor_1 = require("../ChangeRequestEditor");
|
|
26
50
|
var useApplyDcrChanges_1 = require("../hooks/useApplyDcrChanges");
|
|
27
51
|
var DCRErrorsPanel_1 = require("./DCRErrorsPanel/DCRErrorsPanel");
|
|
52
|
+
var AddedAttributesContext_1 = require("../contexts/AddedAttributesContext");
|
|
53
|
+
var ChangeRequestEditorContext_1 = require("../contexts/ChangeRequestEditorContext");
|
|
28
54
|
var ReviewDCRDialog_module_css_1 = __importDefault(require("./ReviewDCRDialog.module.css"));
|
|
29
55
|
var ReviewDCRDialog = function (_a) {
|
|
30
|
-
var open = _a.open, onClose = _a.onClose, dcr = _a.dcr, task = _a.task, groupedObjects = _a.groupedObjects;
|
|
56
|
+
var open = _a.open, onClose = _a.onClose, dcr = _a.dcr, task = _a.task, groupedObjects = _a.groupedObjects, onReloadDcr = _a.onReloadDcr;
|
|
31
57
|
var entity = (0, MdmModuleContext_1.useMdmEntity)();
|
|
32
58
|
var checkWorkflowPermission = (0, useWorkflowCheckPermission_1.useWorkflowCheckPermission)();
|
|
33
59
|
var canViewComments = checkWorkflowPermission('VIEW_PROCESS_INSTANCE_COMMENTS');
|
|
34
60
|
var applyDcrChanges = (0, useApplyDcrChanges_1.useApplyDcrChanges)(dcr);
|
|
61
|
+
var resetAddedAttributes = (0, react_context_selector_1.useContextSelector)(AddedAttributesContext_1.AddedAttributesContext, function (ctx) { return ctx.resetState; });
|
|
62
|
+
var resetEditorState = (0, react_context_selector_1.useContextSelector)(ChangeRequestEditorContext_1.ChangeRequestEditorContext, function (ctx) { return ctx.resetState; });
|
|
63
|
+
var handleError = (0, react_1.useCallback)(function () {
|
|
64
|
+
resetAddedAttributes();
|
|
65
|
+
resetEditorState();
|
|
66
|
+
onReloadDcr === null || onReloadDcr === void 0 ? void 0 : onReloadDcr();
|
|
67
|
+
}, [resetAddedAttributes, resetEditorState, onReloadDcr]);
|
|
35
68
|
var _b = (0, useWorkflowActions_1.useWorkflowActions)({
|
|
36
69
|
task: {
|
|
37
70
|
taskId: task.taskId,
|
|
@@ -39,7 +72,8 @@ var ReviewDCRDialog = function (_a) {
|
|
|
39
72
|
assignee: task.assignee,
|
|
40
73
|
isOpen: task.isOpen
|
|
41
74
|
},
|
|
42
|
-
beforeAction: applyDcrChanges
|
|
75
|
+
beforeAction: applyDcrChanges,
|
|
76
|
+
onError: handleError
|
|
43
77
|
}), workflowActions = _b.actions, actionRequestIsInProgress = _b.actionRequestIsInProgress;
|
|
44
78
|
return (react_1.default.createElement(Dialog_1.default, { open: open, onClose: onClose, fullScreen: true },
|
|
45
79
|
react_1.default.createElement(DialogTitle_1.default, { className: ReviewDCRDialog_module_css_1.default.dialogTitle },
|
|
@@ -55,7 +55,7 @@ var DataChangeRequestTaskCard = function (_a) {
|
|
|
55
55
|
var _b = (0, react_1.useState)(false), isReviewDCRDialogOpen = _b[0], setIsReviewDCRDialogOpen = _b[1];
|
|
56
56
|
var objectURIs = task.objectURIs, assignee = task.assignee;
|
|
57
57
|
var dcrUri = (0, common_1.getDCRUri)(objectURIs);
|
|
58
|
-
var _c = (0, useChangeRequest_1.useChangeRequest)(dcrUri), dcr = _c.dcr, groupedObjects = _c.groupedObjects;
|
|
58
|
+
var _c = (0, useChangeRequest_1.useChangeRequest)(dcrUri), dcr = _c.dcr, groupedObjects = _c.groupedObjects, reloadDcr = _c.reloadDcr;
|
|
59
59
|
var handleReviewDCR = (0, react_1.useCallback)(function () {
|
|
60
60
|
setIsReviewDCRDialogOpen(true);
|
|
61
61
|
}, []);
|
|
@@ -73,6 +73,6 @@ var DataChangeRequestTaskCard = function (_a) {
|
|
|
73
73
|
react_1.default.createElement(ChangeRequestEditorContext_1.ChangeRequestEditorProvider, null,
|
|
74
74
|
react_1.default.createElement(ScrollToElementContext_1.ScrollToElementProvider, null,
|
|
75
75
|
react_1.default.createElement(ScrollToAddedAttributeContext_1.ScrollToAddedAttributeProvider, null,
|
|
76
|
-
react_1.default.createElement(ReviewDCRDialog_1.ReviewDCRDialog, { open: isReviewDCRDialogOpen, onClose: handleCloseReviewDCRDialog, dcr: dcr, groupedObjects: groupedObjects, task: task }))))))));
|
|
76
|
+
react_1.default.createElement(ReviewDCRDialog_1.ReviewDCRDialog, { open: isReviewDCRDialogOpen, onClose: handleCloseReviewDCRDialog, dcr: dcr, groupedObjects: groupedObjects, task: task, onReloadDcr: reloadDcr }))))))));
|
|
77
77
|
};
|
|
78
78
|
exports.DataChangeRequestTaskCard = DataChangeRequestTaskCard;
|
|
@@ -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 }: {
|
|
@@ -56,7 +56,8 @@ exports.AddedAttributesContext = (0, react_context_selector_1.createContext)({
|
|
|
56
56
|
getAddedAttributes: undefined,
|
|
57
57
|
addAddedAttributes: undefined,
|
|
58
58
|
removeAddedAttribute: undefined,
|
|
59
|
-
updateAddedAttributeRefEntity: undefined
|
|
59
|
+
updateAddedAttributeRefEntity: undefined,
|
|
60
|
+
resetState: undefined
|
|
60
61
|
});
|
|
61
62
|
var getInitialAttributeValue = function (attrType) {
|
|
62
63
|
if ((0, mdm_sdk_1.isComplexAttribute)(attrType) || (0, mdm_sdk_1.isImage)(attrType))
|
|
@@ -141,12 +142,16 @@ var AddedAttributesProvider = function (_a) {
|
|
|
141
142
|
var updateAddedAttributeRefEntity = (0, react_1.useCallback)(function (id, refEntity) {
|
|
142
143
|
setState(function (prev) { return prev.map(function (attr) { return (attr.id === id ? __assign(__assign({}, attr), { refEntity: refEntity }) : attr); }); });
|
|
143
144
|
}, []);
|
|
145
|
+
var resetState = (0, react_1.useCallback)(function () {
|
|
146
|
+
setState([]);
|
|
147
|
+
}, []);
|
|
144
148
|
var value = (0, react_1.useMemo)(function () { return ({
|
|
145
149
|
getAddedAttributes: getAddedAttributes,
|
|
146
150
|
addAddedAttributes: addAddedAttributes,
|
|
147
151
|
removeAddedAttribute: removeAddedAttribute,
|
|
148
|
-
updateAddedAttributeRefEntity: updateAddedAttributeRefEntity
|
|
149
|
-
|
|
152
|
+
updateAddedAttributeRefEntity: updateAddedAttributeRefEntity,
|
|
153
|
+
resetState: resetState
|
|
154
|
+
}); }, [getAddedAttributes, addAddedAttributes, removeAddedAttribute, updateAddedAttributeRefEntity, resetState]);
|
|
150
155
|
return react_1.default.createElement(exports.AddedAttributesContext.Provider, { value: value }, children);
|
|
151
156
|
};
|
|
152
157
|
exports.AddedAttributesProvider = AddedAttributesProvider;
|
|
@@ -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 }: {
|
|
@@ -40,7 +40,8 @@ exports.ChangeRequestEditorContext = (0, react_context_selector_1.createContext)
|
|
|
40
40
|
getAllChanges: undefined,
|
|
41
41
|
setErrors: undefined,
|
|
42
42
|
getErrorByLineId: undefined,
|
|
43
|
-
getErrors: undefined
|
|
43
|
+
getErrors: undefined,
|
|
44
|
+
resetState: undefined
|
|
44
45
|
});
|
|
45
46
|
var emptyArray = [];
|
|
46
47
|
var removeLineDataFromMap = function (map, lineIds) {
|
|
@@ -160,6 +161,10 @@ var ChangeRequestEditorProvider = function (_a) {
|
|
|
160
161
|
var getErrors = (0, react_1.useCallback)(function () {
|
|
161
162
|
return errors;
|
|
162
163
|
}, [errors]);
|
|
164
|
+
var resetState = (0, react_1.useCallback)(function () {
|
|
165
|
+
setLineDataMap(new Map());
|
|
166
|
+
setErrors([]);
|
|
167
|
+
}, []);
|
|
163
168
|
var contextValue = {
|
|
164
169
|
updateChange: updateChange,
|
|
165
170
|
getLineData: getLineData,
|
|
@@ -173,7 +178,8 @@ var ChangeRequestEditorProvider = function (_a) {
|
|
|
173
178
|
getAllChanges: getAllChanges,
|
|
174
179
|
setErrors: setErrors,
|
|
175
180
|
getErrorByLineId: getErrorByLineId,
|
|
176
|
-
getErrors: getErrors
|
|
181
|
+
getErrors: getErrors,
|
|
182
|
+
resetState: resetState
|
|
177
183
|
};
|
|
178
184
|
return react_1.default.createElement(exports.ChangeRequestEditorContext.Provider, { value: contextValue }, children);
|
|
179
185
|
};
|
|
@@ -57,7 +57,7 @@ var dcrAttributesFactory = function (metadata, attributeType, attributeValue, le
|
|
|
57
57
|
switch (attributeType.type) {
|
|
58
58
|
case mdm_sdk_1.DataTypes.TYPE_NESTED:
|
|
59
59
|
case mdm_sdk_1.DataTypes.TYPE_IMAGE:
|
|
60
|
-
return getNestedAttributeChange(metadata, attributeType, attributeValue, level);
|
|
60
|
+
return getNestedAttributeChange(metadata, attributeType, attributeValue, level, isReferenceSubAttribute);
|
|
61
61
|
case mdm_sdk_1.DataTypes.TYPE_REFERENCE:
|
|
62
62
|
return getReferenceAttributeChange(metadata, attributeType, attributeValue, level);
|
|
63
63
|
default: {
|
|
@@ -77,14 +77,15 @@ var extractAddedId = function (attributeValue) {
|
|
|
77
77
|
var innerChange = attributeValue.value;
|
|
78
78
|
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);
|
|
79
79
|
};
|
|
80
|
-
var getNestedAttributeChange = function (metadata, attributeType, attributeValue, level) {
|
|
80
|
+
var getNestedAttributeChange = function (metadata, attributeType, attributeValue, level, isReferenceSubAttribute) {
|
|
81
|
+
if (isReferenceSubAttribute === void 0) { isReferenceSubAttribute = false; }
|
|
81
82
|
var attributeTypeList = (0, mdm_sdk_1.getAttributeTypeSubAttributes)({}, attributeType);
|
|
82
83
|
var label = (0, mdm_sdk_1.getLabel)((attributeType === null || attributeType === void 0 ? void 0 : attributeType.label) || (attributeType === null || attributeType === void 0 ? void 0 : attributeType.name));
|
|
83
84
|
var lineIds = extractLineIds(attributeValue);
|
|
84
85
|
var addedId = extractAddedId(attributeValue);
|
|
85
86
|
return [
|
|
86
|
-
__assign({ level: level, label: label, attributeType: attributeType, attributeValue: attributeValue, lineIds: lineIds }, (addedId && { addedId: addedId })),
|
|
87
|
-
getAttributesList(metadata, attributeTypeList, attributeValue.value, level + 1)
|
|
87
|
+
__assign(__assign({ level: level, label: label, attributeType: attributeType, attributeValue: attributeValue, lineIds: lineIds }, (isReferenceSubAttribute && { isReferenceSubAttribute: isReferenceSubAttribute })), (addedId && { addedId: addedId })),
|
|
88
|
+
getAttributesList(metadata, attributeTypeList, attributeValue.value, level + 1, isReferenceSubAttribute)
|
|
88
89
|
];
|
|
89
90
|
};
|
|
90
91
|
var getReferenceAttributeChange = function (metadata, attributeType, attributeValue, level) {
|
|
@@ -125,6 +125,61 @@ describe('attributes helpers tests', function () {
|
|
|
125
125
|
}
|
|
126
126
|
]);
|
|
127
127
|
});
|
|
128
|
+
it('should mark a nested attribute and its sub-attributes inside a reference attribute as isReferenceSubAttribute=true', function () {
|
|
129
|
+
var metadata = (0, metadata_test_data_1.getMetadata)();
|
|
130
|
+
var objectInfo = {
|
|
131
|
+
isExist: true,
|
|
132
|
+
label: 'HCA',
|
|
133
|
+
secondaryLabel: '',
|
|
134
|
+
type: 'configuration/entityTypes/HCA',
|
|
135
|
+
uri: 'entities/1hRTSKE5'
|
|
136
|
+
};
|
|
137
|
+
var changes = {
|
|
138
|
+
Address: [
|
|
139
|
+
{
|
|
140
|
+
value: {
|
|
141
|
+
AdditionalAttributes: [
|
|
142
|
+
{
|
|
143
|
+
value: {
|
|
144
|
+
AttributeType: [
|
|
145
|
+
{
|
|
146
|
+
value: {
|
|
147
|
+
newValue: { value: 'TypeA' },
|
|
148
|
+
type: mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
};
|
|
159
|
+
expect((0, attributes_1.getEntityChanges)(metadata, objectInfo, changes)).toEqual([
|
|
160
|
+
{
|
|
161
|
+
attributeType: metadata.entityTypes[0].attributes[4],
|
|
162
|
+
attributeValue: changes.Address[0],
|
|
163
|
+
label: 'Address',
|
|
164
|
+
level: 0
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
attributeType: metadata.relationTypes[0].attributes[0],
|
|
168
|
+
attributeValue: changes.Address[0].value.AdditionalAttributes[0],
|
|
169
|
+
label: 'Additional Attributes',
|
|
170
|
+
level: 1,
|
|
171
|
+
isReferenceSubAttribute: true
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
attributeType: metadata.relationTypes[0].attributes[0].attributes[0],
|
|
175
|
+
label: 'Attribute Type',
|
|
176
|
+
level: 2,
|
|
177
|
+
newValue: changes.Address[0].value.AdditionalAttributes[0].value.AttributeType[0].value.newValue,
|
|
178
|
+
operation: mdm_sdk_1.DCROperationTypes.ADDED,
|
|
179
|
+
isReferenceSubAttribute: true
|
|
180
|
+
}
|
|
181
|
+
]);
|
|
182
|
+
});
|
|
128
183
|
describe('getRelationsChanges behaviour', function () {
|
|
129
184
|
var relationInfo = {
|
|
130
185
|
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) => {
|
|
@@ -3,10 +3,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.prepareRolesOrTagsValue = exports.findWorkflowDefinitionByType = exports.isRequestedTask = exports.isOpenTask = exports.getDCRId = exports.getDCRUri = exports.getSuggestionsCount = exports.getDataTypeDefinition = exports.getAttributeDescription = exports.getOperationLabel = exports.getOperationType = void 0;
|
|
6
|
+
exports.prepareRolesOrTagsValue = exports.findWorkflowDefinitionByType = exports.isRequestedTask = exports.isOpenTask = exports.getDCRId = exports.getDCRUri = exports.getSuggestionsCount = exports.getDataTypeDefinition = exports.getAttributeDescription = exports.getOperationLabel = exports.getOperationType = exports.isPrimitiveValue = void 0;
|
|
7
7
|
var ramda_1 = require("ramda");
|
|
8
8
|
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
9
9
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
10
|
+
var isPrimitiveValue = function (value) {
|
|
11
|
+
return typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean';
|
|
12
|
+
};
|
|
13
|
+
exports.isPrimitiveValue = isPrimitiveValue;
|
|
10
14
|
var getOperationType = function (type, newPinOrIgnoreValue) {
|
|
11
15
|
switch (type) {
|
|
12
16
|
case mdm_sdk_1.DCRTypes.CREATE_RELATIONSHIP:
|
|
@@ -24,6 +24,7 @@ exports.mergeExistingRolesAndTags = exports.buildDCRSavePlan = exports.isCreateE
|
|
|
24
24
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
25
25
|
var ramda_1 = require("ramda");
|
|
26
26
|
var AddedAttributesContext_1 = require("../contexts/AddedAttributesContext");
|
|
27
|
+
var common_1 = require("./common");
|
|
27
28
|
var isAddedChange = function (changeId) { return changeId === null || changeId === void 0 ? void 0 : changeId.startsWith(AddedAttributesContext_1.ADDED_CHANGE_ID_PREFIX); };
|
|
28
29
|
var normalizeReferenceValueForApi = function (val, change, metadata) {
|
|
29
30
|
var attrType = (0, mdm_sdk_1.findAttributeTypeByUri)(metadata, change.attributeType);
|
|
@@ -108,7 +109,7 @@ var isCreateEntityOperation = function (dcr) {
|
|
|
108
109
|
};
|
|
109
110
|
exports.isCreateEntityOperation = isCreateEntityOperation;
|
|
110
111
|
var cleanValueRecursively = function (value) {
|
|
111
|
-
if ((0, ramda_1.isNil)(value) ||
|
|
112
|
+
if ((0, ramda_1.isNil)(value) || (0, common_1.isPrimitiveValue)(value) || (0, ramda_1.isEmpty)(value)) {
|
|
112
113
|
return value;
|
|
113
114
|
}
|
|
114
115
|
var cleanedProperties = (0, ramda_1.map)(function (propertyValues) {
|
|
@@ -282,6 +282,53 @@ describe('dcr helpers tests', function () {
|
|
|
282
282
|
]
|
|
283
283
|
} }));
|
|
284
284
|
});
|
|
285
|
+
it('should preserve primitive boolean defaultValue for added attribute when no lineData exists', function () {
|
|
286
|
+
var changes = {
|
|
287
|
+
'entities/456': [
|
|
288
|
+
{
|
|
289
|
+
id: 'added|bool1',
|
|
290
|
+
type: mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE,
|
|
291
|
+
attributePath: 'PrimaryAffiliationIndicator',
|
|
292
|
+
attributeType: 'configuration/entityTypes/HCP/attributes/PrimaryAffiliationIndicator',
|
|
293
|
+
newValue: { value: false }
|
|
294
|
+
}
|
|
295
|
+
]
|
|
296
|
+
};
|
|
297
|
+
var result = (0, dcr_1.buildDCRSavePlan)(changes, noLineData, emptyMetadata);
|
|
298
|
+
expect(result).toEqual(__assign(__assign({}, emptyPlan), { insertEntityAttributes: {
|
|
299
|
+
'entities/456': [
|
|
300
|
+
{
|
|
301
|
+
type: 'INSERT_ATTRIBUTE',
|
|
302
|
+
uri: 'entities/456/attributes/PrimaryAffiliationIndicator',
|
|
303
|
+
newValue: [{ value: false }]
|
|
304
|
+
}
|
|
305
|
+
]
|
|
306
|
+
} }));
|
|
307
|
+
});
|
|
308
|
+
it('should send user-edited boolean value for added attribute', function () {
|
|
309
|
+
var changes = {
|
|
310
|
+
'entities/456': [
|
|
311
|
+
{
|
|
312
|
+
id: 'added|bool2',
|
|
313
|
+
type: mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE,
|
|
314
|
+
attributePath: 'PrimaryAffiliationIndicator',
|
|
315
|
+
attributeType: 'configuration/entityTypes/HCP/attributes/PrimaryAffiliationIndicator',
|
|
316
|
+
newValue: { value: false }
|
|
317
|
+
}
|
|
318
|
+
]
|
|
319
|
+
};
|
|
320
|
+
var lineData = [['456/added|bool2/newValue', { value: { value: 'true' } }]];
|
|
321
|
+
var result = (0, dcr_1.buildDCRSavePlan)(changes, function (changeId) { return (changeId === 'added|bool2' ? lineData : []); }, emptyMetadata);
|
|
322
|
+
expect(result).toEqual(__assign(__assign({}, emptyPlan), { insertEntityAttributes: {
|
|
323
|
+
'entities/456': [
|
|
324
|
+
{
|
|
325
|
+
type: 'INSERT_ATTRIBUTE',
|
|
326
|
+
uri: 'entities/456/attributes/PrimaryAffiliationIndicator',
|
|
327
|
+
newValue: [{ value: 'true' }]
|
|
328
|
+
}
|
|
329
|
+
]
|
|
330
|
+
} }));
|
|
331
|
+
});
|
|
285
332
|
it('should preserve lookup sub-attribute with lookupCode inside nested parent', function () {
|
|
286
333
|
var metadata = {
|
|
287
334
|
entityTypes: [
|
|
@@ -171,7 +171,7 @@ var createEntityOrRelation = function (metadata, value) {
|
|
|
171
171
|
newObject[mdm_sdk_1.EntityAttrTypes.roles.name] = [
|
|
172
172
|
{
|
|
173
173
|
type: mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE,
|
|
174
|
-
newValue: __assign({ value: addedId ? [] : roles
|
|
174
|
+
newValue: __assign({ value: addedId ? [] : roles, lineIds: lineIds && ["".concat(lineIds[0], "/").concat(mdm_sdk_1.EntityAttrTypes.roles.name)] }, (addedId && { addedId: addedId }))
|
|
175
175
|
}
|
|
176
176
|
];
|
|
177
177
|
}
|