@reltio/components 1.4.896 → 1.4.900

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 (87) hide show
  1. package/cjs/components/SmallIconButton/SmallIconButton.d.ts +1 -1
  2. package/cjs/components/SmallIconButton/index.d.ts +2 -2
  3. package/cjs/components/attributes/PivotingAttributes/PivotingTooltipContent.js +11 -3
  4. package/cjs/components/attributes/PivotingAttributes/helpers.d.ts +4 -0
  5. package/cjs/components/attributes/PivotingAttributes/helpers.js +17 -1
  6. package/cjs/components/attributes/PivotingAttributes/styles.d.ts +1 -1
  7. package/cjs/components/attributes/PivotingAttributes/styles.js +3 -0
  8. package/cjs/components/workflow/cards/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +6 -12
  9. package/cjs/components/workflow/components/AttributesChanges/AttributesChanges.d.ts +8 -0
  10. package/cjs/components/workflow/components/AttributesChanges/AttributesChanges.js +47 -0
  11. package/cjs/components/workflow/components/AttributesChanges/components/ChangeView/ChangeView.d.ts +11 -0
  12. package/cjs/components/workflow/components/AttributesChanges/components/ChangeView/ChangeView.js +27 -0
  13. package/cjs/components/workflow/components/AttributesChanges/components/ChangeView/styles.d.ts +1 -0
  14. package/cjs/components/workflow/components/AttributesChanges/components/ChangeView/styles.js +55 -0
  15. package/cjs/components/workflow/components/AttributesChanges/components/DCRChangesList/DCRChangesList.d.ts +7 -0
  16. package/cjs/components/workflow/components/AttributesChanges/components/DCRChangesList/DCRChangesList.js +25 -0
  17. package/cjs/components/workflow/components/AttributesChanges/components/DiffRenderer/DiffRenderer.d.ts +15 -0
  18. package/cjs/components/workflow/components/AttributesChanges/components/DiffRenderer/DiffRenderer.js +61 -0
  19. package/cjs/components/workflow/components/AttributesChanges/components/DiffRenderer/styles.d.ts +5 -0
  20. package/cjs/components/workflow/components/AttributesChanges/components/DiffRenderer/styles.js +18 -0
  21. package/cjs/components/workflow/components/AttributesChanges/components/ShowMoreLink/ShowMoreLink.d.ts +9 -0
  22. package/cjs/components/workflow/components/AttributesChanges/components/ShowMoreLink/ShowMoreLink.js +18 -0
  23. package/cjs/components/workflow/components/AttributesChanges/components/ShowMoreLink/styles.d.ts +1 -0
  24. package/cjs/components/workflow/components/AttributesChanges/components/ShowMoreLink/styles.js +12 -0
  25. package/cjs/components/workflow/components/AttributesChanges/constants/operations.d.ts +25 -0
  26. package/cjs/components/workflow/components/AttributesChanges/constants/operations.js +30 -0
  27. package/cjs/components/workflow/components/AttributesChanges/contexts/AttributesChangesContext.d.ts +3 -0
  28. package/cjs/components/workflow/components/AttributesChanges/contexts/AttributesChangesContext.js +9 -0
  29. package/cjs/components/workflow/components/AttributesChanges/helpers/attributesHelpers.d.ts +2 -0
  30. package/cjs/components/workflow/components/AttributesChanges/helpers/attributesHelpers.js +89 -0
  31. package/cjs/components/workflow/components/AttributesChanges/helpers/contextHelpers.d.ts +1 -0
  32. package/cjs/components/workflow/components/AttributesChanges/helpers/contextHelpers.js +5 -0
  33. package/cjs/components/workflow/components/AttributesChanges/helpers/helpers.d.ts +12 -0
  34. package/cjs/components/workflow/components/AttributesChanges/helpers/helpers.js +88 -0
  35. package/cjs/components/workflow/components/AttributesChanges/helpers/mergeHelpers.d.ts +4 -0
  36. package/cjs/components/workflow/components/AttributesChanges/helpers/mergeHelpers.js +137 -0
  37. package/cjs/components/workflow/components/AttributesChanges/hooks/useCollapsibleList.d.ts +6 -0
  38. package/cjs/components/workflow/components/AttributesChanges/hooks/useCollapsibleList.js +18 -0
  39. package/cjs/components/workflow/components/AttributesChanges/styles.d.ts +1 -0
  40. package/cjs/components/workflow/components/AttributesChanges/styles.js +27 -0
  41. package/cjs/components/workflow/components/AttributesChanges/types/DCRTypes.d.ts +63 -0
  42. package/cjs/components/workflow/components/AttributesChanges/types/DCRTypes.js +2 -0
  43. package/cjs/components/workflow/components/LineDecorator/styles.js +4 -2
  44. package/esm/components/SmallIconButton/SmallIconButton.d.ts +1 -1
  45. package/esm/components/SmallIconButton/index.d.ts +2 -2
  46. package/esm/components/attributes/PivotingAttributes/PivotingTooltipContent.js +13 -5
  47. package/esm/components/attributes/PivotingAttributes/helpers.d.ts +4 -0
  48. package/esm/components/attributes/PivotingAttributes/helpers.js +15 -1
  49. package/esm/components/attributes/PivotingAttributes/styles.d.ts +1 -1
  50. package/esm/components/attributes/PivotingAttributes/styles.js +3 -0
  51. package/esm/components/workflow/cards/DataChangeRequestTaskCard/DataChangeRequestTaskCard.js +7 -13
  52. package/esm/components/workflow/components/AttributesChanges/AttributesChanges.d.ts +8 -0
  53. package/esm/components/workflow/components/AttributesChanges/AttributesChanges.js +23 -0
  54. package/esm/components/workflow/components/AttributesChanges/components/ChangeView/ChangeView.d.ts +11 -0
  55. package/esm/components/workflow/components/AttributesChanges/components/ChangeView/ChangeView.js +22 -0
  56. package/esm/components/workflow/components/AttributesChanges/components/ChangeView/styles.d.ts +1 -0
  57. package/esm/components/workflow/components/AttributesChanges/components/ChangeView/styles.js +52 -0
  58. package/esm/components/workflow/components/AttributesChanges/components/DCRChangesList/DCRChangesList.d.ts +7 -0
  59. package/esm/components/workflow/components/AttributesChanges/components/DCRChangesList/DCRChangesList.js +20 -0
  60. package/esm/components/workflow/components/AttributesChanges/components/DiffRenderer/DiffRenderer.d.ts +15 -0
  61. package/esm/components/workflow/components/AttributesChanges/components/DiffRenderer/DiffRenderer.js +37 -0
  62. package/esm/components/workflow/components/AttributesChanges/components/DiffRenderer/styles.d.ts +5 -0
  63. package/esm/components/workflow/components/AttributesChanges/components/DiffRenderer/styles.js +15 -0
  64. package/esm/components/workflow/components/AttributesChanges/components/ShowMoreLink/ShowMoreLink.d.ts +9 -0
  65. package/esm/components/workflow/components/AttributesChanges/components/ShowMoreLink/ShowMoreLink.js +13 -0
  66. package/esm/components/workflow/components/AttributesChanges/components/ShowMoreLink/styles.d.ts +1 -0
  67. package/esm/components/workflow/components/AttributesChanges/components/ShowMoreLink/styles.js +9 -0
  68. package/esm/components/workflow/components/AttributesChanges/constants/operations.d.ts +25 -0
  69. package/esm/components/workflow/components/AttributesChanges/constants/operations.js +27 -0
  70. package/esm/components/workflow/components/AttributesChanges/contexts/AttributesChangesContext.d.ts +3 -0
  71. package/esm/components/workflow/components/AttributesChanges/contexts/AttributesChangesContext.js +3 -0
  72. package/esm/components/workflow/components/AttributesChanges/helpers/attributesHelpers.d.ts +2 -0
  73. package/esm/components/workflow/components/AttributesChanges/helpers/attributesHelpers.js +86 -0
  74. package/esm/components/workflow/components/AttributesChanges/helpers/contextHelpers.d.ts +1 -0
  75. package/esm/components/workflow/components/AttributesChanges/helpers/contextHelpers.js +2 -0
  76. package/esm/components/workflow/components/AttributesChanges/helpers/helpers.d.ts +12 -0
  77. package/esm/components/workflow/components/AttributesChanges/helpers/helpers.js +77 -0
  78. package/esm/components/workflow/components/AttributesChanges/helpers/mergeHelpers.d.ts +4 -0
  79. package/esm/components/workflow/components/AttributesChanges/helpers/mergeHelpers.js +134 -0
  80. package/esm/components/workflow/components/AttributesChanges/hooks/useCollapsibleList.d.ts +6 -0
  81. package/esm/components/workflow/components/AttributesChanges/hooks/useCollapsibleList.js +14 -0
  82. package/esm/components/workflow/components/AttributesChanges/styles.d.ts +1 -0
  83. package/esm/components/workflow/components/AttributesChanges/styles.js +24 -0
  84. package/esm/components/workflow/components/AttributesChanges/types/DCRTypes.d.ts +63 -0
  85. package/esm/components/workflow/components/AttributesChanges/types/DCRTypes.js +1 -0
  86. package/esm/components/workflow/components/LineDecorator/styles.js +4 -2
  87. package/package.json +3 -3
@@ -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 };
@@ -0,0 +1,134 @@
1
+ import { concat, curry, difference, identity, is, isNil, omit, pick, propEq, pipe, reduce } from 'ramda';
2
+ import { generateTempUri, getRoleLabel, isEmptyValue, EntityAttrTypes } from '@reltio/mdm-sdk';
3
+ import { DCRTypes } from '../constants/operations';
4
+ import { getChanges } from './attributesHelpers';
5
+ var ATTRIBUTE_DELIMITER = '/';
6
+ var SPECIAL_ATTRIBUTES_NAMES = [
7
+ 'defaultProfilePicValue',
8
+ EntityAttrTypes.tags.name,
9
+ EntityAttrTypes.roles.name,
10
+ EntityAttrTypes.startDate.name,
11
+ EntityAttrTypes.endDate.name
12
+ ];
13
+ var prepareStartOrEndDate = function (_a) {
14
+ var newValue = _a.newValue, oldValue = _a.oldValue;
15
+ var parseValue = function (value) { return (is(String) ? parseInt(value) : value); };
16
+ var isExistedValue = function (value) { return (value === null || value === void 0 ? void 0 : value.length) && !isEmptyValue(value); };
17
+ var isExistNewValue = isExistedValue(newValue);
18
+ var isExistOldValue = isExistedValue(oldValue);
19
+ if (isExistNewValue && isExistOldValue) {
20
+ return {
21
+ type: DCRTypes.UPDATE_ATTRIBUTE,
22
+ oldValue: { value: parseValue(oldValue[0]) },
23
+ newValue: { value: parseValue(newValue[0]) }
24
+ };
25
+ }
26
+ else if (isExistNewValue) {
27
+ return {
28
+ type: DCRTypes.INSERT_ATTRIBUTE,
29
+ newValue: { value: parseValue(newValue[0]) }
30
+ };
31
+ }
32
+ else if (isExistOldValue) {
33
+ return {
34
+ type: DCRTypes.DELETE_ATTRIBUTE,
35
+ oldValue: { value: parseValue(oldValue[0]) }
36
+ };
37
+ }
38
+ };
39
+ var prepareRolesOrTags = function (change, metadata) {
40
+ var _a = change.newValue, newValue = _a === void 0 ? [] : _a, _b = change.oldValue, oldValue = _b === void 0 ? [] : _b, type = change.type;
41
+ var getLabel = type === DCRTypes.UPDATE_ROLES ? getRoleLabel(metadata) : identity;
42
+ var diffNewValue = difference(newValue, oldValue);
43
+ var diffOldValue = difference(oldValue, newValue);
44
+ var items = [];
45
+ if (diffNewValue.length) {
46
+ items.push({
47
+ type: DCRTypes.INSERT_ATTRIBUTE,
48
+ newValue: { value: diffNewValue.map(getLabel).join(', ') }
49
+ });
50
+ }
51
+ if (diffOldValue.length) {
52
+ items.push({
53
+ type: DCRTypes.DELETE_ATTRIBUTE,
54
+ oldValue: { value: diffOldValue.map(getLabel).join(', ') }
55
+ });
56
+ }
57
+ return items;
58
+ };
59
+ var getPath = function (change) {
60
+ var type = change.type, attributePath = change.attributePath, refObjectURI = change.refObjectURI, refAttributeType = change.refAttributeType;
61
+ var path = type === DCRTypes.INSERT_ATTRIBUTE ? generateTempUri(attributePath) : attributePath;
62
+ if (refObjectURI) {
63
+ var typePath = refAttributeType.split('/attributes/');
64
+ var id = refObjectURI.split(ATTRIBUTE_DELIMITER)[1];
65
+ return [typePath[1], id, path].join(ATTRIBUTE_DELIMITER);
66
+ }
67
+ return path;
68
+ };
69
+ var prepareAttribute = function (container, change) {
70
+ var _a;
71
+ var changePath = getPath(change);
72
+ var pathArray = changePath.split(ATTRIBUTE_DELIMITER);
73
+ var holder = container;
74
+ for (var i = 0; i < pathArray.length - 1; i = i + 2) {
75
+ var key = pathArray[i];
76
+ var id = pathArray[i + 1];
77
+ var currentValue = (holder[key] || []).find(propEq('id', id));
78
+ var newValue = pathArray.length === i + 2 ? change : {};
79
+ var value = currentValue ? currentValue : { id: id, value: newValue };
80
+ var refObjectURI = ((_a = change.refObjectURI) === null || _a === void 0 ? void 0 : _a.indexOf(id)) >= 0 && change.refObjectURI;
81
+ if (refObjectURI) {
82
+ value.refObjectURI = refObjectURI;
83
+ }
84
+ if (isNil(currentValue)) {
85
+ holder[key] = (holder[key] || []).concat(value);
86
+ }
87
+ holder = value.value;
88
+ }
89
+ return container;
90
+ };
91
+ var mergeAttributesInChange = function (metadata, objectInfo, change, container) {
92
+ if (container === void 0) { container = {}; }
93
+ var type = change.type;
94
+ switch (type) {
95
+ case DCRTypes.UPDATE_PROFILE_PIC_BY_URL:
96
+ container['defaultProfilePicValue'] = [change.newValue];
97
+ break;
98
+ case DCRTypes.UPDATE_TAGS:
99
+ container[EntityAttrTypes.tags.name] = prepareRolesOrTags(change, metadata);
100
+ break;
101
+ case DCRTypes.UPDATE_ROLES: {
102
+ container[EntityAttrTypes.roles.name] = prepareRolesOrTags(change, metadata);
103
+ break;
104
+ }
105
+ case DCRTypes.UPDATE_START_DATE:
106
+ container[EntityAttrTypes.startDate.name] = [prepareStartOrEndDate(change)];
107
+ break;
108
+ case DCRTypes.UPDATE_END_DATE:
109
+ container[EntityAttrTypes.endDate.name] = [prepareStartOrEndDate(change)];
110
+ break;
111
+ default: {
112
+ prepareAttribute(container, change);
113
+ break;
114
+ }
115
+ }
116
+ return container;
117
+ };
118
+ var mergeChanges = function (metadata, changes, objectInfo) {
119
+ var getAttributeChanges = function (attributeName) { return pipe(pick([attributeName]), getChanges(metadata, objectInfo)); };
120
+ var concatChanges = curry(function (getters, attributesTree) {
121
+ return reduce(function (acc, getter) { return concat(acc, getter(attributesTree)); }, [], getters);
122
+ });
123
+ var changesTree = changes.reduce(function (result, change) {
124
+ return mergeAttributesInChange(metadata, objectInfo, change, result);
125
+ }, {});
126
+ return concatChanges([
127
+ pipe(omit(SPECIAL_ATTRIBUTES_NAMES), getChanges(metadata, objectInfo)),
128
+ getAttributeChanges(EntityAttrTypes.roles.name),
129
+ getAttributeChanges(EntityAttrTypes.tags.name),
130
+ getAttributeChanges(EntityAttrTypes.startDate.name),
131
+ getAttributeChanges(EntityAttrTypes.endDate.name)
132
+ ], changesTree);
133
+ };
134
+ export { mergeChanges };
@@ -0,0 +1,6 @@
1
+ export declare const useCollapsibleList: (changes: any, limit?: number) => {
2
+ isExpanded: boolean;
3
+ onToggle: () => void;
4
+ itemsToShow: any;
5
+ collapsedSuggestionsCount: number;
6
+ };
@@ -0,0 +1,14 @@
1
+ import { useCallback, useMemo, useState } from 'react';
2
+ import { getSuggestionsCount } from '../helpers/contextHelpers';
3
+ var DEFAULT_VISIBLE_ITEMS_COUNT = 3;
4
+ export var useCollapsibleList = function (changes, limit) {
5
+ if (limit === void 0) { limit = DEFAULT_VISIBLE_ITEMS_COUNT; }
6
+ var _a = useState(false), isExpanded = _a[0], setIsExpanded = _a[1];
7
+ var onToggle = useCallback(function () { return setIsExpanded(function (value) { return !value; }); }, []);
8
+ var collapsedItems = useMemo(function () { return changes.slice(0, limit); }, [changes, limit]);
9
+ var suggestionsCount = useMemo(function () { return getSuggestionsCount(changes); }, [changes]);
10
+ var visibleSuggestionsCount = useMemo(function () { return getSuggestionsCount(collapsedItems); }, [collapsedItems]);
11
+ var itemsToShow = isExpanded ? changes : collapsedItems;
12
+ var collapsedSuggestionsCount = suggestionsCount - visibleSuggestionsCount;
13
+ return { isExpanded: isExpanded, onToggle: onToggle, itemsToShow: itemsToShow, collapsedSuggestionsCount: collapsedSuggestionsCount };
14
+ };
@@ -0,0 +1 @@
1
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"uri" | "label" | "container" | "showMoreLink">;
@@ -0,0 +1,24 @@
1
+ import { makeStyles } from '@material-ui/core/styles';
2
+ export var useStyles = makeStyles(function (theme) { return ({
3
+ container: {
4
+ boxSizing: 'border-box',
5
+ border: '1px solid rgba(0,0,0,0.03)',
6
+ borderRadius: '3px',
7
+ backgroundColor: 'rgba(0,0,0,0.03)',
8
+ padding: '10px',
9
+ margin: '12px 16px 12px 0'
10
+ },
11
+ uri: {
12
+ color: theme.palette.primary.main,
13
+ textDecoration: 'none',
14
+ cursor: 'pointer'
15
+ },
16
+ label: {
17
+ fontSize: '12px',
18
+ letterSpacing: 0,
19
+ lineHeight: '16px'
20
+ },
21
+ showMoreLink: {
22
+ marginTop: '8px'
23
+ }
24
+ }); });
@@ -0,0 +1,63 @@
1
+ import { Crosswalk, NestedAttributeValue, ReferenceAttributeValue, SimpleAttributeValue } from '@reltio/mdm-sdk';
2
+ import { DCRTypes } from '../constants/operations';
3
+ export declare type EntityInfo = {
4
+ isExist: boolean;
5
+ label: string;
6
+ secondaryLabel: string;
7
+ type: string;
8
+ };
9
+ export declare type RelationInfo = {
10
+ type: string;
11
+ startObjectLabel: string;
12
+ startObjectUri: string;
13
+ endObjectLabel: string;
14
+ endObjectUri: string;
15
+ isExist: boolean;
16
+ };
17
+ export declare type DCRObjectInfo = EntityInfo | RelationInfo;
18
+ export declare type DCRObjectsInfo = {
19
+ [key: string]: DCRObjectInfo;
20
+ };
21
+ export declare type Value = DCRAttributes | DCRChange | string | boolean | number;
22
+ export declare type DCRAttributeValue = Omit<SimpleAttributeValue | NestedAttributeValue | ReferenceAttributeValue, 'uri' | 'value'> & {
23
+ value: Value;
24
+ refObjectURI?: string;
25
+ refEntity?: {
26
+ objectURI: string;
27
+ };
28
+ uri?: string;
29
+ };
30
+ export declare type DCRAttributes = {
31
+ [attributeName: string]: DCRAttributeValue[];
32
+ };
33
+ export declare type ChangeValue = DCRAttributeValue | string[];
34
+ export declare type DCRChange = {
35
+ attributePath?: string;
36
+ attributeType?: string;
37
+ conflict?: string;
38
+ conflictDetails?: string;
39
+ createdBy?: string;
40
+ createdTime?: string;
41
+ crosswalk?: Crosswalk;
42
+ id?: string;
43
+ newPinOrIgnoreValue?: boolean;
44
+ newValue?: ChangeValue;
45
+ oldValue?: ChangeValue;
46
+ type?: DCRTypes;
47
+ refAttributeType?: string;
48
+ refObjectURI?: string;
49
+ };
50
+ export declare type DCRChanges = {
51
+ [key: string]: DCRChange[];
52
+ };
53
+ export declare type ChangeRequest = {
54
+ changes: DCRChanges;
55
+ createdBy: string;
56
+ createdTime: number;
57
+ objectsInfo: DCRObjectsInfo;
58
+ state: string;
59
+ type: string;
60
+ updatedBy: string;
61
+ updatedTime: number;
62
+ uri: string;
63
+ };