@reltio/components 1.4.895 → 1.4.899

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.
Files changed (83) hide show
  1. package/cjs/components/attributes/PivotingAttributes/PivotingTooltipContent.js +11 -3
  2. package/cjs/components/attributes/PivotingAttributes/helpers.d.ts +4 -0
  3. package/cjs/components/attributes/PivotingAttributes/helpers.js +17 -1
  4. package/cjs/components/attributes/PivotingAttributes/styles.d.ts +1 -1
  5. package/cjs/components/attributes/PivotingAttributes/styles.js +3 -0
  6. package/cjs/components/workflow/cards/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +6 -12
  7. package/cjs/components/workflow/components/AttributesChanges/AttributesChanges.d.ts +8 -0
  8. package/cjs/components/workflow/components/AttributesChanges/AttributesChanges.js +47 -0
  9. package/cjs/components/workflow/components/AttributesChanges/components/ChangeView/ChangeView.d.ts +11 -0
  10. package/cjs/components/workflow/components/AttributesChanges/components/ChangeView/ChangeView.js +27 -0
  11. package/cjs/components/workflow/components/AttributesChanges/components/ChangeView/styles.d.ts +1 -0
  12. package/cjs/components/workflow/components/AttributesChanges/components/ChangeView/styles.js +55 -0
  13. package/cjs/components/workflow/components/AttributesChanges/components/DCRChangesList/DCRChangesList.d.ts +7 -0
  14. package/cjs/components/workflow/components/AttributesChanges/components/DCRChangesList/DCRChangesList.js +25 -0
  15. package/cjs/components/workflow/components/AttributesChanges/components/DiffRenderer/DiffRenderer.d.ts +15 -0
  16. package/cjs/components/workflow/components/AttributesChanges/components/DiffRenderer/DiffRenderer.js +61 -0
  17. package/cjs/components/workflow/components/AttributesChanges/components/DiffRenderer/styles.d.ts +5 -0
  18. package/cjs/components/workflow/components/AttributesChanges/components/DiffRenderer/styles.js +18 -0
  19. package/cjs/components/workflow/components/AttributesChanges/components/ShowMoreLink/ShowMoreLink.d.ts +9 -0
  20. package/cjs/components/workflow/components/AttributesChanges/components/ShowMoreLink/ShowMoreLink.js +18 -0
  21. package/cjs/components/workflow/components/AttributesChanges/components/ShowMoreLink/styles.d.ts +1 -0
  22. package/cjs/components/workflow/components/AttributesChanges/components/ShowMoreLink/styles.js +12 -0
  23. package/cjs/components/workflow/components/AttributesChanges/constants/operations.d.ts +25 -0
  24. package/cjs/components/workflow/components/AttributesChanges/constants/operations.js +30 -0
  25. package/cjs/components/workflow/components/AttributesChanges/contexts/AttributesChangesContext.d.ts +3 -0
  26. package/cjs/components/workflow/components/AttributesChanges/contexts/AttributesChangesContext.js +9 -0
  27. package/cjs/components/workflow/components/AttributesChanges/helpers/attributesHelpers.d.ts +2 -0
  28. package/cjs/components/workflow/components/AttributesChanges/helpers/attributesHelpers.js +89 -0
  29. package/cjs/components/workflow/components/AttributesChanges/helpers/contextHelpers.d.ts +1 -0
  30. package/cjs/components/workflow/components/AttributesChanges/helpers/contextHelpers.js +5 -0
  31. package/cjs/components/workflow/components/AttributesChanges/helpers/helpers.d.ts +12 -0
  32. package/cjs/components/workflow/components/AttributesChanges/helpers/helpers.js +88 -0
  33. package/cjs/components/workflow/components/AttributesChanges/helpers/mergeHelpers.d.ts +4 -0
  34. package/cjs/components/workflow/components/AttributesChanges/helpers/mergeHelpers.js +137 -0
  35. package/cjs/components/workflow/components/AttributesChanges/hooks/useCollapsibleList.d.ts +6 -0
  36. package/cjs/components/workflow/components/AttributesChanges/hooks/useCollapsibleList.js +18 -0
  37. package/cjs/components/workflow/components/AttributesChanges/styles.d.ts +1 -0
  38. package/cjs/components/workflow/components/AttributesChanges/styles.js +27 -0
  39. package/cjs/components/workflow/components/AttributesChanges/types/DCRTypes.d.ts +63 -0
  40. package/cjs/components/workflow/components/AttributesChanges/types/DCRTypes.js +2 -0
  41. package/cjs/components/workflow/components/LineDecorator/styles.js +4 -2
  42. package/esm/components/attributes/PivotingAttributes/PivotingTooltipContent.js +13 -5
  43. package/esm/components/attributes/PivotingAttributes/helpers.d.ts +4 -0
  44. package/esm/components/attributes/PivotingAttributes/helpers.js +15 -1
  45. package/esm/components/attributes/PivotingAttributes/styles.d.ts +1 -1
  46. package/esm/components/attributes/PivotingAttributes/styles.js +3 -0
  47. package/esm/components/workflow/cards/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +7 -13
  48. package/esm/components/workflow/components/AttributesChanges/AttributesChanges.d.ts +8 -0
  49. package/esm/components/workflow/components/AttributesChanges/AttributesChanges.js +23 -0
  50. package/esm/components/workflow/components/AttributesChanges/components/ChangeView/ChangeView.d.ts +11 -0
  51. package/esm/components/workflow/components/AttributesChanges/components/ChangeView/ChangeView.js +22 -0
  52. package/esm/components/workflow/components/AttributesChanges/components/ChangeView/styles.d.ts +1 -0
  53. package/esm/components/workflow/components/AttributesChanges/components/ChangeView/styles.js +52 -0
  54. package/esm/components/workflow/components/AttributesChanges/components/DCRChangesList/DCRChangesList.d.ts +7 -0
  55. package/esm/components/workflow/components/AttributesChanges/components/DCRChangesList/DCRChangesList.js +20 -0
  56. package/esm/components/workflow/components/AttributesChanges/components/DiffRenderer/DiffRenderer.d.ts +15 -0
  57. package/esm/components/workflow/components/AttributesChanges/components/DiffRenderer/DiffRenderer.js +37 -0
  58. package/esm/components/workflow/components/AttributesChanges/components/DiffRenderer/styles.d.ts +5 -0
  59. package/esm/components/workflow/components/AttributesChanges/components/DiffRenderer/styles.js +15 -0
  60. package/esm/components/workflow/components/AttributesChanges/components/ShowMoreLink/ShowMoreLink.d.ts +9 -0
  61. package/esm/components/workflow/components/AttributesChanges/components/ShowMoreLink/ShowMoreLink.js +13 -0
  62. package/esm/components/workflow/components/AttributesChanges/components/ShowMoreLink/styles.d.ts +1 -0
  63. package/esm/components/workflow/components/AttributesChanges/components/ShowMoreLink/styles.js +9 -0
  64. package/esm/components/workflow/components/AttributesChanges/constants/operations.d.ts +25 -0
  65. package/esm/components/workflow/components/AttributesChanges/constants/operations.js +27 -0
  66. package/esm/components/workflow/components/AttributesChanges/contexts/AttributesChangesContext.d.ts +3 -0
  67. package/esm/components/workflow/components/AttributesChanges/contexts/AttributesChangesContext.js +3 -0
  68. package/esm/components/workflow/components/AttributesChanges/helpers/attributesHelpers.d.ts +2 -0
  69. package/esm/components/workflow/components/AttributesChanges/helpers/attributesHelpers.js +86 -0
  70. package/esm/components/workflow/components/AttributesChanges/helpers/contextHelpers.d.ts +1 -0
  71. package/esm/components/workflow/components/AttributesChanges/helpers/contextHelpers.js +2 -0
  72. package/esm/components/workflow/components/AttributesChanges/helpers/helpers.d.ts +12 -0
  73. package/esm/components/workflow/components/AttributesChanges/helpers/helpers.js +77 -0
  74. package/esm/components/workflow/components/AttributesChanges/helpers/mergeHelpers.d.ts +4 -0
  75. package/esm/components/workflow/components/AttributesChanges/helpers/mergeHelpers.js +134 -0
  76. package/esm/components/workflow/components/AttributesChanges/hooks/useCollapsibleList.d.ts +6 -0
  77. package/esm/components/workflow/components/AttributesChanges/hooks/useCollapsibleList.js +14 -0
  78. package/esm/components/workflow/components/AttributesChanges/styles.d.ts +1 -0
  79. package/esm/components/workflow/components/AttributesChanges/styles.js +24 -0
  80. package/esm/components/workflow/components/AttributesChanges/types/DCRTypes.d.ts +63 -0
  81. package/esm/components/workflow/components/AttributesChanges/types/DCRTypes.js +1 -0
  82. package/esm/components/workflow/components/LineDecorator/styles.js +4 -2
  83. package/package.json +3 -3
@@ -0,0 +1,23 @@
1
+ import React, { useMemo } from 'react';
2
+ import { useSelector } from 'react-redux';
3
+ import mdmModule from '@reltio/mdm-module';
4
+ import { getEntityUriForLink, getLabel } from '@reltio/mdm-sdk';
5
+ import { mergeChanges } from './helpers/mergeHelpers';
6
+ import EntityUriLink from '../../../EntityUriLink/EntityUriLink';
7
+ import ShowMoreLink from './components/ShowMoreLink/ShowMoreLink';
8
+ import DCRChangesList from './components/DCRChangesList/DCRChangesList';
9
+ import { useCollapsibleList } from './hooks/useCollapsibleList';
10
+ import { useStyles } from './styles';
11
+ var AttributesChanges = function (_a) {
12
+ var changes = _a.changes, objectInfo = _a.objectInfo;
13
+ var styles = useStyles();
14
+ var metadata = useSelector(mdmModule.selectors.getMetadata);
15
+ var mergedChanges = useMemo(function () { return mergeChanges(metadata, changes, objectInfo); }, [metadata, changes, objectInfo]);
16
+ var _b = useCollapsibleList(mergedChanges), isExpanded = _b.isExpanded, onToggle = _b.onToggle, itemsToShow = _b.itemsToShow, collapsedSuggestionsCount = _b.collapsedSuggestionsCount;
17
+ return (React.createElement("div", { className: styles.container },
18
+ React.createElement(EntityUriLink, { className: styles.uri, value: getEntityUriForLink(objectInfo) },
19
+ React.createElement("div", { className: styles.label }, getLabel(objectInfo.label))),
20
+ React.createElement(DCRChangesList, { changes: itemsToShow }),
21
+ collapsedSuggestionsCount > 0 && (React.createElement(ShowMoreLink, { onClick: onToggle, suggestionsCount: collapsedSuggestionsCount, isExpanded: isExpanded, className: styles.showMoreLink }))));
22
+ };
23
+ export default AttributesChanges;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import { OperationTypes } from '../../constants/operations';
3
+ declare type Props = {
4
+ label: React.ReactElement;
5
+ oldValue?: React.ReactElement;
6
+ newValue?: React.ReactElement;
7
+ operation?: OperationTypes;
8
+ className?: string;
9
+ };
10
+ declare const ChangeView: ({ label, oldValue, newValue, operation, className }: Props) => JSX.Element;
11
+ export default ChangeView;
@@ -0,0 +1,22 @@
1
+ import React from 'react';
2
+ import classnames from 'classnames';
3
+ import ArrowRightAltIcon from '@material-ui/icons/ArrowRightAlt';
4
+ import Chip from '@material-ui/core/Chip';
5
+ import { getOperationLabel } from '../../helpers/helpers';
6
+ import { useStyles } from './styles';
7
+ var ChangeView = function (_a) {
8
+ var label = _a.label, oldValue = _a.oldValue, newValue = _a.newValue, operation = _a.operation, className = _a.className;
9
+ var styles = useStyles();
10
+ var value = oldValue || newValue;
11
+ return (React.createElement("div", { className: classnames(styles.field, className) },
12
+ React.createElement("span", { className: styles.fieldName },
13
+ label,
14
+ ":"),
15
+ React.createElement("span", { className: styles.difference },
16
+ value,
17
+ newValue && oldValue && (React.createElement(React.Fragment, null,
18
+ React.createElement(ArrowRightAltIcon, { className: styles.arrow }),
19
+ newValue))),
20
+ operation && (React.createElement(Chip, { variant: "outlined", label: getOperationLabel(operation), className: classnames(styles.chip, operation) }))));
21
+ };
22
+ export default ChangeView;
@@ -0,0 +1 @@
1
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"fieldName" | "difference" | "field" | "arrow" | "chip">;
@@ -0,0 +1,52 @@
1
+ import { makeStyles } from '@material-ui/core/styles';
2
+ export var useStyles = makeStyles(function (theme) { return ({
3
+ field: {
4
+ fontSize: '12px',
5
+ lineHeight: '20px',
6
+ color: theme.palette.text.primary,
7
+ marginTop: '6px',
8
+ display: 'flex',
9
+ flexWrap: 'wrap',
10
+ overflow: 'hidden'
11
+ },
12
+ fieldName: {
13
+ display: 'flex',
14
+ alignItems: 'center',
15
+ color: theme.palette.text.secondary,
16
+ marginRight: '8px'
17
+ },
18
+ difference: {
19
+ display: 'flex',
20
+ alignItems: 'center',
21
+ flexDirection: 'row'
22
+ },
23
+ arrow: {
24
+ margin: '0 4px',
25
+ fontSize: '12px',
26
+ color: theme.palette.text.primary
27
+ },
28
+ chip: {
29
+ height: '20px',
30
+ fontSize: '10px',
31
+ fontWeight: 500,
32
+ lineHeight: '16px',
33
+ letterSpacing: 0,
34
+ marginLeft: '8px',
35
+ flexShrink: 0,
36
+ textTransform: 'capitalize',
37
+ color: theme.palette.primary.main,
38
+ borderColor: theme.palette.primary.main,
39
+ '&.edited': {
40
+ color: '#CC7500',
41
+ borderColor: '#CC7500'
42
+ },
43
+ '&.added': {
44
+ color: '#599E0E',
45
+ borderColor: '#599E0E'
46
+ },
47
+ '&.deleted': {
48
+ color: '#CF0E26',
49
+ borderColor: '#CF0E26'
50
+ }
51
+ }
52
+ }); });
@@ -0,0 +1,7 @@
1
+ /// <reference types="react" />
2
+ import { Props as Change } from '../DiffRenderer/DiffRenderer';
3
+ declare type Props = {
4
+ changes: Change[];
5
+ };
6
+ declare const DCRChangesList: ({ changes }: Props) => JSX.Element;
7
+ export default DCRChangesList;
@@ -0,0 +1,20 @@
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 from 'react';
13
+ import DiffRenderer from '../DiffRenderer/DiffRenderer';
14
+ var DCRChangesList = function (_a) {
15
+ var changes = _a.changes;
16
+ return (React.createElement(React.Fragment, null, changes.map(function (change, index) {
17
+ return React.createElement(DiffRenderer, __assign({}, change, { key: index }));
18
+ })));
19
+ };
20
+ export default DCRChangesList;
@@ -0,0 +1,15 @@
1
+ /// <reference types="react" />
2
+ import { AttributeType } from '@reltio/mdm-sdk';
3
+ import { OperationTypes } from '../../constants/operations';
4
+ import { ChangeValue, DCRAttributeValue } from '../../types/DCRTypes';
5
+ export declare type Props = {
6
+ level: number;
7
+ label: string;
8
+ attributeType: AttributeType;
9
+ attributeValue?: DCRAttributeValue;
10
+ newValue?: ChangeValue;
11
+ oldValue?: ChangeValue;
12
+ operation?: OperationTypes;
13
+ };
14
+ declare const DiffRenderer: ({ label, level, attributeType, attributeValue, oldValue, newValue, operation }: Props) => JSX.Element;
15
+ export default DiffRenderer;
@@ -0,0 +1,37 @@
1
+ import React, { useCallback, useContext, useMemo } from 'react';
2
+ import { useSelector } from 'react-redux';
3
+ import { anyPass, ifElse, hasPath, path, when } from 'ramda';
4
+ import { getAttributeValue, getLabel, isReference } from '@reltio/mdm-sdk';
5
+ import mdmModule from '@reltio/mdm-module';
6
+ import ChangeView from '../ChangeView/ChangeView';
7
+ import { getAttributeDescription, getDataTypeDefinition } from '../../helpers/helpers';
8
+ import EntityUriLink from '../../../../../EntityUriLink/EntityUriLink';
9
+ import { AttributesChangesContext } from '../../contexts/AttributesChangesContext';
10
+ import DataTypeValue from '../../../../../DataTypeValue/DataTypeValue';
11
+ import { useStyles } from './styles';
12
+ var DiffRenderer = function (_a) {
13
+ var label = _a.label, level = _a.level, attributeType = _a.attributeType, attributeValue = _a.attributeValue, oldValue = _a.oldValue, newValue = _a.newValue, operation = _a.operation;
14
+ var styles = useStyles({ level: level });
15
+ var entity = useSelector(mdmModule.selectors.getEntity);
16
+ var objectsInfo = useContext(AttributesChangesContext);
17
+ var renderLink = useCallback(function () {
18
+ if (isReference(attributeType)) {
19
+ var value = when(anyPass([hasPath(['value', 'newValue']), hasPath(['value', 'oldValue'])]), ifElse(hasPath(['value', 'newValue']), path(['value', 'newValue']), path(['value', 'oldValue'])))(attributeValue);
20
+ var _a = getAttributeDescription(attributeType, value, entity.uri, objectsInfo), objectUri = _a.objectUri, objectLabel = _a.objectLabel;
21
+ return (React.createElement(EntityUriLink, { value: objectUri, className: styles.uri },
22
+ React.createElement("span", null, getLabel(objectLabel))));
23
+ }
24
+ return null;
25
+ }, [attributeType, attributeValue, entity.uri, objectsInfo, styles.uri]);
26
+ var changeLabel = useMemo(function () {
27
+ return (React.createElement("div", null,
28
+ label,
29
+ renderLink()));
30
+ }, [label, renderLink]);
31
+ var renderValue = useCallback(function (value) {
32
+ var attrValue = getAttributeValue(value);
33
+ return (React.createElement(DataTypeValue, { value: attrValue, dataTypeDefinition: getDataTypeDefinition(attributeType, attrValue) }));
34
+ }, [attributeType]);
35
+ return (React.createElement(ChangeView, { className: styles.change, label: changeLabel, oldValue: oldValue && renderValue(oldValue), newValue: newValue && renderValue(newValue), operation: operation }));
36
+ };
37
+ export default DiffRenderer;
@@ -0,0 +1,5 @@
1
+ declare type StylesProps = {
2
+ level: number;
3
+ };
4
+ export declare const useStyles: (props: StylesProps) => import("@material-ui/core/styles/withStyles").ClassNameMap<"uri" | "change">;
5
+ export {};
@@ -0,0 +1,15 @@
1
+ import { makeStyles } from '@material-ui/core/styles';
2
+ export var useStyles = makeStyles(function (theme) { return ({
3
+ uri: {
4
+ color: theme.palette.primary.main,
5
+ textDecoration: 'none',
6
+ cursor: 'pointer',
7
+ marginLeft: '4px'
8
+ },
9
+ change: function (_a) {
10
+ var _b = _a.level, level = _b === void 0 ? 0 : _b;
11
+ return ({
12
+ marginLeft: level * 16 + "px"
13
+ });
14
+ }
15
+ }); });
@@ -0,0 +1,9 @@
1
+ /// <reference types="react" />
2
+ declare type Props = {
3
+ onClick: () => void;
4
+ suggestionsCount: number;
5
+ isExpanded: boolean;
6
+ className?: string;
7
+ };
8
+ declare const ShowMoreLink: ({ suggestionsCount, isExpanded, onClick, className }: Props) => JSX.Element;
9
+ export default ShowMoreLink;
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import i18n from 'ui-i18n';
3
+ import Link from '@material-ui/core/Link';
4
+ import { useStyles } from './styles';
5
+ var ShowMoreLink = function (_a) {
6
+ var suggestionsCount = _a.suggestionsCount, isExpanded = _a.isExpanded, onClick = _a.onClick, className = _a.className;
7
+ var styles = useStyles();
8
+ return (React.createElement(Link, { component: "button", variant: "caption", underline: "none", onClick: onClick, className: className },
9
+ React.createElement("span", { className: styles.linkLabel }, isExpanded
10
+ ? i18n.text('View less suggestions')
11
+ : i18n.text('View ${suggestionsCount} more suggestions', { suggestionsCount: suggestionsCount }))));
12
+ };
13
+ export default ShowMoreLink;
@@ -0,0 +1 @@
1
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"linkLabel">;
@@ -0,0 +1,9 @@
1
+ import { makeStyles } from '@material-ui/core/styles';
2
+ export var useStyles = makeStyles(function (theme) { return ({
3
+ linkLabel: {
4
+ color: theme.palette.primary.main,
5
+ fontSize: '12px',
6
+ letterSpacing: 0,
7
+ lineHeight: '16px'
8
+ }
9
+ }); });
@@ -0,0 +1,25 @@
1
+ export declare enum OperationTypes {
2
+ ADDED = "added",
3
+ EDITED = "edited",
4
+ DELETED = "deleted",
5
+ PINNED = "pinned",
6
+ IGNORED = "ignored",
7
+ PIN_DELETED = "pin_deleted",
8
+ IGNORE_DELETED = "ignore_deleted"
9
+ }
10
+ export declare enum DCRTypes {
11
+ INSERT_ATTRIBUTE = "INSERT_ATTRIBUTE",
12
+ UPDATE_ATTRIBUTE = "UPDATE_ATTRIBUTE",
13
+ DELETE_ATTRIBUTE = "DELETE_ATTRIBUTE",
14
+ PIN_ATTRIBUTE = "PIN_ATTRIBUTE",
15
+ IGNORE_ATTRIBUTE = "IGNORE_ATTRIBUTE",
16
+ CREATE_ENTITY = "CREATE_ENTITY",
17
+ CREATE_RELATIONSHIP = "CREATE_RELATIONSHIP",
18
+ UPDATE_TAGS = "UPDATE_TAGS",
19
+ UPDATE_ROLES = "UPDATE_ROLES",
20
+ UPDATE_START_DATE = "UPDATE_START_DATE",
21
+ UPDATE_END_DATE = "UPDATE_END_DATE",
22
+ UPDATE_PROFILE_PIC_BY_URL = "UPDATE_PROFILE_PIC_BY_URL",
23
+ UPDATE_PROFILE_PIC_BY_URI = "UPDATE_PROFILE_PIC_BY_URI",
24
+ DELETE_RELATIONSHIP = "DELETE_RELATIONSHIP"
25
+ }
@@ -0,0 +1,27 @@
1
+ export var OperationTypes;
2
+ (function (OperationTypes) {
3
+ OperationTypes["ADDED"] = "added";
4
+ OperationTypes["EDITED"] = "edited";
5
+ OperationTypes["DELETED"] = "deleted";
6
+ OperationTypes["PINNED"] = "pinned";
7
+ OperationTypes["IGNORED"] = "ignored";
8
+ OperationTypes["PIN_DELETED"] = "pin_deleted";
9
+ OperationTypes["IGNORE_DELETED"] = "ignore_deleted";
10
+ })(OperationTypes || (OperationTypes = {}));
11
+ export var DCRTypes;
12
+ (function (DCRTypes) {
13
+ DCRTypes["INSERT_ATTRIBUTE"] = "INSERT_ATTRIBUTE";
14
+ DCRTypes["UPDATE_ATTRIBUTE"] = "UPDATE_ATTRIBUTE";
15
+ DCRTypes["DELETE_ATTRIBUTE"] = "DELETE_ATTRIBUTE";
16
+ DCRTypes["PIN_ATTRIBUTE"] = "PIN_ATTRIBUTE";
17
+ DCRTypes["IGNORE_ATTRIBUTE"] = "IGNORE_ATTRIBUTE";
18
+ DCRTypes["CREATE_ENTITY"] = "CREATE_ENTITY";
19
+ DCRTypes["CREATE_RELATIONSHIP"] = "CREATE_RELATIONSHIP";
20
+ DCRTypes["UPDATE_TAGS"] = "UPDATE_TAGS";
21
+ DCRTypes["UPDATE_ROLES"] = "UPDATE_ROLES";
22
+ DCRTypes["UPDATE_START_DATE"] = "UPDATE_START_DATE";
23
+ DCRTypes["UPDATE_END_DATE"] = "UPDATE_END_DATE";
24
+ DCRTypes["UPDATE_PROFILE_PIC_BY_URL"] = "UPDATE_PROFILE_PIC_BY_URL";
25
+ DCRTypes["UPDATE_PROFILE_PIC_BY_URI"] = "UPDATE_PROFILE_PIC_BY_URI";
26
+ DCRTypes["DELETE_RELATIONSHIP"] = "DELETE_RELATIONSHIP";
27
+ })(DCRTypes || (DCRTypes = {}));
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ import { DCRObjectsInfo } from '../types/DCRTypes';
3
+ export declare const AttributesChangesContext: React.Context<DCRObjectsInfo>;
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ export var AttributesChangesContext = React.createContext(null);
3
+ AttributesChangesContext.displayName = 'AttributesChangesContext';
@@ -0,0 +1,2 @@
1
+ declare const getChanges: any;
2
+ export { getChanges };
@@ -0,0 +1,86 @@
1
+ import { complement, curry, flatten, isEmpty, pathOr, times } from 'ramda';
2
+ import { DataTypes, getAttributeTypeSubAttributes, getLabel, isSpecialAttribute } from '@reltio/mdm-sdk';
3
+ import { getFilteredAttrTypes } from '../../../../attributes/helpers/attributesView';
4
+ import { getOperationType } from './helpers';
5
+ import { DCRTypes } from '../constants/operations';
6
+ var getValues = function (attributes, attrType) {
7
+ if ('newValue' in attributes || 'oldValue' in attributes) {
8
+ var newValue = attributes.newValue, oldValue = attributes.oldValue, type_1 = attributes.type;
9
+ var newAttrValues_1 = pathOr([], ['value', attrType.name])(newValue);
10
+ var oldAttrValues_1 = pathOr([], ['value', attrType.name])(oldValue);
11
+ var length_1 = Math.max(newAttrValues_1.length, oldAttrValues_1.length);
12
+ return times(function (index) {
13
+ var attributeValue = {
14
+ newValue: newAttrValues_1[index],
15
+ oldValue: oldAttrValues_1[index],
16
+ type: type_1
17
+ };
18
+ return [{ value: attributeValue }];
19
+ }, length_1);
20
+ }
21
+ var values = attributes[attrType.name];
22
+ return values ? [values] : [];
23
+ };
24
+ var getChanges = curry(function (metadata, objectInfo, changes) {
25
+ var attrTypes = getFilteredAttrTypes(metadata, objectInfo.type, [], []);
26
+ return getAttributesList(metadata, attrTypes, changes);
27
+ });
28
+ var getAttributesList = function (metadata, attrTypes, attributes, level) {
29
+ if (level === void 0) { level = 0; }
30
+ return flatten(attrTypes
31
+ .map(function (attrType) {
32
+ return getValues(attributes, attrType).map(function (value) {
33
+ return value.map(function (attributeValue) {
34
+ return dcrAttributesFactory(metadata, attrType, attributeValue, level);
35
+ });
36
+ });
37
+ })
38
+ .filter(complement(isEmpty)));
39
+ };
40
+ var dcrAttributesFactory = function (metadata, attributeType, attributeValue, level) {
41
+ switch (attributeType.type) {
42
+ case DataTypes.TYPE_NESTED:
43
+ case DataTypes.TYPE_IMAGE:
44
+ return getNestedAttributeChange(metadata, attributeType, attributeValue, level);
45
+ case DataTypes.TYPE_REFERENCE:
46
+ return getReferenceAttributeChange(metadata, attributeType, attributeValue, level);
47
+ default: {
48
+ var value = isSpecialAttribute(attributeType) ? attributeValue : attributeValue.value;
49
+ return getSimpleAttributeChange(attributeType, value, level);
50
+ }
51
+ }
52
+ };
53
+ var getNestedAttributeChange = function (metadata, attributeType, attributeValue, level) {
54
+ var attributeTypeList = getAttributeTypeSubAttributes({}, attributeType);
55
+ var label = getLabel((attributeType === null || attributeType === void 0 ? void 0 : attributeType.label) || (attributeType === null || attributeType === void 0 ? void 0 : attributeType.name));
56
+ return [
57
+ { level: level, label: label, attributeType: attributeType, attributeValue: attributeValue },
58
+ getAttributesList(metadata, attributeTypeList, attributeValue.value, level + 1)
59
+ ];
60
+ };
61
+ var getReferenceAttributeChange = function (metadata, attributeType, attributeValue, level) {
62
+ var attributeTypeList = getAttributeTypeSubAttributes(metadata, attributeType);
63
+ var label = (attributeType === null || attributeType === void 0 ? void 0 : attributeType.label) || (attributeType === null || attributeType === void 0 ? void 0 : attributeType.name);
64
+ return [
65
+ { level: level, label: label, attributeType: attributeType, attributeValue: attributeValue },
66
+ getAttributesList(metadata, attributeTypeList, attributeValue.value, level + 1)
67
+ ];
68
+ };
69
+ var getDiffParameters = function (_a) {
70
+ var newValue = _a.newValue, oldValue = _a.oldValue, type = _a.type;
71
+ return type === DCRTypes.UPDATE_ATTRIBUTE ? { type: type, newValue: newValue, oldValue: oldValue } : { type: type, newValue: oldValue || newValue };
72
+ };
73
+ var getSimpleAttributeChange = function (attributeType, attributeValue, level) {
74
+ var _a = getDiffParameters(attributeValue), newValue = _a.newValue, oldValue = _a.oldValue, type = _a.type;
75
+ var operation = getOperationType(type, oldValue);
76
+ var label = (attributeType === null || attributeType === void 0 ? void 0 : attributeType.label) || (attributeType === null || attributeType === void 0 ? void 0 : attributeType.name);
77
+ return {
78
+ attributeType: attributeType,
79
+ newValue: newValue,
80
+ oldValue: oldValue,
81
+ operation: operation,
82
+ label: label,
83
+ level: level
84
+ };
85
+ };
86
+ export { getChanges };
@@ -0,0 +1 @@
1
+ export declare const getSuggestionsCount: any;
@@ -0,0 +1,2 @@
1
+ import { has, filter, length, pipe } from 'ramda';
2
+ export var getSuggestionsCount = pipe(filter(has('operation')), length);
@@ -0,0 +1,12 @@
1
+ import { AttributeType } from '@reltio/mdm-sdk';
2
+ import { OperationTypes } from '../constants/operations';
3
+ import { ChangeRequest, DCRAttributeValue, DCRObjectsInfo, Value } from '../types/DCRTypes';
4
+ export declare const getOperationType: (type: string, oldValue?: DCRAttributeValue) => OperationTypes;
5
+ export declare const getOperationLabel: (operation: OperationTypes) => string;
6
+ export declare const getAttributeDescription: (attrType: AttributeType, value: DCRAttributeValue, currentEntityUri: string, objectsInfo?: DCRObjectsInfo) => {
7
+ objectUri: any;
8
+ objectLabel: any;
9
+ entityTypeUri: any;
10
+ };
11
+ export declare const extractObjectsFromChangeRequest: ({ objectsInfo, changes }: ChangeRequest) => any;
12
+ export declare const getDataTypeDefinition: (attributeType: AttributeType, attributeValue: Value) => any;
@@ -0,0 +1,77 @@
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 i18n from 'ui-i18n';
13
+ import { allPass, always, evolve, equals, filter, keys, map, prop, pipe, when } from 'ramda';
14
+ import { DataTypes, getAttrDataTypeDefinition, isUrl } from '@reltio/mdm-sdk';
15
+ import { DCRTypes, OperationTypes } from '../constants/operations';
16
+ export var getOperationType = function (type, oldValue) {
17
+ switch (type) {
18
+ case DCRTypes.CREATE_RELATIONSHIP:
19
+ case DCRTypes.INSERT_ATTRIBUTE:
20
+ return OperationTypes.ADDED;
21
+ case DCRTypes.UPDATE_TAGS:
22
+ case DCRTypes.UPDATE_ROLES:
23
+ case DCRTypes.UPDATE_ATTRIBUTE:
24
+ return OperationTypes.EDITED;
25
+ case DCRTypes.DELETE_ATTRIBUTE:
26
+ case DCRTypes.DELETE_RELATIONSHIP:
27
+ return OperationTypes.DELETED;
28
+ case DCRTypes.PIN_ATTRIBUTE:
29
+ return (oldValue === null || oldValue === void 0 ? void 0 : oldValue.pin) ? OperationTypes.PIN_DELETED : OperationTypes.PINNED;
30
+ case DCRTypes.IGNORE_ATTRIBUTE:
31
+ return (oldValue === null || oldValue === void 0 ? void 0 : oldValue.ignored) ? OperationTypes.IGNORE_DELETED : OperationTypes.IGNORED;
32
+ }
33
+ };
34
+ export var getOperationLabel = function (operation) {
35
+ var _a;
36
+ var labels = (_a = {},
37
+ _a[OperationTypes.ADDED] = i18n.text('added'),
38
+ _a[OperationTypes.EDITED] = i18n.text('edited'),
39
+ _a[OperationTypes.DELETED] = i18n.text('deleted'),
40
+ _a[OperationTypes.PINNED] = i18n.text('pinned'),
41
+ _a[OperationTypes.PIN_DELETED] = i18n.text('pin deleted'),
42
+ _a[OperationTypes.IGNORED] = i18n.text('ignored'),
43
+ _a[OperationTypes.IGNORE_DELETED] = i18n.text('ignore deleted'),
44
+ _a);
45
+ return labels[operation] || '';
46
+ };
47
+ export var getAttributeDescription = function (attrType, value, currentEntityUri, objectsInfo) {
48
+ if (objectsInfo === void 0) { objectsInfo = {}; }
49
+ var objectLabel, objectUri, entityTypeUri;
50
+ var relation = objectsInfo[value.refObjectURI];
51
+ if (relation) {
52
+ objectUri = currentEntityUri === relation.startObjectUri ? relation.endObjectUri : relation.startObjectUri;
53
+ objectLabel =
54
+ currentEntityUri === relation.startObjectUri ? relation.endObjectLabel : relation.startObjectLabel;
55
+ }
56
+ else if (value.refEntity) {
57
+ objectUri = value.refEntity.objectURI;
58
+ objectLabel = objectsInfo[objectUri].label;
59
+ }
60
+ if (objectUri && objectLabel) {
61
+ var objectInfo = objectsInfo[objectUri];
62
+ entityTypeUri = objectInfo ? objectInfo.type : attrType.referencedEntityTypeURI;
63
+ }
64
+ return {
65
+ objectUri: objectUri,
66
+ objectLabel: objectLabel,
67
+ entityTypeUri: entityTypeUri
68
+ };
69
+ };
70
+ export var extractObjectsFromChangeRequest = function (_a) {
71
+ var _b = _a.objectsInfo, objectsInfo = _b === void 0 ? {} : _b, _c = _a.changes, changes = _c === void 0 ? {} : _c;
72
+ var getChange = function (key) { return prop([key], changes); };
73
+ return pipe(keys, filter(getChange), map(function (key) { return (__assign(__assign({}, objectsInfo[key]), { uri: key })); }))(objectsInfo);
74
+ };
75
+ export var getDataTypeDefinition = function (attributeType, attributeValue) {
76
+ return when(allPass([pipe(prop('type'), equals(DataTypes.TYPE_STRING)), function () { return isUrl(attributeValue); }]), evolve({ type: always(DataTypes.TYPE_URL) }))(getAttrDataTypeDefinition(attributeType));
77
+ };
@@ -0,0 +1,4 @@
1
+ import { Metadata } from '@reltio/mdm-sdk';
2
+ import { DCRChange, DCRObjectInfo } from '../types/DCRTypes';
3
+ declare const mergeChanges: (metadata: Metadata, changes: DCRChange[], objectInfo: DCRObjectInfo) => any;
4
+ export { mergeChanges };