@reltio/components 1.4.882 → 1.4.883
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/components/RelationEditor/RelationEditor.d.ts +31 -0
- package/cjs/components/RelationEditor/RelationEditor.js +175 -0
- package/cjs/components/RelationEditor/index.d.ts +142 -0
- package/cjs/components/RelationEditor/index.js +42 -0
- package/cjs/components/RelationEditor/styles.d.ts +1 -0
- package/cjs/components/RelationEditor/styles.js +36 -0
- package/cjs/components/index.d.ts +1 -0
- package/cjs/components/index.js +3 -1
- package/esm/components/RelationEditor/RelationEditor.d.ts +31 -0
- package/esm/components/RelationEditor/RelationEditor.js +151 -0
- package/esm/components/RelationEditor/index.d.ts +142 -0
- package/esm/components/RelationEditor/index.js +17 -0
- package/esm/components/RelationEditor/styles.d.ts +1 -0
- package/esm/components/RelationEditor/styles.js +33 -0
- package/esm/components/index.d.ts +1 -0
- package/esm/components/index.js +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export default RelationEditor;
|
|
2
|
+
declare function RelationEditor({ connection, modifiedEntity, allModifiedEntities, dispatch, config, mode, metadata, globalSearchRequestOptions, error }: {
|
|
3
|
+
connection: any;
|
|
4
|
+
modifiedEntity: any;
|
|
5
|
+
allModifiedEntities: any;
|
|
6
|
+
dispatch: any;
|
|
7
|
+
config: any;
|
|
8
|
+
mode: any;
|
|
9
|
+
metadata: any;
|
|
10
|
+
globalSearchRequestOptions: any;
|
|
11
|
+
error: any;
|
|
12
|
+
}): JSX.Element;
|
|
13
|
+
declare namespace RelationEditor {
|
|
14
|
+
namespace propTypes {
|
|
15
|
+
export { ConnectionType as connection };
|
|
16
|
+
export { EntityType as modifiedEntity };
|
|
17
|
+
export const allModifiedEntities: PropTypes.Requireable<object>;
|
|
18
|
+
export const dispatch: PropTypes.Requireable<(...args: any[]) => any>;
|
|
19
|
+
export { RelationsConfigType as config };
|
|
20
|
+
export const mode: PropTypes.Requireable<string>;
|
|
21
|
+
export { MetadataType as metadata };
|
|
22
|
+
export const globalSearchRequestOptions: PropTypes.Requireable<object>;
|
|
23
|
+
export { AttributeErrorType as error };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
import { ConnectionType } from "@reltio/mdm-sdk/src/constants";
|
|
27
|
+
import { EntityType } from "@reltio/mdm-sdk/src/constants";
|
|
28
|
+
import PropTypes from "prop-types";
|
|
29
|
+
import { RelationsConfigType } from "@reltio/mdm-sdk/src/constants";
|
|
30
|
+
import { MetadataType } from "@reltio/mdm-sdk/src/constants";
|
|
31
|
+
import { AttributeErrorType } from "@reltio/mdm-sdk/src/constants";
|
|
@@ -0,0 +1,175 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
26
|
+
if (mod && mod.__esModule) return mod;
|
|
27
|
+
var result = {};
|
|
28
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
29
|
+
__setModuleDefault(result, mod);
|
|
30
|
+
return result;
|
|
31
|
+
};
|
|
32
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
|
+
};
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
var react_1 = __importStar(require("react"));
|
|
37
|
+
var prop_types_1 = __importDefault(require("prop-types"));
|
|
38
|
+
var Button_1 = __importDefault(require("@material-ui/core/Button"));
|
|
39
|
+
var Typography_1 = __importDefault(require("@material-ui/core/Typography"));
|
|
40
|
+
var ui_i18n_1 = __importDefault(require("ui-i18n"));
|
|
41
|
+
var classnames_1 = __importDefault(require("classnames"));
|
|
42
|
+
var ramda_1 = require("ramda");
|
|
43
|
+
var styles_1 = require("./styles");
|
|
44
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
45
|
+
var mdm_module_1 = require("@reltio/mdm-module");
|
|
46
|
+
var Divider_1 = __importDefault(require("@material-ui/core/Divider"));
|
|
47
|
+
var ConnectionRelationTypeSelector_1 = __importDefault(require("../ConnectionRelationTypeSelector/ConnectionRelationTypeSelector"));
|
|
48
|
+
var ErrorWrapper_1 = __importDefault(require("../ErrorWrapper/ErrorWrapper"));
|
|
49
|
+
var EntitySelector_1 = __importDefault(require("../attributes/editMode/EntitySelector/EntitySelector"));
|
|
50
|
+
var AttributesList_1 = __importDefault(require("../attributes/editMode/AttributesList"));
|
|
51
|
+
var areRelatedEntitiesChanged = function (initial, actual) {
|
|
52
|
+
return initial.length !== actual.length || initial.some(function (_, i) { return initial[i] !== actual[i]; });
|
|
53
|
+
};
|
|
54
|
+
var RelationEditor = function (_a) {
|
|
55
|
+
var _b;
|
|
56
|
+
var connection = _a.connection, modifiedEntity = _a.modifiedEntity, allModifiedEntities = _a.allModifiedEntities, dispatch = _a.dispatch, config = _a.config, mode = _a.mode, metadata = _a.metadata, globalSearchRequestOptions = _a.globalSearchRequestOptions, error = _a.error;
|
|
57
|
+
var _c = connection.relation, relationUri = _c.relationUri, relationType = _c.relationType, direction = _c.direction;
|
|
58
|
+
var isNew = connection.isNew;
|
|
59
|
+
var styles = styles_1.useStyles();
|
|
60
|
+
var _d = react_1.useMemo(function () { return mdm_sdk_1.getInOutRelations({ config: config, direction: direction, relationType: relationType, mode: mode, metadata: metadata }); }, [config, direction, relationType, mode, metadata]), _e = _d.inRelations, inRelationTypes = _e === void 0 ? [] : _e, _f = _d.outRelations, outRelationTypes = _f === void 0 ? [] : _f;
|
|
61
|
+
var firstLevelRelationAttrTypes = react_1.useMemo(function () { return mdm_sdk_1.getRelationAttributesList(metadata, relationType); }, [
|
|
62
|
+
relationType,
|
|
63
|
+
metadata
|
|
64
|
+
]);
|
|
65
|
+
var attributeListEntity = react_1.useMemo(function () { return (__assign({ attributes: __assign({}, mdm_module_1.profile.relations.selectors.getRelationAttributesFromConnection(connection)) }, mdm_sdk_1.getActivenessAttributes(connection.relation))); }, [connection]);
|
|
66
|
+
var initialConnection = react_1.useRef(connection);
|
|
67
|
+
var initialModifiedEntity = react_1.useRef(modifiedEntity);
|
|
68
|
+
var relatedTempEntities = react_1.useMemo(function () { return mdm_sdk_1.findRelatedTemporaryEntities(allModifiedEntities, modifiedEntity); }, [
|
|
69
|
+
allModifiedEntities,
|
|
70
|
+
modifiedEntity
|
|
71
|
+
]);
|
|
72
|
+
var relatedTempEntitiesUrisHistory = react_1.useRef([]);
|
|
73
|
+
react_1.useEffect(function () {
|
|
74
|
+
relatedTempEntitiesUrisHistory.current = ramda_1.pipe(ramda_1.concat(relatedTempEntities.map(ramda_1.prop('uri'))), ramda_1.uniq)(relatedTempEntitiesUrisHistory.current);
|
|
75
|
+
}, [relatedTempEntities]);
|
|
76
|
+
var initialRelatedTempEntities = react_1.useRef(relatedTempEntities);
|
|
77
|
+
var defaultRelationType = mdm_sdk_1.getDefaultRelationTypeObject(inRelationTypes, outRelationTypes);
|
|
78
|
+
var hasChanges = initialConnection.current !== connection ||
|
|
79
|
+
initialModifiedEntity.current !== modifiedEntity ||
|
|
80
|
+
areRelatedEntitiesChanged(initialRelatedTempEntities.current, relatedTempEntities) ||
|
|
81
|
+
(connection.isNew && !mdm_sdk_1.isEmptyValue(ramda_1.path(['relation', 'object', 'attributes'], connection)));
|
|
82
|
+
var applyAction = isNew ? mdm_module_1.profile.relations.actions.addRelation : mdm_module_1.profile.relations.actions.editRelation;
|
|
83
|
+
var onRelationTypeChange = react_1.useCallback(ramda_1.pipe(mdm_module_1.profile.relations.actions.setRelationType(config.id, relationUri), dispatch), [config, relationUri, dispatch]);
|
|
84
|
+
var handleClose = react_1.useCallback(function () { return ramda_1.pipe(mdm_module_1.profile.relations.actions.closeRelationEditor, dispatch)(config.id, relationUri); }, [config, relationUri, dispatch]);
|
|
85
|
+
var updateModifiedEntityLabel = react_1.useCallback(function (connection) {
|
|
86
|
+
if (modifiedEntity) {
|
|
87
|
+
var entityType = mdm_sdk_1.getEntityType(metadata, modifiedEntity.type);
|
|
88
|
+
return mdm_sdk_1.updateConnectionEntityLabel(entityType, modifiedEntity, connection);
|
|
89
|
+
}
|
|
90
|
+
return connection;
|
|
91
|
+
}, [modifiedEntity, metadata]);
|
|
92
|
+
var setModifiedEntity = react_1.useCallback(function (entity) { return dispatch(mdm_module_1.profile.modifiedEntities.actions.entityCreated(entity)); }, [dispatch]);
|
|
93
|
+
var deleteModifiedEntity = react_1.useCallback(function (entityUri) { return dispatch(mdm_module_1.profile.modifiedEntities.actions.entityDeleted(entityUri)); }, [dispatch]);
|
|
94
|
+
var onChangeEntity = react_1.useCallback(function (entity) {
|
|
95
|
+
if (modifiedEntity) {
|
|
96
|
+
deleteModifiedEntity(modifiedEntity.uri);
|
|
97
|
+
}
|
|
98
|
+
dispatch(mdm_module_1.profile.relations.actions.setRelationEntity(config.id, relationUri, entity));
|
|
99
|
+
if (error) {
|
|
100
|
+
dispatch(mdm_module_1.profile.errors.actions.errorDeactivated(mdm_sdk_1.getErrorId(error)));
|
|
101
|
+
}
|
|
102
|
+
}, [config.id, relationUri, dispatch, modifiedEntity, deleteModifiedEntity, error]);
|
|
103
|
+
var validate = react_1.useCallback(function () {
|
|
104
|
+
var errors = mdm_sdk_1.validateConnection(metadata, allModifiedEntities, connection);
|
|
105
|
+
dispatch(mdm_module_1.profile.errors.actions.errorsSet(errors));
|
|
106
|
+
return errors.length === 0;
|
|
107
|
+
}, [connection, metadata, allModifiedEntities, dispatch]);
|
|
108
|
+
var resetErrors = react_1.useCallback(function () { return dispatch(mdm_module_1.profile.errors.actions.errorsSet([])); }, [dispatch]);
|
|
109
|
+
var onApply = react_1.useCallback(ramda_1.pipe(ramda_1.always(connection), ramda_1.when(validate, ramda_1.pipe(mdm_sdk_1.omitMarks, updateModifiedEntityLabel, applyAction(config.id), dispatch, ramda_1.always(ramda_1.differenceWith(ramda_1.equals, relatedTempEntitiesUrisHistory.current, relatedTempEntities.map(ramda_1.prop('uri')))), ramda_1.forEach(deleteModifiedEntity), handleClose))), [connection, config, dispatch, updateModifiedEntityLabel, validate, relatedTempEntities]);
|
|
110
|
+
var onCancel = react_1.useCallback(function () {
|
|
111
|
+
var initialEntity = initialModifiedEntity.current;
|
|
112
|
+
if (modifiedEntity !== initialEntity) {
|
|
113
|
+
if (initialEntity) {
|
|
114
|
+
setModifiedEntity(initialEntity);
|
|
115
|
+
if (modifiedEntity && modifiedEntity.uri !== initialEntity.uri) {
|
|
116
|
+
deleteModifiedEntity(modifiedEntity.uri);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
deleteModifiedEntity(modifiedEntity.uri);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
var initialTempEntities = initialRelatedTempEntities.current;
|
|
124
|
+
var entitiesUrisToDelete = ramda_1.differenceWith(ramda_1.equals, relatedTempEntitiesUrisHistory.current, initialTempEntities.map(ramda_1.prop('uri')));
|
|
125
|
+
entitiesUrisToDelete.forEach(deleteModifiedEntity);
|
|
126
|
+
initialTempEntities.forEach(setModifiedEntity);
|
|
127
|
+
resetErrors();
|
|
128
|
+
handleClose();
|
|
129
|
+
}, [handleClose, setModifiedEntity, deleteModifiedEntity, resetErrors, modifiedEntity]);
|
|
130
|
+
var onAddAttributes = react_1.useCallback(function (params) {
|
|
131
|
+
return ramda_1.pipe(mdm_module_1.profile.actions.addAttributes, dispatch)(params.map(function (param) { return (__assign(__assign({}, param), { viewId: config.id })); }));
|
|
132
|
+
}, [config.id, dispatch]);
|
|
133
|
+
var onChangeAttribute = react_1.useCallback(function (params) { return ramda_1.pipe(mdm_module_1.profile.actions.modifyAttribute, dispatch)(__assign(__assign({}, params), { viewId: config.id })); }, [config.id, dispatch]);
|
|
134
|
+
var onDeleteAttribute = react_1.useCallback(function (params) { return ramda_1.pipe(mdm_module_1.profile.actions.removeAttribute, dispatch)(__assign(__assign({}, params), { viewId: config.id })); }, [config.id, dispatch]);
|
|
135
|
+
var onCreateEntity = react_1.useCallback(function (entityTypeUri, initValue) {
|
|
136
|
+
var entityType = mdm_sdk_1.getEntityType(metadata, entityTypeUri);
|
|
137
|
+
var newEntityAttrTypes = ramda_1.pipe(mdm_sdk_1.relationEditorAttributeTypesSelectionStrategy, mdm_sdk_1.getCreatableAttributeTypes(mode))(entityType);
|
|
138
|
+
var newEntity = mdm_sdk_1.createTemporaryEntity({
|
|
139
|
+
entityTypeUri: entityTypeUri,
|
|
140
|
+
initValue: initValue,
|
|
141
|
+
attributeTypes: newEntityAttrTypes,
|
|
142
|
+
metadata: metadata,
|
|
143
|
+
mode: mode
|
|
144
|
+
});
|
|
145
|
+
onChangeEntity(newEntity);
|
|
146
|
+
setModifiedEntity(newEntity);
|
|
147
|
+
}, [setModifiedEntity, onChangeEntity, mode, metadata]);
|
|
148
|
+
var errorMessage = mdm_sdk_1.getErrorMessage(error);
|
|
149
|
+
return (react_1.default.createElement(react_1.default.Fragment, null,
|
|
150
|
+
react_1.default.createElement("div", { className: styles.editor },
|
|
151
|
+
react_1.default.createElement(Typography_1.default, { className: styles.title }, isNew ? ui_i18n_1.default.text('Add new item') : ui_i18n_1.default.text('Edit item')),
|
|
152
|
+
defaultRelationType === null && (react_1.default.createElement(ConnectionRelationTypeSelector_1.default, { className: styles.item, relation: connection.relation, inRelationTypes: inRelationTypes, outRelationTypes: outRelationTypes, onChange: onRelationTypeChange })),
|
|
153
|
+
Boolean(relationType) && (react_1.default.createElement(react_1.default.Fragment, null,
|
|
154
|
+
react_1.default.createElement(ErrorWrapper_1.default, { errorMessage: errorMessage },
|
|
155
|
+
react_1.default.createElement(EntitySelector_1.default, { className: classnames_1.default(styles.item, (_b = {},
|
|
156
|
+
_b[styles.dense] = errorMessage || (connection.entity && mdm_sdk_1.isTempUri(connection.entity.entityUri)),
|
|
157
|
+
_b)), entity: connection.entity || {}, entityTypesUris: config.content.entityTypes || [], max: config.max || 20, globalSearchRequestOptions: globalSearchRequestOptions, mode: mode, onChange: onChangeEntity, onCreate: onCreateEntity, metadata: metadata, attributeTypesSelectionStrategy: mdm_sdk_1.relationEditorAttributeTypesSelectionStrategy })),
|
|
158
|
+
react_1.default.createElement(AttributesList_1.default, { className: styles.item, attrTypes: firstLevelRelationAttrTypes, entity: attributeListEntity, showEmptyEditors: true, crosswalks: connection.crosswalks, mode: mode, parentUri: relationUri, onAddAttributes: onAddAttributes, onChangeAttribute: onChangeAttribute, onDeleteAttribute: onDeleteAttribute })))),
|
|
159
|
+
react_1.default.createElement("div", { className: styles.actionButtons },
|
|
160
|
+
react_1.default.createElement(Button_1.default, { onClick: onCancel }, ui_i18n_1.default.text('Cancel')),
|
|
161
|
+
react_1.default.createElement(Button_1.default, { color: "primary", disabled: !hasChanges, onClick: onApply }, ui_i18n_1.default.text('Apply'))),
|
|
162
|
+
react_1.default.createElement(Divider_1.default, null)));
|
|
163
|
+
};
|
|
164
|
+
RelationEditor.propTypes = {
|
|
165
|
+
connection: mdm_sdk_1.ConnectionType,
|
|
166
|
+
modifiedEntity: mdm_sdk_1.EntityType,
|
|
167
|
+
allModifiedEntities: prop_types_1.default.object,
|
|
168
|
+
dispatch: prop_types_1.default.func,
|
|
169
|
+
config: mdm_sdk_1.RelationsConfigType,
|
|
170
|
+
mode: prop_types_1.default.string,
|
|
171
|
+
metadata: mdm_sdk_1.MetadataType,
|
|
172
|
+
globalSearchRequestOptions: prop_types_1.default.object,
|
|
173
|
+
error: mdm_sdk_1.AttributeErrorType
|
|
174
|
+
};
|
|
175
|
+
exports.default = RelationEditor;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
export { RelationEditor };
|
|
2
|
+
declare var _default: import("react-redux").ConnectedComponent<{
|
|
3
|
+
({ connection, modifiedEntity, allModifiedEntities, dispatch, config, mode, metadata, globalSearchRequestOptions, error }: {
|
|
4
|
+
connection: any;
|
|
5
|
+
modifiedEntity: any;
|
|
6
|
+
allModifiedEntities: any;
|
|
7
|
+
dispatch: any;
|
|
8
|
+
config: any;
|
|
9
|
+
mode: any;
|
|
10
|
+
metadata: any;
|
|
11
|
+
globalSearchRequestOptions: any;
|
|
12
|
+
error: any;
|
|
13
|
+
}): JSX.Element;
|
|
14
|
+
propTypes: {
|
|
15
|
+
connection: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
16
|
+
entity: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
17
|
+
entityUri: import("prop-types").Requireable<string>;
|
|
18
|
+
entityType: import("prop-types").Requireable<string>;
|
|
19
|
+
entityLabel: import("prop-types").Requireable<string>;
|
|
20
|
+
object: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
21
|
+
uri: import("prop-types").Requireable<string>;
|
|
22
|
+
type: import("prop-types").Requireable<string>;
|
|
23
|
+
}>>;
|
|
24
|
+
}>>;
|
|
25
|
+
relation: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
26
|
+
relationUri: import("prop-types").Requireable<string>;
|
|
27
|
+
relationType: import("prop-types").Requireable<string>;
|
|
28
|
+
relationLabel: import("prop-types").Requireable<string>;
|
|
29
|
+
direction: import("prop-types").Requireable<string>;
|
|
30
|
+
object: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
31
|
+
uri: import("prop-types").Requireable<string>;
|
|
32
|
+
type: import("prop-types").Requireable<string>;
|
|
33
|
+
}>>;
|
|
34
|
+
}>>;
|
|
35
|
+
}>>;
|
|
36
|
+
modifiedEntity: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
37
|
+
uri: import("prop-types").Requireable<string>;
|
|
38
|
+
type: import("prop-types").Requireable<string>;
|
|
39
|
+
}>>;
|
|
40
|
+
allModifiedEntities: import("prop-types").Requireable<object>;
|
|
41
|
+
dispatch: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
42
|
+
config: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
43
|
+
id: import("prop-types").Requireable<string>;
|
|
44
|
+
content: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
45
|
+
inRelations: import("prop-types").Requireable<(string | object)[]>;
|
|
46
|
+
outRelations: import("prop-types").Requireable<(string | object)[]>;
|
|
47
|
+
groups: import("prop-types").Requireable<string[]>;
|
|
48
|
+
entityTypes: import("prop-types").Requireable<string[]>;
|
|
49
|
+
nextEntry: import("prop-types").Requireable<object>;
|
|
50
|
+
}>>;
|
|
51
|
+
allowOnlyCreateNew: import("prop-types").Requireable<boolean>;
|
|
52
|
+
sortColumn: import("prop-types").Requireable<string>;
|
|
53
|
+
sortOrder: import("prop-types").Requireable<string>;
|
|
54
|
+
'text-empty': import("prop-types").Requireable<string>;
|
|
55
|
+
max: import("prop-types").Requireable<number>;
|
|
56
|
+
icon: import("prop-types").Requireable<string>;
|
|
57
|
+
caption: import("prop-types").Requireable<string>;
|
|
58
|
+
canCreate: import("prop-types").Requireable<boolean>;
|
|
59
|
+
canRead: import("prop-types").Requireable<boolean>;
|
|
60
|
+
canUpdate: import("prop-types").Requireable<boolean>;
|
|
61
|
+
canDelete: import("prop-types").Requireable<boolean>;
|
|
62
|
+
editingEnabled: import("prop-types").Requireable<boolean>;
|
|
63
|
+
}>>;
|
|
64
|
+
mode: import("prop-types").Requireable<string>;
|
|
65
|
+
metadata: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
66
|
+
uri: import("prop-types").Requireable<string>;
|
|
67
|
+
description: import("prop-types").Requireable<string>;
|
|
68
|
+
label: import("prop-types").Requireable<string>;
|
|
69
|
+
schemaVersion: import("prop-types").Requireable<string>;
|
|
70
|
+
entityTypes: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
71
|
+
typeColor: import("prop-types").Requireable<string>;
|
|
72
|
+
typeIcon: import("prop-types").Requireable<string>;
|
|
73
|
+
typeImage: import("prop-types").Requireable<string>;
|
|
74
|
+
label: import("prop-types").Requireable<string>;
|
|
75
|
+
uri: import("prop-types").Requireable<string>;
|
|
76
|
+
attributes: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
77
|
+
label: import("prop-types").Requireable<string>;
|
|
78
|
+
name: import("prop-types").Requireable<string>;
|
|
79
|
+
description: import("prop-types").Requireable<string>;
|
|
80
|
+
type: import("prop-types").Requireable<string>;
|
|
81
|
+
hidden: import("prop-types").Requireable<boolean>;
|
|
82
|
+
faceted: import("prop-types").Requireable<boolean>;
|
|
83
|
+
searchable: import("prop-types").Requireable<boolean>;
|
|
84
|
+
uri: import("prop-types").Requireable<string>;
|
|
85
|
+
access: import("prop-types").Requireable<string[]>;
|
|
86
|
+
cardinality: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
87
|
+
minValue: import("prop-types").Requireable<number>;
|
|
88
|
+
maxValue: import("prop-types").Requireable<number>;
|
|
89
|
+
}>>;
|
|
90
|
+
}>[]>;
|
|
91
|
+
}>[]>;
|
|
92
|
+
roles: import("prop-types").Requireable<object[]>;
|
|
93
|
+
groupTypes: import("prop-types").Requireable<object[]>;
|
|
94
|
+
relationTypes: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
95
|
+
label: import("prop-types").Requireable<string>;
|
|
96
|
+
uri: import("prop-types").Requireable<string>;
|
|
97
|
+
typeColor: import("prop-types").Requireable<string>;
|
|
98
|
+
direction: import("prop-types").Requireable<string>;
|
|
99
|
+
startObject: import("prop-types").Requireable<object>;
|
|
100
|
+
endObject: import("prop-types").Requireable<object>;
|
|
101
|
+
}>[]>;
|
|
102
|
+
graphTypes: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
103
|
+
uri: import("prop-types").Requireable<string>;
|
|
104
|
+
label: import("prop-types").Requireable<string>;
|
|
105
|
+
extendsTypeUri: import("prop-types").Requireable<string>;
|
|
106
|
+
relationshipTypeURIs: import("prop-types").Requireable<string[]>;
|
|
107
|
+
}>[]>;
|
|
108
|
+
interactionTypes: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
109
|
+
uri: import("prop-types").Requireable<string>;
|
|
110
|
+
label: import("prop-types").Requireable<string>;
|
|
111
|
+
memberTypes: import("prop-types").Requireable<any[]>;
|
|
112
|
+
extendsTypeUri: import("prop-types").Requireable<string>;
|
|
113
|
+
attributes: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
114
|
+
label: import("prop-types").Requireable<string>;
|
|
115
|
+
name: import("prop-types").Requireable<string>;
|
|
116
|
+
description: import("prop-types").Requireable<string>;
|
|
117
|
+
type: import("prop-types").Requireable<string>;
|
|
118
|
+
hidden: import("prop-types").Requireable<boolean>;
|
|
119
|
+
faceted: import("prop-types").Requireable<boolean>;
|
|
120
|
+
searchable: import("prop-types").Requireable<boolean>;
|
|
121
|
+
uri: import("prop-types").Requireable<string>;
|
|
122
|
+
access: import("prop-types").Requireable<string[]>;
|
|
123
|
+
cardinality: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
124
|
+
minValue: import("prop-types").Requireable<number>;
|
|
125
|
+
maxValue: import("prop-types").Requireable<number>;
|
|
126
|
+
}>>;
|
|
127
|
+
}>[]>;
|
|
128
|
+
}>[]>;
|
|
129
|
+
sources: import("prop-types").Requireable<object[]>;
|
|
130
|
+
}>>;
|
|
131
|
+
globalSearchRequestOptions: import("prop-types").Requireable<object>;
|
|
132
|
+
error: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
133
|
+
type: import("prop-types").Validator<import("@reltio/mdm-sdk").ErrorType>;
|
|
134
|
+
attributeTypeUri: import("prop-types").Validator<string>;
|
|
135
|
+
parentUri: import("prop-types").Validator<string>;
|
|
136
|
+
uri: import("prop-types").Requireable<string>;
|
|
137
|
+
message: import("prop-types").Requireable<string>;
|
|
138
|
+
}>>;
|
|
139
|
+
};
|
|
140
|
+
}, any>;
|
|
141
|
+
export default _default;
|
|
142
|
+
import RelationEditor from "./RelationEditor";
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.RelationEditor = void 0;
|
|
26
|
+
var RelationEditor_1 = __importDefault(require("./RelationEditor"));
|
|
27
|
+
exports.RelationEditor = RelationEditor_1.default;
|
|
28
|
+
var mdm_module_1 = __importStar(require("@reltio/mdm-module"));
|
|
29
|
+
var react_redux_1 = require("react-redux");
|
|
30
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
31
|
+
var getConnectionEntityUri = function (props) { return mdm_module_1.profile.relations.selectors.getEntityUriFromConnection(props.connection); };
|
|
32
|
+
var mapStateToProps = function (state, ownProps) {
|
|
33
|
+
var entityUri = getConnectionEntityUri(ownProps);
|
|
34
|
+
var isTempEntity = mdm_sdk_1.isTempUri(entityUri);
|
|
35
|
+
return {
|
|
36
|
+
modifiedEntity: isTempEntity ? mdm_module_1.default.selectors.getModifiedEntity(state, entityUri) : null,
|
|
37
|
+
allModifiedEntities: isTempEntity ? mdm_module_1.default.selectors.getModifiedEntities(state) : null,
|
|
38
|
+
globalSearchRequestOptions: mdm_module_1.default.selectors.getGlobalSearchRequestOptions(state, ['ovOnly']),
|
|
39
|
+
error: mdm_sdk_1.getRelationEditorActiveError(ownProps.connection, mdm_module_1.default.selectors.getProfileErrors(state))
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
exports.default = react_redux_1.connect(mapStateToProps)(RelationEditor_1.default);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"title" | "item" | "dense" | "editor" | "actionButtons">;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useStyles = void 0;
|
|
4
|
+
var styles_1 = require("@material-ui/core/styles");
|
|
5
|
+
exports.useStyles = styles_1.makeStyles({
|
|
6
|
+
editor: {
|
|
7
|
+
display: 'flex',
|
|
8
|
+
flexDirection: 'column',
|
|
9
|
+
padding: '0 24px 5px'
|
|
10
|
+
},
|
|
11
|
+
title: {
|
|
12
|
+
color: 'rgba(0, 0, 0, 0.6)',
|
|
13
|
+
fontSize: '16px',
|
|
14
|
+
letterSpacing: '0.15px',
|
|
15
|
+
lineHeight: '24px',
|
|
16
|
+
margin: '17px 0 24px'
|
|
17
|
+
},
|
|
18
|
+
item: {
|
|
19
|
+
marginBottom: '20px'
|
|
20
|
+
},
|
|
21
|
+
dense: {
|
|
22
|
+
marginBottom: 0
|
|
23
|
+
},
|
|
24
|
+
actionButtons: {
|
|
25
|
+
display: 'flex',
|
|
26
|
+
justifyContent: 'flex-end',
|
|
27
|
+
margin: '0 8px 10px',
|
|
28
|
+
'& > button': {
|
|
29
|
+
fontSize: '14px',
|
|
30
|
+
lineHeight: '16px',
|
|
31
|
+
marginLeft: '8px',
|
|
32
|
+
padding: '10px 8px',
|
|
33
|
+
backgroundColor: 'rgba(98, 2, 238, 0)'
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
});
|
|
@@ -119,4 +119,5 @@ export { ReltioMap } from './ReltioMap';
|
|
|
119
119
|
export { default as ErrorMessage } from './ErrorWrapper/ErrorMessage';
|
|
120
120
|
export * from './history';
|
|
121
121
|
export { default as OvIcon } from './attributes/OvIcon';
|
|
122
|
+
export { default as RelationEditor } from './RelationEditor';
|
|
122
123
|
export * from './workflow';
|
package/cjs/components/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
16
|
exports.EntityTypeIcon = exports.EntityTypeBadge = exports.EntityAvatar = exports.EMPTY_STATE_VARIANTS = exports.EMPTY_STATE_ICONS = exports.EmptyState = exports.NoResults = exports.NoData = exports.DropDownSelector = exports.DropDownMenuButton = exports.Drawer = exports.DataTypeValue = exports.ConnectionRelationTypeSelector = exports.ConfigureColumnsPopup = exports.MenuWithPopper = exports.DropdownIndicatorWithIconButton = exports.DropdownIndicator = exports.CommentsContainer = exports.ColorBar = exports.CollapseButton = exports.CollaborationItem = exports.ClickAwayProvider = exports.BasicViewHeader = exports.BasicViewContent = exports.BasicView = exports.ProfileBandNavigation = exports.AvatarWithFallback = exports.AutoSizeList = exports.ReadOnlyAttributesPager = exports.SimpleAttribute = exports.ReferenceAttribute = exports.NestedAttribute = exports.ImageAttributesLine = exports.ReadOnlyAttributesList = exports.ReadOnlyAttributeValuesBlock = exports.EditableAttribute = exports.ReadOnlyAttribute = exports.CardinalityMessage = exports.AttributesPager = exports.SimpleAttributeEditor = exports.RelationTypeSelector = exports.ReferenceAttributeEditor = exports.NestedAttributeEditor = exports.MoreAttributesButton = exports.EntitySelector = exports.EntityCreator = exports.AttributesList = exports.BranchDecorator = exports.AttributesView = exports.AttributeListItem = void 0;
|
|
17
17
|
exports.SimpleDropDownSelector = exports.SidePanelContentHeader = exports.SidePanel = exports.SideButtonsPanel = exports.SelectorWithOnlyOptionAutoSelect = exports.SelectionPopupPopper = exports.SelectionPopup = exports.useKeyboardNavigation = exports.WhiteSearchInput = exports.SearchInput = exports.ScoreLabel = exports.Score = exports.ResizablePanes = exports.ReltioGridLayout = exports.ReactSortableTreeUtils = exports.ReactSortableTreeHandlers = exports.ReactSortableTree = exports.ReactSelectOptionFilters = exports.MultiSelect = exports.QueryBuilderRowsGroup = exports.QueryBuilderRow = exports.ProfileCard = exports.ProfileBand = exports.PotentialMatchReviewCard = exports.PopupWithArrow = exports.Popper = exports.MultipleInput = exports.ModeSwitcherSelect = exports.ModeSwitcher = exports.TransitiveMatchBlock = exports.SimpleMatchRulesBuilder = exports.SimpleMatchRulesBlock = exports.MatchRulesBlock = exports.LoadingSpinner = exports.Link = exports.LinearLoadIndicator = exports.ImportModes = exports.ImportButton = exports.ImageGalleryDialog = exports.Highlighter = exports.HierarchicalAttributeTooltip = exports.HideOnShrink = exports.FlipCard = exports.FacetViewHeader = exports.ExpandedValueTooltip = exports.ErrorWrapper = exports.ErrorPopup = exports.ErrorBoundary = exports.EntityUriLink = exports.EntityTypesSelector = void 0;
|
|
18
|
-
exports.OvIcon = exports.ErrorMessage = exports.ReltioMap = exports.ConfirmDeleteDialog = exports.ConfirmationDialog = exports.Marginator = exports.LightArrowTooltip = exports.ArrowExpandButton = exports.ScrollableTabs = exports.ExpandableSearchInput = exports.VirtualGroupedList = exports.ViewMoreToggle = exports.VerticalHeadingsTable = exports.VerticalDivider = exports.AttributeTitle = exports.Spacer = exports.SourceIcon = exports.SmallIconButtonWithTooltip = exports.SmallIconButton = void 0;
|
|
18
|
+
exports.RelationEditor = exports.OvIcon = exports.ErrorMessage = exports.ReltioMap = exports.ConfirmDeleteDialog = exports.ConfirmationDialog = exports.Marginator = exports.LightArrowTooltip = exports.ArrowExpandButton = exports.ScrollableTabs = exports.ExpandableSearchInput = exports.VirtualGroupedList = exports.ViewMoreToggle = exports.VerticalHeadingsTable = exports.VerticalDivider = exports.AttributeTitle = exports.Spacer = exports.SourceIcon = exports.SmallIconButtonWithTooltip = exports.SmallIconButton = void 0;
|
|
19
19
|
__exportStar(require("./activityLog"), exports);
|
|
20
20
|
var AttributeListItem_1 = require("./AttributeListItem/AttributeListItem");
|
|
21
21
|
Object.defineProperty(exports, "AttributeListItem", { enumerable: true, get: function () { return __importDefault(AttributeListItem_1).default; } });
|
|
@@ -255,4 +255,6 @@ Object.defineProperty(exports, "ErrorMessage", { enumerable: true, get: function
|
|
|
255
255
|
__exportStar(require("./history"), exports);
|
|
256
256
|
var OvIcon_1 = require("./attributes/OvIcon");
|
|
257
257
|
Object.defineProperty(exports, "OvIcon", { enumerable: true, get: function () { return __importDefault(OvIcon_1).default; } });
|
|
258
|
+
var RelationEditor_1 = require("./RelationEditor");
|
|
259
|
+
Object.defineProperty(exports, "RelationEditor", { enumerable: true, get: function () { return __importDefault(RelationEditor_1).default; } });
|
|
258
260
|
__exportStar(require("./workflow"), exports);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export default RelationEditor;
|
|
2
|
+
declare function RelationEditor({ connection, modifiedEntity, allModifiedEntities, dispatch, config, mode, metadata, globalSearchRequestOptions, error }: {
|
|
3
|
+
connection: any;
|
|
4
|
+
modifiedEntity: any;
|
|
5
|
+
allModifiedEntities: any;
|
|
6
|
+
dispatch: any;
|
|
7
|
+
config: any;
|
|
8
|
+
mode: any;
|
|
9
|
+
metadata: any;
|
|
10
|
+
globalSearchRequestOptions: any;
|
|
11
|
+
error: any;
|
|
12
|
+
}): JSX.Element;
|
|
13
|
+
declare namespace RelationEditor {
|
|
14
|
+
namespace propTypes {
|
|
15
|
+
export { ConnectionType as connection };
|
|
16
|
+
export { EntityType as modifiedEntity };
|
|
17
|
+
export const allModifiedEntities: PropTypes.Requireable<object>;
|
|
18
|
+
export const dispatch: PropTypes.Requireable<(...args: any[]) => any>;
|
|
19
|
+
export { RelationsConfigType as config };
|
|
20
|
+
export const mode: PropTypes.Requireable<string>;
|
|
21
|
+
export { MetadataType as metadata };
|
|
22
|
+
export const globalSearchRequestOptions: PropTypes.Requireable<object>;
|
|
23
|
+
export { AttributeErrorType as error };
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
import { ConnectionType } from "@reltio/mdm-sdk/src/constants";
|
|
27
|
+
import { EntityType } from "@reltio/mdm-sdk/src/constants";
|
|
28
|
+
import PropTypes from "prop-types";
|
|
29
|
+
import { RelationsConfigType } from "@reltio/mdm-sdk/src/constants";
|
|
30
|
+
import { MetadataType } from "@reltio/mdm-sdk/src/constants";
|
|
31
|
+
import { AttributeErrorType } from "@reltio/mdm-sdk/src/constants";
|
|
@@ -0,0 +1,151 @@
|
|
|
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
|
+
import React, { useCallback, useEffect, useMemo, useRef } from 'react';
|
|
13
|
+
import PropTypes from 'prop-types';
|
|
14
|
+
import Button from '@material-ui/core/Button';
|
|
15
|
+
import Typography from '@material-ui/core/Typography';
|
|
16
|
+
import i18n from 'ui-i18n';
|
|
17
|
+
import classnames from 'classnames';
|
|
18
|
+
import { always, concat, differenceWith, equals, forEach, path, pipe, prop, when, uniq } from 'ramda';
|
|
19
|
+
import { useStyles } from './styles';
|
|
20
|
+
import { AttributeErrorType, ConnectionType, createTemporaryEntity, EntityType, findRelatedTemporaryEntities, getActivenessAttributes, getCreatableAttributeTypes, getEntityType, getErrorMessage, getErrorId, MetadataType, omitMarks, relationEditorAttributeTypesSelectionStrategy, RelationsConfigType, validateConnection, updateConnectionEntityLabel, isTempUri, isEmptyValue, getRelationAttributesList, getDefaultRelationTypeObject, getInOutRelations } from '@reltio/mdm-sdk';
|
|
21
|
+
import { profile } from '@reltio/mdm-module';
|
|
22
|
+
import Divider from '@material-ui/core/Divider';
|
|
23
|
+
import ConnectionRelationTypeSelector from '../ConnectionRelationTypeSelector/ConnectionRelationTypeSelector';
|
|
24
|
+
import ErrorWrapper from '../ErrorWrapper/ErrorWrapper';
|
|
25
|
+
import EntitySelector from '../attributes/editMode/EntitySelector/EntitySelector';
|
|
26
|
+
import AttributesList from '../attributes/editMode/AttributesList';
|
|
27
|
+
var areRelatedEntitiesChanged = function (initial, actual) {
|
|
28
|
+
return initial.length !== actual.length || initial.some(function (_, i) { return initial[i] !== actual[i]; });
|
|
29
|
+
};
|
|
30
|
+
var RelationEditor = function (_a) {
|
|
31
|
+
var _b;
|
|
32
|
+
var connection = _a.connection, modifiedEntity = _a.modifiedEntity, allModifiedEntities = _a.allModifiedEntities, dispatch = _a.dispatch, config = _a.config, mode = _a.mode, metadata = _a.metadata, globalSearchRequestOptions = _a.globalSearchRequestOptions, error = _a.error;
|
|
33
|
+
var _c = connection.relation, relationUri = _c.relationUri, relationType = _c.relationType, direction = _c.direction;
|
|
34
|
+
var isNew = connection.isNew;
|
|
35
|
+
var styles = useStyles();
|
|
36
|
+
var _d = useMemo(function () { return getInOutRelations({ config: config, direction: direction, relationType: relationType, mode: mode, metadata: metadata }); }, [config, direction, relationType, mode, metadata]), _e = _d.inRelations, inRelationTypes = _e === void 0 ? [] : _e, _f = _d.outRelations, outRelationTypes = _f === void 0 ? [] : _f;
|
|
37
|
+
var firstLevelRelationAttrTypes = useMemo(function () { return getRelationAttributesList(metadata, relationType); }, [
|
|
38
|
+
relationType,
|
|
39
|
+
metadata
|
|
40
|
+
]);
|
|
41
|
+
var attributeListEntity = useMemo(function () { return (__assign({ attributes: __assign({}, profile.relations.selectors.getRelationAttributesFromConnection(connection)) }, getActivenessAttributes(connection.relation))); }, [connection]);
|
|
42
|
+
var initialConnection = useRef(connection);
|
|
43
|
+
var initialModifiedEntity = useRef(modifiedEntity);
|
|
44
|
+
var relatedTempEntities = useMemo(function () { return findRelatedTemporaryEntities(allModifiedEntities, modifiedEntity); }, [
|
|
45
|
+
allModifiedEntities,
|
|
46
|
+
modifiedEntity
|
|
47
|
+
]);
|
|
48
|
+
var relatedTempEntitiesUrisHistory = useRef([]);
|
|
49
|
+
useEffect(function () {
|
|
50
|
+
relatedTempEntitiesUrisHistory.current = pipe(concat(relatedTempEntities.map(prop('uri'))), uniq)(relatedTempEntitiesUrisHistory.current);
|
|
51
|
+
}, [relatedTempEntities]);
|
|
52
|
+
var initialRelatedTempEntities = useRef(relatedTempEntities);
|
|
53
|
+
var defaultRelationType = getDefaultRelationTypeObject(inRelationTypes, outRelationTypes);
|
|
54
|
+
var hasChanges = initialConnection.current !== connection ||
|
|
55
|
+
initialModifiedEntity.current !== modifiedEntity ||
|
|
56
|
+
areRelatedEntitiesChanged(initialRelatedTempEntities.current, relatedTempEntities) ||
|
|
57
|
+
(connection.isNew && !isEmptyValue(path(['relation', 'object', 'attributes'], connection)));
|
|
58
|
+
var applyAction = isNew ? profile.relations.actions.addRelation : profile.relations.actions.editRelation;
|
|
59
|
+
var onRelationTypeChange = useCallback(pipe(profile.relations.actions.setRelationType(config.id, relationUri), dispatch), [config, relationUri, dispatch]);
|
|
60
|
+
var handleClose = useCallback(function () { return pipe(profile.relations.actions.closeRelationEditor, dispatch)(config.id, relationUri); }, [config, relationUri, dispatch]);
|
|
61
|
+
var updateModifiedEntityLabel = useCallback(function (connection) {
|
|
62
|
+
if (modifiedEntity) {
|
|
63
|
+
var entityType = getEntityType(metadata, modifiedEntity.type);
|
|
64
|
+
return updateConnectionEntityLabel(entityType, modifiedEntity, connection);
|
|
65
|
+
}
|
|
66
|
+
return connection;
|
|
67
|
+
}, [modifiedEntity, metadata]);
|
|
68
|
+
var setModifiedEntity = useCallback(function (entity) { return dispatch(profile.modifiedEntities.actions.entityCreated(entity)); }, [dispatch]);
|
|
69
|
+
var deleteModifiedEntity = useCallback(function (entityUri) { return dispatch(profile.modifiedEntities.actions.entityDeleted(entityUri)); }, [dispatch]);
|
|
70
|
+
var onChangeEntity = useCallback(function (entity) {
|
|
71
|
+
if (modifiedEntity) {
|
|
72
|
+
deleteModifiedEntity(modifiedEntity.uri);
|
|
73
|
+
}
|
|
74
|
+
dispatch(profile.relations.actions.setRelationEntity(config.id, relationUri, entity));
|
|
75
|
+
if (error) {
|
|
76
|
+
dispatch(profile.errors.actions.errorDeactivated(getErrorId(error)));
|
|
77
|
+
}
|
|
78
|
+
}, [config.id, relationUri, dispatch, modifiedEntity, deleteModifiedEntity, error]);
|
|
79
|
+
var validate = useCallback(function () {
|
|
80
|
+
var errors = validateConnection(metadata, allModifiedEntities, connection);
|
|
81
|
+
dispatch(profile.errors.actions.errorsSet(errors));
|
|
82
|
+
return errors.length === 0;
|
|
83
|
+
}, [connection, metadata, allModifiedEntities, dispatch]);
|
|
84
|
+
var resetErrors = useCallback(function () { return dispatch(profile.errors.actions.errorsSet([])); }, [dispatch]);
|
|
85
|
+
var onApply = useCallback(pipe(always(connection), when(validate, pipe(omitMarks, updateModifiedEntityLabel, applyAction(config.id), dispatch, always(differenceWith(equals, relatedTempEntitiesUrisHistory.current, relatedTempEntities.map(prop('uri')))), forEach(deleteModifiedEntity), handleClose))), [connection, config, dispatch, updateModifiedEntityLabel, validate, relatedTempEntities]);
|
|
86
|
+
var onCancel = useCallback(function () {
|
|
87
|
+
var initialEntity = initialModifiedEntity.current;
|
|
88
|
+
if (modifiedEntity !== initialEntity) {
|
|
89
|
+
if (initialEntity) {
|
|
90
|
+
setModifiedEntity(initialEntity);
|
|
91
|
+
if (modifiedEntity && modifiedEntity.uri !== initialEntity.uri) {
|
|
92
|
+
deleteModifiedEntity(modifiedEntity.uri);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
deleteModifiedEntity(modifiedEntity.uri);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
var initialTempEntities = initialRelatedTempEntities.current;
|
|
100
|
+
var entitiesUrisToDelete = differenceWith(equals, relatedTempEntitiesUrisHistory.current, initialTempEntities.map(prop('uri')));
|
|
101
|
+
entitiesUrisToDelete.forEach(deleteModifiedEntity);
|
|
102
|
+
initialTempEntities.forEach(setModifiedEntity);
|
|
103
|
+
resetErrors();
|
|
104
|
+
handleClose();
|
|
105
|
+
}, [handleClose, setModifiedEntity, deleteModifiedEntity, resetErrors, modifiedEntity]);
|
|
106
|
+
var onAddAttributes = useCallback(function (params) {
|
|
107
|
+
return pipe(profile.actions.addAttributes, dispatch)(params.map(function (param) { return (__assign(__assign({}, param), { viewId: config.id })); }));
|
|
108
|
+
}, [config.id, dispatch]);
|
|
109
|
+
var onChangeAttribute = useCallback(function (params) { return pipe(profile.actions.modifyAttribute, dispatch)(__assign(__assign({}, params), { viewId: config.id })); }, [config.id, dispatch]);
|
|
110
|
+
var onDeleteAttribute = useCallback(function (params) { return pipe(profile.actions.removeAttribute, dispatch)(__assign(__assign({}, params), { viewId: config.id })); }, [config.id, dispatch]);
|
|
111
|
+
var onCreateEntity = useCallback(function (entityTypeUri, initValue) {
|
|
112
|
+
var entityType = getEntityType(metadata, entityTypeUri);
|
|
113
|
+
var newEntityAttrTypes = pipe(relationEditorAttributeTypesSelectionStrategy, getCreatableAttributeTypes(mode))(entityType);
|
|
114
|
+
var newEntity = createTemporaryEntity({
|
|
115
|
+
entityTypeUri: entityTypeUri,
|
|
116
|
+
initValue: initValue,
|
|
117
|
+
attributeTypes: newEntityAttrTypes,
|
|
118
|
+
metadata: metadata,
|
|
119
|
+
mode: mode
|
|
120
|
+
});
|
|
121
|
+
onChangeEntity(newEntity);
|
|
122
|
+
setModifiedEntity(newEntity);
|
|
123
|
+
}, [setModifiedEntity, onChangeEntity, mode, metadata]);
|
|
124
|
+
var errorMessage = getErrorMessage(error);
|
|
125
|
+
return (React.createElement(React.Fragment, null,
|
|
126
|
+
React.createElement("div", { className: styles.editor },
|
|
127
|
+
React.createElement(Typography, { className: styles.title }, isNew ? i18n.text('Add new item') : i18n.text('Edit item')),
|
|
128
|
+
defaultRelationType === null && (React.createElement(ConnectionRelationTypeSelector, { className: styles.item, relation: connection.relation, inRelationTypes: inRelationTypes, outRelationTypes: outRelationTypes, onChange: onRelationTypeChange })),
|
|
129
|
+
Boolean(relationType) && (React.createElement(React.Fragment, null,
|
|
130
|
+
React.createElement(ErrorWrapper, { errorMessage: errorMessage },
|
|
131
|
+
React.createElement(EntitySelector, { className: classnames(styles.item, (_b = {},
|
|
132
|
+
_b[styles.dense] = errorMessage || (connection.entity && isTempUri(connection.entity.entityUri)),
|
|
133
|
+
_b)), entity: connection.entity || {}, entityTypesUris: config.content.entityTypes || [], max: config.max || 20, globalSearchRequestOptions: globalSearchRequestOptions, mode: mode, onChange: onChangeEntity, onCreate: onCreateEntity, metadata: metadata, attributeTypesSelectionStrategy: relationEditorAttributeTypesSelectionStrategy })),
|
|
134
|
+
React.createElement(AttributesList, { className: styles.item, attrTypes: firstLevelRelationAttrTypes, entity: attributeListEntity, showEmptyEditors: true, crosswalks: connection.crosswalks, mode: mode, parentUri: relationUri, onAddAttributes: onAddAttributes, onChangeAttribute: onChangeAttribute, onDeleteAttribute: onDeleteAttribute })))),
|
|
135
|
+
React.createElement("div", { className: styles.actionButtons },
|
|
136
|
+
React.createElement(Button, { onClick: onCancel }, i18n.text('Cancel')),
|
|
137
|
+
React.createElement(Button, { color: "primary", disabled: !hasChanges, onClick: onApply }, i18n.text('Apply'))),
|
|
138
|
+
React.createElement(Divider, null)));
|
|
139
|
+
};
|
|
140
|
+
RelationEditor.propTypes = {
|
|
141
|
+
connection: ConnectionType,
|
|
142
|
+
modifiedEntity: EntityType,
|
|
143
|
+
allModifiedEntities: PropTypes.object,
|
|
144
|
+
dispatch: PropTypes.func,
|
|
145
|
+
config: RelationsConfigType,
|
|
146
|
+
mode: PropTypes.string,
|
|
147
|
+
metadata: MetadataType,
|
|
148
|
+
globalSearchRequestOptions: PropTypes.object,
|
|
149
|
+
error: AttributeErrorType
|
|
150
|
+
};
|
|
151
|
+
export default RelationEditor;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
export { RelationEditor };
|
|
2
|
+
declare var _default: import("react-redux").ConnectedComponent<{
|
|
3
|
+
({ connection, modifiedEntity, allModifiedEntities, dispatch, config, mode, metadata, globalSearchRequestOptions, error }: {
|
|
4
|
+
connection: any;
|
|
5
|
+
modifiedEntity: any;
|
|
6
|
+
allModifiedEntities: any;
|
|
7
|
+
dispatch: any;
|
|
8
|
+
config: any;
|
|
9
|
+
mode: any;
|
|
10
|
+
metadata: any;
|
|
11
|
+
globalSearchRequestOptions: any;
|
|
12
|
+
error: any;
|
|
13
|
+
}): JSX.Element;
|
|
14
|
+
propTypes: {
|
|
15
|
+
connection: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
16
|
+
entity: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
17
|
+
entityUri: import("prop-types").Requireable<string>;
|
|
18
|
+
entityType: import("prop-types").Requireable<string>;
|
|
19
|
+
entityLabel: import("prop-types").Requireable<string>;
|
|
20
|
+
object: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
21
|
+
uri: import("prop-types").Requireable<string>;
|
|
22
|
+
type: import("prop-types").Requireable<string>;
|
|
23
|
+
}>>;
|
|
24
|
+
}>>;
|
|
25
|
+
relation: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
26
|
+
relationUri: import("prop-types").Requireable<string>;
|
|
27
|
+
relationType: import("prop-types").Requireable<string>;
|
|
28
|
+
relationLabel: import("prop-types").Requireable<string>;
|
|
29
|
+
direction: import("prop-types").Requireable<string>;
|
|
30
|
+
object: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
31
|
+
uri: import("prop-types").Requireable<string>;
|
|
32
|
+
type: import("prop-types").Requireable<string>;
|
|
33
|
+
}>>;
|
|
34
|
+
}>>;
|
|
35
|
+
}>>;
|
|
36
|
+
modifiedEntity: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
37
|
+
uri: import("prop-types").Requireable<string>;
|
|
38
|
+
type: import("prop-types").Requireable<string>;
|
|
39
|
+
}>>;
|
|
40
|
+
allModifiedEntities: import("prop-types").Requireable<object>;
|
|
41
|
+
dispatch: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
42
|
+
config: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
43
|
+
id: import("prop-types").Requireable<string>;
|
|
44
|
+
content: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
45
|
+
inRelations: import("prop-types").Requireable<(string | object)[]>;
|
|
46
|
+
outRelations: import("prop-types").Requireable<(string | object)[]>;
|
|
47
|
+
groups: import("prop-types").Requireable<string[]>;
|
|
48
|
+
entityTypes: import("prop-types").Requireable<string[]>;
|
|
49
|
+
nextEntry: import("prop-types").Requireable<object>;
|
|
50
|
+
}>>;
|
|
51
|
+
allowOnlyCreateNew: import("prop-types").Requireable<boolean>;
|
|
52
|
+
sortColumn: import("prop-types").Requireable<string>;
|
|
53
|
+
sortOrder: import("prop-types").Requireable<string>;
|
|
54
|
+
'text-empty': import("prop-types").Requireable<string>;
|
|
55
|
+
max: import("prop-types").Requireable<number>;
|
|
56
|
+
icon: import("prop-types").Requireable<string>;
|
|
57
|
+
caption: import("prop-types").Requireable<string>;
|
|
58
|
+
canCreate: import("prop-types").Requireable<boolean>;
|
|
59
|
+
canRead: import("prop-types").Requireable<boolean>;
|
|
60
|
+
canUpdate: import("prop-types").Requireable<boolean>;
|
|
61
|
+
canDelete: import("prop-types").Requireable<boolean>;
|
|
62
|
+
editingEnabled: import("prop-types").Requireable<boolean>;
|
|
63
|
+
}>>;
|
|
64
|
+
mode: import("prop-types").Requireable<string>;
|
|
65
|
+
metadata: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
66
|
+
uri: import("prop-types").Requireable<string>;
|
|
67
|
+
description: import("prop-types").Requireable<string>;
|
|
68
|
+
label: import("prop-types").Requireable<string>;
|
|
69
|
+
schemaVersion: import("prop-types").Requireable<string>;
|
|
70
|
+
entityTypes: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
71
|
+
typeColor: import("prop-types").Requireable<string>;
|
|
72
|
+
typeIcon: import("prop-types").Requireable<string>;
|
|
73
|
+
typeImage: import("prop-types").Requireable<string>;
|
|
74
|
+
label: import("prop-types").Requireable<string>;
|
|
75
|
+
uri: import("prop-types").Requireable<string>;
|
|
76
|
+
attributes: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
77
|
+
label: import("prop-types").Requireable<string>;
|
|
78
|
+
name: import("prop-types").Requireable<string>;
|
|
79
|
+
description: import("prop-types").Requireable<string>;
|
|
80
|
+
type: import("prop-types").Requireable<string>;
|
|
81
|
+
hidden: import("prop-types").Requireable<boolean>;
|
|
82
|
+
faceted: import("prop-types").Requireable<boolean>;
|
|
83
|
+
searchable: import("prop-types").Requireable<boolean>;
|
|
84
|
+
uri: import("prop-types").Requireable<string>;
|
|
85
|
+
access: import("prop-types").Requireable<string[]>;
|
|
86
|
+
cardinality: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
87
|
+
minValue: import("prop-types").Requireable<number>;
|
|
88
|
+
maxValue: import("prop-types").Requireable<number>;
|
|
89
|
+
}>>;
|
|
90
|
+
}>[]>;
|
|
91
|
+
}>[]>;
|
|
92
|
+
roles: import("prop-types").Requireable<object[]>;
|
|
93
|
+
groupTypes: import("prop-types").Requireable<object[]>;
|
|
94
|
+
relationTypes: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
95
|
+
label: import("prop-types").Requireable<string>;
|
|
96
|
+
uri: import("prop-types").Requireable<string>;
|
|
97
|
+
typeColor: import("prop-types").Requireable<string>;
|
|
98
|
+
direction: import("prop-types").Requireable<string>;
|
|
99
|
+
startObject: import("prop-types").Requireable<object>;
|
|
100
|
+
endObject: import("prop-types").Requireable<object>;
|
|
101
|
+
}>[]>;
|
|
102
|
+
graphTypes: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
103
|
+
uri: import("prop-types").Requireable<string>;
|
|
104
|
+
label: import("prop-types").Requireable<string>;
|
|
105
|
+
extendsTypeUri: import("prop-types").Requireable<string>;
|
|
106
|
+
relationshipTypeURIs: import("prop-types").Requireable<string[]>;
|
|
107
|
+
}>[]>;
|
|
108
|
+
interactionTypes: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
109
|
+
uri: import("prop-types").Requireable<string>;
|
|
110
|
+
label: import("prop-types").Requireable<string>;
|
|
111
|
+
memberTypes: import("prop-types").Requireable<any[]>;
|
|
112
|
+
extendsTypeUri: import("prop-types").Requireable<string>;
|
|
113
|
+
attributes: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
114
|
+
label: import("prop-types").Requireable<string>;
|
|
115
|
+
name: import("prop-types").Requireable<string>;
|
|
116
|
+
description: import("prop-types").Requireable<string>;
|
|
117
|
+
type: import("prop-types").Requireable<string>;
|
|
118
|
+
hidden: import("prop-types").Requireable<boolean>;
|
|
119
|
+
faceted: import("prop-types").Requireable<boolean>;
|
|
120
|
+
searchable: import("prop-types").Requireable<boolean>;
|
|
121
|
+
uri: import("prop-types").Requireable<string>;
|
|
122
|
+
access: import("prop-types").Requireable<string[]>;
|
|
123
|
+
cardinality: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
124
|
+
minValue: import("prop-types").Requireable<number>;
|
|
125
|
+
maxValue: import("prop-types").Requireable<number>;
|
|
126
|
+
}>>;
|
|
127
|
+
}>[]>;
|
|
128
|
+
}>[]>;
|
|
129
|
+
sources: import("prop-types").Requireable<object[]>;
|
|
130
|
+
}>>;
|
|
131
|
+
globalSearchRequestOptions: import("prop-types").Requireable<object>;
|
|
132
|
+
error: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
133
|
+
type: import("prop-types").Validator<import("@reltio/mdm-sdk").ErrorType>;
|
|
134
|
+
attributeTypeUri: import("prop-types").Validator<string>;
|
|
135
|
+
parentUri: import("prop-types").Validator<string>;
|
|
136
|
+
uri: import("prop-types").Requireable<string>;
|
|
137
|
+
message: import("prop-types").Requireable<string>;
|
|
138
|
+
}>>;
|
|
139
|
+
};
|
|
140
|
+
}, any>;
|
|
141
|
+
export default _default;
|
|
142
|
+
import RelationEditor from "./RelationEditor";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import RelationEditor from './RelationEditor';
|
|
2
|
+
import mdmModule, { profile } from '@reltio/mdm-module';
|
|
3
|
+
import { connect } from 'react-redux';
|
|
4
|
+
import { getRelationEditorActiveError, isTempUri } from '@reltio/mdm-sdk';
|
|
5
|
+
var getConnectionEntityUri = function (props) { return profile.relations.selectors.getEntityUriFromConnection(props.connection); };
|
|
6
|
+
var mapStateToProps = function (state, ownProps) {
|
|
7
|
+
var entityUri = getConnectionEntityUri(ownProps);
|
|
8
|
+
var isTempEntity = isTempUri(entityUri);
|
|
9
|
+
return {
|
|
10
|
+
modifiedEntity: isTempEntity ? mdmModule.selectors.getModifiedEntity(state, entityUri) : null,
|
|
11
|
+
allModifiedEntities: isTempEntity ? mdmModule.selectors.getModifiedEntities(state) : null,
|
|
12
|
+
globalSearchRequestOptions: mdmModule.selectors.getGlobalSearchRequestOptions(state, ['ovOnly']),
|
|
13
|
+
error: getRelationEditorActiveError(ownProps.connection, mdmModule.selectors.getProfileErrors(state))
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export { RelationEditor };
|
|
17
|
+
export default connect(mapStateToProps)(RelationEditor);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"title" | "item" | "dense" | "editor" | "actionButtons">;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { makeStyles } from '@material-ui/core/styles';
|
|
2
|
+
export var useStyles = makeStyles({
|
|
3
|
+
editor: {
|
|
4
|
+
display: 'flex',
|
|
5
|
+
flexDirection: 'column',
|
|
6
|
+
padding: '0 24px 5px'
|
|
7
|
+
},
|
|
8
|
+
title: {
|
|
9
|
+
color: 'rgba(0, 0, 0, 0.6)',
|
|
10
|
+
fontSize: '16px',
|
|
11
|
+
letterSpacing: '0.15px',
|
|
12
|
+
lineHeight: '24px',
|
|
13
|
+
margin: '17px 0 24px'
|
|
14
|
+
},
|
|
15
|
+
item: {
|
|
16
|
+
marginBottom: '20px'
|
|
17
|
+
},
|
|
18
|
+
dense: {
|
|
19
|
+
marginBottom: 0
|
|
20
|
+
},
|
|
21
|
+
actionButtons: {
|
|
22
|
+
display: 'flex',
|
|
23
|
+
justifyContent: 'flex-end',
|
|
24
|
+
margin: '0 8px 10px',
|
|
25
|
+
'& > button': {
|
|
26
|
+
fontSize: '14px',
|
|
27
|
+
lineHeight: '16px',
|
|
28
|
+
marginLeft: '8px',
|
|
29
|
+
padding: '10px 8px',
|
|
30
|
+
backgroundColor: 'rgba(98, 2, 238, 0)'
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
});
|
|
@@ -119,4 +119,5 @@ export { ReltioMap } from './ReltioMap';
|
|
|
119
119
|
export { default as ErrorMessage } from './ErrorWrapper/ErrorMessage';
|
|
120
120
|
export * from './history';
|
|
121
121
|
export { default as OvIcon } from './attributes/OvIcon';
|
|
122
|
+
export { default as RelationEditor } from './RelationEditor';
|
|
122
123
|
export * from './workflow';
|
package/esm/components/index.js
CHANGED
|
@@ -118,4 +118,5 @@ export { ReltioMap } from './ReltioMap';
|
|
|
118
118
|
export { default as ErrorMessage } from './ErrorWrapper/ErrorMessage';
|
|
119
119
|
export * from './history';
|
|
120
120
|
export { default as OvIcon } from './attributes/OvIcon';
|
|
121
|
+
export { default as RelationEditor } from './RelationEditor';
|
|
121
122
|
export * from './workflow';
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.883",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE FILE",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@date-io/moment": "^1.3.5",
|
|
9
9
|
"@react-google-maps/api": "^2.7.0",
|
|
10
|
-
"@reltio/mdm-module": "^1.4.
|
|
11
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
10
|
+
"@reltio/mdm-module": "^1.4.883",
|
|
11
|
+
"@reltio/mdm-sdk": "^1.4.883",
|
|
12
12
|
"classnames": "^2.2.5",
|
|
13
13
|
"frontend-collective-react-dnd-scrollzone": "^1.0.2",
|
|
14
14
|
"nanoid": "^2.0.0",
|