@reltio/components 1.4.2207 → 1.4.2209
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/ChangeRequestEditor.js +1 -2
- package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.js +2 -1
- package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemLabel/ChangeItemLabel.js +8 -3
- package/cjs/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.js +49 -8
- 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 +2 -1
- package/cjs/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.js +14 -8
- 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 +12 -7
- package/cjs/features/workflow/TaskActionButtons/TaskActionButtons.js +6 -4
- package/cjs/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +10 -3
- package/cjs/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/GenericWorkflowTaskCard.js +6 -4
- package/cjs/features/workflow/{ChangeRequestEditor/context → contexts/ChangeRequestEditorContext}/index.d.ts +20 -10
- package/cjs/features/workflow/{ChangeRequestEditor/context → contexts/ChangeRequestEditorContext}/index.js +40 -2
- 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 +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.d.ts +3 -0
- package/cjs/features/workflow/hooks/useApplyDcrChanges.js +155 -0
- package/cjs/features/workflow/hooks/useDCRValidation.d.ts +5 -0
- package/cjs/features/workflow/hooks/useDCRValidation.js +153 -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 +12 -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/ChangeRequestEditor.js +1 -2
- package/features/workflow/ChangeRequestEditor/components/ChangeItemEditor/ChangeItemEditor.js +2 -1
- package/features/workflow/ChangeRequestEditor/components/ChangeItemLabel/ChangeItemLabel.js +8 -3
- package/features/workflow/ChangeRequestEditor/components/ChangeItemRow/ChangeItemRow.js +23 -5
- 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 +2 -1
- package/features/workflow/ChangeRequestEditor/hooks/useChangeRequestEditor.js +8 -2
- 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 +12 -7
- package/features/workflow/TaskActionButtons/TaskActionButtons.js +6 -4
- package/features/workflow/WorkflowTaskCard/components/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +11 -4
- package/features/workflow/WorkflowTaskCard/components/GenericWorkflowTaskCard/GenericWorkflowTaskCard.js +6 -4
- package/features/workflow/{ChangeRequestEditor/context → contexts/ChangeRequestEditorContext}/index.d.ts +20 -10
- package/features/workflow/{ChangeRequestEditor/context → contexts/ChangeRequestEditorContext}/index.js +41 -3
- package/features/workflow/helpers/dcr.d.ts +8 -1
- package/features/workflow/helpers/dcr.js +186 -2
- 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.d.ts +3 -0
- package/features/workflow/hooks/useApplyDcrChanges.js +151 -0
- package/features/workflow/hooks/useDCRValidation.d.ts +5 -0
- package/features/workflow/hooks/useDCRValidation.js +149 -0
- package/features/workflow/hooks/useWorkflowActions.d.ts +7 -2
- package/features/workflow/hooks/useWorkflowActions.js +31 -8
- package/features/workflow/types.d.ts +12 -1
- package/hooks/useScrollToAttributeError/useScrollToAttributeError.d.ts +2 -1
- package/hooks/useScrollToAttributeError/useScrollToAttributeError.js +2 -2
- package/package.json +2 -2
|
@@ -0,0 +1,155 @@
|
|
|
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 useDCRValidation_1 = require("./useDCRValidation");
|
|
48
|
+
var withChangeRequestId = function (dcrUri) { return function (url) {
|
|
49
|
+
return url + (url.includes('?') ? '&' : '?') + "changeRequestId=".concat(encodeURIComponent(dcrUri.split('/')[1]));
|
|
50
|
+
}; };
|
|
51
|
+
var useApplyDcrChanges = function (dcr) {
|
|
52
|
+
var getLinesByChangeId = (0, react_context_selector_1.useContextSelector)(ChangeRequestEditorContext_1.ChangeRequestEditorContext, function (context) { return context.getLinesByChangeId; });
|
|
53
|
+
var metadata = (0, MdmModuleContext_1.useMdmMetadata)();
|
|
54
|
+
var getErrors = (0, useDCRValidation_1.useDCRValidation)(dcr);
|
|
55
|
+
var applyDcrChanges = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
+
var errors, _a, rejectedChangeIds, updatedChanges, deleteEntityAttributes, deleteRelationAttributes, deleteChangeResults, deleteEntityAttributesResults, deleteRelationAttributesResults, deleteChangeFailures, error_1, deleteEntityAttributesFailures, deleteRelationAttributesFailures;
|
|
57
|
+
return __generator(this, function (_b) {
|
|
58
|
+
switch (_b.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
if (!(dcr === null || dcr === void 0 ? void 0 : dcr.changes)) return [3 /*break*/, 12];
|
|
61
|
+
return [4 /*yield*/, getErrors()];
|
|
62
|
+
case 1:
|
|
63
|
+
errors = _b.sent();
|
|
64
|
+
if (errors.length > 0) {
|
|
65
|
+
return [2 /*return*/, {
|
|
66
|
+
proceed: false
|
|
67
|
+
}];
|
|
68
|
+
}
|
|
69
|
+
_a = (0, dcr_1.buildDCRSavePlan)(dcr.changes, getLinesByChangeId, metadata), rejectedChangeIds = _a.rejectedChangeIds, updatedChanges = _a.updatedChanges, deleteEntityAttributes = _a.deleteEntityAttributes, deleteRelationAttributes = _a.deleteRelationAttributes;
|
|
70
|
+
deleteChangeResults = [];
|
|
71
|
+
deleteEntityAttributesResults = [];
|
|
72
|
+
deleteRelationAttributesResults = [];
|
|
73
|
+
if (!(rejectedChangeIds.length > 0)) return [3 /*break*/, 3];
|
|
74
|
+
return [4 /*yield*/, (0, mdm_sdk_1.promiseAllSettled)(rejectedChangeIds.map(function (changeId) {
|
|
75
|
+
return (0, mdm_sdk_1.deleteChangeRequestItem)({ dcrUri: dcr.uri, changeItemId: changeId });
|
|
76
|
+
}))];
|
|
77
|
+
case 2:
|
|
78
|
+
deleteChangeResults = _b.sent();
|
|
79
|
+
_b.label = 3;
|
|
80
|
+
case 3:
|
|
81
|
+
deleteChangeFailures = deleteChangeResults.filter(function (result) { return result.status === 'rejected'; });
|
|
82
|
+
if (deleteChangeFailures.length) {
|
|
83
|
+
return [2 /*return*/, {
|
|
84
|
+
proceed: false,
|
|
85
|
+
error: new Error("Failed to delete DCR change(s): ".concat(deleteChangeFailures.map(function (result) { return result.reason; }).join(', ')))
|
|
86
|
+
}];
|
|
87
|
+
}
|
|
88
|
+
if (!!(0, ramda_1.isEmpty)(updatedChanges)) return [3 /*break*/, 7];
|
|
89
|
+
_b.label = 4;
|
|
90
|
+
case 4:
|
|
91
|
+
_b.trys.push([4, 6, , 7]);
|
|
92
|
+
return [4 /*yield*/, (0, mdm_sdk_1.updateChangeRequest)({ dcrUri: dcr.uri, payload: updatedChanges })];
|
|
93
|
+
case 5:
|
|
94
|
+
_b.sent();
|
|
95
|
+
return [3 /*break*/, 7];
|
|
96
|
+
case 6:
|
|
97
|
+
error_1 = _b.sent();
|
|
98
|
+
return [2 /*return*/, {
|
|
99
|
+
proceed: false,
|
|
100
|
+
error: error_1
|
|
101
|
+
}];
|
|
102
|
+
case 7:
|
|
103
|
+
if (!!(0, ramda_1.isEmpty)(deleteEntityAttributes)) return [3 /*break*/, 9];
|
|
104
|
+
return [4 /*yield*/, (0, mdm_sdk_1.promiseAllSettled)(Object.entries(deleteEntityAttributes).map(function (_a) {
|
|
105
|
+
var entityUri = _a[0], diff = _a[1];
|
|
106
|
+
return (0, mdm_sdk_1.entityCumulativeUpdate)({
|
|
107
|
+
uri: entityUri,
|
|
108
|
+
diff: diff,
|
|
109
|
+
uriPreprocessor: withChangeRequestId(dcr.uri)
|
|
110
|
+
});
|
|
111
|
+
}))];
|
|
112
|
+
case 8:
|
|
113
|
+
deleteEntityAttributesResults = _b.sent();
|
|
114
|
+
_b.label = 9;
|
|
115
|
+
case 9:
|
|
116
|
+
deleteEntityAttributesFailures = deleteEntityAttributesResults.filter(function (result) { return result.status === 'rejected'; });
|
|
117
|
+
if (deleteEntityAttributesFailures.length) {
|
|
118
|
+
return [2 /*return*/, {
|
|
119
|
+
proceed: false,
|
|
120
|
+
error: new Error("Failed to delete entity attributes: ".concat(deleteEntityAttributesFailures.map(function (result) { return result.reason; }).join(', ')))
|
|
121
|
+
}];
|
|
122
|
+
}
|
|
123
|
+
if (!!(0, ramda_1.isEmpty)(deleteRelationAttributes)) return [3 /*break*/, 11];
|
|
124
|
+
return [4 /*yield*/, (0, mdm_sdk_1.promiseAllSettled)(Object.entries(deleteRelationAttributes).map(function (_a) {
|
|
125
|
+
var relationUri = _a[0], diff = _a[1];
|
|
126
|
+
return (0, mdm_sdk_1.updateRelationWithDiff)({
|
|
127
|
+
uri: relationUri,
|
|
128
|
+
diff: diff,
|
|
129
|
+
uriPreprocessor: withChangeRequestId(dcr.uri)
|
|
130
|
+
});
|
|
131
|
+
}))];
|
|
132
|
+
case 10:
|
|
133
|
+
deleteRelationAttributesResults = _b.sent();
|
|
134
|
+
_b.label = 11;
|
|
135
|
+
case 11:
|
|
136
|
+
deleteRelationAttributesFailures = deleteRelationAttributesResults.filter(function (result) { return result.status === 'rejected'; });
|
|
137
|
+
if (deleteRelationAttributesFailures.length) {
|
|
138
|
+
return [2 /*return*/, {
|
|
139
|
+
proceed: false,
|
|
140
|
+
error: new Error("Failed to delete relation attributes: ".concat(deleteRelationAttributesFailures.map(function (result) { return result.reason; }).join(', ')))
|
|
141
|
+
}];
|
|
142
|
+
}
|
|
143
|
+
return [2 /*return*/, {
|
|
144
|
+
proceed: true
|
|
145
|
+
}];
|
|
146
|
+
case 12: return [2 /*return*/, {
|
|
147
|
+
proceed: false,
|
|
148
|
+
error: new Error('No changes to apply')
|
|
149
|
+
}];
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}); }, [dcr, getLinesByChangeId, metadata, getErrors]);
|
|
153
|
+
return applyDcrChanges;
|
|
154
|
+
};
|
|
155
|
+
exports.useApplyDcrChanges = useApplyDcrChanges;
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
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);
|
|
24
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.useDCRValidation = void 0;
|
|
51
|
+
var react_1 = require("react");
|
|
52
|
+
var react_context_selector_1 = require("@fluentui/react-context-selector");
|
|
53
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
54
|
+
var MdmModuleContext_1 = require("../../../contexts/MdmModuleContext");
|
|
55
|
+
var useSafePromise_1 = require("../../../hooks/useSafePromise");
|
|
56
|
+
var context_1 = require("../../../contexts/MdmModuleContext/context");
|
|
57
|
+
var ChangeRequestEditorContext_1 = require("../contexts/ChangeRequestEditorContext");
|
|
58
|
+
var validation_1 = require("../helpers/validation");
|
|
59
|
+
var useDCRValidation = function (dcr) {
|
|
60
|
+
var metadata = (0, MdmModuleContext_1.useMdmMetadata)();
|
|
61
|
+
var currentEntity = (0, MdmModuleContext_1.useMdmEntity)();
|
|
62
|
+
var dcrReviewValidation = (0, MdmModuleContext_1.useMdmDcrReviewValidation)();
|
|
63
|
+
var relationsState = (0, react_context_selector_1.useContextSelector)(context_1.MdmModuleValuesContext, function (context) { return context.relations; });
|
|
64
|
+
var getAllChanges = (0, react_context_selector_1.useContextSelector)(ChangeRequestEditorContext_1.ChangeRequestEditorContext, function (context) { return context.getAllChanges; });
|
|
65
|
+
var setErrors = (0, react_context_selector_1.useContextSelector)(ChangeRequestEditorContext_1.ChangeRequestEditorContext, function (context) { return context.setErrors; });
|
|
66
|
+
var relationsRef = (0, react_1.useRef)(null);
|
|
67
|
+
var safePromise = (0, useSafePromise_1.useSafePromise)();
|
|
68
|
+
var findRelationInStore = (0, react_1.useCallback)(function (uri) {
|
|
69
|
+
if (!relationsState)
|
|
70
|
+
return null;
|
|
71
|
+
for (var viewId in relationsState) {
|
|
72
|
+
var viewState = relationsState[viewId];
|
|
73
|
+
if (viewState === null || viewState === void 0 ? void 0 : viewState.connections) {
|
|
74
|
+
return (0, mdm_sdk_1.findConnectionRelationObjectByRelationUri)(viewState.connections, uri);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return null;
|
|
78
|
+
}, [relationsState]);
|
|
79
|
+
var urisFromDcr = (0, react_1.useMemo)(function () {
|
|
80
|
+
var result = [];
|
|
81
|
+
if (!(dcr === null || dcr === void 0 ? void 0 : dcr.changes))
|
|
82
|
+
return result;
|
|
83
|
+
for (var key in dcr.changes) {
|
|
84
|
+
var changes = dcr.changes[key] || [];
|
|
85
|
+
var hasCreate = changes.some(function (c) { return (c === null || c === void 0 ? void 0 : c.type) === mdm_sdk_1.DCRTypes.CREATE_ENTITY || (c === null || c === void 0 ? void 0 : c.type) === mdm_sdk_1.DCRTypes.CREATE_RELATIONSHIP; });
|
|
86
|
+
if (!hasCreate) {
|
|
87
|
+
result.push(key);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
}, [dcr]);
|
|
92
|
+
var localObjects = (0, react_1.useMemo)(function () {
|
|
93
|
+
var currentEntityObject = {};
|
|
94
|
+
currentEntityObject[currentEntity === null || currentEntity === void 0 ? void 0 : currentEntity.uri] = currentEntity;
|
|
95
|
+
return urisFromDcr.reduce(function (acc, uri) {
|
|
96
|
+
if ((0, mdm_sdk_1.isRelationUri)(uri)) {
|
|
97
|
+
var localRelation = findRelationInStore(uri);
|
|
98
|
+
if (localRelation) {
|
|
99
|
+
acc[uri] = localRelation;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return acc;
|
|
103
|
+
}, currentEntityObject);
|
|
104
|
+
}, [urisFromDcr, findRelationInStore, currentEntity]);
|
|
105
|
+
(0, react_1.useEffect)(function () {
|
|
106
|
+
if (!dcrReviewValidation || !urisFromDcr.length || (relationsRef === null || relationsRef === void 0 ? void 0 : relationsRef.current))
|
|
107
|
+
return;
|
|
108
|
+
var relationsPromises = [];
|
|
109
|
+
urisFromDcr.forEach(function (uri) {
|
|
110
|
+
if ((0, mdm_sdk_1.isRelationUri)(uri) && !localObjects[uri]) {
|
|
111
|
+
relationsPromises.push((0, mdm_sdk_1.getRelation)(uri));
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
relationsRef.current = safePromise(Promise.all(relationsPromises));
|
|
115
|
+
}, [dcrReviewValidation, urisFromDcr, findRelationInStore, safePromise, localObjects]);
|
|
116
|
+
var getErrors = (0, react_1.useCallback)(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
117
|
+
var relations, _a, loadedRelationsObject, objectsByUri, userChanges, errors;
|
|
118
|
+
return __generator(this, function (_b) {
|
|
119
|
+
switch (_b.label) {
|
|
120
|
+
case 0:
|
|
121
|
+
if (!dcrReviewValidation) {
|
|
122
|
+
return [2 /*return*/, []];
|
|
123
|
+
}
|
|
124
|
+
if (!relationsRef.current) return [3 /*break*/, 2];
|
|
125
|
+
return [4 /*yield*/, relationsRef.current];
|
|
126
|
+
case 1:
|
|
127
|
+
_a = _b.sent();
|
|
128
|
+
return [3 /*break*/, 3];
|
|
129
|
+
case 2:
|
|
130
|
+
_a = [];
|
|
131
|
+
_b.label = 3;
|
|
132
|
+
case 3:
|
|
133
|
+
relations = _a;
|
|
134
|
+
loadedRelationsObject = relations.reduce(function (acc, relation) {
|
|
135
|
+
acc[relation.uri] = relation;
|
|
136
|
+
return acc;
|
|
137
|
+
}, {});
|
|
138
|
+
objectsByUri = __assign(__assign({}, localObjects), loadedRelationsObject);
|
|
139
|
+
userChanges = getAllChanges();
|
|
140
|
+
errors = (0, validation_1.getValidationErrors)({
|
|
141
|
+
changes: dcr === null || dcr === void 0 ? void 0 : dcr.changes,
|
|
142
|
+
userChanges: userChanges,
|
|
143
|
+
entitiesOrRelations: objectsByUri,
|
|
144
|
+
metadata: metadata
|
|
145
|
+
});
|
|
146
|
+
setErrors(errors);
|
|
147
|
+
return [2 /*return*/, errors];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}); }, [dcrReviewValidation, dcr === null || dcr === void 0 ? void 0 : dcr.changes, getAllChanges, localObjects, metadata, setErrors]);
|
|
151
|
+
return getErrors;
|
|
152
|
+
};
|
|
153
|
+
exports.useDCRValidation = useDCRValidation;
|
|
@@ -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) {
|
|
@@ -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;
|
|
@@ -19,3 +19,14 @@ export type Diff = {
|
|
|
19
19
|
export type Title = {
|
|
20
20
|
label: string;
|
|
21
21
|
};
|
|
22
|
+
export type BeforeActionOutcome = {
|
|
23
|
+
proceed: boolean;
|
|
24
|
+
error?: unknown;
|
|
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
|
} | {
|
|
@@ -11,7 +11,7 @@ var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
|
11
11
|
var styles_1 = require("./styles");
|
|
12
12
|
var useScrollToAttributeError = function (_a) {
|
|
13
13
|
var _b;
|
|
14
|
-
var context = _a.highlightedError, _c = _a.isSimple, isSimple = _c === void 0 ? false : _c;
|
|
14
|
+
var context = _a.highlightedError, _c = _a.isSimple, isSimple = _c === void 0 ? false : _c, className = _a.className;
|
|
15
15
|
var styles = (0, styles_1.useStyles)();
|
|
16
16
|
var ref = (0, react_1.useRef)(null);
|
|
17
17
|
var severity = (0, ramda_1.pathOr)(mdm_sdk_1.ErrorSeverity.ERROR, ['element', 'severity'])(context);
|
|
@@ -19,7 +19,7 @@ var useScrollToAttributeError = function (_a) {
|
|
|
19
19
|
_b[styles.highlightError] = severity === mdm_sdk_1.ErrorSeverity.ERROR,
|
|
20
20
|
_b[styles.highlightWarning] = severity === mdm_sdk_1.ErrorSeverity.WARNING,
|
|
21
21
|
_b[styles.simpleAttribute] = isSimple,
|
|
22
|
-
_b));
|
|
22
|
+
_b), className);
|
|
23
23
|
(0, react_1.useEffect)(function () {
|
|
24
24
|
if (context) {
|
|
25
25
|
context.scrollIntoRef(ref);
|
|
@@ -58,6 +58,7 @@ export type MdmModuleValuesContextProps = Partial<{
|
|
|
58
58
|
uiConfigProfile: Profile;
|
|
59
59
|
showMasking: boolean;
|
|
60
60
|
reviewDCREnabled: boolean;
|
|
61
|
+
dcrReviewValidation: boolean;
|
|
61
62
|
}>;
|
|
62
63
|
export type MdmModuleActionsContextProps = Partial<{
|
|
63
64
|
openSearch: (payload: SearchState) => void;
|
|
@@ -264,6 +265,7 @@ export declare const MdmModuleValuesContext: import("@fluentui/react-context-sel
|
|
|
264
265
|
uiConfigProfile: Profile;
|
|
265
266
|
showMasking: boolean;
|
|
266
267
|
reviewDCREnabled: boolean;
|
|
268
|
+
dcrReviewValidation: boolean;
|
|
267
269
|
}>>;
|
|
268
270
|
export declare const MdmModuleListenersContext: import("@fluentui/react-context-selector").Context<Partial<{
|
|
269
271
|
expandInvalidRelatonsListener: (callback: () => void) => (action: any) => void;
|
|
@@ -153,3 +153,4 @@ export declare const useMdmHiddenAttributes: () => Record<string, string[]>;
|
|
|
153
153
|
export declare const useMdmControlAttributes: () => string[];
|
|
154
154
|
export declare const useMdmShowMasking: () => boolean;
|
|
155
155
|
export declare const useMdmReviewDCREnabled: () => boolean;
|
|
156
|
+
export declare const useMdmDcrReviewValidation: () => boolean;
|
|
@@ -162,3 +162,4 @@ export var useMdmControlAttributes = function () {
|
|
|
162
162
|
};
|
|
163
163
|
export var useMdmShowMasking = function () { return useMdmModuleValuesContext(function (context) { return context.showMasking; }); };
|
|
164
164
|
export var useMdmReviewDCREnabled = function () { return useMdmModuleValuesContext(function (context) { return context.reviewDCREnabled; }); };
|
|
165
|
+
export var useMdmDcrReviewValidation = function () { return useMdmModuleValuesContext(function (context) { return context.dcrReviewValidation; }); };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { MdmModuleProvider } from './provider';
|
|
2
|
-
export { useMdmAutoCloseInterval, useMdmUiError, useMdmWorkflowEnvironmentUrl, useMdmExportPath, useMdmAbsoluteImagePath, useMdmUiPath, useMdmDtssPath, useMdmServicesPath, useMdmWorkflowPath, useMdmImageServicePath, useMdmReltioPath, useMdmApiPath, useMdmCollaborationPath, useMdmImageAttributesFieldsOrder, useMdmShowEntityId, useMdmPivotingAttributes, useMdmDateMask, useMdmDateTimeMask, useMdmAttributesPresentation, useMdmMaxValuesInResponse, useMdmAttributesSortingStrategy, useMdmLookupAutocomplete, useMdmModifiedEntities, useMdmEntity, useMdmEntityUri, useMdmEntityWithDiff, useMdmEntityUriWithDataTenant, useMdmMode, useMdmIsViewMode, useMdmIsEditableMode, useMdmHistoryDiff, useMdmHistoryMode, useMdmHistorySlice, useMdmHistoryEvent, useMdmProfileLastLoadedTime, useMdmLookups, useMdmDependentLookups, useMdmMetadata, useMdmUser, useMdmUsername, useMdmUserRoles, useMdmTenantObject, useMdmTenant, useMdmTenantName, useMdmEnvironment, useMdmDataTenants, useMdmSearchNavigationData, useMdmSearchProviderData, useMdmIsCollaborationEnabled, useMdmIsWorkflowEnabled, useMdmProfileErrors, useMdmRelationsDrafts, useMdmModifiedEntityDefaultProfilePic, useMdmModifiedEntity, useMdmInitialConnectionTempEntity, useMdmInitialConnection, useMdmDependentLookupEditorState, useMdmActiveErrorsForAttributesPager, useMdmDependentLookupsStructureNode, useMdmAllRelationsToAddAndEdit, useMdmDependentLookupEditorContext, useMdmGlobalSearchRequestOptions, useMdmAuthoringItemsByEntityType, useMdmAction, useMdmListener, useMdmIsSourcesScreenEnabled, useMdmHiddenAttributes, useMdmControlAttributes, useMdmShowMasking, useMdmReviewDCREnabled, useMdmImagePath } from './hooks';
|
|
2
|
+
export { useMdmAutoCloseInterval, useMdmUiError, useMdmWorkflowEnvironmentUrl, useMdmExportPath, useMdmAbsoluteImagePath, useMdmUiPath, useMdmDtssPath, useMdmServicesPath, useMdmWorkflowPath, useMdmImageServicePath, useMdmReltioPath, useMdmApiPath, useMdmCollaborationPath, useMdmImageAttributesFieldsOrder, useMdmShowEntityId, useMdmPivotingAttributes, useMdmDateMask, useMdmDateTimeMask, useMdmAttributesPresentation, useMdmMaxValuesInResponse, useMdmAttributesSortingStrategy, useMdmLookupAutocomplete, useMdmModifiedEntities, useMdmEntity, useMdmEntityUri, useMdmEntityWithDiff, useMdmEntityUriWithDataTenant, useMdmMode, useMdmIsViewMode, useMdmIsEditableMode, useMdmHistoryDiff, useMdmHistoryMode, useMdmHistorySlice, useMdmHistoryEvent, useMdmProfileLastLoadedTime, useMdmLookups, useMdmDependentLookups, useMdmMetadata, useMdmUser, useMdmUsername, useMdmUserRoles, useMdmTenantObject, useMdmTenant, useMdmTenantName, useMdmEnvironment, useMdmDataTenants, useMdmSearchNavigationData, useMdmSearchProviderData, useMdmIsCollaborationEnabled, useMdmIsWorkflowEnabled, useMdmProfileErrors, useMdmRelationsDrafts, useMdmModifiedEntityDefaultProfilePic, useMdmModifiedEntity, useMdmInitialConnectionTempEntity, useMdmInitialConnection, useMdmDependentLookupEditorState, useMdmActiveErrorsForAttributesPager, useMdmDependentLookupsStructureNode, useMdmAllRelationsToAddAndEdit, useMdmDependentLookupEditorContext, useMdmGlobalSearchRequestOptions, useMdmAuthoringItemsByEntityType, useMdmAction, useMdmListener, useMdmIsSourcesScreenEnabled, useMdmHiddenAttributes, useMdmControlAttributes, useMdmShowMasking, useMdmReviewDCREnabled, useMdmDcrReviewValidation, useMdmImagePath } from './hooks';
|
|
3
3
|
export type { MdmModuleActionsContextProps, MdmModuleValuesContextProps, MdmModuleListenersContextProps } from './context';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { MdmModuleProvider } from './provider';
|
|
2
|
-
export { useMdmAutoCloseInterval, useMdmUiError, useMdmWorkflowEnvironmentUrl, useMdmExportPath, useMdmAbsoluteImagePath, useMdmUiPath, useMdmDtssPath, useMdmServicesPath, useMdmWorkflowPath, useMdmImageServicePath, useMdmReltioPath, useMdmApiPath, useMdmCollaborationPath, useMdmImageAttributesFieldsOrder, useMdmShowEntityId, useMdmPivotingAttributes, useMdmDateMask, useMdmDateTimeMask, useMdmAttributesPresentation, useMdmMaxValuesInResponse, useMdmAttributesSortingStrategy, useMdmLookupAutocomplete, useMdmModifiedEntities, useMdmEntity, useMdmEntityUri, useMdmEntityWithDiff, useMdmEntityUriWithDataTenant, useMdmMode, useMdmIsViewMode, useMdmIsEditableMode, useMdmHistoryDiff, useMdmHistoryMode, useMdmHistorySlice, useMdmHistoryEvent, useMdmProfileLastLoadedTime, useMdmLookups, useMdmDependentLookups, useMdmMetadata, useMdmUser, useMdmUsername, useMdmUserRoles, useMdmTenantObject, useMdmTenant, useMdmTenantName, useMdmEnvironment, useMdmDataTenants, useMdmSearchNavigationData, useMdmSearchProviderData, useMdmIsCollaborationEnabled, useMdmIsWorkflowEnabled, useMdmProfileErrors, useMdmRelationsDrafts, useMdmModifiedEntityDefaultProfilePic, useMdmModifiedEntity, useMdmInitialConnectionTempEntity, useMdmInitialConnection, useMdmDependentLookupEditorState, useMdmActiveErrorsForAttributesPager, useMdmDependentLookupsStructureNode, useMdmAllRelationsToAddAndEdit, useMdmDependentLookupEditorContext, useMdmGlobalSearchRequestOptions, useMdmAuthoringItemsByEntityType, useMdmAction, useMdmListener, useMdmIsSourcesScreenEnabled, useMdmHiddenAttributes, useMdmControlAttributes, useMdmShowMasking, useMdmReviewDCREnabled, useMdmImagePath } from './hooks';
|
|
2
|
+
export { useMdmAutoCloseInterval, useMdmUiError, useMdmWorkflowEnvironmentUrl, useMdmExportPath, useMdmAbsoluteImagePath, useMdmUiPath, useMdmDtssPath, useMdmServicesPath, useMdmWorkflowPath, useMdmImageServicePath, useMdmReltioPath, useMdmApiPath, useMdmCollaborationPath, useMdmImageAttributesFieldsOrder, useMdmShowEntityId, useMdmPivotingAttributes, useMdmDateMask, useMdmDateTimeMask, useMdmAttributesPresentation, useMdmMaxValuesInResponse, useMdmAttributesSortingStrategy, useMdmLookupAutocomplete, useMdmModifiedEntities, useMdmEntity, useMdmEntityUri, useMdmEntityWithDiff, useMdmEntityUriWithDataTenant, useMdmMode, useMdmIsViewMode, useMdmIsEditableMode, useMdmHistoryDiff, useMdmHistoryMode, useMdmHistorySlice, useMdmHistoryEvent, useMdmProfileLastLoadedTime, useMdmLookups, useMdmDependentLookups, useMdmMetadata, useMdmUser, useMdmUsername, useMdmUserRoles, useMdmTenantObject, useMdmTenant, useMdmTenantName, useMdmEnvironment, useMdmDataTenants, useMdmSearchNavigationData, useMdmSearchProviderData, useMdmIsCollaborationEnabled, useMdmIsWorkflowEnabled, useMdmProfileErrors, useMdmRelationsDrafts, useMdmModifiedEntityDefaultProfilePic, useMdmModifiedEntity, useMdmInitialConnectionTempEntity, useMdmInitialConnection, useMdmDependentLookupEditorState, useMdmActiveErrorsForAttributesPager, useMdmDependentLookupsStructureNode, useMdmAllRelationsToAddAndEdit, useMdmDependentLookupEditorContext, useMdmGlobalSearchRequestOptions, useMdmAuthoringItemsByEntityType, useMdmAction, useMdmListener, useMdmIsSourcesScreenEnabled, useMdmHiddenAttributes, useMdmControlAttributes, useMdmShowMasking, useMdmReviewDCREnabled, useMdmDcrReviewValidation, useMdmImagePath } from './hooks';
|
|
@@ -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,7 +21,7 @@ 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;
|
|
@@ -48,6 +48,7 @@ export var ChangeItemEditor = function (_a) {
|
|
|
48
48
|
!isUpdated &&
|
|
49
49
|
!isParentLineRejected &&
|
|
50
50
|
hasChangeId &&
|
|
51
|
+
!isSubAttributeOfDeletedAttribute &&
|
|
51
52
|
!(change.isReferenceSubAttribute && !editable);
|
|
52
53
|
var showStatusChips = !isParentLineRejected;
|
|
53
54
|
var isRejected = isLineRejected || isParentLineRejected;
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
3
|
import { useCssVariableStyles } from '../../../../../hooks/useCssVariableStyles';
|
|
4
|
+
import { RequiredMark } from '../../../../../RequiredMark';
|
|
4
5
|
import styles from './ChangeItemLabel.module.css';
|
|
5
6
|
export var ChangeItemLabel = function (_a) {
|
|
6
|
-
var
|
|
7
|
-
var
|
|
7
|
+
var _b;
|
|
8
|
+
var change = _a.change, className = _a.className, _c = _a.showLabel, showLabel = _c === void 0 ? true : _c;
|
|
9
|
+
var _d = change.level, level = _d === void 0 ? 0 : _d, label = change.label;
|
|
10
|
+
var isRequired = (_b = change === null || change === void 0 ? void 0 : change.attributeType) === null || _b === void 0 ? void 0 : _b.required;
|
|
8
11
|
var variableStyles = useCssVariableStyles({
|
|
9
12
|
'--level': level
|
|
10
13
|
});
|
|
11
|
-
return (React.createElement("div", { className: classnames(styles.changeLabel, className), style: variableStyles }, showLabel &&
|
|
14
|
+
return (React.createElement("div", { className: classnames(styles.changeLabel, className), style: variableStyles }, showLabel && (React.createElement(React.Fragment, null,
|
|
15
|
+
label,
|
|
16
|
+
isRequired && React.createElement(RequiredMark, null)))));
|
|
12
17
|
};
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import classnames from 'classnames';
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useContext } 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
|
+
import { ErrorWrapper } from '../../../../../ErrorWrapper';
|
|
10
|
+
import { ScrollToElementContext, isHighlightedErrorType } from '../../../../../contexts/ScrollToElementContext';
|
|
11
|
+
import { useScrollToAttributeError } from '../../../../../hooks/useScrollToAttributeError';
|
|
9
12
|
import styles from './ChangeItemRow.module.css';
|
|
10
13
|
export var ChangeItemRow = function (_a) {
|
|
11
14
|
var _b;
|
|
@@ -20,13 +23,28 @@ export var ChangeItemRow = function (_a) {
|
|
|
20
23
|
var isUpdated = useContextSelector(ChangeRequestEditorContext, function (context) {
|
|
21
24
|
return context.getIsLineUpdated(lineIds === null || lineIds === void 0 ? void 0 : lineIds[0]);
|
|
22
25
|
});
|
|
26
|
+
var errorByLineId = useContextSelector(ChangeRequestEditorContext, function (context) {
|
|
27
|
+
return context.getErrorByLineId(lineIds === null || lineIds === void 0 ? void 0 : lineIds[0]);
|
|
28
|
+
});
|
|
29
|
+
var error = errorByLineId === null || errorByLineId === void 0 ? void 0 : errorByLineId.error;
|
|
30
|
+
var errorLineIds = (errorByLineId === null || errorByLineId === void 0 ? void 0 : errorByLineId.lineIds) || [];
|
|
31
|
+
var scrollToElementContext = useContext(ScrollToElementContext);
|
|
32
|
+
var highlightedError = scrollToElementContext === null || scrollToElementContext === void 0 ? void 0 : scrollToElementContext.element;
|
|
33
|
+
var isHighlighted = isHighlightedErrorType(scrollToElementContext === null || scrollToElementContext === void 0 ? void 0 : scrollToElementContext.type) &&
|
|
34
|
+
highlightedError &&
|
|
35
|
+
errorLineIds.includes(highlightedError.uri);
|
|
36
|
+
var _c = useScrollToAttributeError({
|
|
37
|
+
highlightedError: isHighlighted ? scrollToElementContext : null,
|
|
38
|
+
className: styles.changeItemRowWithError
|
|
39
|
+
}), ref = _c.ref, errorClassName = _c.errorClassName;
|
|
23
40
|
var isEditedOperation = change.operation === DCROperationTypes.EDITED;
|
|
24
41
|
var editable = isEditableChange(change, entityInfo);
|
|
25
|
-
return (React.createElement("div", { className: classnames(styles.changeItemRow, (_b = {},
|
|
42
|
+
return (React.createElement("div", { ref: ref, className: classnames(styles.changeItemRow, errorClassName, (_b = {},
|
|
26
43
|
_b[styles.editableRow] = editable,
|
|
27
44
|
_b[styles.changedRow] = isUpdated,
|
|
28
45
|
_b[styles.rejectedRow] = isLineRejected || isParentLineRejected,
|
|
29
46
|
_b)) },
|
|
30
|
-
|
|
31
|
-
|
|
47
|
+
React.createElement(ErrorWrapper, { errorMessage: error === null || error === void 0 ? void 0 : error.message, classes: { helperText: styles.errorText } },
|
|
48
|
+
isEditedOperation && React.createElement(ChangeItemOldValue, { change: change }),
|
|
49
|
+
React.createElement(ChangeItemEditor, { change: change, editable: editable, classes: { rejectButton: styles.rejectButton } }))));
|
|
32
50
|
};
|