@reltio/components 1.4.1709 → 1.4.1711

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.
@@ -3,4 +3,5 @@ export type EditAttributeEvent = {
3
3
  attributeType: AttributeType;
4
4
  attributeValue: SimpleAttributeValue;
5
5
  crosswalk: Crosswalk | RelationCrosswalk;
6
+ clearAttributeFlags?: boolean;
6
7
  };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import { AttributesViewProps } from '../../types';
3
3
  type Props = Omit<AttributesViewProps, 'mode' | 'pinnedAttributes'>;
4
- declare const AttributesView: ({ className, entity, caption, excludeUris, includeUris, attributesCount }: Props) => JSX.Element;
4
+ declare const AttributesView: ({ className, entity, caption, excludeUris, includeUris, attributesCount: attributesCountProp }: Props) => JSX.Element;
5
5
  export default AttributesView;
@@ -38,13 +38,15 @@ var FacetViewHeader_1 = __importDefault(require("../../../FacetViewHeader/FacetV
38
38
  var AttributesList_1 = __importDefault(require("../AttributesList"));
39
39
  var attributesView_1 = require("../../helpers/attributesView");
40
40
  var styles_1 = require("./styles");
41
+ var DEFAULT_ATTRIBUTES_COUNT = 16;
41
42
  var AttributesView = function (_a) {
42
43
  var _b;
43
- var className = _a.className, _c = _a.entity, entity = _c === void 0 ? {} : _c, _d = _a.caption, caption = _d === void 0 ? '' : _d, _e = _a.excludeUris, excludeUris = _e === void 0 ? [] : _e, _f = _a.includeUris, includeUris = _f === void 0 ? [] : _f, _g = _a.attributesCount, attributesCount = _g === void 0 ? 16 : _g;
44
+ var className = _a.className, _c = _a.entity, entity = _c === void 0 ? {} : _c, _d = _a.caption, caption = _d === void 0 ? '' : _d, _e = _a.excludeUris, excludeUris = _e === void 0 ? [] : _e, _f = _a.includeUris, includeUris = _f === void 0 ? [] : _f, attributesCountProp = _a.attributesCount;
44
45
  var styles = (0, styles_1.useStyles)();
45
46
  var metadata = (0, contexts_1.useMdmMetadata)();
46
47
  var pivotingAttributes = (0, contexts_1.useMdmPivotingAttributes)();
47
48
  var filteredAttrTypes = (0, react_1.useMemo)(function () { return (0, attributesView_1.getFilteredAttrTypes)(metadata, entity.type, includeUris, excludeUris); }, [excludeUris, includeUris, metadata, entity.type]);
49
+ var attributesCount = attributesCountProp || DEFAULT_ATTRIBUTES_COUNT;
48
50
  var attributesList = (0, mdm_sdk_1.getAttributesListForReadMode)(filteredAttrTypes, entity);
49
51
  var isShowAttributeList = attributesList.filter(function (_a) {
50
52
  var values = _a.values;
@@ -139,8 +139,7 @@ var AttributesTable = function (_a) {
139
139
  react_1.default.createElement(BasicTableView_1.BasicTable, { fixFirstColumn: true, headRowHeight: 48, defaultColumnWidth: 250, defaultColumnMinWidth: 200, columnsData: visibleColumnsData, dndRowReorderingEnabled: false, dndRowReorderingHandler: handleReorderAttributeTypes, getIdFromRowValue: getIdFromRowValue, rowsData: rowsData, renderRowCell: renderRowCell, getRowCellHeight: getRowCellHeight, context: tableContext })),
140
140
  react_1.default.createElement(ConfirmDeleteDialog_1.default, { open: !!pendingDeletion, onClose: function () { return setPendingDeletion(null); }, onConfirm: handleDelete }),
141
141
  react_1.default.createElement(ConfirmEditIgnoredDialog_1.default, { open: !!pendingIgnoredEditing, onClose: function () { return setPendingIgnoredEditing(null); }, onConfirmEditWithIgnore: function () { return onEdit(pendingIgnoredEditing); }, onConfirmEditWithoutIgnore: function () {
142
- onIgnore({ attributeValue: pendingIgnoredEditing.attributeValue });
143
- onEdit(pendingIgnoredEditing);
142
+ onEdit(__assign(__assign({}, pendingIgnoredEditing), { clearAttributeFlags: true }));
144
143
  } })));
145
144
  };
146
145
  exports.default = (0, react_1.memo)(AttributesTable);
@@ -9,7 +9,7 @@ export declare const useAttributeActions: ({ onSuccess, onError, onLoad }: Props
9
9
  deleteAttribute: ({ attributeValue, attributeType, crosswalks }: DeleteInlineAttributeEvent) => void;
10
10
  pinAttribute: ({ attributeValue }: PinInlineAttributeEvent) => void;
11
11
  ignoreAttribute: ({ attributeValue }: IgnoreInlineAttributeEvent) => void;
12
- updateAttribute: ({ attributeValue, attributeType, crosswalk }: EditInlineAttributeEvent) => void;
12
+ updateAttribute: ({ attributeValue, attributeType, crosswalk, clearAttributeFlags }: EditInlineAttributeEvent) => void;
13
13
  createAttribute: ({ attributeValue, crosswalk }: CreateAttributeEvent) => void;
14
14
  };
15
15
  export {};
@@ -1,4 +1,40 @@
1
1
  "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
2
38
  Object.defineProperty(exports, "__esModule", { value: true });
3
39
  exports.useAttributeActions = void 0;
4
40
  var react_1 = require("react");
@@ -52,16 +88,46 @@ var useAttributeActions = function (_a) {
52
88
  });
53
89
  }, [handleAction, handleErrorResponse]);
54
90
  var updateAttributeAction = (0, react_1.useCallback)(function (_a) {
55
- var attributeValue = _a.attributeValue, attributeType = _a.attributeType, crosswalk = _a.crosswalk;
91
+ var attributeValue = _a.attributeValue, attributeType = _a.attributeType, crosswalk = _a.crosswalk, clearAttributeFlags = _a.clearAttributeFlags;
56
92
  if ((0, mdm_sdk_1.isComplexAttribute)(attributeType) || (0, mdm_sdk_1.isImage)(attributeType))
57
93
  return;
58
- (0, ramda_1.pipe)(mdm_sdk_1.updateAttribute, handleErrorResponse, handleAction)({
59
- attributeUri: attributeValue.uri,
60
- sourceUri: crosswalk.type,
61
- crosswalkValue: crosswalk.value,
62
- crosswalkSourceTable: crosswalk.sourceTable,
63
- value: (0, mdm_sdk_1.isLookupAttrType)(attributeType) ? attributeValue.lookupCode : attributeValue.value
64
- });
94
+ var update = function () { return __awaiter(void 0, void 0, void 0, function () {
95
+ return __generator(this, function (_a) {
96
+ switch (_a.label) {
97
+ case 0: return [4 /*yield*/, handleErrorResponse((0, mdm_sdk_1.updateAttribute)({
98
+ attributeUri: attributeValue.uri,
99
+ sourceUri: crosswalk.type,
100
+ crosswalkValue: crosswalk.value,
101
+ crosswalkSourceTable: crosswalk.sourceTable,
102
+ value: (0, mdm_sdk_1.isLookupAttrType)(attributeType)
103
+ ? attributeValue.lookupCode
104
+ : attributeValue.value
105
+ }))];
106
+ case 1:
107
+ _a.sent();
108
+ if (!!clearAttributeFlags) return [3 /*break*/, 5];
109
+ if (!attributeValue.ignored) return [3 /*break*/, 3];
110
+ return [4 /*yield*/, handleErrorResponse((0, mdm_sdk_1.ignoreAttribute)({
111
+ attributeUri: attributeValue.uri,
112
+ value: true
113
+ }))];
114
+ case 2:
115
+ _a.sent();
116
+ return [3 /*break*/, 5];
117
+ case 3:
118
+ if (!attributeValue.pin) return [3 /*break*/, 5];
119
+ return [4 /*yield*/, handleErrorResponse((0, mdm_sdk_1.pinAttribute)({
120
+ attributeUri: attributeValue.uri,
121
+ value: true
122
+ }))];
123
+ case 4:
124
+ _a.sent();
125
+ _a.label = 5;
126
+ case 5: return [2 /*return*/];
127
+ }
128
+ });
129
+ }); };
130
+ handleAction(update());
65
131
  }, [handleAction, handleErrorResponse]);
66
132
  var createAttributeAction = (0, react_1.useCallback)(function (_a) {
67
133
  var attributeValue = _a.attributeValue, crosswalk = _a.crosswalk;
@@ -3,4 +3,5 @@ export type EditAttributeEvent = {
3
3
  attributeType: AttributeType;
4
4
  attributeValue: SimpleAttributeValue;
5
5
  crosswalk: Crosswalk | RelationCrosswalk;
6
+ clearAttributeFlags?: boolean;
6
7
  };
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
2
  import { AttributesViewProps } from '../../types';
3
3
  type Props = Omit<AttributesViewProps, 'mode' | 'pinnedAttributes'>;
4
- declare const AttributesView: ({ className, entity, caption, excludeUris, includeUris, attributesCount }: Props) => JSX.Element;
4
+ declare const AttributesView: ({ className, entity, caption, excludeUris, includeUris, attributesCount: attributesCountProp }: Props) => JSX.Element;
5
5
  export default AttributesView;
@@ -10,13 +10,15 @@ import FacetViewHeader from '../../../FacetViewHeader/FacetViewHeader';
10
10
  import AttributesList from '../AttributesList';
11
11
  import { getFilteredAttrTypes } from '../../helpers/attributesView';
12
12
  import { useStyles } from './styles';
13
+ var DEFAULT_ATTRIBUTES_COUNT = 16;
13
14
  var AttributesView = function (_a) {
14
15
  var _b;
15
- var className = _a.className, _c = _a.entity, entity = _c === void 0 ? {} : _c, _d = _a.caption, caption = _d === void 0 ? '' : _d, _e = _a.excludeUris, excludeUris = _e === void 0 ? [] : _e, _f = _a.includeUris, includeUris = _f === void 0 ? [] : _f, _g = _a.attributesCount, attributesCount = _g === void 0 ? 16 : _g;
16
+ var className = _a.className, _c = _a.entity, entity = _c === void 0 ? {} : _c, _d = _a.caption, caption = _d === void 0 ? '' : _d, _e = _a.excludeUris, excludeUris = _e === void 0 ? [] : _e, _f = _a.includeUris, includeUris = _f === void 0 ? [] : _f, attributesCountProp = _a.attributesCount;
16
17
  var styles = useStyles();
17
18
  var metadata = useMdmMetadata();
18
19
  var pivotingAttributes = useMdmPivotingAttributes();
19
20
  var filteredAttrTypes = useMemo(function () { return getFilteredAttrTypes(metadata, entity.type, includeUris, excludeUris); }, [excludeUris, includeUris, metadata, entity.type]);
21
+ var attributesCount = attributesCountProp || DEFAULT_ATTRIBUTES_COUNT;
20
22
  var attributesList = getAttributesListForReadMode(filteredAttrTypes, entity);
21
23
  var isShowAttributeList = attributesList.filter(function (_a) {
22
24
  var values = _a.values;
@@ -111,8 +111,7 @@ var AttributesTable = function (_a) {
111
111
  React.createElement(BasicTable, { fixFirstColumn: true, headRowHeight: 48, defaultColumnWidth: 250, defaultColumnMinWidth: 200, columnsData: visibleColumnsData, dndRowReorderingEnabled: false, dndRowReorderingHandler: handleReorderAttributeTypes, getIdFromRowValue: getIdFromRowValue, rowsData: rowsData, renderRowCell: renderRowCell, getRowCellHeight: getRowCellHeight, context: tableContext })),
112
112
  React.createElement(ConfirmDeleteDialog, { open: !!pendingDeletion, onClose: function () { return setPendingDeletion(null); }, onConfirm: handleDelete }),
113
113
  React.createElement(ConfirmEditIgnoredDialog, { open: !!pendingIgnoredEditing, onClose: function () { return setPendingIgnoredEditing(null); }, onConfirmEditWithIgnore: function () { return onEdit(pendingIgnoredEditing); }, onConfirmEditWithoutIgnore: function () {
114
- onIgnore({ attributeValue: pendingIgnoredEditing.attributeValue });
115
- onEdit(pendingIgnoredEditing);
114
+ onEdit(__assign(__assign({}, pendingIgnoredEditing), { clearAttributeFlags: true }));
116
115
  } })));
117
116
  };
118
117
  export default memo(AttributesTable);
@@ -9,7 +9,7 @@ export declare const useAttributeActions: ({ onSuccess, onError, onLoad }: Props
9
9
  deleteAttribute: ({ attributeValue, attributeType, crosswalks }: DeleteInlineAttributeEvent) => void;
10
10
  pinAttribute: ({ attributeValue }: PinInlineAttributeEvent) => void;
11
11
  ignoreAttribute: ({ attributeValue }: IgnoreInlineAttributeEvent) => void;
12
- updateAttribute: ({ attributeValue, attributeType, crosswalk }: EditInlineAttributeEvent) => void;
12
+ updateAttribute: ({ attributeValue, attributeType, crosswalk, clearAttributeFlags }: EditInlineAttributeEvent) => void;
13
13
  createAttribute: ({ attributeValue, crosswalk }: CreateAttributeEvent) => void;
14
14
  };
15
15
  export {};
@@ -1,3 +1,39 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
1
37
  import { useCallback } from 'react';
2
38
  import { createAttribute, deleteAttribute, getReferencedRelationFromAttrValue, ignoreAttribute, isComplexAttribute, isImage, isLookupAttrType, isReference, pinAttribute, removeRelation, updateAttribute } from '@reltio/mdm-sdk';
3
39
  import { andThen, pipe, prop } from 'ramda';
@@ -49,16 +85,46 @@ export var useAttributeActions = function (_a) {
49
85
  });
50
86
  }, [handleAction, handleErrorResponse]);
51
87
  var updateAttributeAction = useCallback(function (_a) {
52
- var attributeValue = _a.attributeValue, attributeType = _a.attributeType, crosswalk = _a.crosswalk;
88
+ var attributeValue = _a.attributeValue, attributeType = _a.attributeType, crosswalk = _a.crosswalk, clearAttributeFlags = _a.clearAttributeFlags;
53
89
  if (isComplexAttribute(attributeType) || isImage(attributeType))
54
90
  return;
55
- pipe(updateAttribute, handleErrorResponse, handleAction)({
56
- attributeUri: attributeValue.uri,
57
- sourceUri: crosswalk.type,
58
- crosswalkValue: crosswalk.value,
59
- crosswalkSourceTable: crosswalk.sourceTable,
60
- value: isLookupAttrType(attributeType) ? attributeValue.lookupCode : attributeValue.value
61
- });
91
+ var update = function () { return __awaiter(void 0, void 0, void 0, function () {
92
+ return __generator(this, function (_a) {
93
+ switch (_a.label) {
94
+ case 0: return [4 /*yield*/, handleErrorResponse(updateAttribute({
95
+ attributeUri: attributeValue.uri,
96
+ sourceUri: crosswalk.type,
97
+ crosswalkValue: crosswalk.value,
98
+ crosswalkSourceTable: crosswalk.sourceTable,
99
+ value: isLookupAttrType(attributeType)
100
+ ? attributeValue.lookupCode
101
+ : attributeValue.value
102
+ }))];
103
+ case 1:
104
+ _a.sent();
105
+ if (!!clearAttributeFlags) return [3 /*break*/, 5];
106
+ if (!attributeValue.ignored) return [3 /*break*/, 3];
107
+ return [4 /*yield*/, handleErrorResponse(ignoreAttribute({
108
+ attributeUri: attributeValue.uri,
109
+ value: true
110
+ }))];
111
+ case 2:
112
+ _a.sent();
113
+ return [3 /*break*/, 5];
114
+ case 3:
115
+ if (!attributeValue.pin) return [3 /*break*/, 5];
116
+ return [4 /*yield*/, handleErrorResponse(pinAttribute({
117
+ attributeUri: attributeValue.uri,
118
+ value: true
119
+ }))];
120
+ case 4:
121
+ _a.sent();
122
+ _a.label = 5;
123
+ case 5: return [2 /*return*/];
124
+ }
125
+ });
126
+ }); };
127
+ handleAction(update());
62
128
  }, [handleAction, handleErrorResponse]);
63
129
  var createAttributeAction = useCallback(function (_a) {
64
130
  var attributeValue = _a.attributeValue, crosswalk = _a.crosswalk;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.1709",
3
+ "version": "1.4.1711",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",