@reltio/components 1.4.2206 → 1.4.2208
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/contexts/WorkflowTasksContext/index.d.ts +1 -0
- package/cjs/features/workflow/ChangeRequestEditor/ChangeRequestEditor.js +1 -2
- package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.js +3 -4
- package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.js +4 -4
- 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 +2 -1
- package/cjs/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.js +14 -8
- package/cjs/features/workflow/ReviewDCRDialog/ReviewDCRDialog.js +10 -7
- package/cjs/features/workflow/TaskActionButtons/TaskActionButtons.js +6 -4
- package/cjs/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +12 -3
- package/cjs/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/GenericWorkflowTaskCard.js +6 -4
- package/cjs/features/workflow/{ChangeRequestEditor/context → contexts/ChangeRequestEditorContext}/index.d.ts +1 -0
- package/cjs/features/workflow/{ChangeRequestEditor/context → contexts/ChangeRequestEditorContext}/index.js +12 -0
- package/cjs/features/workflow/helpers/attributes.js +2 -2
- package/cjs/features/workflow/helpers/attributes.test.js +9 -6
- package/cjs/features/workflow/helpers/dcr.d.ts +8 -1
- package/cjs/features/workflow/helpers/dcr.js +186 -1
- package/cjs/features/workflow/helpers/merge.js +2 -1
- package/cjs/features/workflow/hooks/useApplyDcrChanges.d.ts +3 -0
- package/cjs/features/workflow/hooks/useApplyDcrChanges.js +145 -0
- package/cjs/features/workflow/hooks/useWorkflowActions.d.ts +7 -2
- package/cjs/features/workflow/hooks/useWorkflowActions.js +31 -8
- package/cjs/features/workflow/types.d.ts +4 -0
- package/contexts/WorkflowTasksContext/index.d.ts +1 -0
- package/features/workflow/ChangeRequestEditor/ChangeRequestEditor.js +1 -2
- package/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.js +3 -4
- package/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.js +1 -1
- 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 +2 -1
- package/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.js +8 -2
- package/features/workflow/ReviewDCRDialog/ReviewDCRDialog.js +10 -7
- package/features/workflow/TaskActionButtons/TaskActionButtons.js +6 -4
- package/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +14 -5
- package/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/GenericWorkflowTaskCard.js +6 -4
- package/features/workflow/{ChangeRequestEditor/context → contexts/ChangeRequestEditorContext}/index.d.ts +1 -0
- package/features/workflow/{ChangeRequestEditor/context → contexts/ChangeRequestEditorContext}/index.js +13 -1
- package/features/workflow/helpers/attributes.js +2 -2
- package/features/workflow/helpers/attributes.test.js +9 -6
- package/features/workflow/helpers/dcr.d.ts +8 -1
- package/features/workflow/helpers/dcr.js +186 -2
- package/features/workflow/helpers/merge.js +2 -1
- package/features/workflow/hooks/useApplyDcrChanges.d.ts +3 -0
- package/features/workflow/hooks/useApplyDcrChanges.js +141 -0
- package/features/workflow/hooks/useWorkflowActions.d.ts +7 -2
- package/features/workflow/hooks/useWorkflowActions.js +31 -8
- package/features/workflow/types.d.ts +4 -0
- package/package.json +2 -2
|
@@ -10,8 +10,17 @@ 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
|
-
exports.isCreateEntityOperation = exports.getEntityUriForChangeRequest = exports.concatEntityRelationsObjects = exports.createEntityRelationsObjectByRelation = exports.createEntityRelationsObjectByEntity = exports.extractObjectsFromChangeRequest = exports.getRelationsObjects = exports.getEntitiesObjects = void 0;
|
|
23
|
+
exports.buildDCRSavePlan = exports.isCreateEntityOperation = exports.getEntityUriForChangeRequest = exports.concatEntityRelationsObjects = exports.createEntityRelationsObjectByRelation = exports.createEntityRelationsObjectByEntity = exports.extractObjectsFromChangeRequest = exports.getRelationsObjects = exports.getEntitiesObjects = void 0;
|
|
15
24
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
16
25
|
var ramda_1 = require("ramda");
|
|
17
26
|
exports.getEntitiesObjects = (0, ramda_1.filter)((0, ramda_1.pipe)((0, ramda_1.prop)('uri'), mdm_sdk_1.isEntityUri));
|
|
@@ -54,3 +63,179 @@ var isCreateEntityOperation = function (dcr) {
|
|
|
54
63
|
return dcr.type === mdm_sdk_1.DCRTypes.CREATE_ENTITY;
|
|
55
64
|
};
|
|
56
65
|
exports.isCreateEntityOperation = isCreateEntityOperation;
|
|
66
|
+
var cleanValueRecursively = function (value) {
|
|
67
|
+
if (typeof value === 'string' || (0, ramda_1.isEmpty)(value)) {
|
|
68
|
+
return value;
|
|
69
|
+
}
|
|
70
|
+
var cleanedProperties = (0, ramda_1.map)(function (propertyValues) {
|
|
71
|
+
return propertyValues
|
|
72
|
+
.map(function (item) {
|
|
73
|
+
var itemValue = item.value;
|
|
74
|
+
var cleanedItemValue = itemValue && typeof itemValue === 'object' ? cleanValueRecursively(itemValue) : itemValue;
|
|
75
|
+
return __assign(__assign({}, item), { value: cleanedItemValue });
|
|
76
|
+
})
|
|
77
|
+
.filter(function (item) {
|
|
78
|
+
var itemValue = item.value;
|
|
79
|
+
return !(0, ramda_1.isEmpty)(itemValue) && !(0, ramda_1.isNil)(itemValue);
|
|
80
|
+
});
|
|
81
|
+
}, value);
|
|
82
|
+
return (0, ramda_1.filter)(function (propertyValues) { return !(0, ramda_1.isEmpty)(propertyValues); }, cleanedProperties);
|
|
83
|
+
};
|
|
84
|
+
var cleanChange = function (change) {
|
|
85
|
+
var _a, _b, _c;
|
|
86
|
+
if (Array.isArray(change.newValue)) {
|
|
87
|
+
return change;
|
|
88
|
+
}
|
|
89
|
+
if ((0, mdm_sdk_1.isRelationTypeUri)(change.objectType)) {
|
|
90
|
+
if (change.type === mdm_sdk_1.DCRTypes.INSERT_ATTRIBUTE || change.type === mdm_sdk_1.DCRTypes.UPDATE_ATTRIBUTE) {
|
|
91
|
+
var cleanedValues = cleanValueRecursively((_a = change.newValue) === null || _a === void 0 ? void 0 : _a.value);
|
|
92
|
+
return (0, ramda_1.assocPath)(['newValue', 'value'], cleanedValues, change);
|
|
93
|
+
}
|
|
94
|
+
var cleanedAttributes = cleanValueRecursively((_b = change.newValue) === null || _b === void 0 ? void 0 : _b.attributes);
|
|
95
|
+
var changeWithCleanedAttributes = (0, ramda_1.assocPath)(['newValue', 'attributes'], cleanedAttributes, change);
|
|
96
|
+
if (change.type === mdm_sdk_1.DCRTypes.CREATE_RELATIONSHIP) {
|
|
97
|
+
var cleanByPath = function (valuePath) {
|
|
98
|
+
return (0, ramda_1.when)((0, ramda_1.allPass)([(0, ramda_1.hasPath)(valuePath), (0, ramda_1.pipe)((0, ramda_1.path)(valuePath), ramda_1.isNil)]), (0, ramda_1.dissocPath)(valuePath));
|
|
99
|
+
};
|
|
100
|
+
return (0, ramda_1.pipe)(cleanByPath(['newValue', 'startDate']), cleanByPath(['newValue', 'endDate']))(changeWithCleanedAttributes);
|
|
101
|
+
}
|
|
102
|
+
return changeWithCleanedAttributes;
|
|
103
|
+
}
|
|
104
|
+
if (typeof change.newValue === 'object') {
|
|
105
|
+
var cleanedValue = cleanValueRecursively((_c = change.newValue) === null || _c === void 0 ? void 0 : _c.value);
|
|
106
|
+
return (0, ramda_1.assocPath)(['newValue', 'value'], cleanedValue, change);
|
|
107
|
+
}
|
|
108
|
+
return change;
|
|
109
|
+
};
|
|
110
|
+
var calculateValuePath = function (key, change) {
|
|
111
|
+
var path = key
|
|
112
|
+
.split('/')
|
|
113
|
+
.slice(2)
|
|
114
|
+
.map(function (part) { return (isNaN(Number(part)) ? part : parseInt(part)); });
|
|
115
|
+
switch (change.type) {
|
|
116
|
+
case mdm_sdk_1.DCRTypes.UPDATE_TAGS:
|
|
117
|
+
case mdm_sdk_1.DCRTypes.UPDATE_ROLES:
|
|
118
|
+
return path;
|
|
119
|
+
case mdm_sdk_1.DCRTypes.UPDATE_START_DATE:
|
|
120
|
+
case mdm_sdk_1.DCRTypes.UPDATE_END_DATE:
|
|
121
|
+
return __spreadArray(__spreadArray([], path, true), [0], false);
|
|
122
|
+
case mdm_sdk_1.DCRTypes.CREATE_RELATIONSHIP:
|
|
123
|
+
if (path.length === 2) {
|
|
124
|
+
if (path[1] === 'activeness.startDate') {
|
|
125
|
+
return [path[0], 'startDate'];
|
|
126
|
+
}
|
|
127
|
+
if (path[1] === 'activeness.endDate') {
|
|
128
|
+
return [path[0], 'endDate'];
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
return __spreadArray(__spreadArray([], path, true), ['value'], false);
|
|
132
|
+
default:
|
|
133
|
+
return __spreadArray(__spreadArray([], path, true), ['value'], false);
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
var valuesAreEqual = function (oldValue, newValue) {
|
|
137
|
+
var sortWithLocale = function (array) { return array.slice().sort(function (a, b) { return a.localeCompare(b); }); };
|
|
138
|
+
if (Array.isArray(oldValue) && Array.isArray(newValue)) {
|
|
139
|
+
return oldValue.length === newValue.length && (0, ramda_1.equals)(sortWithLocale(oldValue), sortWithLocale(newValue));
|
|
140
|
+
}
|
|
141
|
+
if (typeof oldValue === 'string' && typeof newValue === 'number') {
|
|
142
|
+
return oldValue === newValue.toString();
|
|
143
|
+
}
|
|
144
|
+
return oldValue === newValue;
|
|
145
|
+
};
|
|
146
|
+
var getOldValueByNewValuePath = function (valuePath, change) {
|
|
147
|
+
if (valuePath.includes('newValue')) {
|
|
148
|
+
return (0, ramda_1.pathOr)(null, valuePath.map(function (item) { return (item === 'newValue' ? 'oldValue' : item); }), change);
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
};
|
|
152
|
+
var buildDCRSavePlan = function (changes, getLinesByChangeId, metadata) {
|
|
153
|
+
var _a, _b;
|
|
154
|
+
var rejectedChangeIds = [];
|
|
155
|
+
var updatedChanges = {};
|
|
156
|
+
var deleteAttributes = {};
|
|
157
|
+
for (var _i = 0, _c = Object.entries(changes); _i < _c.length; _i++) {
|
|
158
|
+
var _d = _c[_i], objectUri = _d[0], objectChanges = _d[1];
|
|
159
|
+
var rawChanges = new Map();
|
|
160
|
+
var _loop_1 = function (change) {
|
|
161
|
+
var _h = (0, ramda_1.pipe)((0, ramda_1.prop)('id'), getLinesByChangeId, (0, ramda_1.partition)(function (_a) {
|
|
162
|
+
var _b;
|
|
163
|
+
var key = _a[0], lineData = _a[1];
|
|
164
|
+
return key.split('/').length === 3 &&
|
|
165
|
+
(lineData.isRejected ||
|
|
166
|
+
((0, ramda_1.isEmpty)((_b = lineData.value) === null || _b === void 0 ? void 0 : _b.value) && change.type !== mdm_sdk_1.DCRTypes.UPDATE_ATTRIBUTE));
|
|
167
|
+
}))(change), rejectedRootLines = _h[0], otherLines = _h[1];
|
|
168
|
+
rejectedChangeIds.push.apply(rejectedChangeIds, rejectedRootLines.map(function (_a) {
|
|
169
|
+
var key = _a[0];
|
|
170
|
+
return key.split('/')[1];
|
|
171
|
+
}));
|
|
172
|
+
var rejectedRootLinesMap = new Map(rejectedRootLines);
|
|
173
|
+
for (var _j = 0, otherLines_1 = otherLines; _j < otherLines_1.length; _j++) {
|
|
174
|
+
var _k = otherLines_1[_j], key = _k[0], lineData = _k[1];
|
|
175
|
+
var rootId = key.split('/').slice(0, 3).join('/');
|
|
176
|
+
var newValue = (_a = lineData.value) === null || _a === void 0 ? void 0 : _a.value;
|
|
177
|
+
if (rootId === key && change.type === mdm_sdk_1.DCRTypes.UPDATE_ATTRIBUTE && (0, ramda_1.isEmpty)(newValue)) {
|
|
178
|
+
var attributeUri = [objectUri, 'attributes', change.attributePath].join('/');
|
|
179
|
+
var entry = __assign(__assign({}, (0, mdm_sdk_1.createEntryDeleteAttribute)({ uri: attributeUri })[0]), (change.crosswalk && { crosswalk: change.crosswalk }));
|
|
180
|
+
deleteAttributes[objectUri] = (0, ramda_1.uniqBy)((0, ramda_1.prop)('uri'), (0, ramda_1.append)(entry, (0, ramda_1.propOr)([], objectUri, deleteAttributes)));
|
|
181
|
+
rejectedChangeIds.push(change.id);
|
|
182
|
+
}
|
|
183
|
+
else if (!rejectedRootLinesMap.has(rootId)) {
|
|
184
|
+
var valuePath = calculateValuePath(key, change);
|
|
185
|
+
var oldDCRValue = (0, ramda_1.path)(valuePath, change);
|
|
186
|
+
var oldValue = getOldValueByNewValuePath(valuePath, change);
|
|
187
|
+
var initialChange = rawChanges.has(change.id) ? rawChanges.get(change.id) : change;
|
|
188
|
+
var updatedChange = void 0;
|
|
189
|
+
if (lineData.isRejected || (0, ramda_1.isEmpty)(newValue)) {
|
|
190
|
+
updatedChange = (0, ramda_1.assocPath)(valuePath, null, initialChange);
|
|
191
|
+
}
|
|
192
|
+
else if (!valuesAreEqual(oldDCRValue, newValue)) {
|
|
193
|
+
if (oldValue && valuesAreEqual(oldValue, newValue)) {
|
|
194
|
+
rejectedChangeIds.push(change.id);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
var processedNewValue = typeof oldDCRValue === 'string' && typeof newValue === 'number'
|
|
198
|
+
? newValue.toString()
|
|
199
|
+
: newValue;
|
|
200
|
+
updatedChange = (0, ramda_1.assocPath)(valuePath, processedNewValue, initialChange);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
if (updatedChange) {
|
|
204
|
+
rawChanges.set(change.id, updatedChange);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
for (var _e = 0, objectChanges_1 = objectChanges; _e < objectChanges_1.length; _e++) {
|
|
210
|
+
var change = objectChanges_1[_e];
|
|
211
|
+
_loop_1(change);
|
|
212
|
+
}
|
|
213
|
+
for (var _f = 0, _g = Array.from(rawChanges.values()); _f < _g.length; _f++) {
|
|
214
|
+
var rawChange = _g[_f];
|
|
215
|
+
var cleanedChange = cleanChange(rawChange);
|
|
216
|
+
var isNestedChange = (0, ramda_1.has)('attributeType', cleanedChange) &&
|
|
217
|
+
(0, mdm_sdk_1.isNested)((0, mdm_sdk_1.findAttributeTypeByUri)(metadata, cleanedChange.attributeType));
|
|
218
|
+
if (isNestedChange && (0, ramda_1.isEmpty)((_b = cleanedChange.newValue) === null || _b === void 0 ? void 0 : _b.value)) {
|
|
219
|
+
rejectedChangeIds.push(cleanedChange.id);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
updatedChanges[objectUri] = (0, ramda_1.append)(cleanedChange, (0, ramda_1.propOr)([], objectUri, updatedChanges));
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
var rejectedBeforeUpdateIds = (0, ramda_1.pipe)(ramda_1.values, ramda_1.flatten, (0, ramda_1.pluck)('id'))(updatedChanges);
|
|
227
|
+
rejectedChangeIds.push.apply(rejectedChangeIds, rejectedBeforeUpdateIds);
|
|
228
|
+
var deleteAttributesGroups = (0, ramda_1.groupBy)(function (_a) {
|
|
229
|
+
var uri = _a[0];
|
|
230
|
+
return ((0, mdm_sdk_1.isRelationUri)(uri) ? 'relation' : 'entity');
|
|
231
|
+
}, (0, ramda_1.toPairs)(deleteAttributes));
|
|
232
|
+
var deleteRelationAttributes = (0, ramda_1.fromPairs)(deleteAttributesGroups.relation || []);
|
|
233
|
+
var deleteEntityAttributes = (0, ramda_1.fromPairs)(deleteAttributesGroups.entity || []);
|
|
234
|
+
return {
|
|
235
|
+
rejectedChangeIds: rejectedChangeIds,
|
|
236
|
+
updatedChanges: updatedChanges,
|
|
237
|
+
deleteEntityAttributes: deleteEntityAttributes,
|
|
238
|
+
deleteRelationAttributes: deleteRelationAttributes
|
|
239
|
+
};
|
|
240
|
+
};
|
|
241
|
+
exports.buildDCRSavePlan = buildDCRSavePlan;
|
|
@@ -256,7 +256,8 @@ var mergeChanges = function (metadata, changes, entityInfo, relationsInfo) {
|
|
|
256
256
|
], changesTree);
|
|
257
257
|
var relationsChanges = (0, ramda_1.flatten)(relationsInfo.map(function (relationInfo, index) {
|
|
258
258
|
var changeType = (0, ramda_1.path)([relationInfo.uri, 0, 'type'], changes);
|
|
259
|
-
|
|
259
|
+
var relationChangeLineIds = (0, ramda_1.path)([relationInfo.uri, 0, 'lineIds'], changes);
|
|
260
|
+
return (0, attributes_1.getRelationChanges)(metadata, relationInfo, relationsTrees[index], changeType, relationChangeLineIds);
|
|
260
261
|
}));
|
|
261
262
|
return [entityChanges, relationsChanges];
|
|
262
263
|
};
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
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);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.useApplyDcrChanges = void 0;
|
|
40
|
+
var react_1 = require("react");
|
|
41
|
+
var react_context_selector_1 = require("@fluentui/react-context-selector");
|
|
42
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
43
|
+
var ramda_1 = require("ramda");
|
|
44
|
+
var MdmModuleContext_1 = require("../../../contexts/MdmModuleContext");
|
|
45
|
+
var ChangeRequestEditorContext_1 = require("../contexts/ChangeRequestEditorContext");
|
|
46
|
+
var dcr_1 = require("../helpers/dcr");
|
|
47
|
+
var withChangeRequestId = function (dcrUri) { return function (url) {
|
|
48
|
+
return url + (url.includes('?') ? '&' : '?') + "changeRequestId=".concat(encodeURIComponent(dcrUri.split('/')[1]));
|
|
49
|
+
}; };
|
|
50
|
+
var useApplyDcrChanges = function (dcr) {
|
|
51
|
+
var getLinesByChangeId = (0, react_context_selector_1.useContextSelector)(ChangeRequestEditorContext_1.ChangeRequestEditorContext, function (context) { return context.getLinesByChangeId; });
|
|
52
|
+
var metadata = (0, MdmModuleContext_1.useMdmMetadata)();
|
|
53
|
+
var applyDcrChanges = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
54
|
+
var _a, rejectedChangeIds, updatedChanges, deleteEntityAttributes, deleteRelationAttributes, deleteChangeResults, deleteEntityAttributesResults, deleteRelationAttributesResults, deleteChangeFailures, error_1, deleteEntityAttributesFailures, deleteRelationAttributesFailures;
|
|
55
|
+
return __generator(this, function (_b) {
|
|
56
|
+
switch (_b.label) {
|
|
57
|
+
case 0:
|
|
58
|
+
if (!(dcr === null || dcr === void 0 ? void 0 : dcr.changes)) return [3 /*break*/, 11];
|
|
59
|
+
_a = (0, dcr_1.buildDCRSavePlan)(dcr.changes, getLinesByChangeId, metadata), rejectedChangeIds = _a.rejectedChangeIds, updatedChanges = _a.updatedChanges, deleteEntityAttributes = _a.deleteEntityAttributes, deleteRelationAttributes = _a.deleteRelationAttributes;
|
|
60
|
+
deleteChangeResults = [];
|
|
61
|
+
deleteEntityAttributesResults = [];
|
|
62
|
+
deleteRelationAttributesResults = [];
|
|
63
|
+
if (!(rejectedChangeIds.length > 0)) return [3 /*break*/, 2];
|
|
64
|
+
return [4 /*yield*/, (0, mdm_sdk_1.promiseAllSettled)(rejectedChangeIds.map(function (changeId) {
|
|
65
|
+
return (0, mdm_sdk_1.deleteChangeRequestItem)({ dcrUri: dcr.uri, changeItemId: changeId });
|
|
66
|
+
}))];
|
|
67
|
+
case 1:
|
|
68
|
+
deleteChangeResults = _b.sent();
|
|
69
|
+
_b.label = 2;
|
|
70
|
+
case 2:
|
|
71
|
+
deleteChangeFailures = deleteChangeResults.filter(function (result) { return result.status === 'rejected'; });
|
|
72
|
+
if (deleteChangeFailures.length) {
|
|
73
|
+
return [2 /*return*/, {
|
|
74
|
+
proceed: false,
|
|
75
|
+
error: new Error("Failed to delete DCR change(s): ".concat(deleteChangeFailures.map(function (result) { return result.reason; }).join(', ')))
|
|
76
|
+
}];
|
|
77
|
+
}
|
|
78
|
+
if (!!(0, ramda_1.isEmpty)(updatedChanges)) return [3 /*break*/, 6];
|
|
79
|
+
_b.label = 3;
|
|
80
|
+
case 3:
|
|
81
|
+
_b.trys.push([3, 5, , 6]);
|
|
82
|
+
return [4 /*yield*/, (0, mdm_sdk_1.updateChangeRequest)({ dcrUri: dcr.uri, payload: updatedChanges })];
|
|
83
|
+
case 4:
|
|
84
|
+
_b.sent();
|
|
85
|
+
return [3 /*break*/, 6];
|
|
86
|
+
case 5:
|
|
87
|
+
error_1 = _b.sent();
|
|
88
|
+
return [2 /*return*/, {
|
|
89
|
+
proceed: false,
|
|
90
|
+
error: error_1
|
|
91
|
+
}];
|
|
92
|
+
case 6:
|
|
93
|
+
if (!!(0, ramda_1.isEmpty)(deleteEntityAttributes)) return [3 /*break*/, 8];
|
|
94
|
+
return [4 /*yield*/, (0, mdm_sdk_1.promiseAllSettled)(Object.entries(deleteEntityAttributes).map(function (_a) {
|
|
95
|
+
var entityUri = _a[0], diff = _a[1];
|
|
96
|
+
return (0, mdm_sdk_1.entityCumulativeUpdate)({
|
|
97
|
+
uri: entityUri,
|
|
98
|
+
diff: diff,
|
|
99
|
+
uriPreprocessor: withChangeRequestId(dcr.uri)
|
|
100
|
+
});
|
|
101
|
+
}))];
|
|
102
|
+
case 7:
|
|
103
|
+
deleteEntityAttributesResults = _b.sent();
|
|
104
|
+
_b.label = 8;
|
|
105
|
+
case 8:
|
|
106
|
+
deleteEntityAttributesFailures = deleteEntityAttributesResults.filter(function (result) { return result.status === 'rejected'; });
|
|
107
|
+
if (deleteEntityAttributesFailures.length) {
|
|
108
|
+
return [2 /*return*/, {
|
|
109
|
+
proceed: false,
|
|
110
|
+
error: new Error("Failed to delete entity attributes: ".concat(deleteEntityAttributesFailures.map(function (result) { return result.reason; }).join(', ')))
|
|
111
|
+
}];
|
|
112
|
+
}
|
|
113
|
+
if (!!(0, ramda_1.isEmpty)(deleteRelationAttributes)) return [3 /*break*/, 10];
|
|
114
|
+
return [4 /*yield*/, (0, mdm_sdk_1.promiseAllSettled)(Object.entries(deleteRelationAttributes).map(function (_a) {
|
|
115
|
+
var relationUri = _a[0], diff = _a[1];
|
|
116
|
+
return (0, mdm_sdk_1.updateRelationWithDiff)({
|
|
117
|
+
uri: relationUri,
|
|
118
|
+
diff: diff,
|
|
119
|
+
uriPreprocessor: withChangeRequestId(dcr.uri)
|
|
120
|
+
});
|
|
121
|
+
}))];
|
|
122
|
+
case 9:
|
|
123
|
+
deleteRelationAttributesResults = _b.sent();
|
|
124
|
+
_b.label = 10;
|
|
125
|
+
case 10:
|
|
126
|
+
deleteRelationAttributesFailures = deleteRelationAttributesResults.filter(function (result) { return result.status === 'rejected'; });
|
|
127
|
+
if (deleteRelationAttributesFailures.length) {
|
|
128
|
+
return [2 /*return*/, {
|
|
129
|
+
proceed: false,
|
|
130
|
+
error: new Error("Failed to delete relation attributes: ".concat(deleteRelationAttributesFailures.map(function (result) { return result.reason; }).join(', ')))
|
|
131
|
+
}];
|
|
132
|
+
}
|
|
133
|
+
return [2 /*return*/, {
|
|
134
|
+
proceed: true
|
|
135
|
+
}];
|
|
136
|
+
case 11: return [2 /*return*/, {
|
|
137
|
+
proceed: false,
|
|
138
|
+
error: new Error('No changes to apply')
|
|
139
|
+
}];
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}); }, [dcr, getLinesByChangeId, metadata]);
|
|
143
|
+
return applyDcrChanges;
|
|
144
|
+
};
|
|
145
|
+
exports.useApplyDcrChanges = useApplyDcrChanges;
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
import { WorkflowTaskData } from '@reltio/mdm-sdk';
|
|
2
|
-
import { TaskAction } from '../types';
|
|
2
|
+
import { BeforeActionOutcome, TaskAction } from '../types';
|
|
3
3
|
type Task = Partial<Pick<WorkflowTaskData, 'taskId' | 'possibleActions' | 'assignee' | 'isOpen'>>;
|
|
4
|
-
|
|
4
|
+
type Props = {
|
|
5
|
+
task: Task;
|
|
6
|
+
onActionSuccess?: (action: string) => void;
|
|
7
|
+
beforeAction?: () => Promise<BeforeActionOutcome>;
|
|
8
|
+
};
|
|
9
|
+
export declare const useWorkflowActions: ({ task, onActionSuccess, beforeAction }: Props) => {
|
|
5
10
|
actions: TaskAction[];
|
|
6
11
|
actionRequestIsInProgress: boolean;
|
|
7
12
|
};
|
|
@@ -44,23 +44,25 @@ var common_1 = require("../helpers/common");
|
|
|
44
44
|
var WorkflowTasksContext_1 = require("../../../contexts/WorkflowTasksContext");
|
|
45
45
|
var MdmModuleContext_1 = require("../../../contexts/MdmModuleContext");
|
|
46
46
|
var CommentDialogContext_1 = require("../../../contexts/CommentDialogContext");
|
|
47
|
-
var
|
|
48
|
-
|
|
47
|
+
var errors_2 = require("../../../helpers/errors");
|
|
48
|
+
var useWorkflowActions = function (_a) {
|
|
49
|
+
var task = _a.task, onActionSuccess = _a.onActionSuccess, beforeAction = _a.beforeAction;
|
|
50
|
+
var _b = task !== null && task !== void 0 ? task : {}, possibleActions = _b.possibleActions, assignee = _b.assignee, taskId = _b.taskId, isOpen = _b.isOpen;
|
|
49
51
|
var workflowTasks = (0, react_1.useContext)(WorkflowTasksContext_1.WorkflowTasksContext);
|
|
50
52
|
var workflowPath = (0, MdmModuleContext_1.useMdmWorkflowPath)();
|
|
51
53
|
var environment = (0, MdmModuleContext_1.useMdmWorkflowEnvironmentUrl)();
|
|
52
54
|
var tenant = (0, MdmModuleContext_1.useMdmTenant)();
|
|
53
55
|
var username = (0, MdmModuleContext_1.useMdmUsername)();
|
|
54
56
|
var showCommentDialog = (0, CommentDialogContext_1.useCommentDialog)();
|
|
55
|
-
var
|
|
57
|
+
var _c = (0, react_1.useState)(false), actionRequestIsInProgress = _c[0], setActionRequestIsInProgress = _c[1];
|
|
56
58
|
var handleActionSuccess = onActionSuccess !== null && onActionSuccess !== void 0 ? onActionSuccess : workflowTasks === null || workflowTasks === void 0 ? void 0 : workflowTasks.onActionSuccess;
|
|
57
59
|
var performTaskAction = (0, react_1.useCallback)(function (action, commentRequired) {
|
|
58
60
|
return function (comment) { return __awaiter(void 0, void 0, void 0, function () {
|
|
59
|
-
var processInstanceComment;
|
|
61
|
+
var processInstanceComment, outcome, error_1;
|
|
60
62
|
return __generator(this, function (_a) {
|
|
61
63
|
switch (_a.label) {
|
|
62
64
|
case 0:
|
|
63
|
-
if (!(workflowPath && taskId)) return [3 /*break*/,
|
|
65
|
+
if (!(workflowPath && taskId)) return [3 /*break*/, 7];
|
|
64
66
|
setActionRequestIsInProgress(true);
|
|
65
67
|
processInstanceComment = typeof comment === 'string' && comment.length ? comment : null;
|
|
66
68
|
if (!(commentRequired && !processInstanceComment)) return [3 /*break*/, 2];
|
|
@@ -73,6 +75,27 @@ var useWorkflowActions = function (task, onActionSuccess) {
|
|
|
73
75
|
}
|
|
74
76
|
_a.label = 2;
|
|
75
77
|
case 2:
|
|
78
|
+
if (!beforeAction) return [3 /*break*/, 6];
|
|
79
|
+
_a.label = 3;
|
|
80
|
+
case 3:
|
|
81
|
+
_a.trys.push([3, 5, , 6]);
|
|
82
|
+
return [4 /*yield*/, beforeAction()];
|
|
83
|
+
case 4:
|
|
84
|
+
outcome = _a.sent();
|
|
85
|
+
if (!outcome.proceed) {
|
|
86
|
+
if (outcome.error) {
|
|
87
|
+
(0, errors_2.showDefaultErrorMessage)(outcome.error);
|
|
88
|
+
}
|
|
89
|
+
setActionRequestIsInProgress(false);
|
|
90
|
+
return [2 /*return*/];
|
|
91
|
+
}
|
|
92
|
+
return [3 /*break*/, 6];
|
|
93
|
+
case 5:
|
|
94
|
+
error_1 = _a.sent();
|
|
95
|
+
(0, errors_2.showDefaultErrorMessage)(error_1);
|
|
96
|
+
setActionRequestIsInProgress(false);
|
|
97
|
+
return [2 /*return*/];
|
|
98
|
+
case 6:
|
|
76
99
|
(0, mdm_sdk_1.runTaskAction)({
|
|
77
100
|
taskId: taskId,
|
|
78
101
|
workflowPath: workflowPath,
|
|
@@ -88,12 +111,12 @@ var useWorkflowActions = function (task, onActionSuccess) {
|
|
|
88
111
|
.finally(function () {
|
|
89
112
|
setActionRequestIsInProgress(false);
|
|
90
113
|
});
|
|
91
|
-
_a.label =
|
|
92
|
-
case
|
|
114
|
+
_a.label = 7;
|
|
115
|
+
case 7: return [2 /*return*/];
|
|
93
116
|
}
|
|
94
117
|
});
|
|
95
118
|
}); };
|
|
96
|
-
}, [workflowPath, taskId, environment, tenant, handleActionSuccess, showCommentDialog]);
|
|
119
|
+
}, [workflowPath, taskId, environment, tenant, handleActionSuccess, showCommentDialog, beforeAction]);
|
|
97
120
|
var actions = (0, react_1.useMemo)(function () {
|
|
98
121
|
return username === assignee && (0, common_1.isOpenTask)(isOpen)
|
|
99
122
|
? (possibleActions || []).map(function (_a) {
|
|
@@ -5,7 +5,6 @@ import Typography from '@mui/material/Typography';
|
|
|
5
5
|
import { addLineIdToValue } from './helpers/helpers';
|
|
6
6
|
import SvgSuggestedChanges from '../../../icons/SuggestedChanges';
|
|
7
7
|
import { EntityChangesGroup, SkeletonEntityChangesGroupLoader } from './components/EntityChangesGroup';
|
|
8
|
-
import { ChangeRequestEditorProvider } from './context';
|
|
9
8
|
import styles from './ChangeRequestEditor.module.css';
|
|
10
9
|
export var ChangeRequestEditor = function (_a) {
|
|
11
10
|
var dcr = _a.dcr, task = _a.task, groupedObjects = _a.groupedObjects;
|
|
@@ -23,5 +22,5 @@ export var ChangeRequestEditor = function (_a) {
|
|
|
23
22
|
React.createElement("div", { className: styles.suggestedChangesIcon },
|
|
24
23
|
React.createElement(SvgSuggestedChanges, null)),
|
|
25
24
|
React.createElement(Typography, { variant: "h6", className: styles.suggestedChangesTitle }, i18n.text('Suggested changes'))),
|
|
26
|
-
dcrLoaded ? (
|
|
25
|
+
dcrLoaded ? (groupedObjects.map(function (object, index) { return (React.createElement(EntityChangesGroup, { key: "entity-".concat(index), entityInfo: object.entity, relationsInfo: object.relations, task: task, dcr: enrichedDCR })); })) : (React.createElement(SkeletonEntityChangesGroupLoader, null))));
|
|
27
26
|
};
|
package/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.js
CHANGED
|
@@ -21,12 +21,11 @@ export var ChangeItemEditor = function (_a) {
|
|
|
21
21
|
var _b, _c, _d;
|
|
22
22
|
var change = _a.change, _e = _a.editable, editable = _e === void 0 ? true : _e, classes = _a.classes;
|
|
23
23
|
var metadata = useMdmMetadata();
|
|
24
|
-
var _f = useChangeRequestEditor({ change: change }), handleChange = _f.handleChange, handleReject = _f.handleReject, handleRevert = _f.handleRevert, lineData = _f.lineData, isLineRejected = _f.isLineRejected, isParentLineRejected = _f.isParentLineRejected, isUpdated = _f.isUpdated, hasChangeId = _f.hasChangeId;
|
|
24
|
+
var _f = useChangeRequestEditor({ change: change }), handleChange = _f.handleChange, handleReject = _f.handleReject, handleRevert = _f.handleRevert, lineData = _f.lineData, isLineRejected = _f.isLineRejected, isParentLineRejected = _f.isParentLineRejected, isUpdated = _f.isUpdated, hasChangeId = _f.hasChangeId, isSubAttributeOfDeletedAttribute = _f.isSubAttributeOfDeletedAttribute;
|
|
25
25
|
var entity = useMdmEntity();
|
|
26
26
|
var entityType = getEntityType(metadata, entity === null || entity === void 0 ? void 0 : entity.type);
|
|
27
27
|
var isUpdateOperation = change.operation === DCROperationTypes.EDITED;
|
|
28
28
|
var isAddOperation = change.operation === DCROperationTypes.ADDED;
|
|
29
|
-
var hasAnyValue = Boolean(change.oldValue || change.newValue);
|
|
30
29
|
var oldValue = getAttributeValue(change.oldValue);
|
|
31
30
|
var currentNewValue = !isNil(lineData === null || lineData === void 0 ? void 0 : lineData.value) && !isParentLineRejected ? lineData.value : change.newValue;
|
|
32
31
|
var newValue = getAttributeValue(currentNewValue);
|
|
@@ -34,7 +33,6 @@ export var ChangeItemEditor = function (_a) {
|
|
|
34
33
|
var dataTypeDefinition = useMemo(function () {
|
|
35
34
|
return change.attributeType && getDataTypeDefinition(change.attributeType, newValue || oldValue);
|
|
36
35
|
}, [change.attributeType, newValue, oldValue]);
|
|
37
|
-
var shouldShowOperationChip = hasAnyValue && change.operation;
|
|
38
36
|
var isRolesOrTags = ((_b = change === null || change === void 0 ? void 0 : change.attributeType) === null || _b === void 0 ? void 0 : _b.uri) === EntityAttrTypes.roles.uri ||
|
|
39
37
|
((_c = change === null || change === void 0 ? void 0 : change.attributeType) === null || _c === void 0 ? void 0 : _c.uri) === EntityAttrTypes.tags.uri;
|
|
40
38
|
var canEdit = checkCanInitiateChangeRequest(metadata, entityType, change);
|
|
@@ -50,6 +48,7 @@ export var ChangeItemEditor = function (_a) {
|
|
|
50
48
|
!isUpdated &&
|
|
51
49
|
!isParentLineRejected &&
|
|
52
50
|
hasChangeId &&
|
|
51
|
+
!isSubAttributeOfDeletedAttribute &&
|
|
53
52
|
!(change.isReferenceSubAttribute && !editable);
|
|
54
53
|
var showStatusChips = !isParentLineRejected;
|
|
55
54
|
var isRejected = isLineRejected || isParentLineRejected;
|
|
@@ -60,7 +59,7 @@ export var ChangeItemEditor = function (_a) {
|
|
|
60
59
|
shouldShowValueEditor ? (React.createElement(DCRValueEditor, { attributeType: change.attributeType, value: currentNewValue, onChange: handleChange, disabled: !editable || isRejected })) : (hasNewValue && (React.createElement("div", { className: styles.value },
|
|
61
60
|
React.createElement(DataTypeValue, { value: preparedValue, dataTypeDefinition: dataTypeDefinition }))))),
|
|
62
61
|
React.createElement("div", { className: styles.revertColumn }, showUndoButton && (React.createElement(SmallIconButton, { icon: ReplayIcon, onClick: handleRevert, className: styles.revertButton, title: i18n.text('Undo'), size: "S" }))),
|
|
63
|
-
React.createElement("div", { className: styles.operationColumn },
|
|
62
|
+
React.createElement("div", { className: styles.operationColumn }, change.operation && React.createElement(OperationChip, { operation: change.operation, size: "small", variant: "outlined" })),
|
|
64
63
|
React.createElement("div", { className: styles.statusColumn }, showStatusChips && React.createElement(StatusChips, { showUpdatedChip: isUpdated, showRejectedChip: isLineRejected })),
|
|
65
64
|
React.createElement("div", { className: styles.rejectColumn }, showRejectButton && (React.createElement(Button, { onClick: handleReject, className: classnames(styles.rejectButton, classes === null || classes === void 0 ? void 0 : classes.rejectButton), title: i18n.text('Reject'), size: "medium" }, i18n.text('Reject'))))));
|
|
66
65
|
};
|
|
@@ -3,7 +3,7 @@ import React from 'react';
|
|
|
3
3
|
import { useContextSelector } from '@fluentui/react-context-selector';
|
|
4
4
|
import { DCROperationTypes } from '@reltio/mdm-sdk';
|
|
5
5
|
import { isEditableChange } from '../../helpers/helpers';
|
|
6
|
-
import { ChangeRequestEditorContext } from '
|
|
6
|
+
import { ChangeRequestEditorContext } from '../../../contexts/ChangeRequestEditorContext';
|
|
7
7
|
import { ChangeItemEditor, ChangeItemOldValue } from '../ChangeItemEditor';
|
|
8
8
|
import { extractLineIds } from '../../../helpers/merge';
|
|
9
9
|
import styles from './ChangeItemRow.module.css';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AttributeType, ChangeValue, PrimitiveValue, SimpleAttributeValue } from '@reltio/mdm-sdk';
|
|
3
|
-
import { LineDataValue } from '
|
|
3
|
+
import { LineDataValue } from '../../../contexts/ChangeRequestEditorContext';
|
|
4
4
|
type Props = {
|
|
5
5
|
attributeType: AttributeType;
|
|
6
6
|
value: LineDataValue | ChangeValue;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { AttributeType, ChangeValue, DataTypeDefinition, PrimitiveValue, SimpleAttributeValue } from '@reltio/mdm-sdk';
|
|
3
|
-
import { LineDataValue } from '
|
|
3
|
+
import { LineDataValue } from '../../../contexts/ChangeRequestEditorContext';
|
|
4
4
|
type Props = {
|
|
5
5
|
attributeType: AttributeType;
|
|
6
6
|
value: LineDataValue | ChangeValue;
|
|
@@ -7,10 +7,11 @@ export declare const useChangeRequestEditor: ({ change }: Props) => {
|
|
|
7
7
|
handleChange: (newValue: SimpleAttributeValue | string[] | PrimitiveValue) => void;
|
|
8
8
|
handleReject: () => void;
|
|
9
9
|
handleRevert: () => void;
|
|
10
|
-
lineData: import("
|
|
10
|
+
lineData: import("../../contexts/ChangeRequestEditorContext").LineData;
|
|
11
11
|
isLineRejected: boolean;
|
|
12
12
|
isParentLineRejected: boolean;
|
|
13
13
|
isUpdated: boolean;
|
|
14
14
|
hasChangeId: boolean;
|
|
15
|
+
isSubAttributeOfDeletedAttribute: any;
|
|
15
16
|
};
|
|
16
17
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useCallback } from 'react';
|
|
2
2
|
import { useContextSelector } from '@fluentui/react-context-selector';
|
|
3
|
-
import {
|
|
3
|
+
import { DCROperationTypes } from '@reltio/mdm-sdk';
|
|
4
|
+
import { ChangeRequestEditorContext } from '../../contexts/ChangeRequestEditorContext';
|
|
4
5
|
import { extractLineIds } from '../../helpers/merge';
|
|
5
6
|
var emptyLineIds = [];
|
|
6
7
|
export var useChangeRequestEditor = function (_a) {
|
|
@@ -16,6 +17,10 @@ export var useChangeRequestEditor = function (_a) {
|
|
|
16
17
|
var isUpdated = useContextSelector(ChangeRequestEditorContext, function (context) { return context.getIsLineUpdated(lineIds[0]); });
|
|
17
18
|
var isLineRejected = lineData === null || lineData === void 0 ? void 0 : lineData.isRejected;
|
|
18
19
|
var hasChangeId = lineIds.length > 0;
|
|
20
|
+
var isSubAttributeOfDeletedAttribute = change.operation === DCROperationTypes.DELETED &&
|
|
21
|
+
change.level > 0 &&
|
|
22
|
+
lineIds.length > 0 &&
|
|
23
|
+
lineIds[0].includes('/value/');
|
|
19
24
|
var handleChange = useCallback(function (newValue) {
|
|
20
25
|
updateChange(lineIds, typeof newValue === 'object' && 'value' in newValue ? newValue : { value: newValue });
|
|
21
26
|
}, [lineIds, updateChange]);
|
|
@@ -33,6 +38,7 @@ export var useChangeRequestEditor = function (_a) {
|
|
|
33
38
|
isLineRejected: isLineRejected,
|
|
34
39
|
isParentLineRejected: isParentLineRejected,
|
|
35
40
|
isUpdated: isUpdated,
|
|
36
|
-
hasChangeId: hasChangeId
|
|
41
|
+
hasChangeId: hasChangeId,
|
|
42
|
+
isSubAttributeOfDeletedAttribute: isSubAttributeOfDeletedAttribute
|
|
37
43
|
};
|
|
38
44
|
};
|