@reltio/components 1.4.1164 → 1.4.1168
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/CollaborationItem/CollaborationItem.js +3 -10
- package/cjs/components/CollaborationItem/Comment/Comment.d.ts +3 -2
- package/cjs/components/CollaborationItem/Comment/Comment.js +24 -14
- package/cjs/components/CollaborationItem/Comment/styles.d.ts +1 -1
- package/cjs/components/CollaborationItem/RepliedComment/RepliedComment.d.ts +7 -4
- package/cjs/components/CollaborationItem/RepliedComment/RepliedComment.js +57 -5
- package/cjs/components/CollaborationItem/SendMessageArea/SendMessageArea.d.ts +6 -4
- package/cjs/components/CollaborationItem/SendMessageArea/SendMessageArea.js +30 -12
- package/cjs/components/CollaborationItem/SendMessageArea/styles.d.ts +5 -1
- package/cjs/components/CollaborationItem/SendMessageArea/styles.js +15 -9
- package/cjs/components/CollaborationItem/TextFieldWithMentions/styles.js +1 -3
- package/cjs/components/attributes/editMode/AttributesList/AttributesList.d.ts +3 -1
- package/cjs/components/attributes/editMode/AttributesList/AttributesList.js +9 -4
- package/cjs/components/attributes/editMode/ComplexAttribute/ComplexAttribute.js +1 -1
- package/cjs/components/attributes/editMode/MoreAttributesButton/MoreAttributesButton.d.ts +3 -1
- package/cjs/components/attributes/editMode/MoreAttributesButton/MoreAttributesButton.js +22 -23
- package/cjs/components/attributes/editMode/MoreAttributesButton/helpers.d.ts +8 -0
- package/cjs/components/attributes/editMode/MoreAttributesButton/helpers.js +18 -0
- package/cjs/components/attributes/editMode/MoreAttributesButton/styles.d.ts +1 -1
- package/cjs/components/attributes/editMode/MoreAttributesButton/styles.js +20 -0
- package/cjs/components/attributes/editMode/MoreAttributesButton/useMoreAttributesItems.d.ts +22 -0
- package/cjs/components/attributes/editMode/MoreAttributesButton/useMoreAttributesItems.js +60 -0
- package/cjs/contexts/CollaborationContext/index.d.ts +8 -0
- package/cjs/contexts/CollaborationContext/index.js +3 -1
- package/cjs/hooks/useCollaboration.d.ts +2 -0
- package/cjs/hooks/useCollaboration.js +57 -5
- package/esm/components/CollaborationItem/CollaborationItem.js +4 -11
- package/esm/components/CollaborationItem/Comment/Comment.d.ts +3 -2
- package/esm/components/CollaborationItem/Comment/Comment.js +25 -15
- package/esm/components/CollaborationItem/Comment/styles.d.ts +1 -1
- package/esm/components/CollaborationItem/RepliedComment/RepliedComment.d.ts +7 -4
- package/esm/components/CollaborationItem/RepliedComment/RepliedComment.js +38 -5
- package/esm/components/CollaborationItem/SendMessageArea/SendMessageArea.d.ts +6 -4
- package/esm/components/CollaborationItem/SendMessageArea/SendMessageArea.js +30 -12
- package/esm/components/CollaborationItem/SendMessageArea/styles.d.ts +5 -1
- package/esm/components/CollaborationItem/SendMessageArea/styles.js +15 -9
- package/esm/components/CollaborationItem/TextFieldWithMentions/styles.js +1 -3
- package/esm/components/attributes/editMode/AttributesList/AttributesList.d.ts +3 -1
- package/esm/components/attributes/editMode/AttributesList/AttributesList.js +10 -5
- package/esm/components/attributes/editMode/ComplexAttribute/ComplexAttribute.js +1 -1
- package/esm/components/attributes/editMode/MoreAttributesButton/MoreAttributesButton.d.ts +3 -1
- package/esm/components/attributes/editMode/MoreAttributesButton/MoreAttributesButton.js +23 -24
- package/esm/components/attributes/editMode/MoreAttributesButton/helpers.d.ts +8 -0
- package/esm/components/attributes/editMode/MoreAttributesButton/helpers.js +15 -0
- package/esm/components/attributes/editMode/MoreAttributesButton/styles.d.ts +1 -1
- package/esm/components/attributes/editMode/MoreAttributesButton/styles.js +20 -0
- package/esm/components/attributes/editMode/MoreAttributesButton/useMoreAttributesItems.d.ts +22 -0
- package/esm/components/attributes/editMode/MoreAttributesButton/useMoreAttributesItems.js +53 -0
- package/esm/contexts/CollaborationContext/index.d.ts +8 -0
- package/esm/contexts/CollaborationContext/index.js +3 -1
- package/esm/hooks/useCollaboration.d.ts +2 -0
- package/esm/hooks/useCollaboration.js +58 -6
- package/package.json +3 -3
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { makeStyles } from '@material-ui/core/styles';
|
|
2
2
|
export var useStyles = makeStyles({
|
|
3
|
-
root: {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
root: function (_a) {
|
|
4
|
+
var isEditing = _a.isEditing;
|
|
5
|
+
return ({
|
|
6
|
+
padding: isEditing ? '6px 6px 6px 0' : ' 6px 6px 6px 8px',
|
|
7
|
+
borderRadius: '4px',
|
|
8
|
+
backgroundColor: isEditing ? 'transparent' : 'rgba(0,114,206,0.06)'
|
|
9
|
+
});
|
|
7
10
|
},
|
|
8
|
-
textField: {
|
|
9
|
-
|
|
11
|
+
textField: function (_a) {
|
|
12
|
+
var isEditing = _a.isEditing;
|
|
13
|
+
return ({
|
|
14
|
+
maxWidth: isEditing ? '100%' : 'calc(100% - 40px)'
|
|
15
|
+
});
|
|
10
16
|
},
|
|
11
17
|
form: {
|
|
12
18
|
marginBottom: 0
|
|
@@ -18,9 +24,9 @@ export var useStyles = makeStyles({
|
|
|
18
24
|
avatar: {
|
|
19
25
|
marginRight: '8px'
|
|
20
26
|
},
|
|
21
|
-
buttons: {
|
|
22
|
-
|
|
23
|
-
marginTop: '8px'
|
|
27
|
+
buttons: function (_a) {
|
|
28
|
+
var isEditing = _a.isEditing;
|
|
29
|
+
return ({ marginLeft: isEditing ? '0' : '40px', marginTop: '8px' });
|
|
24
30
|
},
|
|
25
31
|
button: {
|
|
26
32
|
'& + $button': {
|
|
@@ -9,15 +9,13 @@ export var useStyles = makeStyles(function (theme) { return ({
|
|
|
9
9
|
},
|
|
10
10
|
'&__highlighter': {
|
|
11
11
|
padding: '10px 22px',
|
|
12
|
-
border: '1px solid transparent !important'
|
|
13
|
-
maxHeight: '70px'
|
|
12
|
+
border: '1px solid transparent !important'
|
|
14
13
|
},
|
|
15
14
|
'&__input': {
|
|
16
15
|
borderRadius: '2px',
|
|
17
16
|
border: '1px solid rgba(0,0,0,0.12)',
|
|
18
17
|
padding: '10px 22px',
|
|
19
18
|
outline: 0,
|
|
20
|
-
maxHeight: '70px',
|
|
21
19
|
overflow: 'auto !important'
|
|
22
20
|
},
|
|
23
21
|
'&__suggestions': {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare var _default: React.MemoExoticComponent<{
|
|
2
|
-
({ attrTypes, entity, parentUri, showEmptyEditors, mode, crosswalks, drawLines, children, className, alwaysVisibleTypeUris, onAddAttributes, onChangeAttribute, onDeleteAttribute, additionalControlsRenderer, showNonOv }: {
|
|
2
|
+
({ parentAttributeType, attrTypes, entity, parentUri, showEmptyEditors, mode, crosswalks, drawLines, children, className, alwaysVisibleTypeUris, onAddAttributes, onChangeAttribute, onDeleteAttribute, additionalControlsRenderer, showNonOv }: {
|
|
3
|
+
parentAttributeType: any;
|
|
3
4
|
attrTypes: any;
|
|
4
5
|
entity: any;
|
|
5
6
|
parentUri: any;
|
|
@@ -17,6 +18,7 @@ declare var _default: React.MemoExoticComponent<{
|
|
|
17
18
|
showNonOv: any;
|
|
18
19
|
}): JSX.Element;
|
|
19
20
|
propTypes: {
|
|
21
|
+
parentAttributeType: PropTypes.Requireable<object>;
|
|
20
22
|
attrTypes: PropTypes.Requireable<any[]>;
|
|
21
23
|
entity: PropTypes.Requireable<object>;
|
|
22
24
|
parentUri: PropTypes.Requireable<string>;
|
|
@@ -12,7 +12,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
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
|
-
import { getCreatableAttributeTypes, getAttributesListForEditMode, ModeType } from '@reltio/mdm-sdk';
|
|
15
|
+
import { getCreatableAttributeTypes, getAttributesListForEditMode, ModeType, getParentUri, checkCanCreateAttribute } from '@reltio/mdm-sdk';
|
|
16
16
|
import { path } from 'ramda';
|
|
17
17
|
import AttributesPager from '../AttributesPager';
|
|
18
18
|
import BranchDecorator from '../../BranchDecorator/BranchDecorator';
|
|
@@ -23,7 +23,7 @@ import { getMoreAttrTypes } from './helpers';
|
|
|
23
23
|
import { PinnedAttributesContext } from '../contexts/PinnedAttributesContext';
|
|
24
24
|
import { HasDeletionsContext } from '../contexts/HasDeletionsContext';
|
|
25
25
|
var AttributesList = function (_a) {
|
|
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
|
+
var parentAttributeType = _a.parentAttributeType, 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;
|
|
27
27
|
var _c = entity.attributes, attributes = _c === void 0 ? {} : _c;
|
|
28
28
|
var _d = useState({}), hasDeletionsMap = _d[0], setHasDeletionsMap = _d[1];
|
|
29
29
|
var setHasDeletions = useCallback(function (attrTypeUri, value) {
|
|
@@ -35,14 +35,18 @@ var AttributesList = function (_a) {
|
|
|
35
35
|
useEffect(function () {
|
|
36
36
|
setHasDeletionsMap({});
|
|
37
37
|
}, [parentUri]);
|
|
38
|
+
var canCreateParentAttrType = useMemo(function () { return parentAttributeType && checkCanCreateAttribute({ attributeType: parentAttributeType, mode: mode }); }, [parentAttributeType, mode]);
|
|
38
39
|
var creatableAttrTypes = useMemo(function () { return getCreatableAttributeTypes(mode, attrTypes); }, [attrTypes, mode]);
|
|
39
40
|
var moreAttrTypes = getMoreAttrTypes(creatableAttrTypes, entity, showEmptyEditors, hasDeletionsMap);
|
|
40
41
|
var pinnedAttributes = useContext(PinnedAttributesContext);
|
|
41
42
|
var pagersData = useMemo(function () { return getAttributesListForEditMode(attrTypes, mode, entity, showEmptyEditors, showNonOv, pinnedAttributes); }, [attrTypes, mode, entity, showEmptyEditors, showNonOv, pinnedAttributes]);
|
|
42
43
|
var _e = useMemo(function () { return splitPagersData(alwaysVisibleTypeUris, pagersData); }, [pagersData, alwaysVisibleTypeUris]), alwaysVisiblePagersData = _e[0], regularPagersData = _e[1];
|
|
43
44
|
var onAddMoreAttributes = useCallback(function (attributeTypes) {
|
|
44
|
-
onAddAttributes(attributeTypes.map(function (attributeType) { return ({
|
|
45
|
-
|
|
45
|
+
onAddAttributes(attributeTypes.map(function (attributeType) { return ({
|
|
46
|
+
attributeType: attributeType,
|
|
47
|
+
parentUri: attributeType === parentAttributeType ? getParentUri(parentUri) : parentUri
|
|
48
|
+
}); }));
|
|
49
|
+
}, [onAddAttributes, parentUri, parentAttributeType]);
|
|
46
50
|
var decoratorProps = {
|
|
47
51
|
enabled: drawLines
|
|
48
52
|
};
|
|
@@ -52,13 +56,14 @@ var AttributesList = function (_a) {
|
|
|
52
56
|
}); }, [hasDeletionsMap, setHasDeletions]);
|
|
53
57
|
return (React.createElement("div", { className: className },
|
|
54
58
|
children && React.createElement(BranchDecorator, __assign({}, decoratorProps), children),
|
|
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 }))),
|
|
59
|
+
React.createElement(BranchDecorator, __assign({}, decoratorProps, { plain: true }), moreAttrTypes.length > 0 && (React.createElement(MoreAttributesButton, { label: i18n.text('More attributes'), onApply: onAddMoreAttributes, dense: drawLines, data: moreAttrTypes, parent: canCreateParentAttrType && parentAttributeType }))),
|
|
56
60
|
React.createElement(HasDeletionsContext.Provider, { value: hasDeletionsContextValue }, regularPagersData.concat(alwaysVisiblePagersData).map(function (_a) {
|
|
57
61
|
var attrType = _a.attrType, values = _a.values;
|
|
58
62
|
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 }));
|
|
59
63
|
}))));
|
|
60
64
|
};
|
|
61
65
|
AttributesList.propTypes = {
|
|
66
|
+
parentAttributeType: PropTypes.object,
|
|
62
67
|
attrTypes: PropTypes.array,
|
|
63
68
|
entity: PropTypes.object,
|
|
64
69
|
parentUri: PropTypes.string,
|
|
@@ -79,7 +79,7 @@ var ComplexAttribute = function (_a) {
|
|
|
79
79
|
")")),
|
|
80
80
|
additionalControlsRenderer && additionalControlsRenderer({ attributeType: attributeType, attributeValue: attributeValue }),
|
|
81
81
|
showDeleteButton && React.createElement(SmallIconButton, { icon: DeleteIcon, onClick: onDeleteThis, size: "L" }))),
|
|
82
|
-
expanded && (React.createElement(AttributesList, { attrTypes: attributeTypesList, entity: attributeListEntity, showEmptyEditors: showEmptyEditors || isNew, drawLines: true, parentUri: uri, mode: mode, crosswalks: crosswalks, onAddAttributes: onAddAttributes, onChangeAttribute: onChangeAttribute, onDeleteAttribute: onDeleteAttribute, additionalControlsRenderer: additionalControlsRenderer, showNonOv: showNonOv }, children))));
|
|
82
|
+
expanded && (React.createElement(AttributesList, { parentAttributeType: attributeType, attrTypes: attributeTypesList, entity: attributeListEntity, showEmptyEditors: showEmptyEditors || isNew, drawLines: true, parentUri: uri, mode: mode, crosswalks: crosswalks, onAddAttributes: onAddAttributes, onChangeAttribute: onChangeAttribute, onDeleteAttribute: onDeleteAttribute, additionalControlsRenderer: additionalControlsRenderer, showNonOv: showNonOv }, children))));
|
|
83
83
|
};
|
|
84
84
|
ComplexAttribute.propTypes = __assign({ label: PropTypes.string, children: PropTypes.node, attributeTypesList: PropTypes.arrayOf(AttributeTypeType), attributeValue: PropTypes.oneOfType([NestedAttributeValueType, ReferenceAttributeValueType]) }, ComplexAttributeType);
|
|
85
85
|
export default ComplexAttribute;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
export default MoreAttributesButton;
|
|
2
|
-
declare function MoreAttributesButton({ label, popupTitle, data, dense, onApply }: {
|
|
2
|
+
declare function MoreAttributesButton({ label, popupTitle, data, parent, dense, onApply }: {
|
|
3
3
|
label: any;
|
|
4
4
|
popupTitle?: any;
|
|
5
5
|
data: any;
|
|
6
|
+
parent: any;
|
|
6
7
|
dense: any;
|
|
7
8
|
onApply: any;
|
|
8
9
|
}): JSX.Element;
|
|
@@ -11,6 +12,7 @@ declare namespace MoreAttributesButton {
|
|
|
11
12
|
const label: PropTypes.Requireable<string>;
|
|
12
13
|
const popupTitle: PropTypes.Requireable<string>;
|
|
13
14
|
const data: PropTypes.Requireable<any[]>;
|
|
15
|
+
const parent: PropTypes.Requireable<object>;
|
|
14
16
|
const dense: PropTypes.Requireable<boolean>;
|
|
15
17
|
const onApply: PropTypes.Requireable<(...args: any[]) => any>;
|
|
16
18
|
}
|
|
@@ -1,27 +1,28 @@
|
|
|
1
|
-
import React, { useCallback,
|
|
1
|
+
import React, { useCallback, useRef, useState } from 'react';
|
|
2
|
+
import i18n from 'ui-i18n';
|
|
2
3
|
import classnames from 'classnames';
|
|
3
4
|
import PropTypes from 'prop-types';
|
|
4
|
-
import { always, any, append,
|
|
5
|
+
import { always, any, append, ifElse, not, pipe, pluck, propEq, reject } from 'ramda';
|
|
5
6
|
import Button from '@material-ui/core/Button';
|
|
7
|
+
import ListItem from '@material-ui/core/ListItem';
|
|
8
|
+
import Typography from '@material-ui/core/Typography';
|
|
6
9
|
import { useStyles } from './styles';
|
|
7
10
|
import SelectionPopup from '../../../SelectionPopup/SelectionPopup';
|
|
8
11
|
import AttributeListItem from '../../../AttributeListItem/AttributeListItem';
|
|
9
|
-
import { flattenGroupedItemsData } from '../../../VirtualGroupedList/helpers';
|
|
10
12
|
import VirtualGroupedList from '../../../VirtualGroupedList/VirtualGroupedList';
|
|
11
13
|
import { useKeyboardNavigation } from '../../../SelectionPopup/helpers';
|
|
12
14
|
import AddIcon from '@material-ui/icons/Add';
|
|
13
15
|
import Highlighter from '../../../Highlighter/Highlighter';
|
|
16
|
+
import { useMoreAttributesItems } from './useMoreAttributesItems';
|
|
14
17
|
var ITEM_HEIGHT = 28;
|
|
18
|
+
var ITEM_GROUP_TITLE_HEIGHT = 40;
|
|
15
19
|
var LIST_CONTAINER_WIDTH = 320;
|
|
16
20
|
var MAX_LIST_CONTAINER_HEIGHT = 255;
|
|
17
21
|
var MIN_CONTAINER_HEIGHT = 140;
|
|
18
22
|
var CONTAINER_HEADER_HEIGHT = 112;
|
|
19
|
-
var filterItems = curry(function (filterText, items) {
|
|
20
|
-
return filter(function (item) { return item.label.toLowerCase().includes(filterText.toLowerCase()); })(items);
|
|
21
|
-
});
|
|
22
23
|
var MoreAttributesButton = function (_a) {
|
|
23
24
|
var _b;
|
|
24
|
-
var label = _a.label, _c = _a.popupTitle, popupTitle = _c === void 0 ? label : _c, data = _a.data, dense = _a.dense, onApply = _a.onApply;
|
|
25
|
+
var label = _a.label, _c = _a.popupTitle, popupTitle = _c === void 0 ? label : _c, data = _a.data, parent = _a.parent, dense = _a.dense, onApply = _a.onApply;
|
|
25
26
|
var styles = useStyles();
|
|
26
27
|
var inputRef = useRef();
|
|
27
28
|
var _d = useState(false), isOpen = _d[0], setIsOpen = _d[1];
|
|
@@ -31,6 +32,7 @@ var MoreAttributesButton = function (_a) {
|
|
|
31
32
|
var clearFilter = function () { return setFilter(''); };
|
|
32
33
|
var _f = useState([]), selectedItems = _f[0], setSelectedItems = _f[1];
|
|
33
34
|
var clearSelectedItems = function () { return setSelectedItems([]); };
|
|
35
|
+
var _g = useMoreAttributesItems({ data: data, parent: parent, filter: filter }), items = _g.items, hasGroups = _g.hasGroups, parentGroupLength = _g.parentGroupLength, attributesGroupLength = _g.attributesGroupLength;
|
|
34
36
|
var addSelectedAttributes = function () {
|
|
35
37
|
if (selectedItems.length > 0) {
|
|
36
38
|
onApply(pluck('attrType', selectedItems));
|
|
@@ -39,48 +41,45 @@ var MoreAttributesButton = function (_a) {
|
|
|
39
41
|
var handleListItemClick = useCallback(function (item, checked) {
|
|
40
42
|
setSelectedItems(ifElse(always(checked), append(item), reject(propEq('id', item.id)))(selectedItems));
|
|
41
43
|
}, [selectedItems]);
|
|
42
|
-
var
|
|
43
|
-
return pipe(filterItems(filter), map(function (attrType) { return ({
|
|
44
|
-
item: {
|
|
45
|
-
id: attrType.uri,
|
|
46
|
-
label: attrType.label,
|
|
47
|
-
attrType: attrType
|
|
48
|
-
}
|
|
49
|
-
}); }))(data);
|
|
50
|
-
}, [data, filter]);
|
|
51
|
-
var items = useMemo(function () { return flattenGroupedItemsData(preparedGroupedItems); }, [preparedGroupedItems]);
|
|
52
|
-
var getItemSize = useCallback(function () { return ITEM_HEIGHT; }, []);
|
|
44
|
+
var getItemSize = useCallback(function (i, item) { return (item.items ? ITEM_GROUP_TITLE_HEIGHT : ITEM_HEIGHT); }, []);
|
|
53
45
|
var handleSearchOnEnter = useCallback(function (_a) {
|
|
54
46
|
var item = _a.item;
|
|
55
47
|
handleListItemClick(item, not(any(propEq('id', item.id))(selectedItems)));
|
|
56
48
|
}, [handleListItemClick, selectedItems]);
|
|
57
|
-
var
|
|
49
|
+
var _h = useKeyboardNavigation({
|
|
58
50
|
items: items,
|
|
59
51
|
open: isOpen,
|
|
60
52
|
onSelectFocusedItem: handleSearchOnEnter,
|
|
61
53
|
selectedItems: selectedItems
|
|
62
|
-
}), focusIndex =
|
|
54
|
+
}), focusIndex = _h.focusIndex, handleKeyDown = _h.handleKeyDown;
|
|
63
55
|
var focusIndexRef = useRef(null);
|
|
64
56
|
focusIndexRef.current = focusIndex;
|
|
65
|
-
var
|
|
57
|
+
var groupsCount = hasGroups ? (parentGroupLength ? 1 : 0) + (attributesGroupLength ? 1 : 0) : 0;
|
|
58
|
+
var itemsCount = items.length - groupsCount;
|
|
59
|
+
var listHeight = Math.min(MAX_LIST_CONTAINER_HEIGHT, ITEM_HEIGHT * itemsCount + ITEM_GROUP_TITLE_HEIGHT * groupsCount);
|
|
66
60
|
var containerHeight = Math.max(MIN_CONTAINER_HEIGHT, listHeight + CONTAINER_HEADER_HEIGHT);
|
|
67
61
|
var listItemRenderer = useCallback(function (style, _a, index) {
|
|
68
|
-
var
|
|
62
|
+
var _b;
|
|
63
|
+
var item = _a.item, _c = _a.level, level = _c === void 0 ? 0 : _c;
|
|
69
64
|
var isChecked = any(propEq('id', item.id))(selectedItems);
|
|
70
65
|
var isFocused = focusIndexRef.current === index;
|
|
71
|
-
return (React.createElement(AttributeListItem, { key: item.uri, onClick: handleListItemClick, checked: isChecked, level: level, data: item, label: React.createElement(Highlighter, { text: item.label, highlight: filter }), labelInText: item.label, style: style, isFocused: isFocused, isRequired: !!item.attrType.required, LogoIcon: item.LogoIcon }));
|
|
66
|
+
return (React.createElement(AttributeListItem, { key: item.uri, onClick: handleListItemClick, checked: isChecked, level: level, data: item, label: React.createElement(Highlighter, { text: item.label, highlight: filter }), labelInText: item.label, style: style, isFocused: isFocused, isRequired: !!((_b = item.attrType) === null || _b === void 0 ? void 0 : _b.required), LogoIcon: item.LogoIcon }));
|
|
72
67
|
}, [filter, handleListItemClick, selectedItems]);
|
|
68
|
+
var renderGroupTitle = useCallback(function (style, item) { return (React.createElement(ListItem, { component: 'div', className: styles.subHeader, style: style, key: "group-" + item.item.id }, item.item.label)); }, []);
|
|
73
69
|
return (React.createElement("div", { className: classnames(styles.moreAttributes, (_b = {}, _b[styles.dense] = dense, _b)) },
|
|
74
70
|
React.createElement(Button, { color: "primary", onClick: togglePopupOpen, ref: inputRef, className: styles.moreButton },
|
|
75
71
|
React.createElement(AddIcon, { classes: { root: styles.icon } }),
|
|
76
72
|
React.createElement("div", { className: styles.buttonLabel }, label)),
|
|
77
73
|
React.createElement(SelectionPopup, { open: isOpen, className: classnames(styles.moreAttributesPopup, styles.popupContainer), anchorEl: inputRef.current, onClose: pipe(addSelectedAttributes, closePopup, clearFilter, clearSelectedItems), onSearch: setFilter, containerHeight: containerHeight, title: popupTitle, containerWidth: LIST_CONTAINER_WIDTH, searchInputOnKeyDown: handleKeyDown },
|
|
78
|
-
React.createElement(VirtualGroupedList, { getItemSize: getItemSize, renderItem: listItemRenderer, items: items, height: listHeight, containerWidth: LIST_CONTAINER_WIDTH, focusIndex: focusIndex })
|
|
74
|
+
React.createElement(VirtualGroupedList, { getItemSize: getItemSize, renderItem: listItemRenderer, renderGroupTitle: renderGroupTitle, items: items, height: listHeight, containerWidth: LIST_CONTAINER_WIDTH, focusIndex: focusIndex }),
|
|
75
|
+
items.length === 0 && (React.createElement("div", { className: styles.noResultsCaptionContainer },
|
|
76
|
+
React.createElement(Typography, { variant: "caption", display: "block", gutterBottom: true }, i18n.text('No results found')))))));
|
|
79
77
|
};
|
|
80
78
|
MoreAttributesButton.propTypes = {
|
|
81
79
|
label: PropTypes.string,
|
|
82
80
|
popupTitle: PropTypes.string,
|
|
83
81
|
data: PropTypes.array,
|
|
82
|
+
parent: PropTypes.object,
|
|
84
83
|
dense: PropTypes.bool,
|
|
85
84
|
onApply: PropTypes.func
|
|
86
85
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { AttributeType } from '@reltio/mdm-sdk';
|
|
2
|
+
import { GroupedItem } from './useMoreAttributesItems';
|
|
3
|
+
declare type Props = {
|
|
4
|
+
attrTypes: AttributeType[];
|
|
5
|
+
filter?: string;
|
|
6
|
+
};
|
|
7
|
+
declare const preparedGroupedItems: ({ attrTypes, filter }: Props) => GroupedItem[];
|
|
8
|
+
export { preparedGroupedItems };
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { curry, filter, map, pipe } from 'ramda';
|
|
2
|
+
var filterItems = curry(function (filterText, items) {
|
|
3
|
+
return filter(function (item) { return item.label.toLowerCase().includes(filterText.toLowerCase()); })(items);
|
|
4
|
+
});
|
|
5
|
+
var preparedGroupedItems = function (_a) {
|
|
6
|
+
var attrTypes = _a.attrTypes, _b = _a.filter, filter = _b === void 0 ? '' : _b;
|
|
7
|
+
return pipe(filterItems(filter), map(function (attrType) { return ({
|
|
8
|
+
item: {
|
|
9
|
+
id: attrType.uri,
|
|
10
|
+
label: attrType.label,
|
|
11
|
+
attrType: attrType
|
|
12
|
+
}
|
|
13
|
+
}); }))(attrTypes);
|
|
14
|
+
};
|
|
15
|
+
export { preparedGroupedItems };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"icon" | "dense" | "buttonLabel" | "moreButton" | "moreAttributes" | "popupContainer" | "moreAttributesPopup">;
|
|
1
|
+
export const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"icon" | "dense" | "buttonLabel" | "moreButton" | "subHeader" | "moreAttributes" | "popupContainer" | "moreAttributesPopup" | "noResultsCaptionContainer">;
|
|
@@ -24,5 +24,25 @@ export var useStyles = makeStyles({
|
|
|
24
24
|
icon: {
|
|
25
25
|
fontSize: '18px',
|
|
26
26
|
marginRight: '8px'
|
|
27
|
+
},
|
|
28
|
+
subHeader: {
|
|
29
|
+
backgroundColor: 'rgb(245, 245, 245)',
|
|
30
|
+
padding: '0 16px',
|
|
31
|
+
margin: 0,
|
|
32
|
+
display: 'flex',
|
|
33
|
+
alignItems: 'center',
|
|
34
|
+
color: 'rgba(0,0,0,0.84)',
|
|
35
|
+
fontSize: '14px',
|
|
36
|
+
fontWeight: 500
|
|
37
|
+
},
|
|
38
|
+
noResultsCaptionContainer: {
|
|
39
|
+
position: 'absolute',
|
|
40
|
+
top: 0,
|
|
41
|
+
bottom: 0,
|
|
42
|
+
left: 0,
|
|
43
|
+
right: 0,
|
|
44
|
+
display: 'flex',
|
|
45
|
+
justifyContent: 'center',
|
|
46
|
+
alignItems: 'center'
|
|
27
47
|
}
|
|
28
48
|
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AttributeType } from '@reltio/mdm-sdk';
|
|
2
|
+
declare type Props = {
|
|
3
|
+
data: AttributeType[];
|
|
4
|
+
parent?: AttributeType;
|
|
5
|
+
filter?: string;
|
|
6
|
+
};
|
|
7
|
+
declare type Item = {
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
attrType?: AttributeType;
|
|
11
|
+
};
|
|
12
|
+
export declare type GroupedItem = {
|
|
13
|
+
item: Item;
|
|
14
|
+
items?: GroupedItem[];
|
|
15
|
+
};
|
|
16
|
+
export declare const useMoreAttributesItems: ({ data, parent, filter }: Props) => {
|
|
17
|
+
items: any;
|
|
18
|
+
hasGroups: boolean;
|
|
19
|
+
parentGroupLength: number;
|
|
20
|
+
attributesGroupLength: number;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import i18n from 'ui-i18n';
|
|
3
|
+
import { flattenGroupedItemsData } from '../../../VirtualGroupedList/helpers';
|
|
4
|
+
import { preparedGroupedItems } from './helpers';
|
|
5
|
+
var GROUP_NAMES;
|
|
6
|
+
(function (GROUP_NAMES) {
|
|
7
|
+
GROUP_NAMES["parent"] = "parent";
|
|
8
|
+
GROUP_NAMES["attributes"] = "attributes";
|
|
9
|
+
})(GROUP_NAMES || (GROUP_NAMES = {}));
|
|
10
|
+
export var useMoreAttributesItems = function (_a) {
|
|
11
|
+
var data = _a.data, parent = _a.parent, filter = _a.filter;
|
|
12
|
+
var hasGroups = Boolean(parent);
|
|
13
|
+
var preparedParentGroupItem = useMemo(function () { return (hasGroups ? preparedGroupedItems({ attrTypes: [parent], filter: filter }) : []); }, [hasGroups, parent, filter]);
|
|
14
|
+
var parentGroup = useMemo(function () {
|
|
15
|
+
return hasGroups && (preparedParentGroupItem === null || preparedParentGroupItem === void 0 ? void 0 : preparedParentGroupItem.length)
|
|
16
|
+
? [
|
|
17
|
+
{
|
|
18
|
+
item: {
|
|
19
|
+
id: GROUP_NAMES.parent,
|
|
20
|
+
label: i18n.text('Parent')
|
|
21
|
+
},
|
|
22
|
+
items: preparedParentGroupItem
|
|
23
|
+
}
|
|
24
|
+
]
|
|
25
|
+
: [];
|
|
26
|
+
}, [hasGroups, preparedParentGroupItem]);
|
|
27
|
+
var preparedAttributesGroupItems = useMemo(function () {
|
|
28
|
+
return preparedGroupedItems({
|
|
29
|
+
attrTypes: data,
|
|
30
|
+
filter: filter
|
|
31
|
+
});
|
|
32
|
+
}, [data, filter]);
|
|
33
|
+
var attributesGroup = useMemo(function () {
|
|
34
|
+
return hasGroups && (preparedAttributesGroupItems === null || preparedAttributesGroupItems === void 0 ? void 0 : preparedAttributesGroupItems.length)
|
|
35
|
+
? [
|
|
36
|
+
{
|
|
37
|
+
item: {
|
|
38
|
+
id: GROUP_NAMES.attributes,
|
|
39
|
+
label: i18n.text('Attributes')
|
|
40
|
+
},
|
|
41
|
+
items: preparedAttributesGroupItems
|
|
42
|
+
}
|
|
43
|
+
]
|
|
44
|
+
: preparedAttributesGroupItems;
|
|
45
|
+
}, [hasGroups, preparedAttributesGroupItems]);
|
|
46
|
+
var items = useMemo(function () { return flattenGroupedItemsData((parentGroup || []).concat(attributesGroup)); }, [
|
|
47
|
+
parentGroup,
|
|
48
|
+
attributesGroup
|
|
49
|
+
]);
|
|
50
|
+
var parentGroupLength = parentGroup.length;
|
|
51
|
+
var attributesGroupLength = attributesGroup.length;
|
|
52
|
+
return { items: items, hasGroups: hasGroups, parentGroupLength: parentGroupLength, attributesGroupLength: attributesGroupLength };
|
|
53
|
+
};
|
|
@@ -14,9 +14,17 @@ export declare const CollaborationContext: React.Context<{
|
|
|
14
14
|
editComment: (params: Pick<Comment, 'content' | 'namedUsers' | 'objectType' | 'relatedObjectUris' | 'commentId' | 'replies'> & {
|
|
15
15
|
uri: string;
|
|
16
16
|
}) => Promise<void>;
|
|
17
|
+
editReply: (params: Pick<Reply, 'content' | 'namedUsers' | 'replyId'> & {
|
|
18
|
+
commentId: string;
|
|
19
|
+
}) => Promise<void>;
|
|
17
20
|
deleteComment: (params: Pick<Comment, 'commentId'> & {
|
|
18
21
|
uri: string;
|
|
19
22
|
}) => void;
|
|
23
|
+
deleteReply: (params: {
|
|
24
|
+
uri: string;
|
|
25
|
+
commentId: string;
|
|
26
|
+
reply: Pick<Reply, 'action' | 'replyId'>;
|
|
27
|
+
}) => void;
|
|
20
28
|
createReply: (params: Pick<Reply, 'content' | 'namedUsers' | 'action'> & {
|
|
21
29
|
uri: string;
|
|
22
30
|
commentId: string;
|
|
@@ -16,6 +16,8 @@ export var CollaborationContext = React.createContext({
|
|
|
16
16
|
deleteComment: noop,
|
|
17
17
|
sending: false,
|
|
18
18
|
loading: false,
|
|
19
|
-
pageToken: null
|
|
19
|
+
pageToken: null,
|
|
20
|
+
deleteReply: noop,
|
|
21
|
+
editReply: function () { return new Promise(noop); }
|
|
20
22
|
});
|
|
21
23
|
CollaborationContext.displayName = 'CollaborationContext';
|
|
@@ -22,5 +22,7 @@ export declare const useCollaboration: ({ objectIds, objectTypes, enabled }: Pro
|
|
|
22
22
|
reOpenThread: ({ commentId, uri }: any) => void;
|
|
23
23
|
resolveThread: ({ commentId, uri }: any) => void;
|
|
24
24
|
sending: boolean;
|
|
25
|
+
deleteReply: ({ uri, commentId, reply }: any) => void;
|
|
26
|
+
editReply: ({ content, namedUsers, commentId, replyId }: any) => Promise<void>;
|
|
25
27
|
};
|
|
26
28
|
export {};
|
|
@@ -17,8 +17,18 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
|
|
17
17
|
import { useCallback, useEffect, useState } from 'react';
|
|
18
18
|
import { useSelector } from 'react-redux';
|
|
19
19
|
import { andThen, fromPairs, map, otherwise, pipe, props, uniqBy, prop, propEq, when, always } from 'ramda';
|
|
20
|
-
import { createComment as createCommentRequest, createReply as createReplyRequest, getComment as getCommentRequest, getCommentsCount as getCommentsCountRequest, updateComment as updateCommentRequest, deleteComment as deleteCommentRequest, getComments as getCommentsRequest, isTempUri } from '@reltio/mdm-sdk';
|
|
20
|
+
import { createComment as createCommentRequest, createReply as createReplyRequest, getComment as getCommentRequest, getCommentsCount as getCommentsCountRequest, updateComment as updateCommentRequest, updateReply as updateReplyRequest, deleteComment as deleteCommentRequest, deleteReply as deleteReplyRequest, getComments as getCommentsRequest, isTempUri } from '@reltio/mdm-sdk';
|
|
21
21
|
import mdm from '@reltio/mdm-module';
|
|
22
|
+
var filterReplies = function (replyId, replies) { return replies.filter(function (reply) { return reply.replyId !== replyId; }); };
|
|
23
|
+
var getUpdatedReplies = function (comment, reply) {
|
|
24
|
+
var changedReplyIndex = comment.replies.findIndex(function (_a) {
|
|
25
|
+
var replyId = _a.replyId;
|
|
26
|
+
return replyId === reply.replyId;
|
|
27
|
+
});
|
|
28
|
+
var newReplies = __spreadArray([], comment.replies);
|
|
29
|
+
newReplies[changedReplyIndex] = reply;
|
|
30
|
+
return newReplies;
|
|
31
|
+
};
|
|
22
32
|
var defaultObjectIds = [];
|
|
23
33
|
var catchErrorInRequest = function (e) { return console.error('Collaboration error', e); };
|
|
24
34
|
export var useCollaboration = function (_a) {
|
|
@@ -144,8 +154,9 @@ export var useCollaboration = function (_a) {
|
|
|
144
154
|
.catch(catchErrorInRequest)
|
|
145
155
|
.finally(function () { return setSending(false); });
|
|
146
156
|
}, [collaborationPath, tenant]);
|
|
147
|
-
var updateReplyInState = useCallback(function (reply, uri, commentId) {
|
|
157
|
+
var updateReplyInState = useCallback(function (reply, uri, commentId, isDeleteReply) {
|
|
148
158
|
var newStatus = reply.action === 'resolve' ? 'resolved' : 'open';
|
|
159
|
+
var replyId = reply.replyId;
|
|
149
160
|
if (newStatus === 'resolved') {
|
|
150
161
|
setCurrentComment(function (prevCurrentComment) {
|
|
151
162
|
if (prevCurrentComment) {
|
|
@@ -156,7 +167,9 @@ export var useCollaboration = function (_a) {
|
|
|
156
167
|
else {
|
|
157
168
|
setCurrentComment(function (prevCurrentComment) {
|
|
158
169
|
if (prevCurrentComment) {
|
|
159
|
-
return __assign(__assign({}, prevCurrentComment), { replies:
|
|
170
|
+
return __assign(__assign({}, prevCurrentComment), { replies: isDeleteReply
|
|
171
|
+
? filterReplies(replyId, prevCurrentComment.replies)
|
|
172
|
+
: __spreadArray(__spreadArray([], prevCurrentComment.replies), [reply]) });
|
|
160
173
|
}
|
|
161
174
|
});
|
|
162
175
|
}
|
|
@@ -164,7 +177,7 @@ export var useCollaboration = function (_a) {
|
|
|
164
177
|
var _a;
|
|
165
178
|
return (__assign(__assign({}, prevCommentsMap), (_a = {}, _a[uri] = (prevCommentsMap[uri] || []).map(function (comment) {
|
|
166
179
|
if (comment.commentId === commentId) {
|
|
167
|
-
return __assign(__assign({}, comment), { status: newStatus, replies: comment.replies + 1 });
|
|
180
|
+
return __assign(__assign({}, comment), { status: newStatus, replies: isDeleteReply ? comment.replies - 1 : comment.replies + 1 });
|
|
168
181
|
}
|
|
169
182
|
return comment;
|
|
170
183
|
}), _a)));
|
|
@@ -172,12 +185,49 @@ export var useCollaboration = function (_a) {
|
|
|
172
185
|
setComments(function (prevComments) {
|
|
173
186
|
return prevComments.map(function (comment) {
|
|
174
187
|
if (comment.commentId === commentId) {
|
|
175
|
-
return __assign(__assign({}, comment), { status: newStatus, replies:
|
|
188
|
+
return __assign(__assign({}, comment), { status: newStatus, replies: isDeleteReply
|
|
189
|
+
? filterReplies(reply.replyId, comment.replies)
|
|
190
|
+
: __spreadArray(__spreadArray([], comment.replies), [reply]) });
|
|
191
|
+
}
|
|
192
|
+
return comment;
|
|
193
|
+
});
|
|
194
|
+
});
|
|
195
|
+
}, []);
|
|
196
|
+
var deleteReply = useCallback(function (_a) {
|
|
197
|
+
var uri = _a.uri, commentId = _a.commentId, reply = _a.reply;
|
|
198
|
+
setSending(true);
|
|
199
|
+
deleteReplyRequest({ collaborationPath: collaborationPath, tenant: tenant, commentId: commentId, replyId: reply.replyId })
|
|
200
|
+
.then(function () { return updateReplyInState(reply, uri, commentId, true); })
|
|
201
|
+
.catch(catchErrorInRequest)
|
|
202
|
+
.finally(function () { return setSending(false); });
|
|
203
|
+
}, [collaborationPath, updateReplyInState, tenant]);
|
|
204
|
+
var editReplyInState = useCallback(function (reply, commentId) {
|
|
205
|
+
setCurrentComment(function (prevCurrentComment) {
|
|
206
|
+
if (prevCurrentComment) {
|
|
207
|
+
return __assign(__assign({}, prevCurrentComment), { replies: getUpdatedReplies(prevCurrentComment, reply) });
|
|
208
|
+
}
|
|
209
|
+
});
|
|
210
|
+
setComments(function (prevComments) {
|
|
211
|
+
return prevComments.map(function (comment) {
|
|
212
|
+
if (comment.commentId === commentId) {
|
|
213
|
+
return __assign(__assign({}, comment), { replies: getUpdatedReplies(comment, reply) });
|
|
176
214
|
}
|
|
177
215
|
return comment;
|
|
178
216
|
});
|
|
179
217
|
});
|
|
180
218
|
}, []);
|
|
219
|
+
var editReply = useCallback(function (_a) {
|
|
220
|
+
var content = _a.content, namedUsers = _a.namedUsers, commentId = _a.commentId, replyId = _a.replyId;
|
|
221
|
+
setSending(true);
|
|
222
|
+
var data = {
|
|
223
|
+
content: content,
|
|
224
|
+
namedUsers: namedUsers
|
|
225
|
+
};
|
|
226
|
+
return updateReplyRequest({ collaborationPath: collaborationPath, tenant: tenant, commentId: commentId, replyId: replyId, data: data })
|
|
227
|
+
.then(function (reply) { return editReplyInState(reply, commentId); })
|
|
228
|
+
.catch(catchErrorInRequest)
|
|
229
|
+
.finally(function () { return setSending(false); });
|
|
230
|
+
}, [collaborationPath, tenant, editReplyInState]);
|
|
181
231
|
var createReply = useCallback(function (_a) {
|
|
182
232
|
var content = _a.content, namedUsers = _a.namedUsers, commentId = _a.commentId, action = _a.action, uri = _a.uri;
|
|
183
233
|
setSending(true);
|
|
@@ -222,6 +272,8 @@ export var useCollaboration = function (_a) {
|
|
|
222
272
|
pageToken: pageToken,
|
|
223
273
|
reOpenThread: reOpenThread,
|
|
224
274
|
resolveThread: resolveThread,
|
|
225
|
-
sending: sending
|
|
275
|
+
sending: sending,
|
|
276
|
+
deleteReply: deleteReply,
|
|
277
|
+
editReply: editReply
|
|
226
278
|
};
|
|
227
279
|
};
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1168",
|
|
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.1168",
|
|
11
|
+
"@reltio/mdm-sdk": "^1.4.1168",
|
|
12
12
|
"classnames": "^2.2.5",
|
|
13
13
|
"d3-cloud": "^1.2.5",
|
|
14
14
|
"d3-geo": "^2.0.1",
|