@reltio/components 1.4.2244 → 1.4.2246
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/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.js +9 -6
- package/cjs/features/workflow/helpers/dcr.js +10 -1
- package/cjs/features/workflow/helpers/dcr.test.js +49 -0
- package/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.js +9 -6
- package/features/workflow/helpers/dcr.js +10 -1
- package/features/workflow/helpers/dcr.test.js +49 -0
- package/package.json +2 -2
|
@@ -43,6 +43,7 @@ var ScrollToAddedAttributeContext_1 = require("../../../contexts/ScrollToAddedAt
|
|
|
43
43
|
var ChangeItemRow_module_css_1 = __importDefault(require("./ChangeItemRow.module.css"));
|
|
44
44
|
var ChangeItemRow = function (_a) {
|
|
45
45
|
var _b;
|
|
46
|
+
var _c;
|
|
46
47
|
var change = _a.change, entityInfo = _a.entityInfo;
|
|
47
48
|
var lineIds = change.lineIds || (0, merge_1.extractLineIds)(change === null || change === void 0 ? void 0 : change.newValue);
|
|
48
49
|
var isParentLineRejected = (0, react_context_selector_1.useContextSelector)(ChangeRequestEditorContext_1.ChangeRequestEditorContext, function (context) {
|
|
@@ -54,6 +55,7 @@ var ChangeItemRow = function (_a) {
|
|
|
54
55
|
var isUpdated = (0, react_context_selector_1.useContextSelector)(ChangeRequestEditorContext_1.ChangeRequestEditorContext, function (context) {
|
|
55
56
|
return context.getIsLineUpdated(lineIds === null || lineIds === void 0 ? void 0 : lineIds[0]);
|
|
56
57
|
});
|
|
58
|
+
var lineData = (0, react_context_selector_1.useContextSelector)(ChangeRequestEditorContext_1.ChangeRequestEditorContext, function (context) { return context.getLineData(lineIds === null || lineIds === void 0 ? void 0 : lineIds[0]); });
|
|
57
59
|
var errorByLineId = (0, react_context_selector_1.useContextSelector)(ChangeRequestEditorContext_1.ChangeRequestEditorContext, function (context) {
|
|
58
60
|
return context.getErrorByLineId(lineIds === null || lineIds === void 0 ? void 0 : lineIds[0]);
|
|
59
61
|
});
|
|
@@ -64,12 +66,12 @@ var ChangeItemRow = function (_a) {
|
|
|
64
66
|
var isHighlighted = (0, ScrollToElementContext_1.isHighlightedErrorType)(scrollToElementContext === null || scrollToElementContext === void 0 ? void 0 : scrollToElementContext.type) &&
|
|
65
67
|
highlightedError &&
|
|
66
68
|
errorLineIds.includes(highlightedError.uri);
|
|
67
|
-
var
|
|
69
|
+
var _d = (0, useScrollToAttributeError_1.useScrollToAttributeError)({
|
|
68
70
|
highlightedError: isHighlighted ? scrollToElementContext : null,
|
|
69
71
|
className: ChangeItemRow_module_css_1.default.changeItemRowWithError
|
|
70
|
-
}), ref =
|
|
72
|
+
}), ref = _d.ref, errorClassName = _d.errorClassName;
|
|
71
73
|
var addedId = (0, addedAttributes_1.getAddedId)(change);
|
|
72
|
-
var
|
|
74
|
+
var _e = (0, react_1.useContext)(ScrollToAddedAttributeContext_1.ScrollToAddedAttributeContext), highlightedIds = _e.highlightedIds, scrollToFirst = _e.scrollToFirst;
|
|
73
75
|
var isHighlightedAdded = !!addedId && highlightedIds.has(addedId);
|
|
74
76
|
var scrollRef = (0, react_1.useRef)(null);
|
|
75
77
|
(0, react_1.useEffect)(function () {
|
|
@@ -84,10 +86,11 @@ var ChangeItemRow = function (_a) {
|
|
|
84
86
|
var isEditedOperation = change.operation === mdm_sdk_1.DCROperationTypes.EDITED;
|
|
85
87
|
var editable = (0, helpers_1.isEditableChange)(change, entityInfo);
|
|
86
88
|
var isAdded = (0, addedAttributes_1.isAddedAttribute)(change);
|
|
87
|
-
var
|
|
88
|
-
var
|
|
89
|
+
var currentValue = (_c = lineData === null || lineData === void 0 ? void 0 : lineData.value) !== null && _c !== void 0 ? _c : change.newValue;
|
|
90
|
+
var hasValue = !!(0, mdm_sdk_1.getAttributeValue)(currentValue);
|
|
91
|
+
var isAddedWithValue = isAdded && hasValue;
|
|
89
92
|
return (react_1.default.createElement("div", { ref: combinedRef, className: (0, classnames_1.default)(ChangeItemRow_module_css_1.default.changeItemRow, errorClassName, (_b = {},
|
|
90
|
-
_b[ChangeItemRow_module_css_1.default.changedRow] = isUpdated,
|
|
93
|
+
_b[ChangeItemRow_module_css_1.default.changedRow] = isUpdated && !isAdded,
|
|
91
94
|
_b[ChangeItemRow_module_css_1.default.addedWithValueRow] = isAddedWithValue,
|
|
92
95
|
_b[ChangeItemRow_module_css_1.default.rejectedRow] = isLineRejected || isParentLineRejected,
|
|
93
96
|
_b[ChangeItemRow_module_css_1.default.highlightedRow] = isHighlightedAdded,
|
|
@@ -88,11 +88,12 @@ exports.createEntityRelationsObjectByRelation = (0, ramda_1.curry)(function (obj
|
|
|
88
88
|
return entity ? { entity: __assign(__assign({}, entity), { uri: relation.startObjectUri }), relations: relations } : { relations: relations };
|
|
89
89
|
});
|
|
90
90
|
var concatEntityRelationsObjects = function (acc, object) {
|
|
91
|
+
var _a, _b;
|
|
91
92
|
var entity = object.entity, relations = object.relations;
|
|
92
93
|
var entityUri = entity.uri;
|
|
93
94
|
var mergedRelations = (0, ramda_1.pipe)((0, ramda_1.pathOr)([], [entityUri, 'relations']), (0, ramda_1.concat)(relations), ramda_1.uniq)(acc);
|
|
94
95
|
acc[entityUri] = {
|
|
95
|
-
entity: entity,
|
|
96
|
+
entity: (_b = (_a = acc[entityUri]) === null || _a === void 0 ? void 0 : _a.entity) !== null && _b !== void 0 ? _b : entity,
|
|
96
97
|
relations: mergedRelations
|
|
97
98
|
};
|
|
98
99
|
return acc;
|
|
@@ -260,6 +261,14 @@ var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
|
|
|
260
261
|
? newValue.toString()
|
|
261
262
|
: newValue;
|
|
262
263
|
updatedChange = (0, ramda_1.assocPath)(valuePath, processedNewValue, initialChange);
|
|
264
|
+
var lineValue = lineData.value;
|
|
265
|
+
if (lineValue && typeof lineValue === 'object' && 'lookupCode' in lineValue) {
|
|
266
|
+
var parentPath = valuePath.slice(0, -1);
|
|
267
|
+
updatedChange = (0, ramda_1.assocPath)(__spreadArray(__spreadArray([], parentPath, true), ['lookupCode'], false), lineValue.lookupCode, updatedChange);
|
|
268
|
+
if ('lookupRawValue' in lineValue) {
|
|
269
|
+
updatedChange = (0, ramda_1.assocPath)(__spreadArray(__spreadArray([], parentPath, true), ['lookupRawValue'], false), lineValue.lookupRawValue, updatedChange);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
263
272
|
}
|
|
264
273
|
}
|
|
265
274
|
if (updatedChange) {
|
|
@@ -128,6 +128,55 @@ describe('dcr helpers tests', function () {
|
|
|
128
128
|
'entities/10f6Jabc': objects[3]
|
|
129
129
|
});
|
|
130
130
|
});
|
|
131
|
+
it('concatEntityRelationsObjects preserves existing entity when duplicate uri appears', function () {
|
|
132
|
+
var originalEntity = {
|
|
133
|
+
uri: 'entities/10f6JMNk',
|
|
134
|
+
isExist: true,
|
|
135
|
+
label: 'Test Label',
|
|
136
|
+
secondaryLabel: '',
|
|
137
|
+
type: 'configuration/entityTypes/Type'
|
|
138
|
+
};
|
|
139
|
+
var fetchedEntity = {
|
|
140
|
+
uri: 'entities/10f6JMNk',
|
|
141
|
+
type: 'configuration/entityTypes/Type',
|
|
142
|
+
label: 'Test Label',
|
|
143
|
+
secondaryLabel: '',
|
|
144
|
+
roles: ['configuration/roles/Admin']
|
|
145
|
+
};
|
|
146
|
+
var objects = [
|
|
147
|
+
{
|
|
148
|
+
entity: originalEntity,
|
|
149
|
+
relations: [
|
|
150
|
+
{
|
|
151
|
+
uri: 'relations/rel1',
|
|
152
|
+
type: 'configuration/relationTypes/HasAddress',
|
|
153
|
+
startObjectUri: 'entities/10f6JMNk',
|
|
154
|
+
startObjectLabel: 'label 1',
|
|
155
|
+
endObjectUri: 'entities/abc',
|
|
156
|
+
endObjectLabel: 'label 2',
|
|
157
|
+
isExist: true
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
entity: fetchedEntity,
|
|
163
|
+
relations: [
|
|
164
|
+
{
|
|
165
|
+
uri: 'relations/rel2',
|
|
166
|
+
type: 'configuration/relationTypes/HasAddress',
|
|
167
|
+
startObjectUri: 'entities/10f6JMNk',
|
|
168
|
+
startObjectLabel: 'label 1',
|
|
169
|
+
endObjectUri: 'entities/def',
|
|
170
|
+
endObjectLabel: 'label 3',
|
|
171
|
+
isExist: true
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
];
|
|
176
|
+
var result = objects.reduce(function (acc, object) { return (0, dcr_1.concatEntityRelationsObjects)(acc, object); }, {});
|
|
177
|
+
expect(result['entities/10f6JMNk'].entity).toBe(originalEntity);
|
|
178
|
+
expect(result['entities/10f6JMNk'].relations).toEqual([objects[1].relations[0], objects[0].relations[0]]);
|
|
179
|
+
});
|
|
131
180
|
it('getEntityUriForChangeRequest behaviour', function () {
|
|
132
181
|
expect((0, dcr_1.getEntityUriForChangeRequest)('dcrUri', 'entityUri')).toBe('dcrUri/changes/entityUri');
|
|
133
182
|
});
|
|
@@ -14,6 +14,7 @@ import { ScrollToAddedAttributeContext } from '../../../contexts/ScrollToAddedAt
|
|
|
14
14
|
import styles from './ChangeItemRow.module.css';
|
|
15
15
|
export var ChangeItemRow = function (_a) {
|
|
16
16
|
var _b;
|
|
17
|
+
var _c;
|
|
17
18
|
var change = _a.change, entityInfo = _a.entityInfo;
|
|
18
19
|
var lineIds = change.lineIds || extractLineIds(change === null || change === void 0 ? void 0 : change.newValue);
|
|
19
20
|
var isParentLineRejected = useContextSelector(ChangeRequestEditorContext, function (context) {
|
|
@@ -25,6 +26,7 @@ export var ChangeItemRow = function (_a) {
|
|
|
25
26
|
var isUpdated = useContextSelector(ChangeRequestEditorContext, function (context) {
|
|
26
27
|
return context.getIsLineUpdated(lineIds === null || lineIds === void 0 ? void 0 : lineIds[0]);
|
|
27
28
|
});
|
|
29
|
+
var lineData = useContextSelector(ChangeRequestEditorContext, function (context) { return context.getLineData(lineIds === null || lineIds === void 0 ? void 0 : lineIds[0]); });
|
|
28
30
|
var errorByLineId = useContextSelector(ChangeRequestEditorContext, function (context) {
|
|
29
31
|
return context.getErrorByLineId(lineIds === null || lineIds === void 0 ? void 0 : lineIds[0]);
|
|
30
32
|
});
|
|
@@ -35,12 +37,12 @@ export var ChangeItemRow = function (_a) {
|
|
|
35
37
|
var isHighlighted = isHighlightedErrorType(scrollToElementContext === null || scrollToElementContext === void 0 ? void 0 : scrollToElementContext.type) &&
|
|
36
38
|
highlightedError &&
|
|
37
39
|
errorLineIds.includes(highlightedError.uri);
|
|
38
|
-
var
|
|
40
|
+
var _d = useScrollToAttributeError({
|
|
39
41
|
highlightedError: isHighlighted ? scrollToElementContext : null,
|
|
40
42
|
className: styles.changeItemRowWithError
|
|
41
|
-
}), ref =
|
|
43
|
+
}), ref = _d.ref, errorClassName = _d.errorClassName;
|
|
42
44
|
var addedId = getAddedId(change);
|
|
43
|
-
var
|
|
45
|
+
var _e = useContext(ScrollToAddedAttributeContext), highlightedIds = _e.highlightedIds, scrollToFirst = _e.scrollToFirst;
|
|
44
46
|
var isHighlightedAdded = !!addedId && highlightedIds.has(addedId);
|
|
45
47
|
var scrollRef = useRef(null);
|
|
46
48
|
useEffect(function () {
|
|
@@ -55,10 +57,11 @@ export var ChangeItemRow = function (_a) {
|
|
|
55
57
|
var isEditedOperation = change.operation === DCROperationTypes.EDITED;
|
|
56
58
|
var editable = isEditableChange(change, entityInfo);
|
|
57
59
|
var isAdded = isAddedAttribute(change);
|
|
58
|
-
var
|
|
59
|
-
var
|
|
60
|
+
var currentValue = (_c = lineData === null || lineData === void 0 ? void 0 : lineData.value) !== null && _c !== void 0 ? _c : change.newValue;
|
|
61
|
+
var hasValue = !!getAttributeValue(currentValue);
|
|
62
|
+
var isAddedWithValue = isAdded && hasValue;
|
|
60
63
|
return (React.createElement("div", { ref: combinedRef, className: classnames(styles.changeItemRow, errorClassName, (_b = {},
|
|
61
|
-
_b[styles.changedRow] = isUpdated,
|
|
64
|
+
_b[styles.changedRow] = isUpdated && !isAdded,
|
|
62
65
|
_b[styles.addedWithValueRow] = isAddedWithValue,
|
|
63
66
|
_b[styles.rejectedRow] = isLineRejected || isParentLineRejected,
|
|
64
67
|
_b[styles.highlightedRow] = isHighlightedAdded,
|
|
@@ -84,11 +84,12 @@ export var createEntityRelationsObjectByRelation = curry(function (objectsInfo,
|
|
|
84
84
|
return entity ? { entity: __assign(__assign({}, entity), { uri: relation.startObjectUri }), relations: relations } : { relations: relations };
|
|
85
85
|
});
|
|
86
86
|
export var concatEntityRelationsObjects = function (acc, object) {
|
|
87
|
+
var _a, _b;
|
|
87
88
|
var entity = object.entity, relations = object.relations;
|
|
88
89
|
var entityUri = entity.uri;
|
|
89
90
|
var mergedRelations = pipe(pathOr([], [entityUri, 'relations']), concat(relations), uniq)(acc);
|
|
90
91
|
acc[entityUri] = {
|
|
91
|
-
entity: entity,
|
|
92
|
+
entity: (_b = (_a = acc[entityUri]) === null || _a === void 0 ? void 0 : _a.entity) !== null && _b !== void 0 ? _b : entity,
|
|
92
93
|
relations: mergedRelations
|
|
93
94
|
};
|
|
94
95
|
return acc;
|
|
@@ -253,6 +254,14 @@ export var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
|
|
|
253
254
|
? newValue.toString()
|
|
254
255
|
: newValue;
|
|
255
256
|
updatedChange = assocPath(valuePath, processedNewValue, initialChange);
|
|
257
|
+
var lineValue = lineData.value;
|
|
258
|
+
if (lineValue && typeof lineValue === 'object' && 'lookupCode' in lineValue) {
|
|
259
|
+
var parentPath = valuePath.slice(0, -1);
|
|
260
|
+
updatedChange = assocPath(__spreadArray(__spreadArray([], parentPath, true), ['lookupCode'], false), lineValue.lookupCode, updatedChange);
|
|
261
|
+
if ('lookupRawValue' in lineValue) {
|
|
262
|
+
updatedChange = assocPath(__spreadArray(__spreadArray([], parentPath, true), ['lookupRawValue'], false), lineValue.lookupRawValue, updatedChange);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
256
265
|
}
|
|
257
266
|
}
|
|
258
267
|
if (updatedChange) {
|
|
@@ -126,6 +126,55 @@ describe('dcr helpers tests', function () {
|
|
|
126
126
|
'entities/10f6Jabc': objects[3]
|
|
127
127
|
});
|
|
128
128
|
});
|
|
129
|
+
it('concatEntityRelationsObjects preserves existing entity when duplicate uri appears', function () {
|
|
130
|
+
var originalEntity = {
|
|
131
|
+
uri: 'entities/10f6JMNk',
|
|
132
|
+
isExist: true,
|
|
133
|
+
label: 'Test Label',
|
|
134
|
+
secondaryLabel: '',
|
|
135
|
+
type: 'configuration/entityTypes/Type'
|
|
136
|
+
};
|
|
137
|
+
var fetchedEntity = {
|
|
138
|
+
uri: 'entities/10f6JMNk',
|
|
139
|
+
type: 'configuration/entityTypes/Type',
|
|
140
|
+
label: 'Test Label',
|
|
141
|
+
secondaryLabel: '',
|
|
142
|
+
roles: ['configuration/roles/Admin']
|
|
143
|
+
};
|
|
144
|
+
var objects = [
|
|
145
|
+
{
|
|
146
|
+
entity: originalEntity,
|
|
147
|
+
relations: [
|
|
148
|
+
{
|
|
149
|
+
uri: 'relations/rel1',
|
|
150
|
+
type: 'configuration/relationTypes/HasAddress',
|
|
151
|
+
startObjectUri: 'entities/10f6JMNk',
|
|
152
|
+
startObjectLabel: 'label 1',
|
|
153
|
+
endObjectUri: 'entities/abc',
|
|
154
|
+
endObjectLabel: 'label 2',
|
|
155
|
+
isExist: true
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
entity: fetchedEntity,
|
|
161
|
+
relations: [
|
|
162
|
+
{
|
|
163
|
+
uri: 'relations/rel2',
|
|
164
|
+
type: 'configuration/relationTypes/HasAddress',
|
|
165
|
+
startObjectUri: 'entities/10f6JMNk',
|
|
166
|
+
startObjectLabel: 'label 1',
|
|
167
|
+
endObjectUri: 'entities/def',
|
|
168
|
+
endObjectLabel: 'label 3',
|
|
169
|
+
isExist: true
|
|
170
|
+
}
|
|
171
|
+
]
|
|
172
|
+
}
|
|
173
|
+
];
|
|
174
|
+
var result = objects.reduce(function (acc, object) { return concatEntityRelationsObjects(acc, object); }, {});
|
|
175
|
+
expect(result['entities/10f6JMNk'].entity).toBe(originalEntity);
|
|
176
|
+
expect(result['entities/10f6JMNk'].relations).toEqual([objects[1].relations[0], objects[0].relations[0]]);
|
|
177
|
+
});
|
|
129
178
|
it('getEntityUriForChangeRequest behaviour', function () {
|
|
130
179
|
expect(getEntityUriForChangeRequest('dcrUri', 'entityUri')).toBe('dcrUri/changes/entityUri');
|
|
131
180
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2246",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE FILE",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"@fluentui/react-context-selector": "^9.1.26",
|
|
12
12
|
"@googlemaps/markerclusterer": "^2.5.3",
|
|
13
13
|
"@react-sigma/core": "3.4.0",
|
|
14
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
14
|
+
"@reltio/mdm-sdk": "^1.4.2033",
|
|
15
15
|
"@vis.gl/react-google-maps": "^1.3.0",
|
|
16
16
|
"d3-cloud": "^1.2.5",
|
|
17
17
|
"d3-geo": "^2.0.1",
|