@reltio/components 1.4.1864 → 1.4.1866
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/cjs/EditModeAttributesList/EditModeAttributesList.js +5 -3
- package/cjs/EditModeAttributesPager/EditModeAttributesPager.js +30 -4
- package/cjs/EditModeAttributesView/EditModeAttributesView.test.js +21 -15
- package/cjs/ReadOnlyAttributesList/ReadOnlyAttributesList.js +5 -3
- package/cjs/ReadOnlyAttributesView/ReadOnlyAttributesView.test.js +21 -15
- package/cjs/components/RelationEditor/RelationEditor.js +4 -1
- package/cjs/contexts/HiddenAttributesContext/index.d.ts +2 -0
- package/cjs/contexts/HiddenAttributesContext/index.js +5 -0
- package/cjs/contexts/MdmModuleContext/hooks.d.ts +1 -1
- package/cjs/contexts/MdmModuleContext/hooks.js +3 -2
- package/cjs/contexts/ScrollToElementContext/index.d.ts +2 -2
- package/cjs/contexts/index.d.ts +1 -0
- package/cjs/contexts/index.js +3 -1
- package/cjs/hooks/useDateEditor/constants.js +3 -3
- package/cjs/hooks/useHiddenAttributes/useHiddenAttributes.js +3 -2
- package/esm/EditModeAttributesList/EditModeAttributesList.js +6 -4
- package/esm/EditModeAttributesPager/EditModeAttributesPager.js +9 -3
- package/esm/EditModeAttributesView/EditModeAttributesView.test.js +22 -16
- package/esm/ReadOnlyAttributesList/ReadOnlyAttributesList.js +7 -5
- package/esm/ReadOnlyAttributesView/ReadOnlyAttributesView.test.js +22 -16
- package/esm/components/RelationEditor/RelationEditor.js +4 -1
- package/esm/contexts/HiddenAttributesContext/index.d.ts +2 -0
- package/esm/contexts/HiddenAttributesContext/index.js +2 -0
- package/esm/contexts/MdmModuleContext/hooks.d.ts +1 -1
- package/esm/contexts/MdmModuleContext/hooks.js +3 -2
- package/esm/contexts/ScrollToElementContext/index.d.ts +2 -2
- package/esm/contexts/index.d.ts +1 -0
- package/esm/contexts/index.js +1 -0
- package/esm/hooks/useDateEditor/constants.js +3 -3
- package/esm/hooks/useHiddenAttributes/useHiddenAttributes.js +3 -2
- package/package.json +2 -2
|
@@ -52,11 +52,13 @@ var HasDeletionsContext_1 = require("../contexts/HasDeletionsContext");
|
|
|
52
52
|
var withContext_1 = require("../HOCs/withContext");
|
|
53
53
|
var ConfigPermissionsContext_1 = require("../contexts/ConfigPermissionsContext");
|
|
54
54
|
var ScrollToElementContext_1 = require("../contexts/ScrollToElementContext");
|
|
55
|
-
var
|
|
55
|
+
var HiddenAttributesContext_1 = require("../contexts/HiddenAttributesContext");
|
|
56
56
|
var EditModeAttributesList = function (_a) {
|
|
57
57
|
var parentAttributeType = _a.parentAttributeType, attrTypes = _a.attrTypes, entity = _a.entity, parentUri = _a.parentUri, showEmptyEditors = _a.showEmptyEditors, mode = _a.mode, crosswalks = _a.crosswalks, drawLines = _a.drawLines, children = _a.children, className = _a.className, _b = _a.alwaysVisibleTypeUris, alwaysVisibleTypeUris = _b === void 0 ? constants_1.ALWAYS_VISIBLE_TYPE_URIS : _b, onAddAttributes = _a.onAddAttributes, onChangeAttribute = _a.onChangeAttribute, onDeleteAttribute = _a.onDeleteAttribute, additionalControlsRenderer = _a.additionalControlsRenderer, showNonOv = _a.showNonOv, highlightAttribute = _a.highlightAttribute;
|
|
58
|
-
var hiddenAttributes = (0,
|
|
59
|
-
var
|
|
58
|
+
var hiddenAttributes = (0, react_1.useContext)(HiddenAttributesContext_1.HiddenAttributesContext);
|
|
59
|
+
var entityUri = parentUri && (0, mdm_sdk_1.getBaseUri)(parentUri);
|
|
60
|
+
var currentEntityHiddenAttributes = (0, react_1.useMemo)(function () { return hiddenAttributes[entityUri] || []; }, [hiddenAttributes, entityUri]);
|
|
61
|
+
var filteredAttrTypes = (0, react_1.useMemo)(function () { return attrTypes.filter(function (attrType) { return !currentEntityHiddenAttributes.includes(attrType.uri); }); }, [attrTypes, currentEntityHiddenAttributes]);
|
|
60
62
|
var _c = entity.attributes, attributes = _c === void 0 ? {} : _c;
|
|
61
63
|
var _d = (0, react_1.useState)({}), hasDeletionsMap = _d[0], setHasDeletionsMap = _d[1];
|
|
62
64
|
var setHasDeletions = (0, react_1.useCallback)(function (attrTypeUri, value) {
|
|
@@ -10,11 +10,31 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
-
var
|
|
14
|
-
|
|
13
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
16
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
17
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
18
|
+
}
|
|
19
|
+
Object.defineProperty(o, k2, desc);
|
|
20
|
+
}) : (function(o, m, k, k2) {
|
|
21
|
+
if (k2 === undefined) k2 = k;
|
|
22
|
+
o[k2] = m[k];
|
|
23
|
+
}));
|
|
24
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
25
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
26
|
+
}) : function(o, v) {
|
|
27
|
+
o["default"] = v;
|
|
28
|
+
});
|
|
29
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
30
|
+
if (mod && mod.__esModule) return mod;
|
|
31
|
+
var result = {};
|
|
32
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
33
|
+
__setModuleDefault(result, mod);
|
|
34
|
+
return result;
|
|
15
35
|
};
|
|
16
36
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
var react_1 =
|
|
37
|
+
var react_1 = __importStar(require("react"));
|
|
18
38
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
19
39
|
var ramda_1 = require("ramda");
|
|
20
40
|
var BranchDecorator_1 = require("../BranchDecorator");
|
|
@@ -25,12 +45,18 @@ var withContext_1 = require("../HOCs/withContext");
|
|
|
25
45
|
var types_1 = require("./types");
|
|
26
46
|
var ScrollToElementContext_1 = require("../contexts/ScrollToElementContext");
|
|
27
47
|
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
|
|
48
|
+
var HiddenAttributesContext_1 = require("../contexts/HiddenAttributesContext");
|
|
49
|
+
var mdm_sdk_2 = require("@reltio/mdm-sdk");
|
|
28
50
|
var EditModeAttributesPager = function (_a) {
|
|
29
51
|
var _b;
|
|
30
52
|
var values = _a.values, attributeType = _a.attributeType, _c = _a.mode, mode = _c === void 0 ? mdm_sdk_1.Mode.Viewing : _c, crosswalks = _a.crosswalks, drawLines = _a.drawLines, _d = _a.paging, paging = _d === void 0 ? {} : _d, parentUri = _a.parentUri, maxProp = _a.max, showEmptyEditors = _a.showEmptyEditors, showNonOv = _a.showNonOv, highlightedError = _a.highlightedError, highlightedAttribute = _a.highlightedAttribute, onAddAttributes = _a.onAddAttributes, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, additionalControlsRenderer = _a.additionalControlsRenderer;
|
|
31
53
|
var onDeactivateError = (0, MdmModuleContext_1.useMdmAction)('errorDeactivated');
|
|
32
54
|
var requestNextPageOfAttributeValues = (0, MdmModuleContext_1.useMdmAction)('requestNextPageOfAttributeValues');
|
|
33
|
-
var
|
|
55
|
+
var hiddenAttributes = (0, react_1.useContext)(HiddenAttributesContext_1.HiddenAttributesContext);
|
|
56
|
+
var entityUri = parentUri && (0, mdm_sdk_1.getBaseUri)(parentUri);
|
|
57
|
+
var currentEntityHiddenAttributes = (0, react_1.useMemo)(function () { return hiddenAttributes[entityUri] || []; }, [hiddenAttributes, entityUri]);
|
|
58
|
+
var mdmActiveErrors = (0, MdmModuleContext_1.useMdmActiveErrorsForAttributesPager)(parentUri, attributeType);
|
|
59
|
+
var activeErrors = (0, react_1.useMemo)(function () { return (0, mdm_sdk_2.filterErrorsForHiddenAttributes)(mdmActiveErrors, currentEntityHiddenAttributes); }, [mdmActiveErrors, currentEntityHiddenAttributes]);
|
|
34
60
|
var profileErrors = (0, MdmModuleContext_1.useMdmProfileErrors)();
|
|
35
61
|
var maxValuesInResponse = (0, MdmModuleContext_1.useMdmMaxValuesInResponse)();
|
|
36
62
|
var errorMessage = (0, mdm_sdk_1.getAttributePagerActiveTypeErrorMessage)(parentUri, attributeType, profileErrors);
|
|
@@ -57,7 +57,8 @@ var user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
|
57
57
|
var PinnedAttributesContext_1 = require("../contexts/PinnedAttributesContext");
|
|
58
58
|
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
|
|
59
59
|
var EditModeAttributesView_1 = require("./EditModeAttributesView");
|
|
60
|
-
|
|
60
|
+
var contexts_1 = require("../contexts");
|
|
61
|
+
jest.mock('../contexts/MdmModuleContext', function () { return (__assign(__assign({}, jest.requireActual('../contexts/MdmModuleContext')), { useMdmAction: jest.fn(), useMdmMetadata: jest.fn(), useMdmUserRoles: jest.fn(), useMdmModifiedEntity: jest.fn(), useMdmDependentLookupEditorState: jest.fn() })); });
|
|
61
62
|
var metadata = {
|
|
62
63
|
entityTypes: []
|
|
63
64
|
};
|
|
@@ -148,15 +149,18 @@ describe('EditModeAttributesView', function () {
|
|
|
148
149
|
}
|
|
149
150
|
]
|
|
150
151
|
};
|
|
151
|
-
var setUp = function (props) {
|
|
152
|
+
var setUp = function (props, hiddenAttributes) {
|
|
152
153
|
var user = user_event_1.default.setup();
|
|
153
|
-
|
|
154
|
+
var Providers = function (_a) {
|
|
155
|
+
var children = _a.children;
|
|
156
|
+
return (react_1.default.createElement(contexts_1.HiddenAttributesContext.Provider, { value: hiddenAttributes }, children));
|
|
157
|
+
};
|
|
158
|
+
return __assign(__assign({}, (0, react_2.render)(react_1.default.createElement(EditModeAttributesView_1.EditModeAttributesView, __assign({}, props)), { wrapper: Providers })), { user: user });
|
|
154
159
|
};
|
|
155
160
|
beforeAll(function () {
|
|
156
161
|
MdmModuleContext_1.useMdmUserRoles.mockReturnValue([]);
|
|
157
162
|
MdmModuleContext_1.useMdmAction.mockReturnValue(jest.fn());
|
|
158
163
|
MdmModuleContext_1.useMdmMetadata.mockReturnValue(metadata);
|
|
159
|
-
MdmModuleContext_1.useMdmHiddenAttributes.mockReturnValue([]);
|
|
160
164
|
});
|
|
161
165
|
it('should hide attributes if there are no rules allow to show the attribute', function () {
|
|
162
166
|
var entity = {
|
|
@@ -193,19 +197,21 @@ describe('EditModeAttributesView', function () {
|
|
|
193
197
|
]
|
|
194
198
|
}
|
|
195
199
|
});
|
|
196
|
-
|
|
197
|
-
'
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
200
|
+
var hiddenAttributes = {
|
|
201
|
+
'entities/uri_e': [
|
|
202
|
+
'configuration/entityTypes/HCP/attributes/Category2',
|
|
203
|
+
'configuration/entityTypes/HCP/attributes/Category3',
|
|
204
|
+
'configuration/entityTypes/HCP/attributes/Category4'
|
|
205
|
+
]
|
|
206
|
+
};
|
|
207
|
+
setUp({ entity: entity }, hiddenAttributes);
|
|
202
208
|
expect(react_2.screen.getByText('category1_value1')).toBeInTheDocument();
|
|
203
209
|
expect(react_2.screen.queryByText('category2_value1')).not.toBeInTheDocument();
|
|
204
210
|
expect(react_2.screen.queryByText('category3_value1')).not.toBeInTheDocument();
|
|
205
211
|
expect(react_2.screen.queryByText('category4_value1')).not.toBeInTheDocument();
|
|
206
212
|
});
|
|
207
213
|
it('should hide nested attributes if there are no rules allow to show the attribute', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
208
|
-
var entity, user;
|
|
214
|
+
var entity, hiddenAttributes, user;
|
|
209
215
|
return __generator(this, function (_a) {
|
|
210
216
|
switch (_a.label) {
|
|
211
217
|
case 0:
|
|
@@ -240,10 +246,10 @@ describe('EditModeAttributesView', function () {
|
|
|
240
246
|
]
|
|
241
247
|
}
|
|
242
248
|
});
|
|
243
|
-
|
|
244
|
-
'configuration/entityTypes/HCP/attributes/Nested1/attributes/NestedCategory2'
|
|
245
|
-
|
|
246
|
-
user = setUp({ entity: entity }).user;
|
|
249
|
+
hiddenAttributes = {
|
|
250
|
+
'entities/uri_e': ['configuration/entityTypes/HCP/attributes/Nested1/attributes/NestedCategory2']
|
|
251
|
+
};
|
|
252
|
+
user = setUp({ entity: entity }, hiddenAttributes).user;
|
|
247
253
|
return [4 /*yield*/, user.click(react_2.screen.getByTestId('arrow-expand-button'))];
|
|
248
254
|
case 1:
|
|
249
255
|
_a.sent();
|
|
@@ -43,11 +43,13 @@ var ShowMore_1 = require("../ShowMore");
|
|
|
43
43
|
var ShowLess_1 = require("../ShowLess");
|
|
44
44
|
var constants_1 = require("../constants");
|
|
45
45
|
var attributesView_1 = require("../helpers/attributesView");
|
|
46
|
-
var
|
|
46
|
+
var HiddenAttributesContext_1 = require("../contexts/HiddenAttributesContext");
|
|
47
47
|
var ReadOnlyAttributesList = function (_a) {
|
|
48
48
|
var _b = _a.attrTypes, attrTypes = _b === void 0 ? [] : _b, entity = _a.entity, parentUri = _a.parentUri, drawLines = _a.drawLines, children = _a.children, className = _a.className, max = _a.max, _c = _a.alwaysVisibleTypeUris, alwaysVisibleTypeUris = _c === void 0 ? constants_1.ALWAYS_VISIBLE_TYPE_URIS : _c, showNonOv = _a.showNonOv;
|
|
49
|
-
var hiddenAttributes = (0,
|
|
50
|
-
var
|
|
49
|
+
var hiddenAttributes = (0, react_1.useContext)(HiddenAttributesContext_1.HiddenAttributesContext);
|
|
50
|
+
var entityUri = parentUri && (0, mdm_sdk_1.getBaseUri)(parentUri);
|
|
51
|
+
var currentEntityHiddenAttributes = (0, react_1.useMemo)(function () { return hiddenAttributes[entityUri] || []; }, [hiddenAttributes, entityUri]);
|
|
52
|
+
var filteredAttrTypes = (0, react_1.useMemo)(function () { return (attrTypes || []).filter(function (attrType) { return !currentEntityHiddenAttributes.includes(attrType.uri); }); }, [attrTypes, currentEntityHiddenAttributes]);
|
|
51
53
|
var _d = (0, react_1.useState)(max || Infinity), visibleValuesCount = _d[0], setVisibleValuesCount = _d[1];
|
|
52
54
|
var pagersData = (0, react_1.useMemo)(function () { return (0, mdm_sdk_1.getAttributesListForReadMode)(filteredAttrTypes, entity, showNonOv); }, [filteredAttrTypes, entity, showNonOv]);
|
|
53
55
|
var _e = (0, react_1.useMemo)(function () { return (0, attributesView_1.splitPagersData)(alwaysVisibleTypeUris, pagersData); }, [pagersData, alwaysVisibleTypeUris]), alwaysVisiblePagersData = _e[0], regularPagersData = _e[1];
|
|
@@ -71,7 +71,8 @@ var ReadOnlyAttributesList_1 = require("../ReadOnlyAttributesList");
|
|
|
71
71
|
var FacetViewHeader_1 = require("../FacetViewHeader");
|
|
72
72
|
var PivotingAttributeContext_1 = require("../contexts/PivotingAttributeContext");
|
|
73
73
|
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
|
|
74
|
-
|
|
74
|
+
var contexts_1 = require("../contexts");
|
|
75
|
+
jest.mock('../contexts/MdmModuleContext', function () { return (__assign(__assign({}, jest.requireActual('../contexts/MdmModuleContext')), { useMdmMetadata: jest.fn(), useMdmPivotingAttributes: jest.fn() })); });
|
|
75
76
|
describe('ReadOnlyAttributesView tests', function () {
|
|
76
77
|
var metadata = {
|
|
77
78
|
entityTypes: [
|
|
@@ -293,13 +294,16 @@ describe('ReadOnlyAttributesView tests', function () {
|
|
|
293
294
|
}
|
|
294
295
|
]
|
|
295
296
|
};
|
|
296
|
-
var setUp = function (props) {
|
|
297
|
+
var setUp = function (props, hiddenAttributes) {
|
|
297
298
|
var user = user_event_1.default.setup();
|
|
298
|
-
|
|
299
|
+
var Providers = function (_a) {
|
|
300
|
+
var children = _a.children;
|
|
301
|
+
return (react_1.default.createElement(contexts_1.HiddenAttributesContext.Provider, { value: hiddenAttributes }, children));
|
|
302
|
+
};
|
|
303
|
+
return __assign(__assign({}, (0, react_2.render)(react_1.default.createElement(ReadOnlyAttributesView_1.ReadOnlyAttributesView, __assign({}, props)), { wrapper: Providers })), { user: user });
|
|
299
304
|
};
|
|
300
305
|
beforeAll(function () {
|
|
301
306
|
MdmModuleContext_1.useMdmMetadata.mockReturnValue(metadata);
|
|
302
|
-
MdmModuleContext_1.useMdmHiddenAttributes.mockReturnValue([]);
|
|
303
307
|
});
|
|
304
308
|
it('should hide attributes', function () {
|
|
305
309
|
var entity = {
|
|
@@ -332,19 +336,21 @@ describe('ReadOnlyAttributesView tests', function () {
|
|
|
332
336
|
]
|
|
333
337
|
}
|
|
334
338
|
};
|
|
335
|
-
|
|
336
|
-
'
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
339
|
+
var hiddenAttributes = {
|
|
340
|
+
'entities/uri_e': [
|
|
341
|
+
'configuration/entityTypes/HCP/attributes/Category2',
|
|
342
|
+
'configuration/entityTypes/HCP/attributes/Category3',
|
|
343
|
+
'configuration/entityTypes/HCP/attributes/Category4'
|
|
344
|
+
]
|
|
345
|
+
};
|
|
346
|
+
setUp({ entity: entity }, hiddenAttributes);
|
|
341
347
|
expect(react_2.screen.getByText('category1_value1')).toBeInTheDocument();
|
|
342
348
|
expect(react_2.screen.queryByText('category2_value1')).not.toBeInTheDocument();
|
|
343
349
|
expect(react_2.screen.queryByText('category3_value1')).not.toBeInTheDocument();
|
|
344
350
|
expect(react_2.screen.queryByText('category4_value1')).not.toBeInTheDocument();
|
|
345
351
|
});
|
|
346
352
|
it('should hide nested attributes', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
347
|
-
var entity, user;
|
|
353
|
+
var entity, hiddenAttributes, user;
|
|
348
354
|
return __generator(this, function (_a) {
|
|
349
355
|
switch (_a.label) {
|
|
350
356
|
case 0:
|
|
@@ -375,10 +381,10 @@ describe('ReadOnlyAttributesView tests', function () {
|
|
|
375
381
|
]
|
|
376
382
|
}
|
|
377
383
|
};
|
|
378
|
-
|
|
379
|
-
'configuration/entityTypes/HCP/attributes/Nested1/attributes/NestedCategory2'
|
|
380
|
-
|
|
381
|
-
user = setUp({ entity: entity }).user;
|
|
384
|
+
hiddenAttributes = {
|
|
385
|
+
'entities/uri_e': ['configuration/entityTypes/HCP/attributes/Nested1/attributes/NestedCategory2']
|
|
386
|
+
};
|
|
387
|
+
user = setUp({ entity: entity }, hiddenAttributes).user;
|
|
382
388
|
return [4 /*yield*/, user.click(react_2.screen.getByTestId('arrow-expand-button'))];
|
|
383
389
|
case 1:
|
|
384
390
|
_a.sent();
|
|
@@ -50,11 +50,13 @@ var EntitySelector_1 = require("../../EntitySelector");
|
|
|
50
50
|
var EditModeAttributesList_1 = require("../../EditModeAttributesList");
|
|
51
51
|
var HOCs_1 = require("../../HOCs");
|
|
52
52
|
var contexts_1 = require("../../contexts");
|
|
53
|
+
var HiddenAttributesContext_1 = require("../../contexts/HiddenAttributesContext");
|
|
53
54
|
var hooks_1 = require("../../hooks");
|
|
54
55
|
var styles_1 = require("./styles");
|
|
55
56
|
var areRelatedEntitiesChanged = function (initial, actual) {
|
|
56
57
|
return initial.length !== actual.length || initial.some(function (_, i) { return initial[i] !== actual[i]; });
|
|
57
58
|
};
|
|
59
|
+
var emptyHiddenAttributes = {};
|
|
58
60
|
var RelationEditor = function (_a) {
|
|
59
61
|
var _b;
|
|
60
62
|
var connection = _a.connection, config = _a.config, mode = _a.mode, metadata = _a.metadata, highlightedError = _a.highlightedError;
|
|
@@ -222,7 +224,8 @@ var RelationEditor = function (_a) {
|
|
|
222
224
|
_b[styles.dense] = errorMessage ||
|
|
223
225
|
(connection.entity && (0, mdm_sdk_1.isTempUri)(connection.entity.entityUri)),
|
|
224
226
|
_b)), entity: connection.entity || {}, entityTypesUris: getEntityTypesUris() || [], globalSearchRequestOptions: globalSearchRequestOptions, mode: mode, onChange: onChangeEntity, onCreate: canCreateNewEntity ? onCreateEntity : undefined, metadata: metadata, attributeTypesSelectionStrategy: mdm_sdk_1.relationEditorAttributeTypesSelectionStrategy }))),
|
|
225
|
-
react_1.default.createElement(
|
|
227
|
+
react_1.default.createElement(HiddenAttributesContext_1.HiddenAttributesContext.Provider, { value: emptyHiddenAttributes },
|
|
228
|
+
react_1.default.createElement(EditModeAttributesList_1.EditModeAttributesList, { className: styles.item, attrTypes: firstLevelRelationAttrTypes, entity: attributeListEntity, showEmptyEditors: true, mode: mode, parentUri: relationUri, onAddAttributes: onAddAttributes, onChangeAttribute: onChangeAttribute, onDeleteAttribute: onDeleteAttribute }))))),
|
|
226
229
|
react_1.default.createElement("div", { className: styles.actionButtons },
|
|
227
230
|
react_1.default.createElement(Button_1.default, { onClick: onCancel }, ui_i18n_1.default.text('Cancel')),
|
|
228
231
|
react_1.default.createElement(Button_1.default, { color: "primary", disabled: !hasChanges, onClick: onApply }, ui_i18n_1.default.text('Apply')))));
|
|
@@ -139,4 +139,4 @@ export declare const useMdmListener: <T extends "expandInvalidRelatonsListener"
|
|
|
139
139
|
cleanseLoadingListener: (callback: (value: boolean) => void) => (action: import("../..").AnyAction) => void;
|
|
140
140
|
searchNavigationListener: (action: import("../..").AnyAction, state: any, dispatch: (action: import("../..").AnyAction) => void) => void;
|
|
141
141
|
}>[T];
|
|
142
|
-
export declare const useMdmHiddenAttributes: (
|
|
142
|
+
export declare const useMdmHiddenAttributes: () => {};
|
|
@@ -220,7 +220,8 @@ var useMdmListener = function (listener) {
|
|
|
220
220
|
return useMdmModuleListenersContext(function (context) { return context[listener]; });
|
|
221
221
|
};
|
|
222
222
|
exports.useMdmListener = useMdmListener;
|
|
223
|
-
var
|
|
224
|
-
|
|
223
|
+
var emptyHiddenAttributesObject = {};
|
|
224
|
+
var useMdmHiddenAttributes = function () {
|
|
225
|
+
return useMdmModuleValuesContext(function (context) { return context.hiddenAttributes || emptyHiddenAttributesObject; });
|
|
225
226
|
};
|
|
226
227
|
exports.useMdmHiddenAttributes = useMdmHiddenAttributes;
|
|
@@ -6,8 +6,8 @@ export declare enum ScrollType {
|
|
|
6
6
|
NewView = "NewView"
|
|
7
7
|
}
|
|
8
8
|
type ScrollToElementContextProps = {
|
|
9
|
-
element: AttributeError | AttributeType | string;
|
|
10
|
-
type: ScrollType;
|
|
9
|
+
element: AttributeError | AttributeType | string | null;
|
|
10
|
+
type: ScrollType | null;
|
|
11
11
|
highlightError?: (element: AttributeError) => void;
|
|
12
12
|
highlightAttribute?: (element: AttributeType) => void;
|
|
13
13
|
highlightView?: (element: string) => void;
|
package/cjs/contexts/index.d.ts
CHANGED
|
@@ -34,4 +34,5 @@ export { ConfigPermissionsContext, ConfigPermissionsContextProvider, useAttribut
|
|
|
34
34
|
export * from './MdmModuleContext';
|
|
35
35
|
export { ReloadDataProvider, useReloadData } from './ReloadDataContext';
|
|
36
36
|
export { SegmentationContext } from './SegmentationContext';
|
|
37
|
+
export { HiddenAttributesContext } from './HiddenAttributesContext';
|
|
37
38
|
export * from './MaskedAttributesContext';
|
package/cjs/contexts/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.useAttributeValueConfigPermissions = exports.ConfigPermissionsContextProvider = exports.ConfigPermissionsContext = exports.useActionsHook = exports.ActionsHookProvider = exports.PageRequestsAbortingContext = exports.DependentLookupAutopopulationContext = exports.FeaturesContext = exports.LabelsContext = exports.UrlGeneratorsContext = exports.isHighlightedAttributeType = exports.isHighlightedErrorType = exports.ScrollType = exports.ScrollToElementProvider = exports.ScrollToElementContext = exports.SearchValueContext = exports.InterceptHandlersContext = exports.HighlightedValuesContext = exports.SnackbarContext = exports.SearchFiltersContext = exports.useReloadFacet = exports.ReloadFacetProvider = exports.useReloadAllFacets = exports.SandboxAPIContext = exports.EntityContext = exports.RelatedObjectUrisContext = exports.WorkflowTasksContext = exports.useEntityLoadingIndication = exports.EntityLoadingIndicationProvider = exports.EntityMarkerContext = exports.useAttributeExpanded = exports.ExpandedAttributesProvider = exports.useHighlightedCrosswalks = exports.useCrosswalkHighlight = exports.useCrosswalkFocus = exports.useCrosswalkColor = exports.CrosswalksDisplayProvider = exports.EntitiesMapContext = exports.IdContext = exports.ProfilePerspectiveViewContext = exports.usePerspectivesSettings = exports.PerspectivesSettingsContext = exports.PivotingAttributeContext = exports.UsersContext = exports.CollaborationContextProvider = exports.CollaborationContext = exports.BlockImageGalleryDialogContext = exports.PopupBoundariesContext = exports.HistoryDiffContext = exports.AsyncMountContext = void 0;
|
|
18
|
-
exports.SegmentationContext = exports.useReloadData = exports.ReloadDataProvider = void 0;
|
|
18
|
+
exports.HiddenAttributesContext = exports.SegmentationContext = exports.useReloadData = exports.ReloadDataProvider = void 0;
|
|
19
19
|
var AsyncMountContext_1 = require("./AsyncMountContext");
|
|
20
20
|
Object.defineProperty(exports, "AsyncMountContext", { enumerable: true, get: function () { return AsyncMountContext_1.AsyncMountContext; } });
|
|
21
21
|
var HistoryAppearanceContext_1 = require("./HistoryAppearanceContext");
|
|
@@ -105,4 +105,6 @@ Object.defineProperty(exports, "ReloadDataProvider", { enumerable: true, get: fu
|
|
|
105
105
|
Object.defineProperty(exports, "useReloadData", { enumerable: true, get: function () { return ReloadDataContext_1.useReloadData; } });
|
|
106
106
|
var SegmentationContext_1 = require("./SegmentationContext");
|
|
107
107
|
Object.defineProperty(exports, "SegmentationContext", { enumerable: true, get: function () { return SegmentationContext_1.SegmentationContext; } });
|
|
108
|
+
var HiddenAttributesContext_1 = require("./HiddenAttributesContext");
|
|
109
|
+
Object.defineProperty(exports, "HiddenAttributesContext", { enumerable: true, get: function () { return HiddenAttributesContext_1.HiddenAttributesContext; } });
|
|
108
110
|
__exportStar(require("./MaskedAttributesContext"), exports);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_MAX_DATE_IN_POPUP = exports.DEFAULT_MAX_DATE = exports.DEFAULT_MIN_DATE = void 0;
|
|
4
|
-
exports.DEFAULT_MIN_DATE = new Date(
|
|
5
|
-
exports.DEFAULT_MAX_DATE = new Date(
|
|
6
|
-
exports.DEFAULT_MAX_DATE_IN_POPUP = new Date(
|
|
4
|
+
exports.DEFAULT_MIN_DATE = new Date(1900, 0, 1, 0, 0, 0, 0);
|
|
5
|
+
exports.DEFAULT_MAX_DATE = new Date(9999, 11, 31, 23, 59, 59, 999);
|
|
6
|
+
exports.DEFAULT_MAX_DATE_IN_POPUP = new Date(2099, 11, 31, 23, 59, 59, 999);
|
|
@@ -27,7 +27,8 @@ var useHiddenAttributes = function () {
|
|
|
27
27
|
var entityUri = entity === null || entity === void 0 ? void 0 : entity.uri;
|
|
28
28
|
var updateHiddenAttributes = (0, hooks_1.useMdmAction)('updateHiddenAttributes');
|
|
29
29
|
var resetHiddenAttributes = (0, hooks_1.useMdmAction)('resetHiddenAttributes');
|
|
30
|
-
var hiddenAttributes = (0, hooks_1.useMdmHiddenAttributes)(
|
|
30
|
+
var hiddenAttributes = (0, hooks_1.useMdmHiddenAttributes)();
|
|
31
|
+
var currentEntityHiddenAttributes = (0, react_1.useMemo)(function () { return hiddenAttributes[entityUri] || []; }, [hiddenAttributes, entityUri]);
|
|
31
32
|
var ruleBasedAttributes = (0, react_1.useMemo)(function () { return (0, mdm_sdk_1.getRuleBasedAttributes)(metadata, entity === null || entity === void 0 ? void 0 : entity.type); }, [metadata, entity === null || entity === void 0 ? void 0 : entity.type]);
|
|
32
33
|
var parsedRuleBasedAttributes = (0, react_1.useMemo)(function () {
|
|
33
34
|
return ruleBasedAttributes.map(function (rule) {
|
|
@@ -53,7 +54,7 @@ var useHiddenAttributes = function () {
|
|
|
53
54
|
}, [rulesToCheck, entity, showAttributeURIs]);
|
|
54
55
|
(0, react_1.useEffect)(function () {
|
|
55
56
|
if (entityUri && (addedHiddenAttributes.length || showAttributeURIs.length)) {
|
|
56
|
-
updateHiddenAttributes(entityUri, (0, ramda_1.without)(showAttributeURIs,
|
|
57
|
+
updateHiddenAttributes(entityUri, (0, ramda_1.without)(showAttributeURIs, currentEntityHiddenAttributes).concat(addedHiddenAttributes));
|
|
57
58
|
}
|
|
58
59
|
}, [addedHiddenAttributes, showAttributeURIs, entityUri]);
|
|
59
60
|
(0, react_1.useEffect)(function () { return function () { return resetHiddenAttributes(entityUri); }; }, [entityUri]);
|
|
@@ -11,7 +11,7 @@ var __assign = (this && this.__assign) || function () {
|
|
|
11
11
|
};
|
|
12
12
|
import React, { useCallback, useContext, useMemo, useState, useEffect } from 'react';
|
|
13
13
|
import i18n from 'ui-i18n';
|
|
14
|
-
import { getCreatableAttributeTypes, getAttributesListForEditMode, getParentUri, checkCanCreateAttribute } from '@reltio/mdm-sdk';
|
|
14
|
+
import { getCreatableAttributeTypes, getAttributesListForEditMode, getParentUri, checkCanCreateAttribute, getBaseUri } from '@reltio/mdm-sdk';
|
|
15
15
|
import { last, path } from 'ramda';
|
|
16
16
|
import { EditModeAttributesPager } from '../EditModeAttributesPager';
|
|
17
17
|
import { BranchDecorator } from '../BranchDecorator';
|
|
@@ -24,11 +24,13 @@ import { HasDeletionsContext } from '../contexts/HasDeletionsContext';
|
|
|
24
24
|
import { withContext } from '../HOCs/withContext';
|
|
25
25
|
import { ConfigPermissionsContext } from '../contexts/ConfigPermissionsContext';
|
|
26
26
|
import { ScrollType, ScrollToElementContext } from '../contexts/ScrollToElementContext';
|
|
27
|
-
import {
|
|
27
|
+
import { HiddenAttributesContext } from '../contexts/HiddenAttributesContext';
|
|
28
28
|
var EditModeAttributesList = function (_a) {
|
|
29
29
|
var parentAttributeType = _a.parentAttributeType, attrTypes = _a.attrTypes, entity = _a.entity, parentUri = _a.parentUri, showEmptyEditors = _a.showEmptyEditors, mode = _a.mode, crosswalks = _a.crosswalks, drawLines = _a.drawLines, children = _a.children, className = _a.className, _b = _a.alwaysVisibleTypeUris, alwaysVisibleTypeUris = _b === void 0 ? ALWAYS_VISIBLE_TYPE_URIS : _b, onAddAttributes = _a.onAddAttributes, onChangeAttribute = _a.onChangeAttribute, onDeleteAttribute = _a.onDeleteAttribute, additionalControlsRenderer = _a.additionalControlsRenderer, showNonOv = _a.showNonOv, highlightAttribute = _a.highlightAttribute;
|
|
30
|
-
var hiddenAttributes =
|
|
31
|
-
var
|
|
30
|
+
var hiddenAttributes = useContext(HiddenAttributesContext);
|
|
31
|
+
var entityUri = parentUri && getBaseUri(parentUri);
|
|
32
|
+
var currentEntityHiddenAttributes = useMemo(function () { return hiddenAttributes[entityUri] || []; }, [hiddenAttributes, entityUri]);
|
|
33
|
+
var filteredAttrTypes = useMemo(function () { return attrTypes.filter(function (attrType) { return !currentEntityHiddenAttributes.includes(attrType.uri); }); }, [attrTypes, currentEntityHiddenAttributes]);
|
|
32
34
|
var _c = entity.attributes, attributes = _c === void 0 ? {} : _c;
|
|
33
35
|
var _d = useState({}), hasDeletionsMap = _d[0], setHasDeletionsMap = _d[1];
|
|
34
36
|
var setHasDeletions = useCallback(function (attrTypeUri, value) {
|
|
@@ -9,8 +9,8 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import React from 'react';
|
|
13
|
-
import { getAttributeErrorByTypeUri, getAttributePagerActiveTypeErrorMessage, isAttributeTypeError, isImage, isOv, isSpecialAttribute, Mode } from '@reltio/mdm-sdk';
|
|
12
|
+
import React, { useContext, useMemo } from 'react';
|
|
13
|
+
import { getAttributeErrorByTypeUri, getAttributePagerActiveTypeErrorMessage, getBaseUri, isAttributeTypeError, isImage, isOv, isSpecialAttribute, Mode } from '@reltio/mdm-sdk';
|
|
14
14
|
import { always, cond, T, partition } from 'ramda';
|
|
15
15
|
import { BranchDecorator } from '../BranchDecorator';
|
|
16
16
|
import { AttributeRenderer } from './components/AttributeRenderer';
|
|
@@ -20,12 +20,18 @@ import { withContext } from '../HOCs/withContext';
|
|
|
20
20
|
import { RENDERER_TYPES } from './types';
|
|
21
21
|
import { isHighlightedAttributeType, isHighlightedErrorType, ScrollToElementContext } from '../contexts/ScrollToElementContext';
|
|
22
22
|
import { useMdmAction, useMdmActiveErrorsForAttributesPager, useMdmMaxValuesInResponse, useMdmProfileErrors } from '../contexts/MdmModuleContext';
|
|
23
|
+
import { HiddenAttributesContext } from '../contexts/HiddenAttributesContext';
|
|
24
|
+
import { filterErrorsForHiddenAttributes } from '@reltio/mdm-sdk';
|
|
23
25
|
var EditModeAttributesPager = function (_a) {
|
|
24
26
|
var _b;
|
|
25
27
|
var values = _a.values, attributeType = _a.attributeType, _c = _a.mode, mode = _c === void 0 ? Mode.Viewing : _c, crosswalks = _a.crosswalks, drawLines = _a.drawLines, _d = _a.paging, paging = _d === void 0 ? {} : _d, parentUri = _a.parentUri, maxProp = _a.max, showEmptyEditors = _a.showEmptyEditors, showNonOv = _a.showNonOv, highlightedError = _a.highlightedError, highlightedAttribute = _a.highlightedAttribute, onAddAttributes = _a.onAddAttributes, onDeleteAttribute = _a.onDeleteAttribute, onChangeAttribute = _a.onChangeAttribute, additionalControlsRenderer = _a.additionalControlsRenderer;
|
|
26
28
|
var onDeactivateError = useMdmAction('errorDeactivated');
|
|
27
29
|
var requestNextPageOfAttributeValues = useMdmAction('requestNextPageOfAttributeValues');
|
|
28
|
-
var
|
|
30
|
+
var hiddenAttributes = useContext(HiddenAttributesContext);
|
|
31
|
+
var entityUri = parentUri && getBaseUri(parentUri);
|
|
32
|
+
var currentEntityHiddenAttributes = useMemo(function () { return hiddenAttributes[entityUri] || []; }, [hiddenAttributes, entityUri]);
|
|
33
|
+
var mdmActiveErrors = useMdmActiveErrorsForAttributesPager(parentUri, attributeType);
|
|
34
|
+
var activeErrors = useMemo(function () { return filterErrorsForHiddenAttributes(mdmActiveErrors, currentEntityHiddenAttributes); }, [mdmActiveErrors, currentEntityHiddenAttributes]);
|
|
29
35
|
var profileErrors = useMdmProfileErrors();
|
|
30
36
|
var maxValuesInResponse = useMdmMaxValuesInResponse();
|
|
31
37
|
var errorMessage = getAttributePagerActiveTypeErrorMessage(parentUri, attributeType, profileErrors);
|
|
@@ -50,9 +50,10 @@ import { shallow } from 'enzyme';
|
|
|
50
50
|
import { render, screen } from '@testing-library/react';
|
|
51
51
|
import userEvent from '@testing-library/user-event';
|
|
52
52
|
import { PinnedAttributesContext } from '../contexts/PinnedAttributesContext';
|
|
53
|
-
import { useMdmAction,
|
|
53
|
+
import { useMdmAction, useMdmMetadata, useMdmModifiedEntity, useMdmUserRoles } from '../contexts/MdmModuleContext';
|
|
54
54
|
import { EditModeAttributesView } from './EditModeAttributesView';
|
|
55
|
-
|
|
55
|
+
import { HiddenAttributesContext } from '../contexts';
|
|
56
|
+
jest.mock('../contexts/MdmModuleContext', function () { return (__assign(__assign({}, jest.requireActual('../contexts/MdmModuleContext')), { useMdmAction: jest.fn(), useMdmMetadata: jest.fn(), useMdmUserRoles: jest.fn(), useMdmModifiedEntity: jest.fn(), useMdmDependentLookupEditorState: jest.fn() })); });
|
|
56
57
|
var metadata = {
|
|
57
58
|
entityTypes: []
|
|
58
59
|
};
|
|
@@ -143,15 +144,18 @@ describe('EditModeAttributesView', function () {
|
|
|
143
144
|
}
|
|
144
145
|
]
|
|
145
146
|
};
|
|
146
|
-
var setUp = function (props) {
|
|
147
|
+
var setUp = function (props, hiddenAttributes) {
|
|
147
148
|
var user = userEvent.setup();
|
|
148
|
-
|
|
149
|
+
var Providers = function (_a) {
|
|
150
|
+
var children = _a.children;
|
|
151
|
+
return (React.createElement(HiddenAttributesContext.Provider, { value: hiddenAttributes }, children));
|
|
152
|
+
};
|
|
153
|
+
return __assign(__assign({}, render(React.createElement(EditModeAttributesView, __assign({}, props)), { wrapper: Providers })), { user: user });
|
|
149
154
|
};
|
|
150
155
|
beforeAll(function () {
|
|
151
156
|
useMdmUserRoles.mockReturnValue([]);
|
|
152
157
|
useMdmAction.mockReturnValue(jest.fn());
|
|
153
158
|
useMdmMetadata.mockReturnValue(metadata);
|
|
154
|
-
useMdmHiddenAttributes.mockReturnValue([]);
|
|
155
159
|
});
|
|
156
160
|
it('should hide attributes if there are no rules allow to show the attribute', function () {
|
|
157
161
|
var entity = {
|
|
@@ -188,19 +192,21 @@ describe('EditModeAttributesView', function () {
|
|
|
188
192
|
]
|
|
189
193
|
}
|
|
190
194
|
});
|
|
191
|
-
|
|
192
|
-
'
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
195
|
+
var hiddenAttributes = {
|
|
196
|
+
'entities/uri_e': [
|
|
197
|
+
'configuration/entityTypes/HCP/attributes/Category2',
|
|
198
|
+
'configuration/entityTypes/HCP/attributes/Category3',
|
|
199
|
+
'configuration/entityTypes/HCP/attributes/Category4'
|
|
200
|
+
]
|
|
201
|
+
};
|
|
202
|
+
setUp({ entity: entity }, hiddenAttributes);
|
|
197
203
|
expect(screen.getByText('category1_value1')).toBeInTheDocument();
|
|
198
204
|
expect(screen.queryByText('category2_value1')).not.toBeInTheDocument();
|
|
199
205
|
expect(screen.queryByText('category3_value1')).not.toBeInTheDocument();
|
|
200
206
|
expect(screen.queryByText('category4_value1')).not.toBeInTheDocument();
|
|
201
207
|
});
|
|
202
208
|
it('should hide nested attributes if there are no rules allow to show the attribute', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
203
|
-
var entity, user;
|
|
209
|
+
var entity, hiddenAttributes, user;
|
|
204
210
|
return __generator(this, function (_a) {
|
|
205
211
|
switch (_a.label) {
|
|
206
212
|
case 0:
|
|
@@ -235,10 +241,10 @@ describe('EditModeAttributesView', function () {
|
|
|
235
241
|
]
|
|
236
242
|
}
|
|
237
243
|
});
|
|
238
|
-
|
|
239
|
-
'configuration/entityTypes/HCP/attributes/Nested1/attributes/NestedCategory2'
|
|
240
|
-
|
|
241
|
-
user = setUp({ entity: entity }).user;
|
|
244
|
+
hiddenAttributes = {
|
|
245
|
+
'entities/uri_e': ['configuration/entityTypes/HCP/attributes/Nested1/attributes/NestedCategory2']
|
|
246
|
+
};
|
|
247
|
+
user = setUp({ entity: entity }, hiddenAttributes).user;
|
|
242
248
|
return [4 /*yield*/, user.click(screen.getByTestId('arrow-expand-button'))];
|
|
243
249
|
case 1:
|
|
244
250
|
_a.sent();
|
|
@@ -9,20 +9,22 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
-
import React, { memo, useMemo, useState } from 'react';
|
|
12
|
+
import React, { memo, useContext, useMemo, useState } from 'react';
|
|
13
13
|
import { path } from 'ramda';
|
|
14
|
-
import { getAttributesListForReadMode } from '@reltio/mdm-sdk';
|
|
14
|
+
import { getAttributesListForReadMode, getBaseUri } from '@reltio/mdm-sdk';
|
|
15
15
|
import { BranchDecorator } from '../BranchDecorator';
|
|
16
16
|
import { ReadOnlyAttributesPager } from '../ReadOnlyAttributesPager';
|
|
17
17
|
import { ShowMore } from '../ShowMore';
|
|
18
18
|
import { ShowLess } from '../ShowLess';
|
|
19
19
|
import { ALWAYS_VISIBLE_TYPE_URIS } from '../constants';
|
|
20
20
|
import { splitPagersData } from '../helpers/attributesView';
|
|
21
|
-
import {
|
|
21
|
+
import { HiddenAttributesContext } from '../contexts/HiddenAttributesContext';
|
|
22
22
|
var ReadOnlyAttributesList = function (_a) {
|
|
23
23
|
var _b = _a.attrTypes, attrTypes = _b === void 0 ? [] : _b, entity = _a.entity, parentUri = _a.parentUri, drawLines = _a.drawLines, children = _a.children, className = _a.className, max = _a.max, _c = _a.alwaysVisibleTypeUris, alwaysVisibleTypeUris = _c === void 0 ? ALWAYS_VISIBLE_TYPE_URIS : _c, showNonOv = _a.showNonOv;
|
|
24
|
-
var hiddenAttributes =
|
|
25
|
-
var
|
|
24
|
+
var hiddenAttributes = useContext(HiddenAttributesContext);
|
|
25
|
+
var entityUri = parentUri && getBaseUri(parentUri);
|
|
26
|
+
var currentEntityHiddenAttributes = useMemo(function () { return hiddenAttributes[entityUri] || []; }, [hiddenAttributes, entityUri]);
|
|
27
|
+
var filteredAttrTypes = useMemo(function () { return (attrTypes || []).filter(function (attrType) { return !currentEntityHiddenAttributes.includes(attrType.uri); }); }, [attrTypes, currentEntityHiddenAttributes]);
|
|
26
28
|
var _d = useState(max || Infinity), visibleValuesCount = _d[0], setVisibleValuesCount = _d[1];
|
|
27
29
|
var pagersData = useMemo(function () { return getAttributesListForReadMode(filteredAttrTypes, entity, showNonOv); }, [filteredAttrTypes, entity, showNonOv]);
|
|
28
30
|
var _e = useMemo(function () { return splitPagersData(alwaysVisibleTypeUris, pagersData); }, [pagersData, alwaysVisibleTypeUris]), alwaysVisiblePagersData = _e[0], regularPagersData = _e[1];
|
|
@@ -65,8 +65,9 @@ import { BasicView } from '../BasicView';
|
|
|
65
65
|
import { ReadOnlyAttributesList } from '../ReadOnlyAttributesList';
|
|
66
66
|
import { FacetViewHeader } from '../FacetViewHeader';
|
|
67
67
|
import { PivotingAttributeContext } from '../contexts/PivotingAttributeContext';
|
|
68
|
-
import {
|
|
69
|
-
|
|
68
|
+
import { useMdmMetadata, useMdmPivotingAttributes } from '../contexts/MdmModuleContext';
|
|
69
|
+
import { HiddenAttributesContext } from '../contexts';
|
|
70
|
+
jest.mock('../contexts/MdmModuleContext', function () { return (__assign(__assign({}, jest.requireActual('../contexts/MdmModuleContext')), { useMdmMetadata: jest.fn(), useMdmPivotingAttributes: jest.fn() })); });
|
|
70
71
|
describe('ReadOnlyAttributesView tests', function () {
|
|
71
72
|
var metadata = {
|
|
72
73
|
entityTypes: [
|
|
@@ -288,13 +289,16 @@ describe('ReadOnlyAttributesView tests', function () {
|
|
|
288
289
|
}
|
|
289
290
|
]
|
|
290
291
|
};
|
|
291
|
-
var setUp = function (props) {
|
|
292
|
+
var setUp = function (props, hiddenAttributes) {
|
|
292
293
|
var user = userEvent.setup();
|
|
293
|
-
|
|
294
|
+
var Providers = function (_a) {
|
|
295
|
+
var children = _a.children;
|
|
296
|
+
return (React.createElement(HiddenAttributesContext.Provider, { value: hiddenAttributes }, children));
|
|
297
|
+
};
|
|
298
|
+
return __assign(__assign({}, render(React.createElement(ReadOnlyAttributesView, __assign({}, props)), { wrapper: Providers })), { user: user });
|
|
294
299
|
};
|
|
295
300
|
beforeAll(function () {
|
|
296
301
|
useMdmMetadata.mockReturnValue(metadata);
|
|
297
|
-
useMdmHiddenAttributes.mockReturnValue([]);
|
|
298
302
|
});
|
|
299
303
|
it('should hide attributes', function () {
|
|
300
304
|
var entity = {
|
|
@@ -327,19 +331,21 @@ describe('ReadOnlyAttributesView tests', function () {
|
|
|
327
331
|
]
|
|
328
332
|
}
|
|
329
333
|
};
|
|
330
|
-
|
|
331
|
-
'
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
334
|
+
var hiddenAttributes = {
|
|
335
|
+
'entities/uri_e': [
|
|
336
|
+
'configuration/entityTypes/HCP/attributes/Category2',
|
|
337
|
+
'configuration/entityTypes/HCP/attributes/Category3',
|
|
338
|
+
'configuration/entityTypes/HCP/attributes/Category4'
|
|
339
|
+
]
|
|
340
|
+
};
|
|
341
|
+
setUp({ entity: entity }, hiddenAttributes);
|
|
336
342
|
expect(screen.getByText('category1_value1')).toBeInTheDocument();
|
|
337
343
|
expect(screen.queryByText('category2_value1')).not.toBeInTheDocument();
|
|
338
344
|
expect(screen.queryByText('category3_value1')).not.toBeInTheDocument();
|
|
339
345
|
expect(screen.queryByText('category4_value1')).not.toBeInTheDocument();
|
|
340
346
|
});
|
|
341
347
|
it('should hide nested attributes', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
342
|
-
var entity, user;
|
|
348
|
+
var entity, hiddenAttributes, user;
|
|
343
349
|
return __generator(this, function (_a) {
|
|
344
350
|
switch (_a.label) {
|
|
345
351
|
case 0:
|
|
@@ -370,10 +376,10 @@ describe('ReadOnlyAttributesView tests', function () {
|
|
|
370
376
|
]
|
|
371
377
|
}
|
|
372
378
|
};
|
|
373
|
-
|
|
374
|
-
'configuration/entityTypes/HCP/attributes/Nested1/attributes/NestedCategory2'
|
|
375
|
-
|
|
376
|
-
user = setUp({ entity: entity }).user;
|
|
379
|
+
hiddenAttributes = {
|
|
380
|
+
'entities/uri_e': ['configuration/entityTypes/HCP/attributes/Nested1/attributes/NestedCategory2']
|
|
381
|
+
};
|
|
382
|
+
user = setUp({ entity: entity }, hiddenAttributes).user;
|
|
377
383
|
return [4 /*yield*/, user.click(screen.getByTestId('arrow-expand-button'))];
|
|
378
384
|
case 1:
|
|
379
385
|
_a.sent();
|
|
@@ -22,11 +22,13 @@ import { EntitySelector } from '../../EntitySelector';
|
|
|
22
22
|
import { EditModeAttributesList } from '../../EditModeAttributesList';
|
|
23
23
|
import { withContext } from '../../HOCs';
|
|
24
24
|
import { ConfigPermissionsContextProvider, isHighlightedErrorType, ScrollToElementContext, useMdmAction, useMdmAuthoringItemsByEntityType, useMdmEntity, useMdmGlobalSearchRequestOptions, useMdmInitialConnection, useMdmInitialConnectionTempEntity, useMdmModifiedEntities, useMdmModifiedEntity, useMdmProfileErrors, useMdmEntityUri } from '../../contexts';
|
|
25
|
+
import { HiddenAttributesContext } from '../../contexts/HiddenAttributesContext';
|
|
25
26
|
import { useScrollToAttributeError } from '../../hooks';
|
|
26
27
|
import { useStyles } from './styles';
|
|
27
28
|
var areRelatedEntitiesChanged = function (initial, actual) {
|
|
28
29
|
return initial.length !== actual.length || initial.some(function (_, i) { return initial[i] !== actual[i]; });
|
|
29
30
|
};
|
|
31
|
+
var emptyHiddenAttributes = {};
|
|
30
32
|
var RelationEditor = function (_a) {
|
|
31
33
|
var _b;
|
|
32
34
|
var connection = _a.connection, config = _a.config, mode = _a.mode, metadata = _a.metadata, highlightedError = _a.highlightedError;
|
|
@@ -194,7 +196,8 @@ var RelationEditor = function (_a) {
|
|
|
194
196
|
_b[styles.dense] = errorMessage ||
|
|
195
197
|
(connection.entity && isTempUri(connection.entity.entityUri)),
|
|
196
198
|
_b)), entity: connection.entity || {}, entityTypesUris: getEntityTypesUris() || [], globalSearchRequestOptions: globalSearchRequestOptions, mode: mode, onChange: onChangeEntity, onCreate: canCreateNewEntity ? onCreateEntity : undefined, metadata: metadata, attributeTypesSelectionStrategy: relationEditorAttributeTypesSelectionStrategy }))),
|
|
197
|
-
React.createElement(
|
|
199
|
+
React.createElement(HiddenAttributesContext.Provider, { value: emptyHiddenAttributes },
|
|
200
|
+
React.createElement(EditModeAttributesList, { className: styles.item, attrTypes: firstLevelRelationAttrTypes, entity: attributeListEntity, showEmptyEditors: true, mode: mode, parentUri: relationUri, onAddAttributes: onAddAttributes, onChangeAttribute: onChangeAttribute, onDeleteAttribute: onDeleteAttribute }))))),
|
|
198
201
|
React.createElement("div", { className: styles.actionButtons },
|
|
199
202
|
React.createElement(Button, { onClick: onCancel }, i18n.text('Cancel')),
|
|
200
203
|
React.createElement(Button, { color: "primary", disabled: !hasChanges, onClick: onApply }, i18n.text('Apply')))));
|
|
@@ -139,4 +139,4 @@ export declare const useMdmListener: <T extends "expandInvalidRelatonsListener"
|
|
|
139
139
|
cleanseLoadingListener: (callback: (value: boolean) => void) => (action: import("../..").AnyAction) => void;
|
|
140
140
|
searchNavigationListener: (action: import("../..").AnyAction, state: any, dispatch: (action: import("../..").AnyAction) => void) => void;
|
|
141
141
|
}>[T];
|
|
142
|
-
export declare const useMdmHiddenAttributes: (
|
|
142
|
+
export declare const useMdmHiddenAttributes: () => {};
|
|
@@ -150,6 +150,7 @@ export var useMdmAction = function (action) {
|
|
|
150
150
|
export var useMdmListener = function (listener) {
|
|
151
151
|
return useMdmModuleListenersContext(function (context) { return context[listener]; });
|
|
152
152
|
};
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
var emptyHiddenAttributesObject = {};
|
|
154
|
+
export var useMdmHiddenAttributes = function () {
|
|
155
|
+
return useMdmModuleValuesContext(function (context) { return context.hiddenAttributes || emptyHiddenAttributesObject; });
|
|
155
156
|
};
|
|
@@ -6,8 +6,8 @@ export declare enum ScrollType {
|
|
|
6
6
|
NewView = "NewView"
|
|
7
7
|
}
|
|
8
8
|
type ScrollToElementContextProps = {
|
|
9
|
-
element: AttributeError | AttributeType | string;
|
|
10
|
-
type: ScrollType;
|
|
9
|
+
element: AttributeError | AttributeType | string | null;
|
|
10
|
+
type: ScrollType | null;
|
|
11
11
|
highlightError?: (element: AttributeError) => void;
|
|
12
12
|
highlightAttribute?: (element: AttributeType) => void;
|
|
13
13
|
highlightView?: (element: string) => void;
|
package/esm/contexts/index.d.ts
CHANGED
|
@@ -34,4 +34,5 @@ export { ConfigPermissionsContext, ConfigPermissionsContextProvider, useAttribut
|
|
|
34
34
|
export * from './MdmModuleContext';
|
|
35
35
|
export { ReloadDataProvider, useReloadData } from './ReloadDataContext';
|
|
36
36
|
export { SegmentationContext } from './SegmentationContext';
|
|
37
|
+
export { HiddenAttributesContext } from './HiddenAttributesContext';
|
|
37
38
|
export * from './MaskedAttributesContext';
|
package/esm/contexts/index.js
CHANGED
|
@@ -34,4 +34,5 @@ export { ConfigPermissionsContext, ConfigPermissionsContextProvider, useAttribut
|
|
|
34
34
|
export * from './MdmModuleContext';
|
|
35
35
|
export { ReloadDataProvider, useReloadData } from './ReloadDataContext';
|
|
36
36
|
export { SegmentationContext } from './SegmentationContext';
|
|
37
|
+
export { HiddenAttributesContext } from './HiddenAttributesContext';
|
|
37
38
|
export * from './MaskedAttributesContext';
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export var DEFAULT_MIN_DATE = new Date(
|
|
2
|
-
export var DEFAULT_MAX_DATE = new Date(
|
|
3
|
-
export var DEFAULT_MAX_DATE_IN_POPUP = new Date(
|
|
1
|
+
export var DEFAULT_MIN_DATE = new Date(1900, 0, 1, 0, 0, 0, 0);
|
|
2
|
+
export var DEFAULT_MAX_DATE = new Date(9999, 11, 31, 23, 59, 59, 999);
|
|
3
|
+
export var DEFAULT_MAX_DATE_IN_POPUP = new Date(2099, 11, 31, 23, 59, 59, 999);
|
|
@@ -24,7 +24,8 @@ export var useHiddenAttributes = function () {
|
|
|
24
24
|
var entityUri = entity === null || entity === void 0 ? void 0 : entity.uri;
|
|
25
25
|
var updateHiddenAttributes = useMdmAction('updateHiddenAttributes');
|
|
26
26
|
var resetHiddenAttributes = useMdmAction('resetHiddenAttributes');
|
|
27
|
-
var hiddenAttributes = useMdmHiddenAttributes(
|
|
27
|
+
var hiddenAttributes = useMdmHiddenAttributes();
|
|
28
|
+
var currentEntityHiddenAttributes = useMemo(function () { return hiddenAttributes[entityUri] || []; }, [hiddenAttributes, entityUri]);
|
|
28
29
|
var ruleBasedAttributes = useMemo(function () { return getRuleBasedAttributes(metadata, entity === null || entity === void 0 ? void 0 : entity.type); }, [metadata, entity === null || entity === void 0 ? void 0 : entity.type]);
|
|
29
30
|
var parsedRuleBasedAttributes = useMemo(function () {
|
|
30
31
|
return ruleBasedAttributes.map(function (rule) {
|
|
@@ -50,7 +51,7 @@ export var useHiddenAttributes = function () {
|
|
|
50
51
|
}, [rulesToCheck, entity, showAttributeURIs]);
|
|
51
52
|
useEffect(function () {
|
|
52
53
|
if (entityUri && (addedHiddenAttributes.length || showAttributeURIs.length)) {
|
|
53
|
-
updateHiddenAttributes(entityUri, without(showAttributeURIs,
|
|
54
|
+
updateHiddenAttributes(entityUri, without(showAttributeURIs, currentEntityHiddenAttributes).concat(addedHiddenAttributes));
|
|
54
55
|
}
|
|
55
56
|
}, [addedHiddenAttributes, showAttributeURIs, entityUri]);
|
|
56
57
|
useEffect(function () { return function () { return resetHiddenAttributes(entityUri); }; }, [entityUri]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1866",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE FILE",
|
|
5
5
|
"main": "./cjs/index.js",
|
|
6
6
|
"module": "./esm/index.js",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"@fluentui/react-context-selector": "^9.1.26",
|
|
9
9
|
"@react-google-maps/api": "2.7.0",
|
|
10
10
|
"@react-sigma/core": "3.4.0",
|
|
11
|
-
"@reltio/mdm-sdk": "^1.4.
|
|
11
|
+
"@reltio/mdm-sdk": "^1.4.1809",
|
|
12
12
|
"classnames": "^2.2.5",
|
|
13
13
|
"d3-cloud": "^1.2.5",
|
|
14
14
|
"d3-geo": "^2.0.1",
|