@reltio/components 1.4.2208 → 1.4.2210
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/AttributesErrorsPanel/components/Error/Error.js +2 -2
- package/cjs/AttributesErrorsPanel/components/Error/Error.js +2 -2
- package/cjs/contexts/MdmModuleContext/context.d.ts +2 -0
- package/cjs/contexts/MdmModuleContext/hooks.d.ts +1 -0
- package/cjs/contexts/MdmModuleContext/hooks.js +3 -1
- package/cjs/contexts/MdmModuleContext/index.d.ts +1 -1
- package/cjs/contexts/MdmModuleContext/index.js +2 -1
- package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemLabel/ChangeItemLabel.js +8 -3
- package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.js +45 -4
- package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.module.css.js +2 -2
- package/cjs/features/workflow/ChangeRequestEditor/components/DCRValueEditor/DCRValueEditor.d.ts +1 -1
- package/cjs/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.d.ts +1 -1
- package/cjs/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.d.ts +1 -1
- package/cjs/features/workflow/ReviewDCRDialog/DCRErrorsPanel/DCRErrorsPanel.d.ts +2 -0
- package/cjs/features/workflow/ReviewDCRDialog/DCRErrorsPanel/DCRErrorsPanel.js +44 -0
- package/cjs/features/workflow/ReviewDCRDialog/DCRErrorsPanel/DCRErrorsPanel.module.css.js +9 -0
- package/cjs/features/workflow/ReviewDCRDialog/ReviewDCRDialog.js +2 -0
- package/cjs/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +3 -1
- package/cjs/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.spec.js +15 -7
- package/cjs/features/workflow/contexts/ChangeRequestEditorContext/index.d.ts +19 -10
- package/cjs/features/workflow/contexts/ChangeRequestEditorContext/index.js +28 -2
- package/cjs/features/workflow/helpers/dcr.d.ts +1 -1
- package/cjs/features/workflow/helpers/merge.js +3 -3
- package/cjs/features/workflow/helpers/validation.d.ts +17 -0
- package/cjs/features/workflow/helpers/validation.js +333 -0
- package/cjs/features/workflow/hooks/useApplyDcrChanges.js +34 -24
- package/cjs/features/workflow/hooks/useDCRValidation.d.ts +5 -0
- package/cjs/features/workflow/hooks/useDCRValidation.js +153 -0
- package/cjs/features/workflow/types.d.ts +8 -1
- package/cjs/hooks/useScrollToAttributeError/useScrollToAttributeError.d.ts +2 -1
- package/cjs/hooks/useScrollToAttributeError/useScrollToAttributeError.js +2 -2
- package/contexts/MdmModuleContext/context.d.ts +2 -0
- package/contexts/MdmModuleContext/hooks.d.ts +1 -0
- package/contexts/MdmModuleContext/hooks.js +1 -0
- package/contexts/MdmModuleContext/index.d.ts +1 -1
- package/contexts/MdmModuleContext/index.js +1 -1
- package/features/workflow/ChangeRequestEditor/components/ChangeItemLabel/ChangeItemLabel.js +8 -3
- package/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.js +22 -4
- package/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.module.css.js +2 -2
- package/features/workflow/ChangeRequestEditor/components/DCRValueEditor/DCRValueEditor.d.ts +1 -1
- package/features/workflow/ChangeRequestEditor/components/DCRValueEditorFactory/DCRValueEditorFactory.d.ts +1 -1
- package/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.d.ts +1 -1
- package/features/workflow/ReviewDCRDialog/DCRErrorsPanel/DCRErrorsPanel.d.ts +2 -0
- package/features/workflow/ReviewDCRDialog/DCRErrorsPanel/DCRErrorsPanel.js +14 -0
- package/features/workflow/ReviewDCRDialog/DCRErrorsPanel/DCRErrorsPanel.module.css.js +9 -0
- package/features/workflow/ReviewDCRDialog/ReviewDCRDialog.js +2 -0
- package/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +3 -1
- package/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.spec.js +16 -8
- package/features/workflow/contexts/ChangeRequestEditorContext/index.d.ts +19 -10
- package/features/workflow/contexts/ChangeRequestEditorContext/index.js +28 -2
- package/features/workflow/helpers/dcr.d.ts +1 -1
- package/features/workflow/helpers/merge.js +3 -3
- package/features/workflow/helpers/validation.d.ts +17 -0
- package/features/workflow/helpers/validation.js +326 -0
- package/features/workflow/hooks/useApplyDcrChanges.js +34 -24
- package/features/workflow/hooks/useDCRValidation.d.ts +5 -0
- package/features/workflow/hooks/useDCRValidation.js +149 -0
- package/features/workflow/types.d.ts +8 -1
- package/hooks/useScrollToAttributeError/useScrollToAttributeError.d.ts +2 -1
- package/hooks/useScrollToAttributeError/useScrollToAttributeError.js +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,326 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
|
+
if (ar || !(i in from)) {
|
|
15
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
16
|
+
ar[i] = from[i];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
20
|
+
};
|
|
21
|
+
import { clone } from 'ramda';
|
|
22
|
+
import i18n from 'ui-i18n';
|
|
23
|
+
import { findAttributeTypeByUri, DCRTypes, getRequiredAttributeTypesByTypeUri, buildError, ErrorType, getParentUri, findAttributeValuesByTypeUri, isEmptyValue, isOv, isIgnored, ErrorSource, evaluateErrorPath, isReference } from '@reltio/mdm-sdk';
|
|
24
|
+
var ALLOWED_CHANGE_TYPES = [
|
|
25
|
+
DCRTypes.UPDATE_ATTRIBUTE,
|
|
26
|
+
DCRTypes.INSERT_ATTRIBUTE,
|
|
27
|
+
DCRTypes.DELETE_ATTRIBUTE,
|
|
28
|
+
DCRTypes.IGNORE_ATTRIBUTE
|
|
29
|
+
];
|
|
30
|
+
export var getValidationErrors = function (_a) {
|
|
31
|
+
var changes = _a.changes, userChanges = _a.userChanges, entitiesOrRelations = _a.entitiesOrRelations, metadata = _a.metadata;
|
|
32
|
+
var _b = validateTopLevelAttributes({
|
|
33
|
+
changes: changes,
|
|
34
|
+
userChanges: userChanges,
|
|
35
|
+
entitiesOrRelations: entitiesOrRelations,
|
|
36
|
+
metadata: metadata
|
|
37
|
+
}), topLevelErrors = _b.errors, topRejectedChangeIds = _b.topRejectedChangeIds;
|
|
38
|
+
var complexErrors = validateComplexAttributes({ changes: changes, userChanges: userChanges, metadata: metadata, topRejectedChangeIds: topRejectedChangeIds });
|
|
39
|
+
return __spreadArray(__spreadArray([], topLevelErrors, true), complexErrors, true);
|
|
40
|
+
};
|
|
41
|
+
var validateTopLevelAttributes = function (_a) {
|
|
42
|
+
var changes = _a.changes, userChanges = _a.userChanges, entitiesOrRelations = _a.entitiesOrRelations, metadata = _a.metadata;
|
|
43
|
+
var errors = [];
|
|
44
|
+
var topRejectedChangeIds = [];
|
|
45
|
+
var _loop_1 = function (entityUri) {
|
|
46
|
+
var entityOrRelation = entitiesOrRelations[entityUri];
|
|
47
|
+
var objectChanges = changes[entityUri] || [];
|
|
48
|
+
var requiredAttributeUris = getRequiredAttributeUris(metadata, entityOrRelation.type);
|
|
49
|
+
var changesByAttributePath = {};
|
|
50
|
+
objectChanges.forEach(function (change) {
|
|
51
|
+
var _a;
|
|
52
|
+
var attributeTypeUri = change.refAttributeType || change.attributeType;
|
|
53
|
+
if (!change.type ||
|
|
54
|
+
!ALLOWED_CHANGE_TYPES.includes(change.type) ||
|
|
55
|
+
!requiredAttributeUris.includes(change.attributeType || '')) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
var foundUserChanges = getTopLevelUserChangesByChangeId(userChanges, change.id);
|
|
59
|
+
foundUserChanges.forEach(function (userChange) {
|
|
60
|
+
if (userChange.data.isRejected) {
|
|
61
|
+
topRejectedChangeIds.push(change.id);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
var hasUserChanges = foundUserChanges.length > 0;
|
|
65
|
+
var adjustedChange = adjustChangeWithUserChanges(change, foundUserChanges);
|
|
66
|
+
var currentAttributePath = getCurrentAttributePath(change.attributePath);
|
|
67
|
+
if (!changesByAttributePath[currentAttributePath]) {
|
|
68
|
+
var objectValues = findAttributeValuesByTypeUri(metadata, entityOrRelation, attributeTypeUri);
|
|
69
|
+
changesByAttributePath[currentAttributePath] = {
|
|
70
|
+
changes: [],
|
|
71
|
+
objectValues: objectValues,
|
|
72
|
+
attributeTypeUri: attributeTypeUri,
|
|
73
|
+
attributeType: findAttributeTypeByUri(metadata, attributeTypeUri),
|
|
74
|
+
parentUri: getParentUri(change.attributePath),
|
|
75
|
+
lineIds: []
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (adjustedChange) {
|
|
79
|
+
changesByAttributePath[currentAttributePath].changes.push(adjustedChange);
|
|
80
|
+
}
|
|
81
|
+
if (hasUserChanges) {
|
|
82
|
+
changesByAttributePath[currentAttributePath].hasUserChanges = true;
|
|
83
|
+
}
|
|
84
|
+
(_a = changesByAttributePath[currentAttributePath].lineIds).push.apply(_a, foundUserChanges.map(function (userChange) { return userChange.lineId; }));
|
|
85
|
+
});
|
|
86
|
+
Object.values(changesByAttributePath).forEach(function (_a) {
|
|
87
|
+
var _b;
|
|
88
|
+
var hasUserChanges = _a.hasUserChanges, objectValues = _a.objectValues, attributeChanges = _a.changes, attributeTypeUri = _a.attributeTypeUri, attributeType = _a.attributeType, parentUri = _a.parentUri, lineIds = _a.lineIds;
|
|
89
|
+
if (hasUserChanges && !hasAttributeValue(objectValues, attributeChanges, entityUri)) {
|
|
90
|
+
var valueUri = (_b = objectValues === null || objectValues === void 0 ? void 0 : objectValues[0]) === null || _b === void 0 ? void 0 : _b.uri;
|
|
91
|
+
errors.push(createRequiredError({
|
|
92
|
+
attributeType: attributeType,
|
|
93
|
+
attributeTypeUri: attributeTypeUri,
|
|
94
|
+
parentUri: parentUri,
|
|
95
|
+
lineIds: lineIds,
|
|
96
|
+
metadata: metadata,
|
|
97
|
+
entityUri: entityUri,
|
|
98
|
+
entitiesMap: entitiesOrRelations,
|
|
99
|
+
valueUri: valueUri
|
|
100
|
+
}));
|
|
101
|
+
}
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
for (var entityUri in entitiesOrRelations) {
|
|
105
|
+
_loop_1(entityUri);
|
|
106
|
+
}
|
|
107
|
+
return { errors: errors, topRejectedChangeIds: topRejectedChangeIds };
|
|
108
|
+
};
|
|
109
|
+
var validateComplexAttributes = function (_a) {
|
|
110
|
+
var changes = _a.changes, userChanges = _a.userChanges, metadata = _a.metadata, _b = _a.topRejectedChangeIds, topRejectedChangeIds = _b === void 0 ? [] : _b;
|
|
111
|
+
var errors = [];
|
|
112
|
+
var _loop_2 = function (entityUri) {
|
|
113
|
+
var objectChanges = changes[entityUri] || [];
|
|
114
|
+
objectChanges.forEach(function (change) {
|
|
115
|
+
var _a, _b, _c, _d;
|
|
116
|
+
if (topRejectedChangeIds.includes(change.id)) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
var hasComplexValue = (typeof ((_a = change.newValue) === null || _a === void 0 ? void 0 : _a.value) === 'object' &&
|
|
120
|
+
!Array.isArray((_b = change.newValue) === null || _b === void 0 ? void 0 : _b.value)) ||
|
|
121
|
+
(typeof ((_c = change.oldValue) === null || _c === void 0 ? void 0 : _c.value) === 'object' &&
|
|
122
|
+
!Array.isArray((_d = change.oldValue) === null || _d === void 0 ? void 0 : _d.value));
|
|
123
|
+
var isCreateType = change.type === DCRTypes.CREATE_ENTITY || change.type === DCRTypes.CREATE_RELATIONSHIP;
|
|
124
|
+
if (!hasComplexValue && !isCreateType) {
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
var foundUserChanges = getUserChangesByChangeId(userChanges, change.id);
|
|
128
|
+
var complexErrors = validateRequiredComplexAttributes({
|
|
129
|
+
metadata: metadata,
|
|
130
|
+
change: change,
|
|
131
|
+
userChanges: foundUserChanges,
|
|
132
|
+
entityUri: entityUri
|
|
133
|
+
});
|
|
134
|
+
errors.push.apply(errors, complexErrors);
|
|
135
|
+
});
|
|
136
|
+
};
|
|
137
|
+
for (var entityUri in changes) {
|
|
138
|
+
_loop_2(entityUri);
|
|
139
|
+
}
|
|
140
|
+
return errors;
|
|
141
|
+
};
|
|
142
|
+
var getTopLevelUserChangesByChangeId = function (userChanges, changeId) {
|
|
143
|
+
return getUserChangesByChangeId(userChanges, changeId).filter(function (userChange) { return userChange.lineId.split('/').length === 3; });
|
|
144
|
+
};
|
|
145
|
+
var getUserChangesByChangeId = function (userChanges, changeId) {
|
|
146
|
+
return userChanges.filter(function (userChange) { return userChange.lineId.split('/')[1] === changeId; });
|
|
147
|
+
};
|
|
148
|
+
var getIsChangeRejected = function (userChanges, changeType) {
|
|
149
|
+
if (userChanges.length === 0)
|
|
150
|
+
return false;
|
|
151
|
+
var isInsertType = changeType === DCRTypes.INSERT_ATTRIBUTE;
|
|
152
|
+
return userChanges.some(function (userChange) { var _a; return userChange.data.isRejected || (isInsertType && isEmptyValue((_a = userChange.data.value) === null || _a === void 0 ? void 0 : _a.value)); });
|
|
153
|
+
};
|
|
154
|
+
var adjustChangeWithUserChanges = function (change, userChanges) {
|
|
155
|
+
var _a;
|
|
156
|
+
if (getIsChangeRejected(userChanges, change.type)) {
|
|
157
|
+
return null;
|
|
158
|
+
}
|
|
159
|
+
if (change.type === DCRTypes.UPDATE_ATTRIBUTE && userChanges.length > 0) {
|
|
160
|
+
if (isEmptyValue((_a = userChanges[0].data.value) === null || _a === void 0 ? void 0 : _a.value)) {
|
|
161
|
+
return __assign(__assign({}, change), { type: DCRTypes.DELETE_ATTRIBUTE });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return change;
|
|
165
|
+
};
|
|
166
|
+
var getCurrentAttributePath = function (attributePath) {
|
|
167
|
+
var parts = attributePath.split('/');
|
|
168
|
+
return parts.slice(0, parts.length % 2 === 0 ? parts.length - 1 : parts.length).join('/');
|
|
169
|
+
};
|
|
170
|
+
var getEntityValueUri = function (entityOrRelationTypeUri, change) {
|
|
171
|
+
if (change.refObjectURI) {
|
|
172
|
+
var relationId = change.refObjectURI.split('/').pop();
|
|
173
|
+
var refAttributeTypeParts = change.refAttributeType.split('/attributes/');
|
|
174
|
+
return "".concat(entityOrRelationTypeUri, "/attributes/").concat(refAttributeTypeParts[1], "/").concat(relationId, "/").concat(change.attributePath);
|
|
175
|
+
}
|
|
176
|
+
return "".concat(entityOrRelationTypeUri, "/attributes/").concat(change.attributePath);
|
|
177
|
+
};
|
|
178
|
+
var hasAttributeValue = function (objectValues, changes, entityUri) {
|
|
179
|
+
var values = clone(objectValues);
|
|
180
|
+
var _loop_3 = function (change) {
|
|
181
|
+
if (change.type === DCRTypes.UPDATE_ATTRIBUTE || change.type === DCRTypes.INSERT_ATTRIBUTE) {
|
|
182
|
+
return { value: true };
|
|
183
|
+
}
|
|
184
|
+
var valueUri = getEntityValueUri(entityUri, change);
|
|
185
|
+
var valueIndex = values.findIndex(function (value) { return value.uri === valueUri; });
|
|
186
|
+
if (change.type === DCRTypes.DELETE_ATTRIBUTE) {
|
|
187
|
+
if (valueIndex !== -1) {
|
|
188
|
+
values.splice(valueIndex, 1);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
else if (change.type === DCRTypes.IGNORE_ATTRIBUTE && valueIndex !== -1) {
|
|
192
|
+
values[valueIndex].ignored = change.newPinOrIgnoreValue;
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
for (var _i = 0, changes_1 = changes; _i < changes_1.length; _i++) {
|
|
196
|
+
var change = changes_1[_i];
|
|
197
|
+
var state_1 = _loop_3(change);
|
|
198
|
+
if (typeof state_1 === "object")
|
|
199
|
+
return state_1.value;
|
|
200
|
+
}
|
|
201
|
+
return values.filter(isOv).filter(function (value) { return !isIgnored(value); }).length > 0;
|
|
202
|
+
};
|
|
203
|
+
var getEntityTypeUriFromAttributeUri = function (attributeUri) {
|
|
204
|
+
return attributeUri.split('/').slice(0, 3).join('/');
|
|
205
|
+
};
|
|
206
|
+
var getAttributeTypeUriFromLineId = function (attributeTypeUri, lineId) {
|
|
207
|
+
var EXCLUDED_PARTS = new Set(['value', 'newValue', 'oldValue', 'attributes']);
|
|
208
|
+
var lineParts = lineId
|
|
209
|
+
.split('/')
|
|
210
|
+
.slice(2)
|
|
211
|
+
.filter(function (part) {
|
|
212
|
+
if (!isNaN(Number(part)))
|
|
213
|
+
return false;
|
|
214
|
+
return !EXCLUDED_PARTS.has(part);
|
|
215
|
+
});
|
|
216
|
+
return __spreadArray([attributeTypeUri], lineParts, true).join('/attributes/');
|
|
217
|
+
};
|
|
218
|
+
var getEntityTypeUriFromChange = function (change) {
|
|
219
|
+
if (change.type === DCRTypes.CREATE_ENTITY || change.type === DCRTypes.CREATE_RELATIONSHIP) {
|
|
220
|
+
return change.objectType || '';
|
|
221
|
+
}
|
|
222
|
+
return getEntityTypeUriFromAttributeUri(change.attributeType || change.objectType || '');
|
|
223
|
+
};
|
|
224
|
+
var getRequiredAttributeUris = function (metadata, typeUri) {
|
|
225
|
+
var requiredAttrTypes = getRequiredAttributeTypesByTypeUri(metadata, typeUri, true) || [];
|
|
226
|
+
return requiredAttrTypes.map(function (attr) { return attr.uri; });
|
|
227
|
+
};
|
|
228
|
+
var createRequiredError = function (_a) {
|
|
229
|
+
var attributeType = _a.attributeType, attributeTypeUri = _a.attributeTypeUri, parentUri = _a.parentUri, lineIds = _a.lineIds, metadata = _a.metadata, entityUri = _a.entityUri, entitiesMap = _a.entitiesMap, valueUri = _a.valueUri;
|
|
230
|
+
var error = buildError({
|
|
231
|
+
type: ErrorType.missed,
|
|
232
|
+
attributeType: attributeType,
|
|
233
|
+
attributeTypeUri: attributeTypeUri,
|
|
234
|
+
parentUri: parentUri,
|
|
235
|
+
message: i18n.text('Attribute is required'),
|
|
236
|
+
source: ErrorSource.local,
|
|
237
|
+
alwaysShow: true,
|
|
238
|
+
uri: lineIds[0]
|
|
239
|
+
});
|
|
240
|
+
var path = [];
|
|
241
|
+
if ((entitiesMap === null || entitiesMap === void 0 ? void 0 : entitiesMap[entityUri]) && valueUri) {
|
|
242
|
+
path = evaluateErrorPath({
|
|
243
|
+
entityUri: entityUri,
|
|
244
|
+
metadata: metadata,
|
|
245
|
+
entitiesMap: entitiesMap
|
|
246
|
+
}, valueUri);
|
|
247
|
+
}
|
|
248
|
+
return {
|
|
249
|
+
error: __assign(__assign({}, error), { path: path }),
|
|
250
|
+
lineIds: lineIds
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
var validateRequiredComplexAttributes = function (_a) {
|
|
254
|
+
var _b;
|
|
255
|
+
var metadata = _a.metadata, change = _a.change, userChanges = _a.userChanges, entityUri = _a.entityUri;
|
|
256
|
+
if (userChanges.length === 0 || change.type === DCRTypes.DELETE_ATTRIBUTE) {
|
|
257
|
+
return [];
|
|
258
|
+
}
|
|
259
|
+
var valueHolder = change.type === DCRTypes.CREATE_ENTITY || change.type === DCRTypes.CREATE_RELATIONSHIP ? 'attributes' : 'value';
|
|
260
|
+
var rootAttributeTypeUri = change.refAttributeType || change.attributeType || change.objectType;
|
|
261
|
+
var attributeType = findAttributeTypeByUri(metadata, rootAttributeTypeUri);
|
|
262
|
+
var isReferenceType = isReference(attributeType);
|
|
263
|
+
var entityTypeUri = isReferenceType ? attributeType.relationshipTypeURI : getEntityTypeUriFromChange(change);
|
|
264
|
+
var requiredAttributeUris = getRequiredAttributeUris(metadata, entityTypeUri);
|
|
265
|
+
var calculateLineIdFromPath = function (path) {
|
|
266
|
+
if (path === void 0) { path = ''; }
|
|
267
|
+
var entityId = entityUri.split('/').pop() || '';
|
|
268
|
+
return "".concat(entityId, "/").concat(change.id, "/newValue").concat(path ? "/".concat(path) : '');
|
|
269
|
+
};
|
|
270
|
+
var checkIsChangeRejected = function (path) {
|
|
271
|
+
var _a, _b, _c;
|
|
272
|
+
var searchLineId = calculateLineIdFromPath(path);
|
|
273
|
+
var lineUserChanges = userChanges.find(function (userChange) { return userChange.lineId === searchLineId; });
|
|
274
|
+
return (((_a = lineUserChanges === null || lineUserChanges === void 0 ? void 0 : lineUserChanges.data) === null || _a === void 0 ? void 0 : _a.isRejected) || (lineUserChanges && isEmptyValue((_c = (_b = lineUserChanges === null || lineUserChanges === void 0 ? void 0 : lineUserChanges.data) === null || _b === void 0 ? void 0 : _b.value) === null || _c === void 0 ? void 0 : _c.value)));
|
|
275
|
+
};
|
|
276
|
+
var collectErrors = function (attributes) {
|
|
277
|
+
var errors = [];
|
|
278
|
+
var visitValue = function (value, path) {
|
|
279
|
+
var isRejected = checkIsChangeRejected(path.slice(0, -1).join('/'));
|
|
280
|
+
if (typeof value === 'string') {
|
|
281
|
+
return !isRejected;
|
|
282
|
+
}
|
|
283
|
+
if (isRejected) {
|
|
284
|
+
return false;
|
|
285
|
+
}
|
|
286
|
+
var anyFieldHasValue = false;
|
|
287
|
+
Object.entries(value).forEach(function (_a) {
|
|
288
|
+
var fieldName = _a[0], subAttributes = _a[1];
|
|
289
|
+
var anyChildHasValue = false;
|
|
290
|
+
var attributePath = __spreadArray(__spreadArray([], path, true), [fieldName], false);
|
|
291
|
+
var rejectedLineIds = [];
|
|
292
|
+
subAttributes.forEach(function (subAttribute, index) {
|
|
293
|
+
var childPath = __spreadArray(__spreadArray([], attributePath, true), [index, 'value'], false);
|
|
294
|
+
var childHasValue = visitValue(subAttribute.value, childPath);
|
|
295
|
+
if (!childHasValue) {
|
|
296
|
+
rejectedLineIds.push(calculateLineIdFromPath(childPath.slice(0, -1).join('/')));
|
|
297
|
+
}
|
|
298
|
+
anyChildHasValue = anyChildHasValue || childHasValue;
|
|
299
|
+
});
|
|
300
|
+
anyFieldHasValue = anyFieldHasValue || anyChildHasValue;
|
|
301
|
+
if (!anyChildHasValue) {
|
|
302
|
+
var attributeTypeUri = getAttributeTypeUriFromLineId(isReferenceType ? entityTypeUri : rootAttributeTypeUri, rejectedLineIds[0]);
|
|
303
|
+
var isRequired = requiredAttributeUris.includes(attributeTypeUri);
|
|
304
|
+
if (isRequired) {
|
|
305
|
+
errors.push(createRequiredError({
|
|
306
|
+
attributeType: findAttributeTypeByUri(metadata, attributeTypeUri),
|
|
307
|
+
attributeTypeUri: attributeTypeUri,
|
|
308
|
+
lineIds: rejectedLineIds
|
|
309
|
+
}));
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
return anyFieldHasValue;
|
|
314
|
+
};
|
|
315
|
+
var hasValue = visitValue(attributes, [valueHolder]);
|
|
316
|
+
if (!hasValue && attributeType.required) {
|
|
317
|
+
errors.push(createRequiredError({
|
|
318
|
+
attributeType: attributeType,
|
|
319
|
+
attributeTypeUri: attributeType.uri,
|
|
320
|
+
lineIds: [calculateLineIdFromPath()]
|
|
321
|
+
}));
|
|
322
|
+
}
|
|
323
|
+
return errors;
|
|
324
|
+
};
|
|
325
|
+
return collectErrors((_b = change.newValue) === null || _b === void 0 ? void 0 : _b[valueHolder]);
|
|
326
|
+
};
|
|
@@ -41,30 +41,40 @@ import { isEmpty } from 'ramda';
|
|
|
41
41
|
import { useMdmMetadata } from '../../../contexts/MdmModuleContext';
|
|
42
42
|
import { ChangeRequestEditorContext } from '../contexts/ChangeRequestEditorContext';
|
|
43
43
|
import { buildDCRSavePlan } from '../helpers/dcr';
|
|
44
|
+
import { useDCRValidation } from './useDCRValidation';
|
|
44
45
|
var withChangeRequestId = function (dcrUri) { return function (url) {
|
|
45
46
|
return url + (url.includes('?') ? '&' : '?') + "changeRequestId=".concat(encodeURIComponent(dcrUri.split('/')[1]));
|
|
46
47
|
}; };
|
|
47
48
|
export var useApplyDcrChanges = function (dcr) {
|
|
48
49
|
var getLinesByChangeId = useContextSelector(ChangeRequestEditorContext, function (context) { return context.getLinesByChangeId; });
|
|
49
50
|
var metadata = useMdmMetadata();
|
|
51
|
+
var getErrors = useDCRValidation(dcr);
|
|
50
52
|
var applyDcrChanges = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
51
|
-
var _a, rejectedChangeIds, updatedChanges, deleteEntityAttributes, deleteRelationAttributes, deleteChangeResults, deleteEntityAttributesResults, deleteRelationAttributesResults, deleteChangeFailures, error_1, deleteEntityAttributesFailures, deleteRelationAttributesFailures;
|
|
53
|
+
var errors, _a, rejectedChangeIds, updatedChanges, deleteEntityAttributes, deleteRelationAttributes, deleteChangeResults, deleteEntityAttributesResults, deleteRelationAttributesResults, deleteChangeFailures, error_1, deleteEntityAttributesFailures, deleteRelationAttributesFailures;
|
|
52
54
|
return __generator(this, function (_b) {
|
|
53
55
|
switch (_b.label) {
|
|
54
56
|
case 0:
|
|
55
|
-
if (!(dcr === null || dcr === void 0 ? void 0 : dcr.changes)) return [3 /*break*/,
|
|
57
|
+
if (!(dcr === null || dcr === void 0 ? void 0 : dcr.changes)) return [3 /*break*/, 12];
|
|
58
|
+
return [4 /*yield*/, getErrors()];
|
|
59
|
+
case 1:
|
|
60
|
+
errors = _b.sent();
|
|
61
|
+
if (errors.length > 0) {
|
|
62
|
+
return [2 /*return*/, {
|
|
63
|
+
proceed: false
|
|
64
|
+
}];
|
|
65
|
+
}
|
|
56
66
|
_a = buildDCRSavePlan(dcr.changes, getLinesByChangeId, metadata), rejectedChangeIds = _a.rejectedChangeIds, updatedChanges = _a.updatedChanges, deleteEntityAttributes = _a.deleteEntityAttributes, deleteRelationAttributes = _a.deleteRelationAttributes;
|
|
57
67
|
deleteChangeResults = [];
|
|
58
68
|
deleteEntityAttributesResults = [];
|
|
59
69
|
deleteRelationAttributesResults = [];
|
|
60
|
-
if (!(rejectedChangeIds.length > 0)) return [3 /*break*/,
|
|
70
|
+
if (!(rejectedChangeIds.length > 0)) return [3 /*break*/, 3];
|
|
61
71
|
return [4 /*yield*/, promiseAllSettled(rejectedChangeIds.map(function (changeId) {
|
|
62
72
|
return deleteChangeRequestItem({ dcrUri: dcr.uri, changeItemId: changeId });
|
|
63
73
|
}))];
|
|
64
|
-
case 1:
|
|
65
|
-
deleteChangeResults = _b.sent();
|
|
66
|
-
_b.label = 2;
|
|
67
74
|
case 2:
|
|
75
|
+
deleteChangeResults = _b.sent();
|
|
76
|
+
_b.label = 3;
|
|
77
|
+
case 3:
|
|
68
78
|
deleteChangeFailures = deleteChangeResults.filter(function (result) { return result.status === 'rejected'; });
|
|
69
79
|
if (deleteChangeFailures.length) {
|
|
70
80
|
return [2 /*return*/, {
|
|
@@ -72,22 +82,22 @@ export var useApplyDcrChanges = function (dcr) {
|
|
|
72
82
|
error: new Error("Failed to delete DCR change(s): ".concat(deleteChangeFailures.map(function (result) { return result.reason; }).join(', ')))
|
|
73
83
|
}];
|
|
74
84
|
}
|
|
75
|
-
if (!!isEmpty(updatedChanges)) return [3 /*break*/,
|
|
76
|
-
_b.label =
|
|
77
|
-
case 3:
|
|
78
|
-
_b.trys.push([3, 5, , 6]);
|
|
79
|
-
return [4 /*yield*/, updateChangeRequest({ dcrUri: dcr.uri, payload: updatedChanges })];
|
|
85
|
+
if (!!isEmpty(updatedChanges)) return [3 /*break*/, 7];
|
|
86
|
+
_b.label = 4;
|
|
80
87
|
case 4:
|
|
81
|
-
_b.
|
|
82
|
-
return [
|
|
88
|
+
_b.trys.push([4, 6, , 7]);
|
|
89
|
+
return [4 /*yield*/, updateChangeRequest({ dcrUri: dcr.uri, payload: updatedChanges })];
|
|
83
90
|
case 5:
|
|
91
|
+
_b.sent();
|
|
92
|
+
return [3 /*break*/, 7];
|
|
93
|
+
case 6:
|
|
84
94
|
error_1 = _b.sent();
|
|
85
95
|
return [2 /*return*/, {
|
|
86
96
|
proceed: false,
|
|
87
97
|
error: error_1
|
|
88
98
|
}];
|
|
89
|
-
case
|
|
90
|
-
if (!!isEmpty(deleteEntityAttributes)) return [3 /*break*/,
|
|
99
|
+
case 7:
|
|
100
|
+
if (!!isEmpty(deleteEntityAttributes)) return [3 /*break*/, 9];
|
|
91
101
|
return [4 /*yield*/, promiseAllSettled(Object.entries(deleteEntityAttributes).map(function (_a) {
|
|
92
102
|
var entityUri = _a[0], diff = _a[1];
|
|
93
103
|
return entityCumulativeUpdate({
|
|
@@ -96,10 +106,10 @@ export var useApplyDcrChanges = function (dcr) {
|
|
|
96
106
|
uriPreprocessor: withChangeRequestId(dcr.uri)
|
|
97
107
|
});
|
|
98
108
|
}))];
|
|
99
|
-
case 7:
|
|
100
|
-
deleteEntityAttributesResults = _b.sent();
|
|
101
|
-
_b.label = 8;
|
|
102
109
|
case 8:
|
|
110
|
+
deleteEntityAttributesResults = _b.sent();
|
|
111
|
+
_b.label = 9;
|
|
112
|
+
case 9:
|
|
103
113
|
deleteEntityAttributesFailures = deleteEntityAttributesResults.filter(function (result) { return result.status === 'rejected'; });
|
|
104
114
|
if (deleteEntityAttributesFailures.length) {
|
|
105
115
|
return [2 /*return*/, {
|
|
@@ -107,7 +117,7 @@ export var useApplyDcrChanges = function (dcr) {
|
|
|
107
117
|
error: new Error("Failed to delete entity attributes: ".concat(deleteEntityAttributesFailures.map(function (result) { return result.reason; }).join(', ')))
|
|
108
118
|
}];
|
|
109
119
|
}
|
|
110
|
-
if (!!isEmpty(deleteRelationAttributes)) return [3 /*break*/,
|
|
120
|
+
if (!!isEmpty(deleteRelationAttributes)) return [3 /*break*/, 11];
|
|
111
121
|
return [4 /*yield*/, promiseAllSettled(Object.entries(deleteRelationAttributes).map(function (_a) {
|
|
112
122
|
var relationUri = _a[0], diff = _a[1];
|
|
113
123
|
return updateRelationWithDiff({
|
|
@@ -116,10 +126,10 @@ export var useApplyDcrChanges = function (dcr) {
|
|
|
116
126
|
uriPreprocessor: withChangeRequestId(dcr.uri)
|
|
117
127
|
});
|
|
118
128
|
}))];
|
|
119
|
-
case 9:
|
|
120
|
-
deleteRelationAttributesResults = _b.sent();
|
|
121
|
-
_b.label = 10;
|
|
122
129
|
case 10:
|
|
130
|
+
deleteRelationAttributesResults = _b.sent();
|
|
131
|
+
_b.label = 11;
|
|
132
|
+
case 11:
|
|
123
133
|
deleteRelationAttributesFailures = deleteRelationAttributesResults.filter(function (result) { return result.status === 'rejected'; });
|
|
124
134
|
if (deleteRelationAttributesFailures.length) {
|
|
125
135
|
return [2 /*return*/, {
|
|
@@ -130,12 +140,12 @@ export var useApplyDcrChanges = function (dcr) {
|
|
|
130
140
|
return [2 /*return*/, {
|
|
131
141
|
proceed: true
|
|
132
142
|
}];
|
|
133
|
-
case
|
|
143
|
+
case 12: return [2 /*return*/, {
|
|
134
144
|
proceed: false,
|
|
135
145
|
error: new Error('No changes to apply')
|
|
136
146
|
}];
|
|
137
147
|
}
|
|
138
148
|
});
|
|
139
|
-
}); }, [dcr, getLinesByChangeId, metadata]);
|
|
149
|
+
}); }, [dcr, getLinesByChangeId, metadata, getErrors]);
|
|
140
150
|
return applyDcrChanges;
|
|
141
151
|
};
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
23
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import { useMemo, useEffect, useCallback, useRef } from 'react';
|
|
49
|
+
import { useContextSelector } from '@fluentui/react-context-selector';
|
|
50
|
+
import { DCRTypes, isRelationUri, getRelation, findConnectionRelationObjectByRelationUri } from '@reltio/mdm-sdk';
|
|
51
|
+
import { useMdmMetadata, useMdmEntity, useMdmDcrReviewValidation } from '../../../contexts/MdmModuleContext';
|
|
52
|
+
import { useSafePromise } from '../../../hooks/useSafePromise';
|
|
53
|
+
import { MdmModuleValuesContext } from '../../../contexts/MdmModuleContext/context';
|
|
54
|
+
import { ChangeRequestEditorContext } from '../contexts/ChangeRequestEditorContext';
|
|
55
|
+
import { getValidationErrors } from '../helpers/validation';
|
|
56
|
+
export var useDCRValidation = function (dcr) {
|
|
57
|
+
var metadata = useMdmMetadata();
|
|
58
|
+
var currentEntity = useMdmEntity();
|
|
59
|
+
var dcrReviewValidation = useMdmDcrReviewValidation();
|
|
60
|
+
var relationsState = useContextSelector(MdmModuleValuesContext, function (context) { return context.relations; });
|
|
61
|
+
var getAllChanges = useContextSelector(ChangeRequestEditorContext, function (context) { return context.getAllChanges; });
|
|
62
|
+
var setErrors = useContextSelector(ChangeRequestEditorContext, function (context) { return context.setErrors; });
|
|
63
|
+
var relationsRef = useRef(null);
|
|
64
|
+
var safePromise = useSafePromise();
|
|
65
|
+
var findRelationInStore = useCallback(function (uri) {
|
|
66
|
+
if (!relationsState)
|
|
67
|
+
return null;
|
|
68
|
+
for (var viewId in relationsState) {
|
|
69
|
+
var viewState = relationsState[viewId];
|
|
70
|
+
if (viewState === null || viewState === void 0 ? void 0 : viewState.connections) {
|
|
71
|
+
return findConnectionRelationObjectByRelationUri(viewState.connections, uri);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
return null;
|
|
75
|
+
}, [relationsState]);
|
|
76
|
+
var urisFromDcr = useMemo(function () {
|
|
77
|
+
var result = [];
|
|
78
|
+
if (!(dcr === null || dcr === void 0 ? void 0 : dcr.changes))
|
|
79
|
+
return result;
|
|
80
|
+
for (var key in dcr.changes) {
|
|
81
|
+
var changes = dcr.changes[key] || [];
|
|
82
|
+
var hasCreate = changes.some(function (c) { return (c === null || c === void 0 ? void 0 : c.type) === DCRTypes.CREATE_ENTITY || (c === null || c === void 0 ? void 0 : c.type) === DCRTypes.CREATE_RELATIONSHIP; });
|
|
83
|
+
if (!hasCreate) {
|
|
84
|
+
result.push(key);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return result;
|
|
88
|
+
}, [dcr]);
|
|
89
|
+
var localObjects = useMemo(function () {
|
|
90
|
+
var currentEntityObject = {};
|
|
91
|
+
currentEntityObject[currentEntity === null || currentEntity === void 0 ? void 0 : currentEntity.uri] = currentEntity;
|
|
92
|
+
return urisFromDcr.reduce(function (acc, uri) {
|
|
93
|
+
if (isRelationUri(uri)) {
|
|
94
|
+
var localRelation = findRelationInStore(uri);
|
|
95
|
+
if (localRelation) {
|
|
96
|
+
acc[uri] = localRelation;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return acc;
|
|
100
|
+
}, currentEntityObject);
|
|
101
|
+
}, [urisFromDcr, findRelationInStore, currentEntity]);
|
|
102
|
+
useEffect(function () {
|
|
103
|
+
if (!dcrReviewValidation || !urisFromDcr.length || (relationsRef === null || relationsRef === void 0 ? void 0 : relationsRef.current))
|
|
104
|
+
return;
|
|
105
|
+
var relationsPromises = [];
|
|
106
|
+
urisFromDcr.forEach(function (uri) {
|
|
107
|
+
if (isRelationUri(uri) && !localObjects[uri]) {
|
|
108
|
+
relationsPromises.push(getRelation(uri));
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
relationsRef.current = safePromise(Promise.all(relationsPromises));
|
|
112
|
+
}, [dcrReviewValidation, urisFromDcr, findRelationInStore, safePromise, localObjects]);
|
|
113
|
+
var getErrors = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
114
|
+
var relations, _a, loadedRelationsObject, objectsByUri, userChanges, errors;
|
|
115
|
+
return __generator(this, function (_b) {
|
|
116
|
+
switch (_b.label) {
|
|
117
|
+
case 0:
|
|
118
|
+
if (!dcrReviewValidation) {
|
|
119
|
+
return [2 /*return*/, []];
|
|
120
|
+
}
|
|
121
|
+
if (!relationsRef.current) return [3 /*break*/, 2];
|
|
122
|
+
return [4 /*yield*/, relationsRef.current];
|
|
123
|
+
case 1:
|
|
124
|
+
_a = _b.sent();
|
|
125
|
+
return [3 /*break*/, 3];
|
|
126
|
+
case 2:
|
|
127
|
+
_a = [];
|
|
128
|
+
_b.label = 3;
|
|
129
|
+
case 3:
|
|
130
|
+
relations = _a;
|
|
131
|
+
loadedRelationsObject = relations.reduce(function (acc, relation) {
|
|
132
|
+
acc[relation.uri] = relation;
|
|
133
|
+
return acc;
|
|
134
|
+
}, {});
|
|
135
|
+
objectsByUri = __assign(__assign({}, localObjects), loadedRelationsObject);
|
|
136
|
+
userChanges = getAllChanges();
|
|
137
|
+
errors = getValidationErrors({
|
|
138
|
+
changes: dcr === null || dcr === void 0 ? void 0 : dcr.changes,
|
|
139
|
+
userChanges: userChanges,
|
|
140
|
+
entitiesOrRelations: objectsByUri,
|
|
141
|
+
metadata: metadata
|
|
142
|
+
});
|
|
143
|
+
setErrors(errors);
|
|
144
|
+
return [2 /*return*/, errors];
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}); }, [dcrReviewValidation, dcr === null || dcr === void 0 ? void 0 : dcr.changes, getAllChanges, localObjects, metadata, setErrors]);
|
|
148
|
+
return getErrors;
|
|
149
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AttributeType, DCRAttributeValue, DCROperationTypes, DCRRelationInfo, EnrichedChangeValue, TRelationType, ChangeValue } from '@reltio/mdm-sdk';
|
|
1
|
+
import { AttributeType, DCRAttributeValue, DCROperationTypes, DCRRelationInfo, EnrichedChangeValue, TRelationType, ChangeValue, SimpleAttributeValue, PrimitiveValue } from '@reltio/mdm-sdk';
|
|
2
2
|
export type TaskAction = {
|
|
3
3
|
text: string;
|
|
4
4
|
onClick: (comment: string) => void;
|
|
@@ -23,3 +23,10 @@ export type BeforeActionOutcome = {
|
|
|
23
23
|
proceed: boolean;
|
|
24
24
|
error?: unknown;
|
|
25
25
|
};
|
|
26
|
+
export type LineDataValue = SimpleAttributeValue | {
|
|
27
|
+
value: string[] | PrimitiveValue;
|
|
28
|
+
};
|
|
29
|
+
export type LineData = {
|
|
30
|
+
value?: LineDataValue;
|
|
31
|
+
isRejected?: boolean;
|
|
32
|
+
};
|
|
@@ -3,8 +3,9 @@ import { ScrollToElementContext } from '../../contexts/ScrollToElementContext';
|
|
|
3
3
|
type Props = {
|
|
4
4
|
highlightedError: ContextType<typeof ScrollToElementContext> | null;
|
|
5
5
|
isSimple?: boolean;
|
|
6
|
+
className?: string;
|
|
6
7
|
};
|
|
7
|
-
export declare const useScrollToAttributeError: ({ highlightedError: context, isSimple }: Props) => {
|
|
8
|
+
export declare const useScrollToAttributeError: ({ highlightedError: context, isSimple, className }: Props) => {
|
|
8
9
|
ref: import("react").MutableRefObject<HTMLDivElement>;
|
|
9
10
|
errorClassName: string;
|
|
10
11
|
} | {
|
|
@@ -5,7 +5,7 @@ import { ErrorSeverity } from '@reltio/mdm-sdk';
|
|
|
5
5
|
import { useStyles } from './styles';
|
|
6
6
|
export var useScrollToAttributeError = function (_a) {
|
|
7
7
|
var _b;
|
|
8
|
-
var context = _a.highlightedError, _c = _a.isSimple, isSimple = _c === void 0 ? false : _c;
|
|
8
|
+
var context = _a.highlightedError, _c = _a.isSimple, isSimple = _c === void 0 ? false : _c, className = _a.className;
|
|
9
9
|
var styles = useStyles();
|
|
10
10
|
var ref = useRef(null);
|
|
11
11
|
var severity = pathOr(ErrorSeverity.ERROR, ['element', 'severity'])(context);
|
|
@@ -13,7 +13,7 @@ export var useScrollToAttributeError = function (_a) {
|
|
|
13
13
|
_b[styles.highlightError] = severity === ErrorSeverity.ERROR,
|
|
14
14
|
_b[styles.highlightWarning] = severity === ErrorSeverity.WARNING,
|
|
15
15
|
_b[styles.simpleAttribute] = isSimple,
|
|
16
|
-
_b));
|
|
16
|
+
_b), className);
|
|
17
17
|
useEffect(function () {
|
|
18
18
|
if (context) {
|
|
19
19
|
context.scrollIntoRef(ref);
|