@reltio/components 1.4.2273 → 1.4.2275
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ProfileResizablePanes/ProfileResizablePanes.js +4 -1
- package/ProfileResizablePanes/ProfileResizablePanes.spec.js +11 -0
- package/cjs/ProfileResizablePanes/ProfileResizablePanes.js +4 -1
- package/cjs/ProfileResizablePanes/ProfileResizablePanes.spec.js +11 -0
- package/cjs/features/crosswalks/AttributesTable/AttributesTable.d.ts +2 -2
- package/cjs/features/crosswalks/AttributesTable/AttributesTable.js +15 -13
- package/cjs/features/crosswalks/AttributesTable/components/AddAttributesButton/AddAttributesButton.js +17 -4
- package/cjs/features/crosswalks/AttributesTable/components/AddAttributesButton/getAddableAttributeTypes.d.ts +12 -0
- package/cjs/features/crosswalks/AttributesTable/components/AddAttributesButton/getAddableAttributeTypes.js +20 -0
- package/features/crosswalks/AttributesTable/AttributesTable.d.ts +2 -2
- package/features/crosswalks/AttributesTable/AttributesTable.js +17 -15
- package/features/crosswalks/AttributesTable/components/AddAttributesButton/AddAttributesButton.js +19 -6
- package/features/crosswalks/AttributesTable/components/AddAttributesButton/getAddableAttributeTypes.d.ts +12 -0
- package/features/crosswalks/AttributesTable/components/AddAttributesButton/getAddableAttributeTypes.js +16 -0
- package/package.json +2 -2
|
@@ -14,7 +14,10 @@ export var ProfileResizablePanes = function (_a) {
|
|
|
14
14
|
var _c = (perspectiveSettings || {}).width, width = _c === void 0 ? DEFAULT_R_PANE_SIZE : _c;
|
|
15
15
|
var active = !isNil(defaultTab) ? defaultTab : perspectiveSettings === null || perspectiveSettings === void 0 ? void 0 : perspectiveSettings.active;
|
|
16
16
|
var activeButton = buttonsProps.find(function (button) { return button.id === active; });
|
|
17
|
-
|
|
17
|
+
// When there are no buttons (e.g. the interactions screen drives the panel purely via `active`),
|
|
18
|
+
// open state must not depend on a matching button. Only require `activeButton` when buttons exist,
|
|
19
|
+
// so a stale persisted `active` pointing to a removed tab doesn't open an empty pane.
|
|
20
|
+
var isSidePanelOpen = !isNil(active) && !disabled && (buttonsProps.length === 0 || Boolean(activeButton));
|
|
18
21
|
var handleUpdateSettings = useCallback(function (newSetting) {
|
|
19
22
|
updatePerspectiveSettings(newSetting);
|
|
20
23
|
}, [updatePerspectiveSettings]);
|
|
@@ -83,6 +83,10 @@ var setUp = function (props) {
|
|
|
83
83
|
graph: {
|
|
84
84
|
active: 1,
|
|
85
85
|
width: 320
|
|
86
|
+
},
|
|
87
|
+
interactions: {
|
|
88
|
+
active: 0,
|
|
89
|
+
width: 400
|
|
86
90
|
}
|
|
87
91
|
}
|
|
88
92
|
};
|
|
@@ -143,6 +147,13 @@ describe('ProfileResizablePanes tests', function () {
|
|
|
143
147
|
return [2 /*return*/];
|
|
144
148
|
});
|
|
145
149
|
}); });
|
|
150
|
+
it('should open the second pane when buttonsProps is empty and active is set (interactions screen)', function () {
|
|
151
|
+
var container = setUp(__assign(__assign({}, defaultProps), { perspectiveId: 'interactions', buttonsProps: [] })).container;
|
|
152
|
+
expect(screen.getByTestId('rightPanel')).toBeInTheDocument();
|
|
153
|
+
expect(isResizingDisabled(container)).toBe(false);
|
|
154
|
+
checkPanelSize(getSplitPane1(container), '60.0');
|
|
155
|
+
checkPanelSize(getSplitPane2(container), '40.0');
|
|
156
|
+
});
|
|
146
157
|
it('should render resizable panes with open second pane on button click', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
147
158
|
var _a, container, user, button2;
|
|
148
159
|
return __generator(this, function (_b) {
|
|
@@ -40,7 +40,10 @@ var ProfileResizablePanes = function (_a) {
|
|
|
40
40
|
var _c = (perspectiveSettings || {}).width, width = _c === void 0 ? DEFAULT_R_PANE_SIZE : _c;
|
|
41
41
|
var active = !(0, ramda_1.isNil)(defaultTab) ? defaultTab : perspectiveSettings === null || perspectiveSettings === void 0 ? void 0 : perspectiveSettings.active;
|
|
42
42
|
var activeButton = buttonsProps.find(function (button) { return button.id === active; });
|
|
43
|
-
|
|
43
|
+
// When there are no buttons (e.g. the interactions screen drives the panel purely via `active`),
|
|
44
|
+
// open state must not depend on a matching button. Only require `activeButton` when buttons exist,
|
|
45
|
+
// so a stale persisted `active` pointing to a removed tab doesn't open an empty pane.
|
|
46
|
+
var isSidePanelOpen = !(0, ramda_1.isNil)(active) && !disabled && (buttonsProps.length === 0 || Boolean(activeButton));
|
|
44
47
|
var handleUpdateSettings = (0, react_1.useCallback)(function (newSetting) {
|
|
45
48
|
updatePerspectiveSettings(newSetting);
|
|
46
49
|
}, [updatePerspectiveSettings]);
|
|
@@ -88,6 +88,10 @@ var setUp = function (props) {
|
|
|
88
88
|
graph: {
|
|
89
89
|
active: 1,
|
|
90
90
|
width: 320
|
|
91
|
+
},
|
|
92
|
+
interactions: {
|
|
93
|
+
active: 0,
|
|
94
|
+
width: 400
|
|
91
95
|
}
|
|
92
96
|
}
|
|
93
97
|
};
|
|
@@ -148,6 +152,13 @@ describe('ProfileResizablePanes tests', function () {
|
|
|
148
152
|
return [2 /*return*/];
|
|
149
153
|
});
|
|
150
154
|
}); });
|
|
155
|
+
it('should open the second pane when buttonsProps is empty and active is set (interactions screen)', function () {
|
|
156
|
+
var container = setUp(__assign(__assign({}, defaultProps), { perspectiveId: 'interactions', buttonsProps: [] })).container;
|
|
157
|
+
expect(react_2.screen.getByTestId('rightPanel')).toBeInTheDocument();
|
|
158
|
+
expect(isResizingDisabled(container)).toBe(false);
|
|
159
|
+
checkPanelSize(getSplitPane1(container), '60.0');
|
|
160
|
+
checkPanelSize(getSplitPane2(container), '40.0');
|
|
161
|
+
});
|
|
151
162
|
it('should render resizable panes with open second pane on button click', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
152
163
|
var _a, container, user, button2;
|
|
153
164
|
return __generator(this, function (_b) {
|
|
@@ -22,8 +22,8 @@ type Props = {
|
|
|
22
22
|
className?: string;
|
|
23
23
|
activeSurvivorshipGroupUri?: string;
|
|
24
24
|
tableRef?: React.ElementRef<typeof BasicTable>;
|
|
25
|
+
personalizationEnabled?: boolean;
|
|
25
26
|
onHideAttributeType?: (attributeType: AttributeType) => void;
|
|
26
|
-
attributeRowReorderingEnabled?: boolean;
|
|
27
27
|
};
|
|
28
|
-
declare const _default: React.MemoExoticComponent<({ entity, isLoading, crosswalksMap, visibleColumns, onChangeVisibleColumns, readOnly, onDelete, onPin, onIgnore, onEdit, onAdd, emptyTempAttributeUris, selectedAttributeTypes, onSelectAttributeTypes, additionalHeaderItems, className, activeSurvivorshipGroupUri, tableRef,
|
|
28
|
+
declare const _default: React.MemoExoticComponent<({ entity, isLoading, crosswalksMap, visibleColumns, onChangeVisibleColumns, readOnly, onDelete, onPin, onIgnore, onEdit, onAdd, emptyTempAttributeUris, selectedAttributeTypes, onSelectAttributeTypes, additionalHeaderItems, className, activeSurvivorshipGroupUri, tableRef, personalizationEnabled, onHideAttributeType }: Props) => React.JSX.Element>;
|
|
29
29
|
export default _default;
|
|
@@ -65,7 +65,7 @@ var getRowCellKey = function (_a) {
|
|
|
65
65
|
};
|
|
66
66
|
var debouncedNotifyLazyRenderer = (0, mdm_sdk_1.debounce)(LazyRenderer_1.LazyRenderer.notify, 0);
|
|
67
67
|
var AttributesTable = function (_a) {
|
|
68
|
-
var entity = _a.entity, isLoading = _a.isLoading, crosswalksMap = _a.crosswalksMap, _b = _a.visibleColumns, visibleColumns = _b === void 0 ? helpers_1.DEFAULT_VISIBLE_COLUMNS : _b, onChangeVisibleColumns = _a.onChangeVisibleColumns, readOnly = _a.readOnly, _c = _a.onDelete, onDelete = _c === void 0 ? ramda_1.identity : _c, _d = _a.onPin, onPin = _d === void 0 ? ramda_1.identity : _d, _e = _a.onIgnore, onIgnore = _e === void 0 ? ramda_1.identity : _e, _f = _a.onEdit, onEdit = _f === void 0 ? ramda_1.identity : _f, _g = _a.onAdd, onAdd = _g === void 0 ? ramda_1.identity : _g, emptyTempAttributeUris = _a.emptyTempAttributeUris, selectedAttributeTypes = _a.selectedAttributeTypes, _h = _a.onSelectAttributeTypes, onSelectAttributeTypes = _h === void 0 ? ramda_1.identity : _h, additionalHeaderItems = _a.additionalHeaderItems, className = _a.className, activeSurvivorshipGroupUri = _a.activeSurvivorshipGroupUri, tableRef = _a.tableRef,
|
|
68
|
+
var entity = _a.entity, isLoading = _a.isLoading, crosswalksMap = _a.crosswalksMap, _b = _a.visibleColumns, visibleColumns = _b === void 0 ? helpers_1.DEFAULT_VISIBLE_COLUMNS : _b, onChangeVisibleColumns = _a.onChangeVisibleColumns, readOnly = _a.readOnly, _c = _a.onDelete, onDelete = _c === void 0 ? ramda_1.identity : _c, _d = _a.onPin, onPin = _d === void 0 ? ramda_1.identity : _d, _e = _a.onIgnore, onIgnore = _e === void 0 ? ramda_1.identity : _e, _f = _a.onEdit, onEdit = _f === void 0 ? ramda_1.identity : _f, _g = _a.onAdd, onAdd = _g === void 0 ? ramda_1.identity : _g, emptyTempAttributeUris = _a.emptyTempAttributeUris, selectedAttributeTypes = _a.selectedAttributeTypes, _h = _a.onSelectAttributeTypes, onSelectAttributeTypes = _h === void 0 ? ramda_1.identity : _h, additionalHeaderItems = _a.additionalHeaderItems, className = _a.className, activeSurvivorshipGroupUri = _a.activeSurvivorshipGroupUri, tableRef = _a.tableRef, personalizationEnabled = _a.personalizationEnabled, onHideAttributeType = _a.onHideAttributeType;
|
|
69
69
|
var styles = (0, styles_1.useStyles)();
|
|
70
70
|
var metadata = (0, MdmModuleContext_1.useMdmMetadata)();
|
|
71
71
|
var visibleColumnsData = (0, react_1.useMemo)(function () {
|
|
@@ -74,13 +74,13 @@ var AttributesTable = function (_a) {
|
|
|
74
74
|
return visibleColumns.includes(id);
|
|
75
75
|
}), helpers_1.getBasicTableColumnsData)(helpers_1.COLUMNS_DATA);
|
|
76
76
|
}, [visibleColumns]);
|
|
77
|
-
var
|
|
77
|
+
var _j = entity || {}, parentTypeUri = _j.type, parentUri = _j.uri, _k = _j.attributes, attributes = _k === void 0 ? {} : _k;
|
|
78
78
|
(0, react_1.useEffect)(function () {
|
|
79
79
|
if (entity && (0, ramda_1.isNil)(selectedAttributeTypes)) {
|
|
80
|
-
|
|
81
|
-
onSelectAttributeTypes(initialAttrTypes);
|
|
80
|
+
onSelectAttributeTypes((0, mdm_sdk_1.getReadableAttributeTypesFromEntityAttributes)(metadata, parentTypeUri, attributes));
|
|
82
81
|
}
|
|
83
|
-
|
|
82
|
+
// Fallback init for consumers that omit selectedAttributeTypes; entity covers parentTypeUri/attributes.
|
|
83
|
+
}, [entity, selectedAttributeTypes]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
84
84
|
var rowsData = (0, react_1.useMemo)(function () {
|
|
85
85
|
return parentTypeUri
|
|
86
86
|
? (0, helpers_1.getBasicTableRowsData)(metadata, parentTypeUri, selectedAttributeTypes, visibleColumns, crosswalksMap, attributes, activeSurvivorshipGroupUri)
|
|
@@ -94,7 +94,7 @@ var AttributesTable = function (_a) {
|
|
|
94
94
|
crosswalksMap,
|
|
95
95
|
activeSurvivorshipGroupUri
|
|
96
96
|
]);
|
|
97
|
-
var
|
|
97
|
+
var _l = (0, useDynamicRowCellHeight_1.useDynamicRowCellHeight)(getRowCellKey), getDynamicRowCellHeight = _l.getDynamicRowCellHeight, changeRowCellHeight = _l.changeRowCellHeight;
|
|
98
98
|
var renderRowCell = (0, react_1.useCallback)(function (props) { return react_1.default.createElement(CommonRowCellRenderer_1.CommonRowCellRenderer, __assign({ changeRowCellHeight: changeRowCellHeight }, props)); }, [changeRowCellHeight]);
|
|
99
99
|
var getRowCellHeight = (0, react_1.useCallback)((0, ramda_1.either)(getDynamicRowCellHeight, (0, ramda_1.always)(DEFAULT_ROW_HEIGHT)), [
|
|
100
100
|
getDynamicRowCellHeight
|
|
@@ -102,8 +102,8 @@ var AttributesTable = function (_a) {
|
|
|
102
102
|
(0, react_1.useEffect)(function () {
|
|
103
103
|
debouncedNotifyLazyRenderer();
|
|
104
104
|
}, [getRowCellHeight]);
|
|
105
|
-
var
|
|
106
|
-
var
|
|
105
|
+
var _m = (0, react_1.useState)(null), pendingDeletion = _m[0], setPendingDeletion = _m[1];
|
|
106
|
+
var _o = (0, react_1.useState)(null), pendingIgnoredEditing = _o[0], setPendingIgnoredEditing = _o[1];
|
|
107
107
|
var handleEdit = (0, react_1.useCallback)(function (event) {
|
|
108
108
|
if (event.attributeValue.ignored) {
|
|
109
109
|
setPendingIgnoredEditing(event);
|
|
@@ -127,12 +127,13 @@ var AttributesTable = function (_a) {
|
|
|
127
127
|
onAdd: onAdd,
|
|
128
128
|
parentUri: parentUri,
|
|
129
129
|
parentTypeUri: parentTypeUri,
|
|
130
|
+
entity: entity,
|
|
130
131
|
selectedAttributeTypes: selectedAttributeTypes,
|
|
131
132
|
onSelectAttributeTypes: onSelectAttributeTypes,
|
|
132
133
|
emptyTempAttributeUris: emptyTempAttributeUris,
|
|
133
134
|
readOnly: readOnly,
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
personalizationEnabled: personalizationEnabled,
|
|
136
|
+
onHideAttributeType: onHideAttributeType
|
|
136
137
|
}); }, [
|
|
137
138
|
setPendingDeletion,
|
|
138
139
|
onPin,
|
|
@@ -141,12 +142,13 @@ var AttributesTable = function (_a) {
|
|
|
141
142
|
onAdd,
|
|
142
143
|
parentUri,
|
|
143
144
|
parentTypeUri,
|
|
145
|
+
entity,
|
|
144
146
|
selectedAttributeTypes,
|
|
145
147
|
onSelectAttributeTypes,
|
|
146
148
|
emptyTempAttributeUris,
|
|
147
149
|
readOnly,
|
|
148
|
-
|
|
149
|
-
|
|
150
|
+
personalizationEnabled,
|
|
151
|
+
onHideAttributeType
|
|
150
152
|
]);
|
|
151
153
|
return (react_1.default.createElement("div", { className: (0, classnames_1.default)(styles.tableContainer, className) },
|
|
152
154
|
react_1.default.createElement(BasicViewHeader_1.BasicViewHeader, { classes: { root: styles.tableHeader, title: styles.tableTitle }, title: ui_i18n_1.default.text('Sources') },
|
|
@@ -157,7 +159,7 @@ var AttributesTable = function (_a) {
|
|
|
157
159
|
react_1.default.createElement(AttributeValuesSortContext_1.AttributeValuesSortContext.Provider, { value: helpers_1.sortByPinIgnorePriority },
|
|
158
160
|
react_1.default.createElement(SyncedExpandedAttributesContext_1.SyncedExpandedAttributesProvider, null,
|
|
159
161
|
react_1.default.createElement(SyncedValueHeightsContext_1.SyncedValueHeightsProvider, null,
|
|
160
|
-
react_1.default.createElement(BasicTable_1.BasicTable, { columnsData: visibleColumnsData, context: tableContext, defaultColumnMinWidth: 200, defaultColumnWidth: 250, dndRowReorderingEnabled:
|
|
162
|
+
react_1.default.createElement(BasicTable_1.BasicTable, { columnsData: visibleColumnsData, context: tableContext, defaultColumnMinWidth: 200, defaultColumnWidth: 250, dndRowReorderingEnabled: personalizationEnabled, dndRowReorderingHandler: handleReorderAttributeTypes, externalDndContext: true, fixFirstColumn: true, getIdFromRowValue: getIdFromRowValue, getRowCellHeight: getRowCellHeight, headRowHeight: 48, hoverStateEnabled: personalizationEnabled, onScroll: debouncedNotifyLazyRenderer, ref: tableRef, renderRowCell: renderRowCell, rowsData: rowsData }))))),
|
|
161
163
|
react_1.default.createElement(ConfirmDeleteDialog_1.ConfirmDeleteDialog, { open: !!pendingDeletion, onClose: function () { return setPendingDeletion(null); }, onConfirm: handleDelete }),
|
|
162
164
|
react_1.default.createElement(ConfirmEditIgnoredDialog_1.ConfirmEditIgnoredDialog, { open: !!pendingIgnoredEditing, onClose: function () { return setPendingIgnoredEditing(null); }, onConfirmEditWithIgnore: function () { return pendingIgnoredEditing && onEdit(pendingIgnoredEditing); }, onConfirmEditWithoutIgnore: function () {
|
|
163
165
|
if (pendingIgnoredEditing)
|
|
@@ -19,15 +19,20 @@ var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
|
19
19
|
var MoreAttributesButton_1 = require("../../../../../MoreAttributesButton");
|
|
20
20
|
var withTableContext_1 = require("../../../../../HOCs/withTableContext");
|
|
21
21
|
var MdmModuleContext_1 = require("../../../../../contexts/MdmModuleContext");
|
|
22
|
+
var getAddableAttributeTypes_1 = require("./getAddableAttributeTypes");
|
|
22
23
|
var styles_1 = require("./styles");
|
|
23
24
|
var AddAttributesButton = function (_a) {
|
|
24
|
-
var parentTypeUri = _a.parentTypeUri, parentUri = _a.parentUri, selectedAttributeTypes = _a.selectedAttributeTypes, onSelectAttributeTypes = _a.onSelectAttributeTypes, onAdd = _a.onAdd;
|
|
25
|
+
var parentTypeUri = _a.parentTypeUri, parentUri = _a.parentUri, entity = _a.entity, selectedAttributeTypes = _a.selectedAttributeTypes, onSelectAttributeTypes = _a.onSelectAttributeTypes, onAdd = _a.onAdd, _b = _a.personalizationEnabled, personalizationEnabled = _b === void 0 ? false : _b;
|
|
25
26
|
var styles = (0, styles_1.useStyles)();
|
|
26
27
|
var metadata = (0, MdmModuleContext_1.useMdmMetadata)();
|
|
27
28
|
var parentType = __spreadArray(__spreadArray([], metadata.entityTypes, true), (metadata.relationTypes || []), true).find((0, ramda_1.propEq)('uri', parentTypeUri));
|
|
28
29
|
var isNotSelected = function (attrType) { return !(selectedAttributeTypes === null || selectedAttributeTypes === void 0 ? void 0 : selectedAttributeTypes.find((0, ramda_1.propEq)('uri', attrType.uri))); };
|
|
29
|
-
var
|
|
30
|
-
|
|
30
|
+
var data = (0, getAddableAttributeTypes_1.getAddableAttributeTypes)(parentType, {
|
|
31
|
+
personalizationEnabled: personalizationEnabled,
|
|
32
|
+
selectedAttributeTypes: selectedAttributeTypes,
|
|
33
|
+
entity: entity,
|
|
34
|
+
metadata: metadata
|
|
35
|
+
});
|
|
31
36
|
var handleAdd = function (addedTypes) {
|
|
32
37
|
var typesToSelect = addedTypes.filter(isNotSelected);
|
|
33
38
|
if (typesToSelect.length > 0) {
|
|
@@ -40,4 +45,12 @@ var AddAttributesButton = function (_a) {
|
|
|
40
45
|
return (react_1.default.createElement("div", { className: styles.root },
|
|
41
46
|
react_1.default.createElement(MoreAttributesButton_1.MoreAttributesButton, { label: ui_i18n_1.default.text('Attribute'), popupTitle: ui_i18n_1.default.text('Add attributes'), data: data, onApply: handleAdd })));
|
|
42
47
|
};
|
|
43
|
-
exports.default = (0, withTableContext_1.withTableContext)((0, ramda_1.pick)([
|
|
48
|
+
exports.default = (0, withTableContext_1.withTableContext)((0, ramda_1.pick)([
|
|
49
|
+
'parentUri',
|
|
50
|
+
'parentTypeUri',
|
|
51
|
+
'entity',
|
|
52
|
+
'onAdd',
|
|
53
|
+
'selectedAttributeTypes',
|
|
54
|
+
'onSelectAttributeTypes',
|
|
55
|
+
'personalizationEnabled'
|
|
56
|
+
]))(AddAttributesButton);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AttributeType, Entity, Metadata, Relation } from '@reltio/mdm-sdk';
|
|
2
|
+
type ParentTypeWithAttributes = {
|
|
3
|
+
attributes?: AttributeType[];
|
|
4
|
+
};
|
|
5
|
+
type GetAddableAttributeTypesParams = {
|
|
6
|
+
personalizationEnabled?: boolean;
|
|
7
|
+
selectedAttributeTypes?: AttributeType[];
|
|
8
|
+
entity?: Entity | Relation | null;
|
|
9
|
+
metadata?: Metadata;
|
|
10
|
+
};
|
|
11
|
+
export declare const getAddableAttributeTypes: (parentType: ParentTypeWithAttributes | undefined, { personalizationEnabled, selectedAttributeTypes, entity, metadata }?: GetAddableAttributeTypesParams) => AttributeType[];
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getAddableAttributeTypes = void 0;
|
|
4
|
+
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
5
|
+
var ramda_1 = require("ramda");
|
|
6
|
+
var getAddableAttributeTypes = function (parentType, _a) {
|
|
7
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.personalizationEnabled, personalizationEnabled = _c === void 0 ? false : _c, selectedAttributeTypes = _b.selectedAttributeTypes, entity = _b.entity, metadata = _b.metadata;
|
|
8
|
+
var isNotSelected = function (attrType) { return !(selectedAttributeTypes === null || selectedAttributeTypes === void 0 ? void 0 : selectedAttributeTypes.find((0, ramda_1.propEq)('uri', attrType.uri))); };
|
|
9
|
+
var canCreate = function (attributeType) { return (0, mdm_sdk_1.checkCanCreateAttribute)({ attributeType: attributeType, mode: mdm_sdk_1.Mode.Editing }); };
|
|
10
|
+
var isVisibleInPicker = (0, ramda_1.either)(mdm_sdk_1.isNested, isNotSelected);
|
|
11
|
+
var hasAttributeOnEntity = function (attributeType) {
|
|
12
|
+
if (!entity || !metadata) {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
var values = (0, mdm_sdk_1.findAttributeValuesByTypeUri)(metadata, entity, attributeType.uri);
|
|
16
|
+
return !(0, ramda_1.isNil)(values) && !(0, ramda_1.isEmpty)(values);
|
|
17
|
+
};
|
|
18
|
+
return (0, ramda_1.pipe)((0, ramda_1.propOr)([], 'attributes'), (0, ramda_1.ifElse)(function () { return personalizationEnabled; }, (0, ramda_1.pipe)((0, ramda_1.filter)(mdm_sdk_1.isReadableAttribute), (0, ramda_1.filter)((0, ramda_1.either)(canCreate, hasAttributeOnEntity)), (0, ramda_1.filter)(isVisibleInPicker)), (0, ramda_1.pipe)((0, ramda_1.reject)((0, ramda_1.either)(mdm_sdk_1.isReference, mdm_sdk_1.isImage)), (0, ramda_1.filter)(isVisibleInPicker), (0, ramda_1.filter)((0, ramda_1.both)(mdm_sdk_1.isReadableAttribute, canCreate)))))(parentType);
|
|
19
|
+
};
|
|
20
|
+
exports.getAddableAttributeTypes = getAddableAttributeTypes;
|
|
@@ -22,8 +22,8 @@ type Props = {
|
|
|
22
22
|
className?: string;
|
|
23
23
|
activeSurvivorshipGroupUri?: string;
|
|
24
24
|
tableRef?: React.ElementRef<typeof BasicTable>;
|
|
25
|
+
personalizationEnabled?: boolean;
|
|
25
26
|
onHideAttributeType?: (attributeType: AttributeType) => void;
|
|
26
|
-
attributeRowReorderingEnabled?: boolean;
|
|
27
27
|
};
|
|
28
|
-
declare const _default: React.MemoExoticComponent<({ entity, isLoading, crosswalksMap, visibleColumns, onChangeVisibleColumns, readOnly, onDelete, onPin, onIgnore, onEdit, onAdd, emptyTempAttributeUris, selectedAttributeTypes, onSelectAttributeTypes, additionalHeaderItems, className, activeSurvivorshipGroupUri, tableRef,
|
|
28
|
+
declare const _default: React.MemoExoticComponent<({ entity, isLoading, crosswalksMap, visibleColumns, onChangeVisibleColumns, readOnly, onDelete, onPin, onIgnore, onEdit, onAdd, emptyTempAttributeUris, selectedAttributeTypes, onSelectAttributeTypes, additionalHeaderItems, className, activeSurvivorshipGroupUri, tableRef, personalizationEnabled, onHideAttributeType }: Props) => React.JSX.Element>;
|
|
29
29
|
export default _default;
|
|
@@ -12,8 +12,8 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
import React, { memo, useCallback, useEffect, useMemo, useState } from 'react';
|
|
13
13
|
import classnames from 'classnames';
|
|
14
14
|
import i18n from 'ui-i18n';
|
|
15
|
-
import { always, either, filter, isNil,
|
|
16
|
-
import { debounce,
|
|
15
|
+
import { always, either, filter, isNil, pipe, identity, move } from 'ramda';
|
|
16
|
+
import { debounce, getReadableAttributeTypesFromEntityAttributes } from '@reltio/mdm-sdk';
|
|
17
17
|
import { BasicTable } from '../../../BasicTable';
|
|
18
18
|
import { ColumnsSettings } from '../../../ColumnsSettings';
|
|
19
19
|
import { useDynamicRowCellHeight } from '../../../hooks/useDynamicRowCellHeight';
|
|
@@ -37,7 +37,7 @@ var getRowCellKey = function (_a) {
|
|
|
37
37
|
};
|
|
38
38
|
var debouncedNotifyLazyRenderer = debounce(LazyRenderer.notify, 0);
|
|
39
39
|
var AttributesTable = function (_a) {
|
|
40
|
-
var entity = _a.entity, isLoading = _a.isLoading, crosswalksMap = _a.crosswalksMap, _b = _a.visibleColumns, visibleColumns = _b === void 0 ? DEFAULT_VISIBLE_COLUMNS : _b, onChangeVisibleColumns = _a.onChangeVisibleColumns, readOnly = _a.readOnly, _c = _a.onDelete, onDelete = _c === void 0 ? identity : _c, _d = _a.onPin, onPin = _d === void 0 ? identity : _d, _e = _a.onIgnore, onIgnore = _e === void 0 ? identity : _e, _f = _a.onEdit, onEdit = _f === void 0 ? identity : _f, _g = _a.onAdd, onAdd = _g === void 0 ? identity : _g, emptyTempAttributeUris = _a.emptyTempAttributeUris, selectedAttributeTypes = _a.selectedAttributeTypes, _h = _a.onSelectAttributeTypes, onSelectAttributeTypes = _h === void 0 ? identity : _h, additionalHeaderItems = _a.additionalHeaderItems, className = _a.className, activeSurvivorshipGroupUri = _a.activeSurvivorshipGroupUri, tableRef = _a.tableRef,
|
|
40
|
+
var entity = _a.entity, isLoading = _a.isLoading, crosswalksMap = _a.crosswalksMap, _b = _a.visibleColumns, visibleColumns = _b === void 0 ? DEFAULT_VISIBLE_COLUMNS : _b, onChangeVisibleColumns = _a.onChangeVisibleColumns, readOnly = _a.readOnly, _c = _a.onDelete, onDelete = _c === void 0 ? identity : _c, _d = _a.onPin, onPin = _d === void 0 ? identity : _d, _e = _a.onIgnore, onIgnore = _e === void 0 ? identity : _e, _f = _a.onEdit, onEdit = _f === void 0 ? identity : _f, _g = _a.onAdd, onAdd = _g === void 0 ? identity : _g, emptyTempAttributeUris = _a.emptyTempAttributeUris, selectedAttributeTypes = _a.selectedAttributeTypes, _h = _a.onSelectAttributeTypes, onSelectAttributeTypes = _h === void 0 ? identity : _h, additionalHeaderItems = _a.additionalHeaderItems, className = _a.className, activeSurvivorshipGroupUri = _a.activeSurvivorshipGroupUri, tableRef = _a.tableRef, personalizationEnabled = _a.personalizationEnabled, onHideAttributeType = _a.onHideAttributeType;
|
|
41
41
|
var styles = useStyles();
|
|
42
42
|
var metadata = useMdmMetadata();
|
|
43
43
|
var visibleColumnsData = useMemo(function () {
|
|
@@ -46,13 +46,13 @@ var AttributesTable = function (_a) {
|
|
|
46
46
|
return visibleColumns.includes(id);
|
|
47
47
|
}), getBasicTableColumnsData)(COLUMNS_DATA);
|
|
48
48
|
}, [visibleColumns]);
|
|
49
|
-
var
|
|
49
|
+
var _j = entity || {}, parentTypeUri = _j.type, parentUri = _j.uri, _k = _j.attributes, attributes = _k === void 0 ? {} : _k;
|
|
50
50
|
useEffect(function () {
|
|
51
51
|
if (entity && isNil(selectedAttributeTypes)) {
|
|
52
|
-
|
|
53
|
-
onSelectAttributeTypes(initialAttrTypes);
|
|
52
|
+
onSelectAttributeTypes(getReadableAttributeTypesFromEntityAttributes(metadata, parentTypeUri, attributes));
|
|
54
53
|
}
|
|
55
|
-
|
|
54
|
+
// Fallback init for consumers that omit selectedAttributeTypes; entity covers parentTypeUri/attributes.
|
|
55
|
+
}, [entity, selectedAttributeTypes]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
56
56
|
var rowsData = useMemo(function () {
|
|
57
57
|
return parentTypeUri
|
|
58
58
|
? getBasicTableRowsData(metadata, parentTypeUri, selectedAttributeTypes, visibleColumns, crosswalksMap, attributes, activeSurvivorshipGroupUri)
|
|
@@ -66,7 +66,7 @@ var AttributesTable = function (_a) {
|
|
|
66
66
|
crosswalksMap,
|
|
67
67
|
activeSurvivorshipGroupUri
|
|
68
68
|
]);
|
|
69
|
-
var
|
|
69
|
+
var _l = useDynamicRowCellHeight(getRowCellKey), getDynamicRowCellHeight = _l.getDynamicRowCellHeight, changeRowCellHeight = _l.changeRowCellHeight;
|
|
70
70
|
var renderRowCell = useCallback(function (props) { return React.createElement(CommonRowCellRenderer, __assign({ changeRowCellHeight: changeRowCellHeight }, props)); }, [changeRowCellHeight]);
|
|
71
71
|
var getRowCellHeight = useCallback(either(getDynamicRowCellHeight, always(DEFAULT_ROW_HEIGHT)), [
|
|
72
72
|
getDynamicRowCellHeight
|
|
@@ -74,8 +74,8 @@ var AttributesTable = function (_a) {
|
|
|
74
74
|
useEffect(function () {
|
|
75
75
|
debouncedNotifyLazyRenderer();
|
|
76
76
|
}, [getRowCellHeight]);
|
|
77
|
-
var
|
|
78
|
-
var
|
|
77
|
+
var _m = useState(null), pendingDeletion = _m[0], setPendingDeletion = _m[1];
|
|
78
|
+
var _o = useState(null), pendingIgnoredEditing = _o[0], setPendingIgnoredEditing = _o[1];
|
|
79
79
|
var handleEdit = useCallback(function (event) {
|
|
80
80
|
if (event.attributeValue.ignored) {
|
|
81
81
|
setPendingIgnoredEditing(event);
|
|
@@ -99,12 +99,13 @@ var AttributesTable = function (_a) {
|
|
|
99
99
|
onAdd: onAdd,
|
|
100
100
|
parentUri: parentUri,
|
|
101
101
|
parentTypeUri: parentTypeUri,
|
|
102
|
+
entity: entity,
|
|
102
103
|
selectedAttributeTypes: selectedAttributeTypes,
|
|
103
104
|
onSelectAttributeTypes: onSelectAttributeTypes,
|
|
104
105
|
emptyTempAttributeUris: emptyTempAttributeUris,
|
|
105
106
|
readOnly: readOnly,
|
|
106
|
-
|
|
107
|
-
|
|
107
|
+
personalizationEnabled: personalizationEnabled,
|
|
108
|
+
onHideAttributeType: onHideAttributeType
|
|
108
109
|
}); }, [
|
|
109
110
|
setPendingDeletion,
|
|
110
111
|
onPin,
|
|
@@ -113,12 +114,13 @@ var AttributesTable = function (_a) {
|
|
|
113
114
|
onAdd,
|
|
114
115
|
parentUri,
|
|
115
116
|
parentTypeUri,
|
|
117
|
+
entity,
|
|
116
118
|
selectedAttributeTypes,
|
|
117
119
|
onSelectAttributeTypes,
|
|
118
120
|
emptyTempAttributeUris,
|
|
119
121
|
readOnly,
|
|
120
|
-
|
|
121
|
-
|
|
122
|
+
personalizationEnabled,
|
|
123
|
+
onHideAttributeType
|
|
122
124
|
]);
|
|
123
125
|
return (React.createElement("div", { className: classnames(styles.tableContainer, className) },
|
|
124
126
|
React.createElement(BasicViewHeader, { classes: { root: styles.tableHeader, title: styles.tableTitle }, title: i18n.text('Sources') },
|
|
@@ -129,7 +131,7 @@ var AttributesTable = function (_a) {
|
|
|
129
131
|
React.createElement(AttributeValuesSortContext.Provider, { value: sortByPinIgnorePriority },
|
|
130
132
|
React.createElement(SyncedExpandedAttributesProvider, null,
|
|
131
133
|
React.createElement(SyncedValueHeightsProvider, null,
|
|
132
|
-
React.createElement(BasicTable, { columnsData: visibleColumnsData, context: tableContext, defaultColumnMinWidth: 200, defaultColumnWidth: 250, dndRowReorderingEnabled:
|
|
134
|
+
React.createElement(BasicTable, { columnsData: visibleColumnsData, context: tableContext, defaultColumnMinWidth: 200, defaultColumnWidth: 250, dndRowReorderingEnabled: personalizationEnabled, dndRowReorderingHandler: handleReorderAttributeTypes, externalDndContext: true, fixFirstColumn: true, getIdFromRowValue: getIdFromRowValue, getRowCellHeight: getRowCellHeight, headRowHeight: 48, hoverStateEnabled: personalizationEnabled, onScroll: debouncedNotifyLazyRenderer, ref: tableRef, renderRowCell: renderRowCell, rowsData: rowsData }))))),
|
|
133
135
|
React.createElement(ConfirmDeleteDialog, { open: !!pendingDeletion, onClose: function () { return setPendingDeletion(null); }, onConfirm: handleDelete }),
|
|
134
136
|
React.createElement(ConfirmEditIgnoredDialog, { open: !!pendingIgnoredEditing, onClose: function () { return setPendingIgnoredEditing(null); }, onConfirmEditWithIgnore: function () { return pendingIgnoredEditing && onEdit(pendingIgnoredEditing); }, onConfirmEditWithoutIgnore: function () {
|
|
135
137
|
if (pendingIgnoredEditing)
|
package/features/crosswalks/AttributesTable/components/AddAttributesButton/AddAttributesButton.js
CHANGED
|
@@ -9,20 +9,25 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
9
9
|
};
|
|
10
10
|
import React from 'react';
|
|
11
11
|
import i18n from 'ui-i18n';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
12
|
+
import { pick, propEq } from 'ramda';
|
|
13
|
+
import { isNested } from '@reltio/mdm-sdk';
|
|
14
14
|
import { MoreAttributesButton } from '../../../../../MoreAttributesButton';
|
|
15
15
|
import { withTableContext } from '../../../../../HOCs/withTableContext';
|
|
16
16
|
import { useMdmMetadata } from '../../../../../contexts/MdmModuleContext';
|
|
17
|
+
import { getAddableAttributeTypes } from './getAddableAttributeTypes';
|
|
17
18
|
import { useStyles } from './styles';
|
|
18
19
|
var AddAttributesButton = function (_a) {
|
|
19
|
-
var parentTypeUri = _a.parentTypeUri, parentUri = _a.parentUri, selectedAttributeTypes = _a.selectedAttributeTypes, onSelectAttributeTypes = _a.onSelectAttributeTypes, onAdd = _a.onAdd;
|
|
20
|
+
var parentTypeUri = _a.parentTypeUri, parentUri = _a.parentUri, entity = _a.entity, selectedAttributeTypes = _a.selectedAttributeTypes, onSelectAttributeTypes = _a.onSelectAttributeTypes, onAdd = _a.onAdd, _b = _a.personalizationEnabled, personalizationEnabled = _b === void 0 ? false : _b;
|
|
20
21
|
var styles = useStyles();
|
|
21
22
|
var metadata = useMdmMetadata();
|
|
22
23
|
var parentType = __spreadArray(__spreadArray([], metadata.entityTypes, true), (metadata.relationTypes || []), true).find(propEq('uri', parentTypeUri));
|
|
23
24
|
var isNotSelected = function (attrType) { return !(selectedAttributeTypes === null || selectedAttributeTypes === void 0 ? void 0 : selectedAttributeTypes.find(propEq('uri', attrType.uri))); };
|
|
24
|
-
var
|
|
25
|
-
|
|
25
|
+
var data = getAddableAttributeTypes(parentType, {
|
|
26
|
+
personalizationEnabled: personalizationEnabled,
|
|
27
|
+
selectedAttributeTypes: selectedAttributeTypes,
|
|
28
|
+
entity: entity,
|
|
29
|
+
metadata: metadata
|
|
30
|
+
});
|
|
26
31
|
var handleAdd = function (addedTypes) {
|
|
27
32
|
var typesToSelect = addedTypes.filter(isNotSelected);
|
|
28
33
|
if (typesToSelect.length > 0) {
|
|
@@ -35,4 +40,12 @@ var AddAttributesButton = function (_a) {
|
|
|
35
40
|
return (React.createElement("div", { className: styles.root },
|
|
36
41
|
React.createElement(MoreAttributesButton, { label: i18n.text('Attribute'), popupTitle: i18n.text('Add attributes'), data: data, onApply: handleAdd })));
|
|
37
42
|
};
|
|
38
|
-
export default withTableContext(pick([
|
|
43
|
+
export default withTableContext(pick([
|
|
44
|
+
'parentUri',
|
|
45
|
+
'parentTypeUri',
|
|
46
|
+
'entity',
|
|
47
|
+
'onAdd',
|
|
48
|
+
'selectedAttributeTypes',
|
|
49
|
+
'onSelectAttributeTypes',
|
|
50
|
+
'personalizationEnabled'
|
|
51
|
+
]))(AddAttributesButton);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { AttributeType, Entity, Metadata, Relation } from '@reltio/mdm-sdk';
|
|
2
|
+
type ParentTypeWithAttributes = {
|
|
3
|
+
attributes?: AttributeType[];
|
|
4
|
+
};
|
|
5
|
+
type GetAddableAttributeTypesParams = {
|
|
6
|
+
personalizationEnabled?: boolean;
|
|
7
|
+
selectedAttributeTypes?: AttributeType[];
|
|
8
|
+
entity?: Entity | Relation | null;
|
|
9
|
+
metadata?: Metadata;
|
|
10
|
+
};
|
|
11
|
+
export declare const getAddableAttributeTypes: (parentType: ParentTypeWithAttributes | undefined, { personalizationEnabled, selectedAttributeTypes, entity, metadata }?: GetAddableAttributeTypesParams) => AttributeType[];
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { checkCanCreateAttribute, findAttributeValuesByTypeUri, isImage, isNested, isReadableAttribute, isReference, Mode } from '@reltio/mdm-sdk';
|
|
2
|
+
import { both, either, filter, ifElse, isEmpty, isNil, pipe, propEq, propOr, reject } from 'ramda';
|
|
3
|
+
export var getAddableAttributeTypes = function (parentType, _a) {
|
|
4
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.personalizationEnabled, personalizationEnabled = _c === void 0 ? false : _c, selectedAttributeTypes = _b.selectedAttributeTypes, entity = _b.entity, metadata = _b.metadata;
|
|
5
|
+
var isNotSelected = function (attrType) { return !(selectedAttributeTypes === null || selectedAttributeTypes === void 0 ? void 0 : selectedAttributeTypes.find(propEq('uri', attrType.uri))); };
|
|
6
|
+
var canCreate = function (attributeType) { return checkCanCreateAttribute({ attributeType: attributeType, mode: Mode.Editing }); };
|
|
7
|
+
var isVisibleInPicker = either(isNested, isNotSelected);
|
|
8
|
+
var hasAttributeOnEntity = function (attributeType) {
|
|
9
|
+
if (!entity || !metadata) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
var values = findAttributeValuesByTypeUri(metadata, entity, attributeType.uri);
|
|
13
|
+
return !isNil(values) && !isEmpty(values);
|
|
14
|
+
};
|
|
15
|
+
return pipe(propOr([], 'attributes'), ifElse(function () { return personalizationEnabled; }, pipe(filter(isReadableAttribute), filter(either(canCreate, hasAttributeOnEntity)), filter(isVisibleInPicker)), pipe(reject(either(isReference, isImage)), filter(isVisibleInPicker), filter(both(isReadableAttribute, canCreate)))))(parentType);
|
|
16
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.2275",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE FILE",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"@fluentui/react-context-selector": "^9.1.26",
|
|
12
12
|
"@googlemaps/markerclusterer": "^2.5.3",
|
|
13
13
|
"@react-sigma/core": "3.4.0",
|
|
14
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
14
|
+
"@reltio/mdm-sdk": "^1.4.2052",
|
|
15
15
|
"@vis.gl/react-google-maps": "^1.3.0",
|
|
16
16
|
"d3-cloud": "^1.2.5",
|
|
17
17
|
"d3-geo": "^2.0.1",
|