@reltio/components 1.4.1145 → 1.4.1148
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/attributes/editMode/AttributesList/AttributesList.js +20 -5
- package/cjs/components/attributes/editMode/AttributesList/helpers.d.ts +3 -1
- package/cjs/components/attributes/editMode/AttributesList/helpers.js +2 -2
- package/cjs/components/attributes/editMode/AttributesPager/SpecialRenderer.d.ts +6 -3
- package/cjs/components/attributes/editMode/AttributesPager/SpecialRenderer.js +24 -5
- package/cjs/components/attributes/editMode/contexts/HasDeletionsContext.d.ts +7 -0
- package/cjs/components/attributes/editMode/contexts/HasDeletionsContext.js +8 -0
- package/cjs/hooks/useAPI/useAPI.js +1 -1
- package/cjs/hooks/useCustomScripts.js +13 -4
- package/esm/components/attributes/editMode/AttributesList/AttributesList.js +21 -6
- package/esm/components/attributes/editMode/AttributesList/helpers.d.ts +3 -1
- package/esm/components/attributes/editMode/AttributesList/helpers.js +2 -2
- package/esm/components/attributes/editMode/AttributesPager/SpecialRenderer.d.ts +6 -3
- package/esm/components/attributes/editMode/AttributesPager/SpecialRenderer.js +23 -6
- package/esm/components/attributes/editMode/contexts/HasDeletionsContext.d.ts +7 -0
- package/esm/components/attributes/editMode/contexts/HasDeletionsContext.js +2 -0
- package/esm/hooks/useAPI/useAPI.js +2 -2
- package/esm/hooks/useCustomScripts.js +14 -5
- package/package.json +3 -3
|
@@ -45,27 +45,42 @@ var constants_1 = require("../../../../constants");
|
|
|
45
45
|
var attributesView_1 = require("../../helpers/attributesView");
|
|
46
46
|
var helpers_1 = require("./helpers");
|
|
47
47
|
var PinnedAttributesContext_1 = require("../contexts/PinnedAttributesContext");
|
|
48
|
+
var HasDeletionsContext_1 = require("../contexts/HasDeletionsContext");
|
|
48
49
|
var AttributesList = function (_a) {
|
|
49
50
|
var attrTypes = _a.attrTypes, entity = _a.entity, parentUri = _a.parentUri, showEmptyEditors = _a.showEmptyEditors, mode = _a.mode, crosswalks = _a.crosswalks, drawLines = _a.drawLines, children = _a.children, className = _a.className, _b = _a.alwaysVisibleTypeUris, alwaysVisibleTypeUris = _b === void 0 ? constants_1.ALWAYS_VISIBLE_TYPE_URIS : _b, onAddAttributes = _a.onAddAttributes, onChangeAttribute = _a.onChangeAttribute, onDeleteAttribute = _a.onDeleteAttribute, additionalControlsRenderer = _a.additionalControlsRenderer, showNonOv = _a.showNonOv;
|
|
50
51
|
var _c = entity.attributes, attributes = _c === void 0 ? {} : _c;
|
|
52
|
+
var _d = react_1.useState({}), hasDeletionsMap = _d[0], setHasDeletionsMap = _d[1];
|
|
53
|
+
var setHasDeletions = react_1.useCallback(function (attrTypeUri, value) {
|
|
54
|
+
setHasDeletionsMap(function (prevMap) {
|
|
55
|
+
var _a;
|
|
56
|
+
return (__assign(__assign({}, prevMap), (_a = {}, _a[attrTypeUri] = value, _a)));
|
|
57
|
+
});
|
|
58
|
+
}, []);
|
|
59
|
+
react_1.useEffect(function () {
|
|
60
|
+
setHasDeletionsMap({});
|
|
61
|
+
}, [parentUri]);
|
|
51
62
|
var creatableAttrTypes = react_1.useMemo(function () { return mdm_sdk_1.getCreatableAttributeTypes(mode, attrTypes); }, [attrTypes, mode]);
|
|
52
|
-
var moreAttrTypes = helpers_1.getMoreAttrTypes(creatableAttrTypes, entity);
|
|
63
|
+
var moreAttrTypes = helpers_1.getMoreAttrTypes(creatableAttrTypes, entity, showEmptyEditors, hasDeletionsMap);
|
|
53
64
|
var pinnedAttributes = react_1.useContext(PinnedAttributesContext_1.PinnedAttributesContext);
|
|
54
65
|
var pagersData = react_1.useMemo(function () { return mdm_sdk_1.getAttributesListForEditMode(attrTypes, mode, entity, showEmptyEditors, showNonOv, pinnedAttributes); }, [attrTypes, mode, entity, showEmptyEditors, showNonOv, pinnedAttributes]);
|
|
55
|
-
var
|
|
66
|
+
var _e = react_1.useMemo(function () { return attributesView_1.splitPagersData(alwaysVisibleTypeUris, pagersData); }, [pagersData, alwaysVisibleTypeUris]), alwaysVisiblePagersData = _e[0], regularPagersData = _e[1];
|
|
56
67
|
var onAddMoreAttributes = react_1.useCallback(function (attributeTypes) {
|
|
57
68
|
onAddAttributes(attributeTypes.map(function (attributeType) { return ({ attributeType: attributeType, parentUri: parentUri }); }));
|
|
58
69
|
}, [onAddAttributes, parentUri]);
|
|
59
70
|
var decoratorProps = {
|
|
60
71
|
enabled: drawLines
|
|
61
72
|
};
|
|
73
|
+
var hasDeletionsContextValue = react_1.useMemo(function () { return ({
|
|
74
|
+
hasDeletionsMap: hasDeletionsMap,
|
|
75
|
+
setHasDeletions: setHasDeletions
|
|
76
|
+
}); }, [hasDeletionsMap, setHasDeletions]);
|
|
62
77
|
return (react_1.default.createElement("div", { className: className },
|
|
63
78
|
children && react_1.default.createElement(BranchDecorator_1.default, __assign({}, decoratorProps), children),
|
|
64
|
-
react_1.default.createElement(BranchDecorator_1.default, __assign({}, decoratorProps, { plain: true }),
|
|
65
|
-
regularPagersData.concat(alwaysVisiblePagersData).map(function (_a) {
|
|
79
|
+
react_1.default.createElement(BranchDecorator_1.default, __assign({}, decoratorProps, { plain: true }), moreAttrTypes.length > 0 && (react_1.default.createElement(MoreAttributesButton_1.default, { label: ui_i18n_1.default.text('More attributes'), onApply: onAddMoreAttributes, dense: drawLines, data: moreAttrTypes }))),
|
|
80
|
+
react_1.default.createElement(HasDeletionsContext_1.HasDeletionsContext.Provider, { value: hasDeletionsContextValue }, regularPagersData.concat(alwaysVisiblePagersData).map(function (_a) {
|
|
66
81
|
var attrType = _a.attrType, values = _a.values;
|
|
67
82
|
return (react_1.default.createElement(AttributesPager_1.default, { key: attrType.uri, attributeType: attrType, drawLines: drawLines, values: values, paging: ramda_1.path(['paging', attrType.uri], attributes), parentUri: parentUri, showEmptyEditors: showEmptyEditors, mode: mode, crosswalks: crosswalks, onAddAttributes: onAddAttributes, onChangeAttribute: onChangeAttribute, onDeleteAttribute: onDeleteAttribute, additionalControlsRenderer: additionalControlsRenderer, showNonOv: showNonOv }));
|
|
68
|
-
})));
|
|
83
|
+
}))));
|
|
69
84
|
};
|
|
70
85
|
AttributesList.propTypes = {
|
|
71
86
|
attrTypes: prop_types_1.default.array,
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { AttributeType, Entity } from '@reltio/mdm-sdk';
|
|
2
|
-
export declare const getMoreAttrTypes: (attrTypes: AttributeType[], entity: Entity
|
|
2
|
+
export declare const getMoreAttrTypes: (attrTypes: AttributeType[], entity: Entity, showEmptyEditors?: boolean, hasDeletionsMap?: {
|
|
3
|
+
[attrTypeUri: string]: boolean;
|
|
4
|
+
}) => AttributeType[];
|
|
@@ -14,12 +14,12 @@ var getSource = function (attrType, entity) {
|
|
|
14
14
|
var getNameProp = function (attrType) {
|
|
15
15
|
return mdm_sdk_1.isSpecialAttribute(attrType) ? 'uri' : 'name';
|
|
16
16
|
};
|
|
17
|
-
var getMoreAttrTypes = function (attrTypes, entity) {
|
|
17
|
+
var getMoreAttrTypes = function (attrTypes, entity, showEmptyEditors, hasDeletionsMap) {
|
|
18
18
|
return attrTypes.filter(function (attrType) {
|
|
19
19
|
var source = getSource(attrType, entity);
|
|
20
20
|
var nameProp = getNameProp(attrType);
|
|
21
21
|
return !((attrType.singleValue || mdm_sdk_1.isRoleAttrType(attrType) || mdm_sdk_1.isTagAttrType(attrType)) &&
|
|
22
|
-
ramda_1.has(attrType[nameProp])(source));
|
|
22
|
+
(ramda_1.has(attrType[nameProp])(source) || (showEmptyEditors && !(hasDeletionsMap === null || hasDeletionsMap === void 0 ? void 0 : hasDeletionsMap[attrType.uri]))));
|
|
23
23
|
});
|
|
24
24
|
};
|
|
25
25
|
exports.getMoreAttrTypes = getMoreAttrTypes;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { AttributeType, Mode, AttributeItem } from '@reltio/mdm-sdk';
|
|
3
3
|
declare type Props = {
|
|
4
4
|
values: string[] | number[];
|
|
@@ -9,6 +9,9 @@ declare type Props = {
|
|
|
9
9
|
onDeleteAttribute: (param: AttributeItem) => void;
|
|
10
10
|
onChangeAttribute: (param: AttributeItem) => void;
|
|
11
11
|
showEmptyEditors?: boolean;
|
|
12
|
+
hasDeletions?: boolean;
|
|
13
|
+
setHasDeletions?: (attrTypeUri: string, value: boolean) => void;
|
|
12
14
|
};
|
|
13
|
-
declare const SpecialRenderer: ({ values, attributeType, parentUri, mode, errorMessage, onDeleteAttribute, onChangeAttribute, showEmptyEditors, ...otherProps }: Props) => JSX.Element;
|
|
14
|
-
|
|
15
|
+
export declare const SpecialRenderer: ({ values, attributeType, parentUri, mode, errorMessage, onDeleteAttribute, onChangeAttribute, showEmptyEditors, hasDeletions: hasDeletionsProp, setHasDeletions, ...otherProps }: Props) => JSX.Element;
|
|
16
|
+
declare const _default: React.ComponentType<Props> | ((props: any) => JSX.Element);
|
|
17
|
+
export default _default;
|
|
@@ -44,6 +44,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
44
44
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
45
45
|
};
|
|
46
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
exports.SpecialRenderer = void 0;
|
|
47
48
|
var react_1 = __importStar(require("react"));
|
|
48
49
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
49
50
|
var ramda_1 = require("ramda");
|
|
@@ -55,16 +56,26 @@ var Attribute_1 = __importDefault(require("../AttributesFactory/Attribute"));
|
|
|
55
56
|
var Roles_1 = require("../Roles/Roles");
|
|
56
57
|
var Tags_1 = __importDefault(require("../Tags"));
|
|
57
58
|
var styles_1 = require("./styles");
|
|
59
|
+
var HasDeletionsContext_1 = require("../contexts/HasDeletionsContext");
|
|
60
|
+
var HOCs_1 = require("../../../../HOCs");
|
|
58
61
|
var SpecialRenderer = function (_a) {
|
|
59
|
-
var values = _a.values, attributeType = _a.attributeType, parentUri = _a.parentUri, mode = _a.mode, errorMessage = _a.errorMessage, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, showEmptyEditors = _a.showEmptyEditors, otherProps = __rest(_a, ["values", "attributeType", "parentUri", "mode", "errorMessage", "onDeleteAttribute", "onChangeAttribute", "showEmptyEditors"]);
|
|
62
|
+
var values = _a.values, attributeType = _a.attributeType, parentUri = _a.parentUri, mode = _a.mode, errorMessage = _a.errorMessage, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, showEmptyEditors = _a.showEmptyEditors, hasDeletionsProp = _a.hasDeletions, setHasDeletions = _a.setHasDeletions, otherProps = __rest(_a, ["values", "attributeType", "parentUri", "mode", "errorMessage", "onDeleteAttribute", "onChangeAttribute", "showEmptyEditors", "hasDeletions", "setHasDeletions"]);
|
|
60
63
|
var styles = styles_1.useStyles();
|
|
61
64
|
var label = attributeType.label, isRequired = attributeType.required, cardinality = attributeType.cardinality;
|
|
62
65
|
var isEditableMode = mdm_sdk_1.isEditableMode(mode);
|
|
63
|
-
var _b = react_1.useState(false),
|
|
66
|
+
var _b = react_1.useState(false), hasDeletionsState = _b[0], setHasDeletionsState = _b[1];
|
|
67
|
+
var updateHasDeletions = react_1.useCallback(function (value) {
|
|
68
|
+
setHasDeletionsState(value);
|
|
69
|
+
setHasDeletions === null || setHasDeletions === void 0 ? void 0 : setHasDeletions(attributeType.uri, value);
|
|
70
|
+
}, [attributeType.uri, setHasDeletions]);
|
|
71
|
+
var hasDeletions = hasDeletionsProp !== undefined ? hasDeletionsProp : hasDeletionsState;
|
|
64
72
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
65
|
-
var onDelete = react_1.useCallback(ramda_1.pipe(onDeleteAttribute, ramda_1.T,
|
|
73
|
+
var onDelete = react_1.useCallback(ramda_1.pipe(onDeleteAttribute, ramda_1.T, updateHasDeletions), [
|
|
74
|
+
onDeleteAttribute,
|
|
75
|
+
updateHasDeletions
|
|
76
|
+
]);
|
|
66
77
|
var isEmptyValues = mdm_sdk_1.isEmptyValue(values);
|
|
67
|
-
var showEmpty = !
|
|
78
|
+
var showEmpty = !hasDeletions && showEmptyEditors && isEmptyValues;
|
|
68
79
|
var emptyEditorValue = react_1.useRef(mdm_sdk_1.createNewAttribute({
|
|
69
80
|
parentUri: parentUri,
|
|
70
81
|
attributeType: attributeType
|
|
@@ -91,4 +102,12 @@ var SpecialRenderer = function (_a) {
|
|
|
91
102
|
isEditableMode && react_1.default.createElement(ErrorMessage_1.default, { message: errorMessage }),
|
|
92
103
|
react_1.default.createElement(Box_1.default, { className: styles.attributesWrapper }, renderValue())));
|
|
93
104
|
};
|
|
94
|
-
exports.
|
|
105
|
+
exports.SpecialRenderer = SpecialRenderer;
|
|
106
|
+
exports.default = HOCs_1.withContext(HasDeletionsContext_1.HasDeletionsContext, function (contextValue, _a) {
|
|
107
|
+
var attributeType = _a.attributeType;
|
|
108
|
+
var _b = contextValue || {}, hasDeletionsMap = _b.hasDeletionsMap, setHasDeletions = _b.setHasDeletions;
|
|
109
|
+
return {
|
|
110
|
+
hasDeletions: hasDeletionsMap ? Boolean(hasDeletionsMap[attributeType === null || attributeType === void 0 ? void 0 : attributeType.uri]) : undefined,
|
|
111
|
+
setHasDeletions: setHasDeletions
|
|
112
|
+
};
|
|
113
|
+
}, exports.SpecialRenderer);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.HasDeletionsContext = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
exports.HasDeletionsContext = react_1.default.createContext(null);
|
|
@@ -172,7 +172,7 @@ var useAPI = function (config) {
|
|
|
172
172
|
}
|
|
173
173
|
};
|
|
174
174
|
react_1.useEffect(function () {
|
|
175
|
-
if (!mdm_sdk_1.isEmptyValue(config.action)) {
|
|
175
|
+
if (!mdm_sdk_1.isEmptyValue(config.action) && config.action.platform !== mdm_sdk_1.CustomScriptPlatform.CLASSIC) {
|
|
176
176
|
workerRef.current = mdm_sdk_1.initializeWebWorker(workerUrl, config.action.files, process);
|
|
177
177
|
return function () {
|
|
178
178
|
workerRef.current.terminate();
|
|
@@ -29,6 +29,11 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
29
29
|
__setModuleDefault(result, mod);
|
|
30
30
|
return result;
|
|
31
31
|
};
|
|
32
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
33
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
34
|
+
to[j] = from[i];
|
|
35
|
+
return to;
|
|
36
|
+
};
|
|
32
37
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
33
38
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
34
39
|
};
|
|
@@ -51,7 +56,12 @@ var isURLtoProcess = function (processApi, url) {
|
|
|
51
56
|
};
|
|
52
57
|
var useCustomScripts = function (config, _a) {
|
|
53
58
|
var addInternalRequestInterceptor = _a.addInternalRequestInterceptor, addInternalResponseInterceptor = _a.addInternalResponseInterceptor, removeInternalRequestInterceptor = _a.removeInternalRequestInterceptor, removeInternalResponseInterceptor = _a.removeInternalResponseInterceptor;
|
|
54
|
-
var customScripts = config.
|
|
59
|
+
var customScripts = config.reduce(function (acc, customScript) {
|
|
60
|
+
if (customScript.platform !== mdm_sdk_1.CustomScriptPlatform.CLASSIC) {
|
|
61
|
+
return __spreadArray(__spreadArray([], acc), [__assign(__assign({}, customScript), { actionId: nanoid_1.default() })]);
|
|
62
|
+
}
|
|
63
|
+
return acc;
|
|
64
|
+
}, []);
|
|
55
65
|
var dispatch = react_redux_1.useDispatch();
|
|
56
66
|
var metadata = react_redux_1.useSelector(mdm_module_1.default.selectors.getMetadata) || {};
|
|
57
67
|
var entity = react_redux_1.useSelector(mdm_module_1.default.selectors.getEntity) || {};
|
|
@@ -115,8 +125,7 @@ var useCustomScripts = function (config, _a) {
|
|
|
115
125
|
react_1.useEffect(function () {
|
|
116
126
|
workers.current = customScripts.reduce(function (acc, customScript) {
|
|
117
127
|
var _a;
|
|
118
|
-
|
|
119
|
-
return acc;
|
|
128
|
+
return __assign(__assign({}, acc), (_a = {}, _a[customScript.actionId] = mdm_sdk_1.initializeWebWorker(workerUrl, customScript.files, process), _a));
|
|
120
129
|
}, workers.current);
|
|
121
130
|
return function () {
|
|
122
131
|
Object.keys(workers.current).forEach(function (actionId) {
|
|
@@ -202,7 +211,7 @@ var useCustomScripts = function (config, _a) {
|
|
|
202
211
|
}
|
|
203
212
|
};
|
|
204
213
|
react_1.useEffect(function () {
|
|
205
|
-
if (!mdm_sdk_1.isEmptyValue(
|
|
214
|
+
if (!mdm_sdk_1.isEmptyValue(customScripts)) {
|
|
206
215
|
addInternalRequestInterceptor(customScriptRequestInterceptor);
|
|
207
216
|
addInternalResponseInterceptor(customScriptResponseInterceptor);
|
|
208
217
|
return function () {
|
|
@@ -9,7 +9,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import React, { memo, useCallback, useContext, useMemo } from 'react';
|
|
12
|
+
import React, { memo, useCallback, useContext, useMemo, useState, useEffect } from 'react';
|
|
13
13
|
import PropTypes from 'prop-types';
|
|
14
14
|
import i18n from 'ui-i18n';
|
|
15
15
|
import { getCreatableAttributeTypes, getAttributesListForEditMode, ModeType } from '@reltio/mdm-sdk';
|
|
@@ -21,27 +21,42 @@ import { ALWAYS_VISIBLE_TYPE_URIS } from '../../../../constants';
|
|
|
21
21
|
import { splitPagersData } from '../../helpers/attributesView';
|
|
22
22
|
import { getMoreAttrTypes } from './helpers';
|
|
23
23
|
import { PinnedAttributesContext } from '../contexts/PinnedAttributesContext';
|
|
24
|
+
import { HasDeletionsContext } from '../contexts/HasDeletionsContext';
|
|
24
25
|
var AttributesList = function (_a) {
|
|
25
26
|
var attrTypes = _a.attrTypes, entity = _a.entity, parentUri = _a.parentUri, showEmptyEditors = _a.showEmptyEditors, mode = _a.mode, crosswalks = _a.crosswalks, drawLines = _a.drawLines, children = _a.children, className = _a.className, _b = _a.alwaysVisibleTypeUris, alwaysVisibleTypeUris = _b === void 0 ? ALWAYS_VISIBLE_TYPE_URIS : _b, onAddAttributes = _a.onAddAttributes, onChangeAttribute = _a.onChangeAttribute, onDeleteAttribute = _a.onDeleteAttribute, additionalControlsRenderer = _a.additionalControlsRenderer, showNonOv = _a.showNonOv;
|
|
26
27
|
var _c = entity.attributes, attributes = _c === void 0 ? {} : _c;
|
|
28
|
+
var _d = useState({}), hasDeletionsMap = _d[0], setHasDeletionsMap = _d[1];
|
|
29
|
+
var setHasDeletions = useCallback(function (attrTypeUri, value) {
|
|
30
|
+
setHasDeletionsMap(function (prevMap) {
|
|
31
|
+
var _a;
|
|
32
|
+
return (__assign(__assign({}, prevMap), (_a = {}, _a[attrTypeUri] = value, _a)));
|
|
33
|
+
});
|
|
34
|
+
}, []);
|
|
35
|
+
useEffect(function () {
|
|
36
|
+
setHasDeletionsMap({});
|
|
37
|
+
}, [parentUri]);
|
|
27
38
|
var creatableAttrTypes = useMemo(function () { return getCreatableAttributeTypes(mode, attrTypes); }, [attrTypes, mode]);
|
|
28
|
-
var moreAttrTypes = getMoreAttrTypes(creatableAttrTypes, entity);
|
|
39
|
+
var moreAttrTypes = getMoreAttrTypes(creatableAttrTypes, entity, showEmptyEditors, hasDeletionsMap);
|
|
29
40
|
var pinnedAttributes = useContext(PinnedAttributesContext);
|
|
30
41
|
var pagersData = useMemo(function () { return getAttributesListForEditMode(attrTypes, mode, entity, showEmptyEditors, showNonOv, pinnedAttributes); }, [attrTypes, mode, entity, showEmptyEditors, showNonOv, pinnedAttributes]);
|
|
31
|
-
var
|
|
42
|
+
var _e = useMemo(function () { return splitPagersData(alwaysVisibleTypeUris, pagersData); }, [pagersData, alwaysVisibleTypeUris]), alwaysVisiblePagersData = _e[0], regularPagersData = _e[1];
|
|
32
43
|
var onAddMoreAttributes = useCallback(function (attributeTypes) {
|
|
33
44
|
onAddAttributes(attributeTypes.map(function (attributeType) { return ({ attributeType: attributeType, parentUri: parentUri }); }));
|
|
34
45
|
}, [onAddAttributes, parentUri]);
|
|
35
46
|
var decoratorProps = {
|
|
36
47
|
enabled: drawLines
|
|
37
48
|
};
|
|
49
|
+
var hasDeletionsContextValue = useMemo(function () { return ({
|
|
50
|
+
hasDeletionsMap: hasDeletionsMap,
|
|
51
|
+
setHasDeletions: setHasDeletions
|
|
52
|
+
}); }, [hasDeletionsMap, setHasDeletions]);
|
|
38
53
|
return (React.createElement("div", { className: className },
|
|
39
54
|
children && React.createElement(BranchDecorator, __assign({}, decoratorProps), children),
|
|
40
|
-
React.createElement(BranchDecorator, __assign({}, decoratorProps, { plain: true }),
|
|
41
|
-
regularPagersData.concat(alwaysVisiblePagersData).map(function (_a) {
|
|
55
|
+
React.createElement(BranchDecorator, __assign({}, decoratorProps, { plain: true }), moreAttrTypes.length > 0 && (React.createElement(MoreAttributesButton, { label: i18n.text('More attributes'), onApply: onAddMoreAttributes, dense: drawLines, data: moreAttrTypes }))),
|
|
56
|
+
React.createElement(HasDeletionsContext.Provider, { value: hasDeletionsContextValue }, regularPagersData.concat(alwaysVisiblePagersData).map(function (_a) {
|
|
42
57
|
var attrType = _a.attrType, values = _a.values;
|
|
43
58
|
return (React.createElement(AttributesPager, { key: attrType.uri, attributeType: attrType, drawLines: drawLines, values: values, paging: path(['paging', attrType.uri], attributes), parentUri: parentUri, showEmptyEditors: showEmptyEditors, mode: mode, crosswalks: crosswalks, onAddAttributes: onAddAttributes, onChangeAttribute: onChangeAttribute, onDeleteAttribute: onDeleteAttribute, additionalControlsRenderer: additionalControlsRenderer, showNonOv: showNonOv }));
|
|
44
|
-
})));
|
|
59
|
+
}))));
|
|
45
60
|
};
|
|
46
61
|
AttributesList.propTypes = {
|
|
47
62
|
attrTypes: PropTypes.array,
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import { AttributeType, Entity } from '@reltio/mdm-sdk';
|
|
2
|
-
export declare const getMoreAttrTypes: (attrTypes: AttributeType[], entity: Entity
|
|
2
|
+
export declare const getMoreAttrTypes: (attrTypes: AttributeType[], entity: Entity, showEmptyEditors?: boolean, hasDeletionsMap?: {
|
|
3
|
+
[attrTypeUri: string]: boolean;
|
|
4
|
+
}) => AttributeType[];
|
|
@@ -11,11 +11,11 @@ var getSource = function (attrType, entity) {
|
|
|
11
11
|
var getNameProp = function (attrType) {
|
|
12
12
|
return isSpecialAttribute(attrType) ? 'uri' : 'name';
|
|
13
13
|
};
|
|
14
|
-
export var getMoreAttrTypes = function (attrTypes, entity) {
|
|
14
|
+
export var getMoreAttrTypes = function (attrTypes, entity, showEmptyEditors, hasDeletionsMap) {
|
|
15
15
|
return attrTypes.filter(function (attrType) {
|
|
16
16
|
var source = getSource(attrType, entity);
|
|
17
17
|
var nameProp = getNameProp(attrType);
|
|
18
18
|
return !((attrType.singleValue || isRoleAttrType(attrType) || isTagAttrType(attrType)) &&
|
|
19
|
-
has(attrType[nameProp])(source));
|
|
19
|
+
(has(attrType[nameProp])(source) || (showEmptyEditors && !(hasDeletionsMap === null || hasDeletionsMap === void 0 ? void 0 : hasDeletionsMap[attrType.uri]))));
|
|
20
20
|
});
|
|
21
21
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import React from 'react';
|
|
2
2
|
import { AttributeType, Mode, AttributeItem } from '@reltio/mdm-sdk';
|
|
3
3
|
declare type Props = {
|
|
4
4
|
values: string[] | number[];
|
|
@@ -9,6 +9,9 @@ declare type Props = {
|
|
|
9
9
|
onDeleteAttribute: (param: AttributeItem) => void;
|
|
10
10
|
onChangeAttribute: (param: AttributeItem) => void;
|
|
11
11
|
showEmptyEditors?: boolean;
|
|
12
|
+
hasDeletions?: boolean;
|
|
13
|
+
setHasDeletions?: (attrTypeUri: string, value: boolean) => void;
|
|
12
14
|
};
|
|
13
|
-
declare const SpecialRenderer: ({ values, attributeType, parentUri, mode, errorMessage, onDeleteAttribute, onChangeAttribute, showEmptyEditors, ...otherProps }: Props) => JSX.Element;
|
|
14
|
-
|
|
15
|
+
export declare const SpecialRenderer: ({ values, attributeType, parentUri, mode, errorMessage, onDeleteAttribute, onChangeAttribute, showEmptyEditors, hasDeletions: hasDeletionsProp, setHasDeletions, ...otherProps }: Props) => JSX.Element;
|
|
16
|
+
declare const _default: React.ComponentType<Props> | ((props: any) => JSX.Element);
|
|
17
|
+
export default _default;
|
|
@@ -31,16 +31,26 @@ import Attribute from '../AttributesFactory/Attribute';
|
|
|
31
31
|
import { Roles } from '../Roles/Roles';
|
|
32
32
|
import Tags from '../Tags';
|
|
33
33
|
import { useStyles } from './styles';
|
|
34
|
-
|
|
35
|
-
|
|
34
|
+
import { HasDeletionsContext } from '../contexts/HasDeletionsContext';
|
|
35
|
+
import { withContext } from '../../../../HOCs';
|
|
36
|
+
export var SpecialRenderer = function (_a) {
|
|
37
|
+
var values = _a.values, attributeType = _a.attributeType, parentUri = _a.parentUri, mode = _a.mode, errorMessage = _a.errorMessage, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, showEmptyEditors = _a.showEmptyEditors, hasDeletionsProp = _a.hasDeletions, setHasDeletions = _a.setHasDeletions, otherProps = __rest(_a, ["values", "attributeType", "parentUri", "mode", "errorMessage", "onDeleteAttribute", "onChangeAttribute", "showEmptyEditors", "hasDeletions", "setHasDeletions"]);
|
|
36
38
|
var styles = useStyles();
|
|
37
39
|
var label = attributeType.label, isRequired = attributeType.required, cardinality = attributeType.cardinality;
|
|
38
40
|
var isEditableMode = checkIsEditableMode(mode);
|
|
39
|
-
var _b = useState(false),
|
|
41
|
+
var _b = useState(false), hasDeletionsState = _b[0], setHasDeletionsState = _b[1];
|
|
42
|
+
var updateHasDeletions = useCallback(function (value) {
|
|
43
|
+
setHasDeletionsState(value);
|
|
44
|
+
setHasDeletions === null || setHasDeletions === void 0 ? void 0 : setHasDeletions(attributeType.uri, value);
|
|
45
|
+
}, [attributeType.uri, setHasDeletions]);
|
|
46
|
+
var hasDeletions = hasDeletionsProp !== undefined ? hasDeletionsProp : hasDeletionsState;
|
|
40
47
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
41
|
-
var onDelete = useCallback(pipe(onDeleteAttribute, T,
|
|
48
|
+
var onDelete = useCallback(pipe(onDeleteAttribute, T, updateHasDeletions), [
|
|
49
|
+
onDeleteAttribute,
|
|
50
|
+
updateHasDeletions
|
|
51
|
+
]);
|
|
42
52
|
var isEmptyValues = isEmptyValue(values);
|
|
43
|
-
var showEmpty = !
|
|
53
|
+
var showEmpty = !hasDeletions && showEmptyEditors && isEmptyValues;
|
|
44
54
|
var emptyEditorValue = useRef(createNewAttribute({
|
|
45
55
|
parentUri: parentUri,
|
|
46
56
|
attributeType: attributeType
|
|
@@ -67,4 +77,11 @@ var SpecialRenderer = function (_a) {
|
|
|
67
77
|
isEditableMode && React.createElement(ErrorMessage, { message: errorMessage }),
|
|
68
78
|
React.createElement(Box, { className: styles.attributesWrapper }, renderValue())));
|
|
69
79
|
};
|
|
70
|
-
export default
|
|
80
|
+
export default withContext(HasDeletionsContext, function (contextValue, _a) {
|
|
81
|
+
var attributeType = _a.attributeType;
|
|
82
|
+
var _b = contextValue || {}, hasDeletionsMap = _b.hasDeletionsMap, setHasDeletions = _b.setHasDeletions;
|
|
83
|
+
return {
|
|
84
|
+
hasDeletions: hasDeletionsMap ? Boolean(hasDeletionsMap[attributeType === null || attributeType === void 0 ? void 0 : attributeType.uri]) : undefined,
|
|
85
|
+
setHasDeletions: setHasDeletions
|
|
86
|
+
};
|
|
87
|
+
}, SpecialRenderer);
|
|
@@ -12,7 +12,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import { useCallback, useContext, useEffect, useRef, useState } from 'react';
|
|
13
13
|
import { useDispatch, useSelector } from 'react-redux';
|
|
14
14
|
import mdmModule, { ui } from '@reltio/mdm-module';
|
|
15
|
-
import { initializeWebWorker, isEmptyValue } from '@reltio/mdm-sdk';
|
|
15
|
+
import { CustomScriptPlatform, initializeWebWorker, isEmptyValue } from '@reltio/mdm-sdk';
|
|
16
16
|
import { useWorkflowCheckPermission } from '../../components/workflow';
|
|
17
17
|
import { SandboxAPIContext } from '../../contexts';
|
|
18
18
|
import { processRequest } from './API';
|
|
@@ -150,7 +150,7 @@ export var useAPI = function (config) {
|
|
|
150
150
|
}
|
|
151
151
|
};
|
|
152
152
|
useEffect(function () {
|
|
153
|
-
if (!isEmptyValue(config.action)) {
|
|
153
|
+
if (!isEmptyValue(config.action) && config.action.platform !== CustomScriptPlatform.CLASSIC) {
|
|
154
154
|
workerRef.current = initializeWebWorker(workerUrl, config.action.files, process);
|
|
155
155
|
return function () {
|
|
156
156
|
workerRef.current.terminate();
|
|
@@ -9,10 +9,15 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
13
|
+
for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
|
14
|
+
to[j] = from[i];
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
12
17
|
import { useContext, useEffect, useRef } from 'react';
|
|
13
18
|
import { useDispatch, useSelector } from 'react-redux';
|
|
14
19
|
import mdmModule, { ui } from '@reltio/mdm-module';
|
|
15
|
-
import { initializeWebWorker, isEmptyValue } from '@reltio/mdm-sdk';
|
|
20
|
+
import { CustomScriptPlatform, initializeWebWorker, isEmptyValue } from '@reltio/mdm-sdk';
|
|
16
21
|
import nanoid from 'nanoid';
|
|
17
22
|
import { find, map, pick, pipe, prop, omit } from 'ramda';
|
|
18
23
|
import { useWorkflowCheckPermission } from '../components/workflow';
|
|
@@ -26,7 +31,12 @@ var isURLtoProcess = function (processApi, url) {
|
|
|
26
31
|
};
|
|
27
32
|
export var useCustomScripts = function (config, _a) {
|
|
28
33
|
var addInternalRequestInterceptor = _a.addInternalRequestInterceptor, addInternalResponseInterceptor = _a.addInternalResponseInterceptor, removeInternalRequestInterceptor = _a.removeInternalRequestInterceptor, removeInternalResponseInterceptor = _a.removeInternalResponseInterceptor;
|
|
29
|
-
var customScripts = config.
|
|
34
|
+
var customScripts = config.reduce(function (acc, customScript) {
|
|
35
|
+
if (customScript.platform !== CustomScriptPlatform.CLASSIC) {
|
|
36
|
+
return __spreadArray(__spreadArray([], acc), [__assign(__assign({}, customScript), { actionId: nanoid() })]);
|
|
37
|
+
}
|
|
38
|
+
return acc;
|
|
39
|
+
}, []);
|
|
30
40
|
var dispatch = useDispatch();
|
|
31
41
|
var metadata = useSelector(mdmModule.selectors.getMetadata) || {};
|
|
32
42
|
var entity = useSelector(mdmModule.selectors.getEntity) || {};
|
|
@@ -90,8 +100,7 @@ export var useCustomScripts = function (config, _a) {
|
|
|
90
100
|
useEffect(function () {
|
|
91
101
|
workers.current = customScripts.reduce(function (acc, customScript) {
|
|
92
102
|
var _a;
|
|
93
|
-
|
|
94
|
-
return acc;
|
|
103
|
+
return __assign(__assign({}, acc), (_a = {}, _a[customScript.actionId] = initializeWebWorker(workerUrl, customScript.files, process), _a));
|
|
95
104
|
}, workers.current);
|
|
96
105
|
return function () {
|
|
97
106
|
Object.keys(workers.current).forEach(function (actionId) {
|
|
@@ -177,7 +186,7 @@ export var useCustomScripts = function (config, _a) {
|
|
|
177
186
|
}
|
|
178
187
|
};
|
|
179
188
|
useEffect(function () {
|
|
180
|
-
if (!isEmptyValue(
|
|
189
|
+
if (!isEmptyValue(customScripts)) {
|
|
181
190
|
addInternalRequestInterceptor(customScriptRequestInterceptor);
|
|
182
191
|
addInternalResponseInterceptor(customScriptResponseInterceptor);
|
|
183
192
|
return function () {
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1148",
|
|
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.1148",
|
|
11
|
+
"@reltio/mdm-sdk": "^1.4.1148",
|
|
12
12
|
"classnames": "^2.2.5",
|
|
13
13
|
"d3-cloud": "^1.2.5",
|
|
14
14
|
"d3-geo": "^2.0.1",
|