@reltio/components 1.4.952 → 1.4.953

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 (33) hide show
  1. package/cjs/components/ImageAttributesGallery/HeaderRight/styles.d.ts +1 -1
  2. package/cjs/components/RelationEditor/index.d.ts +16 -4
  3. package/cjs/components/attributes/editMode/AttributesList/helpers.js +1 -1
  4. package/cjs/components/attributes/editMode/AttributesPager/SpecialRenderer.d.ts +2 -1
  5. package/cjs/components/attributes/editMode/AttributesPager/SpecialRenderer.js +6 -6
  6. package/cjs/components/attributes/editMode/Roles/Roles.d.ts +4 -1
  7. package/cjs/components/attributes/editMode/Roles/Roles.js +16 -10
  8. package/cjs/components/attributes/editMode/Roles/styles.d.ts +1 -1
  9. package/cjs/components/attributes/editMode/Roles/styles.js +12 -0
  10. package/cjs/components/attributes/editMode/SimpleAttributeEditor/SimpleAttributeEditor.js +2 -2
  11. package/cjs/components/attributes/editMode/Tags/Tags.d.ts +5 -2
  12. package/cjs/components/attributes/editMode/Tags/Tags.js +16 -8
  13. package/cjs/components/attributes/editMode/Tags/styles.d.ts +1 -0
  14. package/cjs/components/attributes/editMode/Tags/styles.js +15 -0
  15. package/cjs/components/workflow/components/AttributesChanges/helpers/mergeHelpers.js +1 -1
  16. package/cjs/components/workflow/hooks/useWorkflowAssignee.js +5 -1
  17. package/esm/components/ImageAttributesGallery/HeaderRight/styles.d.ts +1 -1
  18. package/esm/components/RelationEditor/index.d.ts +16 -4
  19. package/esm/components/attributes/editMode/AttributesList/helpers.js +2 -2
  20. package/esm/components/attributes/editMode/AttributesPager/SpecialRenderer.d.ts +2 -1
  21. package/esm/components/attributes/editMode/AttributesPager/SpecialRenderer.js +6 -6
  22. package/esm/components/attributes/editMode/Roles/Roles.d.ts +4 -1
  23. package/esm/components/attributes/editMode/Roles/Roles.js +17 -11
  24. package/esm/components/attributes/editMode/Roles/styles.d.ts +1 -1
  25. package/esm/components/attributes/editMode/Roles/styles.js +12 -0
  26. package/esm/components/attributes/editMode/SimpleAttributeEditor/SimpleAttributeEditor.js +2 -2
  27. package/esm/components/attributes/editMode/Tags/Tags.d.ts +5 -2
  28. package/esm/components/attributes/editMode/Tags/Tags.js +17 -9
  29. package/esm/components/attributes/editMode/Tags/styles.d.ts +1 -0
  30. package/esm/components/attributes/editMode/Tags/styles.js +12 -0
  31. package/esm/components/workflow/components/AttributesChanges/helpers/mergeHelpers.js +1 -1
  32. package/esm/components/workflow/hooks/useWorkflowAssignee.js +6 -2
  33. package/package.json +3 -3
@@ -1 +1 @@
1
- export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"divider" | "downloadButton" | "shareButton" | "deleteButton">;
1
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"divider" | "deleteButton" | "downloadButton" | "shareButton">;
@@ -55,10 +55,22 @@ declare var _default: import("react-redux").ConnectedComponent<{
55
55
  max: import("prop-types").Requireable<number>;
56
56
  icon: import("prop-types").Requireable<string>;
57
57
  caption: import("prop-types").Requireable<string>;
58
- canCreate: import("prop-types").Requireable<boolean>;
59
- canRead: import("prop-types").Requireable<boolean>;
60
- canUpdate: import("prop-types").Requireable<boolean>;
61
- canDelete: import("prop-types").Requireable<boolean>;
58
+ canCreate: import("prop-types").Requireable<import("prop-types").InferProps<{
59
+ deviceTypes: import("prop-types").Requireable<string | string[]>;
60
+ roles: import("prop-types").Requireable<string[]>;
61
+ }>>;
62
+ canRead: import("prop-types").Requireable<import("prop-types").InferProps<{
63
+ deviceTypes: import("prop-types").Requireable<string | string[]>;
64
+ roles: import("prop-types").Requireable<string[]>;
65
+ }>>;
66
+ canUpdate: import("prop-types").Requireable<import("prop-types").InferProps<{
67
+ deviceTypes: import("prop-types").Requireable<string | string[]>;
68
+ roles: import("prop-types").Requireable<string[]>;
69
+ }>>;
70
+ canDelete: import("prop-types").Requireable<import("prop-types").InferProps<{
71
+ deviceTypes: import("prop-types").Requireable<string | string[]>;
72
+ roles: import("prop-types").Requireable<string[]>;
73
+ }>>;
62
74
  editingEnabled: import("prop-types").Requireable<boolean>;
63
75
  }>>;
64
76
  mode: import("prop-types").Requireable<string>;
@@ -18,7 +18,7 @@ var getMoreAttrTypes = function (attrTypes, entity) {
18
18
  return attrTypes.filter(function (attrType) {
19
19
  var source = getSource(attrType, entity);
20
20
  var nameProp = getNameProp(attrType);
21
- return !(attrType.singleValue && ramda_1.has(attrType[nameProp])(source));
21
+ return !((attrType.singleValue || mdm_sdk_1.isRoleAttrType(attrType) || mdm_sdk_1.isTagAttrType(attrType)) && ramda_1.has(attrType[nameProp])(source));
22
22
  });
23
23
  };
24
24
  exports.getMoreAttrTypes = getMoreAttrTypes;
@@ -8,7 +8,8 @@ declare type Props = {
8
8
  mode: Mode;
9
9
  errorMessage?: string;
10
10
  onDeleteAttribute: (param: AttributeItem) => void;
11
+ onChangeAttribute: (param: AttributeItem) => void;
11
12
  showEmptyEditors?: boolean;
12
13
  };
13
- declare const SpecialRenderer: ({ values, attributeType, parentUri, mode, errorMessage, onDeleteAttribute, showEmptyEditors, ...otherProps }: Props) => JSX.Element;
14
+ declare const SpecialRenderer: ({ values, attributeType, parentUri, mode, errorMessage, onDeleteAttribute, onChangeAttribute, showEmptyEditors, ...otherProps }: Props) => JSX.Element;
14
15
  export default SpecialRenderer;
@@ -56,11 +56,12 @@ var Roles_1 = require("../Roles/Roles");
56
56
  var Tags_1 = __importDefault(require("../Tags"));
57
57
  var styles_1 = require("./styles");
58
58
  var SpecialRenderer = function (_a) {
59
- var values = _a.values, attributeType = _a.attributeType, parentUri = _a.parentUri, mode = _a.mode, errorMessage = _a.errorMessage, onDeleteAttribute = _a.onDeleteAttribute, showEmptyEditors = _a.showEmptyEditors, otherProps = __rest(_a, ["values", "attributeType", "parentUri", "mode", "errorMessage", "onDeleteAttribute", "showEmptyEditors"]);
59
+ var values = _a.values, attributeType = _a.attributeType, parentUri = _a.parentUri, mode = _a.mode, errorMessage = _a.errorMessage, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, showEmptyEditors = _a.showEmptyEditors, otherProps = __rest(_a, ["values", "attributeType", "parentUri", "mode", "errorMessage", "onDeleteAttribute", "onChangeAttribute", "showEmptyEditors"]);
60
60
  var styles = styles_1.useStyles();
61
61
  var label = attributeType.label, isRequired = attributeType.required, cardinality = attributeType.cardinality;
62
62
  var isEditableMode = mdm_sdk_1.isEditableMode(mode);
63
63
  var _b = react_1.useState(false), hadDeletions = _b[0], setHadDeletions = _b[1];
64
+ // eslint-disable-next-line react-hooks/exhaustive-deps
64
65
  var onDelete = react_1.useCallback(ramda_1.pipe(onDeleteAttribute, ramda_1.T, setHadDeletions), [onDeleteAttribute, setHadDeletions]);
65
66
  var isEmptyValues = mdm_sdk_1.isEmptyValue(values);
66
67
  var showEmpty = !hadDeletions && showEmptyEditors && isEmptyValues;
@@ -71,14 +72,13 @@ var SpecialRenderer = function (_a) {
71
72
  var renderValue = function () {
72
73
  switch (attributeType.uri) {
73
74
  case mdm_sdk_1.EntityAttrTypes.tags.uri:
74
- return react_1.default.createElement(Tags_1.default, { values: values });
75
- case mdm_sdk_1.EntityAttrTypes.roles.uri: {
76
- return react_1.default.createElement(Roles_1.Roles, { values: values });
77
- }
75
+ return react_1.default.createElement(Tags_1.default, { values: values, onDelete: onDelete, onChange: onChangeAttribute });
76
+ case mdm_sdk_1.EntityAttrTypes.roles.uri:
77
+ return react_1.default.createElement(Roles_1.Roles, { values: values, onDelete: onDelete, onChange: onChangeAttribute });
78
78
  default: {
79
79
  //startDate, endDate
80
80
  var value = __assign(__assign({}, emptyEditorValue.current), { value: values[0] || '' });
81
- return (react_1.default.createElement(Attribute_1.default, __assign({ attributeValue: value, attributeType: attributeType, mode: mode, onDeleteAttribute: onDelete }, otherProps)));
81
+ return (react_1.default.createElement(Attribute_1.default, __assign({ attributeValue: value, attributeType: attributeType, mode: mode, onDeleteAttribute: onDelete, onChangeAttribute: onChangeAttribute }, otherProps)));
82
82
  }
83
83
  }
84
84
  };
@@ -1,6 +1,9 @@
1
1
  /// <reference types="react" />
2
+ import { AttributeItem } from '../../..';
2
3
  declare type Props = {
3
4
  values: string[];
5
+ onChange: (param: AttributeItem) => void;
6
+ onDelete?: (param: AttributeItem) => void;
4
7
  };
5
- export declare const Roles: ({ values }: Props) => JSX.Element;
8
+ export declare const Roles: ({ values, onChange, onDelete }: Props) => JSX.Element;
6
9
  export {};
@@ -23,19 +23,20 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
23
23
  };
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  exports.Roles = void 0;
26
- var react_1 = __importDefault(require("react"));
26
+ var react_1 = __importStar(require("react"));
27
27
  var ramda_1 = require("ramda");
28
28
  var react_redux_1 = require("react-redux");
29
29
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
30
- var mdm_module_1 = __importStar(require("@reltio/mdm-module"));
30
+ var mdm_module_1 = __importDefault(require("@reltio/mdm-module"));
31
31
  var SimpleDropDownSelector_1 = __importDefault(require("../../../SimpleDropDownSelector/SimpleDropDownSelector"));
32
32
  var __1 = require("../../..");
33
33
  var styles_1 = require("./styles");
34
+ var SmallIconButton_1 = __importDefault(require("../../../SmallIconButton/SmallIconButton"));
35
+ var Delete_1 = __importDefault(require("@material-ui/icons/Delete"));
34
36
  var components = { MultiValue: __1.MultiValueChip };
35
37
  var Roles = function (_a) {
36
- var values = _a.values;
38
+ var values = _a.values, onChange = _a.onChange, onDelete = _a.onDelete;
37
39
  var styles = styles_1.useStyles();
38
- var dispatch = react_redux_1.useDispatch();
39
40
  var metadata = react_redux_1.useSelector(mdm_module_1.default.selectors.getMetadata);
40
41
  var entity = react_redux_1.useSelector(mdm_module_1.default.selectors.getEntity);
41
42
  var entityUri = entity.uri;
@@ -43,7 +44,7 @@ var Roles = function (_a) {
43
44
  value: role.uri,
44
45
  label: role.label
45
46
  }); });
46
- var formattedValues = values.map(function (value) {
47
+ var formattedValues = (values || []).map(function (value) {
47
48
  var _a;
48
49
  var label = (_a = options.find(ramda_1.propEq('value', value))) === null || _a === void 0 ? void 0 : _a.label;
49
50
  return {
@@ -51,14 +52,19 @@ var Roles = function (_a) {
51
52
  label: label || mdm_sdk_1.getLastUriPart(value)
52
53
  };
53
54
  });
54
- var handleChange = function (values) {
55
+ var handleChange = react_1.useCallback(function (values) {
55
56
  var roles = (values === null || values === void 0 ? void 0 : values.map(ramda_1.prop('value'))) || [];
56
- dispatch(mdm_module_1.profile.actions.modifyAttribute({
57
+ onChange({
57
58
  value: roles,
58
59
  attributeType: mdm_sdk_1.EntityAttrTypes.roles,
59
60
  uri: entityUri
60
- }));
61
- };
62
- return (react_1.default.createElement(SimpleDropDownSelector_1.default, { label: '', height: 40, isMulti: true, options: options, value: formattedValues, onChange: handleChange, components: components, classes: styles }));
61
+ });
62
+ }, [entityUri, onChange]);
63
+ var handleDelete = react_1.useCallback(function () {
64
+ onDelete({ uri: entityUri, attributeType: mdm_sdk_1.EntityAttrTypes.roles });
65
+ }, [entityUri, onDelete]);
66
+ return (react_1.default.createElement("div", { className: styles.container },
67
+ react_1.default.createElement(SimpleDropDownSelector_1.default, { label: '', height: 40, isMulti: true, options: options, value: formattedValues, onChange: handleChange, components: components, classes: styles, className: styles.roleContainer }),
68
+ !!onDelete && (react_1.default.createElement(SmallIconButton_1.default, { className: styles.deleteButton, icon: Delete_1.default, onClick: handleDelete, size: "L" }))));
63
69
  };
64
70
  exports.Roles = Roles;
@@ -1 +1 @@
1
- export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"valueContainer">;
1
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"container" | "valueContainer" | "roleContainer" | "deleteButton">;
@@ -3,8 +3,20 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.useStyles = void 0;
4
4
  var styles_1 = require("@material-ui/core/styles");
5
5
  exports.useStyles = styles_1.makeStyles({
6
+ container: {
7
+ display: 'flex',
8
+ flex: 1,
9
+ alignItems: 'flex-start',
10
+ marginBottom: '10px'
11
+ },
12
+ roleContainer: {
13
+ width: '100%'
14
+ },
6
15
  valueContainer: {
7
16
  marginLeft: '8px',
8
17
  width: 0
18
+ },
19
+ deleteButton: {
20
+ marginLeft: '8px'
9
21
  }
10
22
  });
@@ -53,15 +53,15 @@ var Add_1 = __importDefault(require("@material-ui/icons/Add"));
53
53
  var Delete_1 = __importDefault(require("@material-ui/icons/Delete"));
54
54
  var Typography_1 = __importDefault(require("@material-ui/core/Typography"));
55
55
  var ui_i18n_1 = __importDefault(require("ui-i18n"));
56
- var styles_1 = require("./styles");
57
56
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
58
57
  var DataTypeValue_1 = __importDefault(require("../../../DataTypeValue/DataTypeValue"));
59
58
  var DataTypeValueEditor_1 = __importDefault(require("../../../editors/DataTypeValueEditor/DataTypeValueEditor"));
60
59
  var ErrorWrapper_1 = __importDefault(require("../../../ErrorWrapper/ErrorWrapper"));
61
- var SmallIconButton_1 = __importDefault(require("../../../../components/SmallIconButton/SmallIconButton"));
60
+ var SmallIconButton_1 = __importDefault(require("../../../SmallIconButton/SmallIconButton"));
62
61
  var utils_1 = require("./utils");
63
62
  var withAsyncMount_1 = __importDefault(require("../../../../HOCs/withAsyncMount/withAsyncMount"));
64
63
  var getDependentLookupEditorContext_1 = require("./selectors/getDependentLookupEditorContext");
64
+ var styles_1 = require("./styles");
65
65
  var AsyncMountPlaceholder = function () {
66
66
  var styles = styles_1.useStyles();
67
67
  return react_1.default.createElement("div", { className: styles.placeholder });
@@ -1,7 +1,10 @@
1
1
  /// <reference types="react" />
2
- declare type Props = {
2
+ import { AttributeItem } from '../AttributesPager';
3
+ export declare type Props = {
3
4
  className?: string;
4
5
  values: string[];
6
+ onChange: (param: AttributeItem) => void;
7
+ onDelete?: (param: AttributeItem) => void;
5
8
  };
6
- declare const Tags: ({ className, values }: Props) => JSX.Element;
9
+ declare const Tags: ({ className, values, onChange, onDelete }: Props) => JSX.Element;
7
10
  export default Tags;
@@ -24,9 +24,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
24
24
  Object.defineProperty(exports, "__esModule", { value: true });
25
25
  var react_1 = __importStar(require("react"));
26
26
  var react_redux_1 = require("react-redux");
27
- var mdm_module_1 = __importStar(require("@reltio/mdm-module"));
27
+ var mdm_module_1 = __importDefault(require("@reltio/mdm-module"));
28
28
  var mdm_sdk_1 = require("@reltio/mdm-sdk");
29
+ var Delete_1 = __importDefault(require("@material-ui/icons/Delete"));
29
30
  var TypeaheadEditor_1 = __importDefault(require("../../../editors/TypeaheadEditor/TypeaheadEditor"));
31
+ var SmallIconButton_1 = __importDefault(require("../../../SmallIconButton/SmallIconButton"));
32
+ var styles_1 = require("./styles");
30
33
  var filtersWithSearch = function (searchQuery) { return [
31
34
  {
32
35
  filter: 'containsWordStartingWith',
@@ -47,16 +50,21 @@ var getSuggestions = function (searchQuery) {
47
50
  return mdm_sdk_1.getFacets({ query: getQuery(searchQuery), body: body }).then(function (response) { return Object.keys(response.tags); });
48
51
  };
49
52
  var Tags = function (_a) {
50
- var className = _a.className, values = _a.values;
51
- var dispatch = react_redux_1.useDispatch();
53
+ var className = _a.className, values = _a.values, onChange = _a.onChange, onDelete = _a.onDelete;
54
+ var styles = styles_1.useStyles();
52
55
  var entityUri = react_redux_1.useSelector(mdm_module_1.default.selectors.getEntityUri);
53
- var onChange = react_1.useCallback(function (tags) {
54
- return dispatch(mdm_module_1.profile.actions.modifyAttribute({
56
+ var handleChange = react_1.useCallback(function (tags) {
57
+ onChange({
55
58
  value: tags,
56
59
  attributeType: mdm_sdk_1.EntityAttrTypes.tags,
57
60
  uri: entityUri
58
- }));
59
- }, [dispatch, entityUri]);
60
- return (react_1.default.createElement(TypeaheadEditor_1.default, { fullWidth: true, multiple: true, variant: "filled", className: className, value: values, onChange: onChange, getSuggestions: getSuggestions }));
61
+ });
62
+ }, [onChange, entityUri]);
63
+ var handleDelete = react_1.useCallback(function () {
64
+ onDelete({ uri: entityUri, attributeType: mdm_sdk_1.EntityAttrTypes.tags });
65
+ }, [entityUri, onDelete]);
66
+ return (react_1.default.createElement("div", { className: styles.container },
67
+ react_1.default.createElement(TypeaheadEditor_1.default, { fullWidth: true, multiple: true, variant: "filled", className: className, value: values || [], onChange: handleChange, getSuggestions: getSuggestions }),
68
+ !!onDelete && (react_1.default.createElement(SmallIconButton_1.default, { className: styles.deleteButton, icon: Delete_1.default, onClick: handleDelete, size: "L" }))));
61
69
  };
62
70
  exports.default = Tags;
@@ -0,0 +1 @@
1
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"container" | "deleteButton">;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useStyles = void 0;
4
+ var styles_1 = require("@material-ui/core/styles");
5
+ exports.useStyles = styles_1.makeStyles({
6
+ container: {
7
+ display: 'flex',
8
+ flex: 1,
9
+ alignItems: 'flex-start',
10
+ marginBottom: '10px'
11
+ },
12
+ deleteButton: {
13
+ marginLeft: '8px'
14
+ }
15
+ });
@@ -27,7 +27,7 @@ var SPECIAL_ATTRIBUTES_NAMES = [
27
27
  var prepareStartOrEndDate = function (_a) {
28
28
  var newValue = _a.newValue, oldValue = _a.oldValue;
29
29
  var parseValue = function (value) { return (isNaN(value) || mdm_sdk_1.isEmptyValue(value) ? value : parseInt(value)); };
30
- var isExistedValue = function (value) { return (value === null || value === void 0 ? void 0 : value.length) && !mdm_sdk_1.isEmptyValue(value); };
30
+ var isExistedValue = function (value) { return (value === null || value === void 0 ? void 0 : value.length) && !mdm_sdk_1.isEmptyValue(value) && !mdm_sdk_1.isEmptyValue(value[0]); };
31
31
  var isExistNewValue = isExistedValue(newValue);
32
32
  var isExistOldValue = isExistedValue(oldValue);
33
33
  if (isExistNewValue && isExistOldValue) {
@@ -48,7 +48,11 @@ var useWorkflowAssignee = function (_a) {
48
48
  }))
49
49
  .then(function (result) {
50
50
  var data = result.data;
51
- var assignees = data.map(assigneeToValue);
51
+ var assignees = data
52
+ .sort(function (a, b) {
53
+ return mdm_sdk_1.utils.strings.sort('asc', a, b);
54
+ })
55
+ .map(assigneeToValue);
52
56
  setAssignees(assignees);
53
57
  return filterOutRest_1(assignees);
54
58
  })
@@ -1 +1 @@
1
- export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"divider" | "downloadButton" | "shareButton" | "deleteButton">;
1
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"divider" | "deleteButton" | "downloadButton" | "shareButton">;
@@ -55,10 +55,22 @@ declare var _default: import("react-redux").ConnectedComponent<{
55
55
  max: import("prop-types").Requireable<number>;
56
56
  icon: import("prop-types").Requireable<string>;
57
57
  caption: import("prop-types").Requireable<string>;
58
- canCreate: import("prop-types").Requireable<boolean>;
59
- canRead: import("prop-types").Requireable<boolean>;
60
- canUpdate: import("prop-types").Requireable<boolean>;
61
- canDelete: import("prop-types").Requireable<boolean>;
58
+ canCreate: import("prop-types").Requireable<import("prop-types").InferProps<{
59
+ deviceTypes: import("prop-types").Requireable<string | string[]>;
60
+ roles: import("prop-types").Requireable<string[]>;
61
+ }>>;
62
+ canRead: import("prop-types").Requireable<import("prop-types").InferProps<{
63
+ deviceTypes: import("prop-types").Requireable<string | string[]>;
64
+ roles: import("prop-types").Requireable<string[]>;
65
+ }>>;
66
+ canUpdate: import("prop-types").Requireable<import("prop-types").InferProps<{
67
+ deviceTypes: import("prop-types").Requireable<string | string[]>;
68
+ roles: import("prop-types").Requireable<string[]>;
69
+ }>>;
70
+ canDelete: import("prop-types").Requireable<import("prop-types").InferProps<{
71
+ deviceTypes: import("prop-types").Requireable<string | string[]>;
72
+ roles: import("prop-types").Requireable<string[]>;
73
+ }>>;
62
74
  editingEnabled: import("prop-types").Requireable<boolean>;
63
75
  }>>;
64
76
  mode: import("prop-types").Requireable<string>;
@@ -1,5 +1,5 @@
1
1
  import { always, both, cond, has, T } from 'ramda';
2
- import { isAnalyticAttribute, isSpecialAttribute } from '@reltio/mdm-sdk';
2
+ import { isAnalyticAttribute, isRoleAttrType, isSpecialAttribute, isTagAttrType } from '@reltio/mdm-sdk';
3
3
  var getSource = function (attrType, entity) {
4
4
  var _a = entity.attributes, attributes = _a === void 0 ? {} : _a, _b = entity.analyticsAttributes, analyticsAttributes = _b === void 0 ? {} : _b;
5
5
  return cond([
@@ -15,6 +15,6 @@ export var getMoreAttrTypes = function (attrTypes, entity) {
15
15
  return attrTypes.filter(function (attrType) {
16
16
  var source = getSource(attrType, entity);
17
17
  var nameProp = getNameProp(attrType);
18
- return !(attrType.singleValue && has(attrType[nameProp])(source));
18
+ return !((attrType.singleValue || isRoleAttrType(attrType) || isTagAttrType(attrType)) && has(attrType[nameProp])(source));
19
19
  });
20
20
  };
@@ -8,7 +8,8 @@ declare type Props = {
8
8
  mode: Mode;
9
9
  errorMessage?: string;
10
10
  onDeleteAttribute: (param: AttributeItem) => void;
11
+ onChangeAttribute: (param: AttributeItem) => void;
11
12
  showEmptyEditors?: boolean;
12
13
  };
13
- declare const SpecialRenderer: ({ values, attributeType, parentUri, mode, errorMessage, onDeleteAttribute, showEmptyEditors, ...otherProps }: Props) => JSX.Element;
14
+ declare const SpecialRenderer: ({ values, attributeType, parentUri, mode, errorMessage, onDeleteAttribute, onChangeAttribute, showEmptyEditors, ...otherProps }: Props) => JSX.Element;
14
15
  export default SpecialRenderer;
@@ -32,11 +32,12 @@ import { Roles } from '../Roles/Roles';
32
32
  import Tags from '../Tags';
33
33
  import { useStyles } from './styles';
34
34
  var SpecialRenderer = function (_a) {
35
- var values = _a.values, attributeType = _a.attributeType, parentUri = _a.parentUri, mode = _a.mode, errorMessage = _a.errorMessage, onDeleteAttribute = _a.onDeleteAttribute, showEmptyEditors = _a.showEmptyEditors, otherProps = __rest(_a, ["values", "attributeType", "parentUri", "mode", "errorMessage", "onDeleteAttribute", "showEmptyEditors"]);
35
+ var values = _a.values, attributeType = _a.attributeType, parentUri = _a.parentUri, mode = _a.mode, errorMessage = _a.errorMessage, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, showEmptyEditors = _a.showEmptyEditors, otherProps = __rest(_a, ["values", "attributeType", "parentUri", "mode", "errorMessage", "onDeleteAttribute", "onChangeAttribute", "showEmptyEditors"]);
36
36
  var styles = useStyles();
37
37
  var label = attributeType.label, isRequired = attributeType.required, cardinality = attributeType.cardinality;
38
38
  var isEditableMode = checkIsEditableMode(mode);
39
39
  var _b = useState(false), hadDeletions = _b[0], setHadDeletions = _b[1];
40
+ // eslint-disable-next-line react-hooks/exhaustive-deps
40
41
  var onDelete = useCallback(pipe(onDeleteAttribute, T, setHadDeletions), [onDeleteAttribute, setHadDeletions]);
41
42
  var isEmptyValues = isEmptyValue(values);
42
43
  var showEmpty = !hadDeletions && showEmptyEditors && isEmptyValues;
@@ -47,14 +48,13 @@ var SpecialRenderer = function (_a) {
47
48
  var renderValue = function () {
48
49
  switch (attributeType.uri) {
49
50
  case EntityAttrTypes.tags.uri:
50
- return React.createElement(Tags, { values: values });
51
- case EntityAttrTypes.roles.uri: {
52
- return React.createElement(Roles, { values: values });
53
- }
51
+ return React.createElement(Tags, { values: values, onDelete: onDelete, onChange: onChangeAttribute });
52
+ case EntityAttrTypes.roles.uri:
53
+ return React.createElement(Roles, { values: values, onDelete: onDelete, onChange: onChangeAttribute });
54
54
  default: {
55
55
  //startDate, endDate
56
56
  var value = __assign(__assign({}, emptyEditorValue.current), { value: values[0] || '' });
57
- return (React.createElement(Attribute, __assign({ attributeValue: value, attributeType: attributeType, mode: mode, onDeleteAttribute: onDelete }, otherProps)));
57
+ return (React.createElement(Attribute, __assign({ attributeValue: value, attributeType: attributeType, mode: mode, onDeleteAttribute: onDelete, onChangeAttribute: onChangeAttribute }, otherProps)));
58
58
  }
59
59
  }
60
60
  };
@@ -1,6 +1,9 @@
1
1
  /// <reference types="react" />
2
+ import { AttributeItem } from '../../..';
2
3
  declare type Props = {
3
4
  values: string[];
5
+ onChange: (param: AttributeItem) => void;
6
+ onDelete?: (param: AttributeItem) => void;
4
7
  };
5
- export declare const Roles: ({ values }: Props) => JSX.Element;
8
+ export declare const Roles: ({ values, onChange, onDelete }: Props) => JSX.Element;
6
9
  export {};
@@ -1,16 +1,17 @@
1
- import React from 'react';
1
+ import React, { useCallback } from 'react';
2
2
  import { prop, propEq } from 'ramda';
3
- import { useSelector, useDispatch } from 'react-redux';
3
+ import { useSelector } from 'react-redux';
4
4
  import { EntityAttrTypes, getRolesForEntityType, getLastUriPart } from '@reltio/mdm-sdk';
5
- import mdmModule, { profile } from '@reltio/mdm-module';
5
+ import mdmModule from '@reltio/mdm-module';
6
6
  import SimpleDropDownSelector from '../../../SimpleDropDownSelector/SimpleDropDownSelector';
7
7
  import { MultiValueChip } from '../../..';
8
8
  import { useStyles } from './styles';
9
+ import SmallIconButton from '../../../SmallIconButton/SmallIconButton';
10
+ import DeleteIcon from '@material-ui/icons/Delete';
9
11
  var components = { MultiValue: MultiValueChip };
10
12
  export var Roles = function (_a) {
11
- var values = _a.values;
13
+ var values = _a.values, onChange = _a.onChange, onDelete = _a.onDelete;
12
14
  var styles = useStyles();
13
- var dispatch = useDispatch();
14
15
  var metadata = useSelector(mdmModule.selectors.getMetadata);
15
16
  var entity = useSelector(mdmModule.selectors.getEntity);
16
17
  var entityUri = entity.uri;
@@ -18,7 +19,7 @@ export var Roles = function (_a) {
18
19
  value: role.uri,
19
20
  label: role.label
20
21
  }); });
21
- var formattedValues = values.map(function (value) {
22
+ var formattedValues = (values || []).map(function (value) {
22
23
  var _a;
23
24
  var label = (_a = options.find(propEq('value', value))) === null || _a === void 0 ? void 0 : _a.label;
24
25
  return {
@@ -26,13 +27,18 @@ export var Roles = function (_a) {
26
27
  label: label || getLastUriPart(value)
27
28
  };
28
29
  });
29
- var handleChange = function (values) {
30
+ var handleChange = useCallback(function (values) {
30
31
  var roles = (values === null || values === void 0 ? void 0 : values.map(prop('value'))) || [];
31
- dispatch(profile.actions.modifyAttribute({
32
+ onChange({
32
33
  value: roles,
33
34
  attributeType: EntityAttrTypes.roles,
34
35
  uri: entityUri
35
- }));
36
- };
37
- return (React.createElement(SimpleDropDownSelector, { label: '', height: 40, isMulti: true, options: options, value: formattedValues, onChange: handleChange, components: components, classes: styles }));
36
+ });
37
+ }, [entityUri, onChange]);
38
+ var handleDelete = useCallback(function () {
39
+ onDelete({ uri: entityUri, attributeType: EntityAttrTypes.roles });
40
+ }, [entityUri, onDelete]);
41
+ return (React.createElement("div", { className: styles.container },
42
+ React.createElement(SimpleDropDownSelector, { label: '', height: 40, isMulti: true, options: options, value: formattedValues, onChange: handleChange, components: components, classes: styles, className: styles.roleContainer }),
43
+ !!onDelete && (React.createElement(SmallIconButton, { className: styles.deleteButton, icon: DeleteIcon, onClick: handleDelete, size: "L" }))));
38
44
  };
@@ -1 +1 @@
1
- export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"valueContainer">;
1
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"container" | "valueContainer" | "roleContainer" | "deleteButton">;
@@ -1,7 +1,19 @@
1
1
  import { makeStyles } from '@material-ui/core/styles';
2
2
  export var useStyles = makeStyles({
3
+ container: {
4
+ display: 'flex',
5
+ flex: 1,
6
+ alignItems: 'flex-start',
7
+ marginBottom: '10px'
8
+ },
9
+ roleContainer: {
10
+ width: '100%'
11
+ },
3
12
  valueContainer: {
4
13
  marginLeft: '8px',
5
14
  width: 0
15
+ },
16
+ deleteButton: {
17
+ marginLeft: '8px'
6
18
  }
7
19
  });
@@ -29,15 +29,15 @@ import AddIcon from '@material-ui/icons/Add';
29
29
  import DeleteIcon from '@material-ui/icons/Delete';
30
30
  import Typography from '@material-ui/core/Typography';
31
31
  import i18n from 'ui-i18n';
32
- import { useStyles } from './styles';
33
32
  import { AttributeErrorType, AttributeTypeType, attributeUriToSearchUri, checkCanCreateAttribute, checkCanDeleteAttribute, checkCanEditAttribute, ErrorType, getAttributeValue, getAttrDataTypeDefinition, getErrorId, getErrorMessage, getErrorType, isDependentLookupAttrType, isEditableMode as checkIsEditableMode, ModeType, SimpleAttributeValueType } from '@reltio/mdm-sdk';
34
33
  import DataTypeValue from '../../../DataTypeValue/DataTypeValue';
35
34
  import DataTypeValueEditor from '../../../editors/DataTypeValueEditor/DataTypeValueEditor';
36
35
  import ErrorWrapper from '../../../ErrorWrapper/ErrorWrapper';
37
- import SmallIconButton from '../../../../components/SmallIconButton/SmallIconButton';
36
+ import SmallIconButton from '../../../SmallIconButton/SmallIconButton';
38
37
  import { attributeValueToEditorValue, prepareChangeData } from './utils';
39
38
  import withAsyncMount from '../../../../HOCs/withAsyncMount/withAsyncMount';
40
39
  import { getDependentLookupEditorContext } from './selectors/getDependentLookupEditorContext';
40
+ import { useStyles } from './styles';
41
41
  var AsyncMountPlaceholder = function () {
42
42
  var styles = useStyles();
43
43
  return React.createElement("div", { className: styles.placeholder });
@@ -1,7 +1,10 @@
1
1
  /// <reference types="react" />
2
- declare type Props = {
2
+ import { AttributeItem } from '../AttributesPager';
3
+ export declare type Props = {
3
4
  className?: string;
4
5
  values: string[];
6
+ onChange: (param: AttributeItem) => void;
7
+ onDelete?: (param: AttributeItem) => void;
5
8
  };
6
- declare const Tags: ({ className, values }: Props) => JSX.Element;
9
+ declare const Tags: ({ className, values, onChange, onDelete }: Props) => JSX.Element;
7
10
  export default Tags;
@@ -1,8 +1,11 @@
1
1
  import React, { useCallback } from 'react';
2
- import { useDispatch, useSelector } from 'react-redux';
3
- import mdmModule, { profile } from '@reltio/mdm-module';
2
+ import { useSelector } from 'react-redux';
3
+ import mdmModule from '@reltio/mdm-module';
4
4
  import { getFacets, EntityAttrTypes, buildFilterQueryString } from '@reltio/mdm-sdk';
5
+ import DeleteIcon from '@material-ui/icons/Delete';
5
6
  import TypeaheadEditor from '../../../editors/TypeaheadEditor/TypeaheadEditor';
7
+ import SmallIconButton from '../../../SmallIconButton/SmallIconButton';
8
+ import { useStyles } from './styles';
6
9
  var filtersWithSearch = function (searchQuery) { return [
7
10
  {
8
11
  filter: 'containsWordStartingWith',
@@ -23,16 +26,21 @@ var getSuggestions = function (searchQuery) {
23
26
  return getFacets({ query: getQuery(searchQuery), body: body }).then(function (response) { return Object.keys(response.tags); });
24
27
  };
25
28
  var Tags = function (_a) {
26
- var className = _a.className, values = _a.values;
27
- var dispatch = useDispatch();
29
+ var className = _a.className, values = _a.values, onChange = _a.onChange, onDelete = _a.onDelete;
30
+ var styles = useStyles();
28
31
  var entityUri = useSelector(mdmModule.selectors.getEntityUri);
29
- var onChange = useCallback(function (tags) {
30
- return dispatch(profile.actions.modifyAttribute({
32
+ var handleChange = useCallback(function (tags) {
33
+ onChange({
31
34
  value: tags,
32
35
  attributeType: EntityAttrTypes.tags,
33
36
  uri: entityUri
34
- }));
35
- }, [dispatch, entityUri]);
36
- return (React.createElement(TypeaheadEditor, { fullWidth: true, multiple: true, variant: "filled", className: className, value: values, onChange: onChange, getSuggestions: getSuggestions }));
37
+ });
38
+ }, [onChange, entityUri]);
39
+ var handleDelete = useCallback(function () {
40
+ onDelete({ uri: entityUri, attributeType: EntityAttrTypes.tags });
41
+ }, [entityUri, onDelete]);
42
+ return (React.createElement("div", { className: styles.container },
43
+ React.createElement(TypeaheadEditor, { fullWidth: true, multiple: true, variant: "filled", className: className, value: values || [], onChange: handleChange, getSuggestions: getSuggestions }),
44
+ !!onDelete && (React.createElement(SmallIconButton, { className: styles.deleteButton, icon: DeleteIcon, onClick: handleDelete, size: "L" }))));
37
45
  };
38
46
  export default Tags;
@@ -0,0 +1 @@
1
+ export declare const useStyles: (props?: any) => import("@material-ui/core/styles/withStyles").ClassNameMap<"container" | "deleteButton">;
@@ -0,0 +1,12 @@
1
+ import { makeStyles } from '@material-ui/core/styles';
2
+ export var useStyles = makeStyles({
3
+ container: {
4
+ display: 'flex',
5
+ flex: 1,
6
+ alignItems: 'flex-start',
7
+ marginBottom: '10px'
8
+ },
9
+ deleteButton: {
10
+ marginLeft: '8px'
11
+ }
12
+ });
@@ -24,7 +24,7 @@ var SPECIAL_ATTRIBUTES_NAMES = [
24
24
  var prepareStartOrEndDate = function (_a) {
25
25
  var newValue = _a.newValue, oldValue = _a.oldValue;
26
26
  var parseValue = function (value) { return (isNaN(value) || isEmptyValue(value) ? value : parseInt(value)); };
27
- var isExistedValue = function (value) { return (value === null || value === void 0 ? void 0 : value.length) && !isEmptyValue(value); };
27
+ var isExistedValue = function (value) { return (value === null || value === void 0 ? void 0 : value.length) && !isEmptyValue(value) && !isEmptyValue(value[0]); };
28
28
  var isExistNewValue = isExistedValue(newValue);
29
29
  var isExistOldValue = isExistedValue(oldValue);
30
30
  if (isExistNewValue && isExistOldValue) {
@@ -1,7 +1,7 @@
1
1
  import { useState, useEffect, useCallback, useContext } from 'react';
2
2
  import { filter } from 'ramda';
3
3
  import { useSelector } from 'react-redux';
4
- import { getAssigneeForTask, updateAssigneeForTask } from '@reltio/mdm-sdk';
4
+ import { getAssigneeForTask, updateAssigneeForTask, utils } from '@reltio/mdm-sdk';
5
5
  import mdmModule from '@reltio/mdm-module';
6
6
  import { useSafePromise } from '../../../hooks';
7
7
  import { WorkflowTasksContext } from '../../../contexts/WorkflowTasksContext';
@@ -42,7 +42,11 @@ export var useWorkflowAssignee = function (_a) {
42
42
  }))
43
43
  .then(function (result) {
44
44
  var data = result.data;
45
- var assignees = data.map(assigneeToValue);
45
+ var assignees = data
46
+ .sort(function (a, b) {
47
+ return utils.strings.sort('asc', a, b);
48
+ })
49
+ .map(assigneeToValue);
46
50
  setAssignees(assignees);
47
51
  return filterOutRest_1(assignees);
48
52
  })
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.952",
3
+ "version": "1.4.953",
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.952",
11
- "@reltio/mdm-sdk": "^1.4.952",
10
+ "@reltio/mdm-module": "^1.4.953",
11
+ "@reltio/mdm-sdk": "^1.4.953",
12
12
  "classnames": "^2.2.5",
13
13
  "d3-cloud": "^1.2.5",
14
14
  "d3-geo": "^2.0.1",