@reltio/components 1.4.1850 → 1.4.1852
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 +6 -3
- package/cjs/EditModeAttributesView/EditModeAttributesView.test.js +218 -24
- package/cjs/ReadOnlyAttributesList/ReadOnlyAttributesList.js +4 -1
- package/cjs/ReadOnlyAttributesView/ReadOnlyAttributesView.js +1 -9
- package/cjs/ReadOnlyAttributesView/ReadOnlyAttributesView.test.js +113 -104
- package/cjs/contexts/MdmModuleContext/context.d.ts +6 -0
- package/cjs/contexts/MdmModuleContext/hooks.d.ts +4 -1
- package/cjs/contexts/MdmModuleContext/hooks.js +5 -1
- package/cjs/contexts/MdmModuleContext/index.d.ts +1 -1
- package/cjs/contexts/MdmModuleContext/index.js +2 -1
- package/cjs/hooks/index.d.ts +1 -0
- package/cjs/hooks/index.js +3 -1
- package/cjs/hooks/useHiddenAttributes/helpers.d.ts +7 -0
- package/cjs/hooks/useHiddenAttributes/helpers.js +22 -0
- package/cjs/hooks/useHiddenAttributes/useChangedAttributes.d.ts +2 -0
- package/cjs/hooks/useHiddenAttributes/useChangedAttributes.js +37 -0
- package/cjs/hooks/useHiddenAttributes/useHiddenAttributes.d.ts +1 -0
- package/cjs/hooks/useHiddenAttributes/useHiddenAttributes.js +61 -0
- package/cjs/hooks/useHiddenAttributes/useHiddenAttributes.test.d.ts +1 -0
- package/cjs/hooks/useHiddenAttributes/useHiddenAttributes.test.js +370 -0
- package/esm/EditModeAttributesList/EditModeAttributesList.js +6 -3
- package/esm/EditModeAttributesView/EditModeAttributesView.test.js +219 -25
- package/esm/ReadOnlyAttributesList/ReadOnlyAttributesList.js +4 -1
- package/esm/ReadOnlyAttributesView/ReadOnlyAttributesView.js +2 -10
- package/esm/ReadOnlyAttributesView/ReadOnlyAttributesView.test.js +114 -105
- package/esm/contexts/MdmModuleContext/context.d.ts +6 -0
- package/esm/contexts/MdmModuleContext/hooks.d.ts +4 -1
- package/esm/contexts/MdmModuleContext/hooks.js +3 -0
- package/esm/contexts/MdmModuleContext/index.d.ts +1 -1
- package/esm/contexts/MdmModuleContext/index.js +1 -1
- package/esm/hooks/index.d.ts +1 -0
- package/esm/hooks/index.js +1 -0
- package/esm/hooks/useHiddenAttributes/helpers.d.ts +7 -0
- package/esm/hooks/useHiddenAttributes/helpers.js +17 -0
- package/esm/hooks/useHiddenAttributes/useChangedAttributes.d.ts +2 -0
- package/esm/hooks/useHiddenAttributes/useChangedAttributes.js +33 -0
- package/esm/hooks/useHiddenAttributes/useHiddenAttributes.d.ts +1 -0
- package/esm/hooks/useHiddenAttributes/useHiddenAttributes.js +57 -0
- package/esm/hooks/useHiddenAttributes/useHiddenAttributes.test.d.ts +1 -0
- package/esm/hooks/useHiddenAttributes/useHiddenAttributes.test.js +368 -0
- package/package.json +2 -2
|
@@ -18,10 +18,13 @@ 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 { useMdmHiddenAttributes } from '../contexts';
|
|
21
22
|
var ReadOnlyAttributesList = function (_a) {
|
|
22
23
|
var attrTypes = _a.attrTypes, entity = _a.entity, parentUri = _a.parentUri, drawLines = _a.drawLines, children = _a.children, className = _a.className, max = _a.max, _b = _a.alwaysVisibleTypeUris, alwaysVisibleTypeUris = _b === void 0 ? ALWAYS_VISIBLE_TYPE_URIS : _b, showNonOv = _a.showNonOv;
|
|
24
|
+
var hiddenAttributes = useMdmHiddenAttributes();
|
|
25
|
+
var filteredAttrTypes = useMemo(function () { return attrTypes.filter(function (attrType) { return !hiddenAttributes.includes(attrType.uri); }); }, [attrTypes, hiddenAttributes]);
|
|
23
26
|
var _c = useState(max || Infinity), visibleValuesCount = _c[0], setVisibleValuesCount = _c[1];
|
|
24
|
-
var pagersData = useMemo(function () { return getAttributesListForReadMode(
|
|
27
|
+
var pagersData = useMemo(function () { return getAttributesListForReadMode(filteredAttrTypes, entity, showNonOv); }, [filteredAttrTypes, entity, showNonOv]);
|
|
25
28
|
var _d = useMemo(function () { return splitPagersData(alwaysVisibleTypeUris, pagersData); }, [pagersData, alwaysVisibleTypeUris]), alwaysVisiblePagersData = _d[0], regularPagersData = _d[1];
|
|
26
29
|
var visibleAttributePagersData = regularPagersData.slice(0, visibleValuesCount);
|
|
27
30
|
var showMore = max && visibleAttributePagersData.length < regularPagersData.length;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { useMemo } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { getAttributesListForReadMode, getRuleBasedAttributes, isEmptyValue, getHiddenDynamicAttributes } from '@reltio/mdm-sdk';
|
|
2
|
+
import { getAttributesListForReadMode, isEmptyValue } from '@reltio/mdm-sdk';
|
|
4
3
|
import classnames from 'classnames';
|
|
5
4
|
import i18n from 'ui-i18n';
|
|
6
5
|
import Box from '@mui/material/Box';
|
|
@@ -19,14 +18,7 @@ export var ReadOnlyAttributesView = function (_a) {
|
|
|
19
18
|
var styles = useStyles();
|
|
20
19
|
var metadata = useMdmMetadata();
|
|
21
20
|
var pivotingAttributes = useMdmPivotingAttributes();
|
|
22
|
-
var filteredAttrTypes = useMemo(function () {
|
|
23
|
-
var dynamicRules = getRuleBasedAttributes(metadata, entity.type);
|
|
24
|
-
var hiddenAttributes = getHiddenDynamicAttributes(dynamicRules, entity);
|
|
25
|
-
return pipe(getFilteredAttrTypes, reject(function (_a) {
|
|
26
|
-
var uri = _a.uri;
|
|
27
|
-
return hiddenAttributes.includes(uri);
|
|
28
|
-
}))(metadata, entity.type, includeUris, excludeUris, hiddenAttributes);
|
|
29
|
-
}, [excludeUris, includeUris, metadata, entity]);
|
|
21
|
+
var filteredAttrTypes = useMemo(function () { return getFilteredAttrTypes(metadata, entity.type, includeUris, excludeUris); }, [excludeUris, includeUris, metadata, entity]);
|
|
30
22
|
var attributesCount = attributesCountProp || DEFAULT_ATTRIBUTES_COUNT;
|
|
31
23
|
var attributesList = getAttributesListForReadMode(filteredAttrTypes, entity);
|
|
32
24
|
var isShowAttributeList = attributesList.filter(function (_a) {
|
|
@@ -9,6 +9,42 @@ var __assign = (this && this.__assign) || function () {
|
|
|
9
9
|
};
|
|
10
10
|
return __assign.apply(this, arguments);
|
|
11
11
|
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
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;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
12
48
|
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
13
49
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
14
50
|
if (ar || !(i in from)) {
|
|
@@ -21,6 +57,7 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
21
57
|
import React from 'react';
|
|
22
58
|
import { shallow } from 'enzyme';
|
|
23
59
|
import { render, screen } from '@testing-library/react';
|
|
60
|
+
import userEvent from '@testing-library/user-event';
|
|
24
61
|
import { EntityAttrTypes } from '@reltio/mdm-sdk';
|
|
25
62
|
import Typography from '@mui/material/Typography';
|
|
26
63
|
import { ReadOnlyAttributesView } from './ReadOnlyAttributesView';
|
|
@@ -28,8 +65,8 @@ import { BasicView } from '../BasicView';
|
|
|
28
65
|
import { ReadOnlyAttributesList } from '../ReadOnlyAttributesList';
|
|
29
66
|
import { FacetViewHeader } from '../FacetViewHeader';
|
|
30
67
|
import { PivotingAttributeContext } from '../contexts/PivotingAttributeContext';
|
|
31
|
-
import { useMdmMetadata, useMdmPivotingAttributes } from '../contexts/MdmModuleContext';
|
|
32
|
-
jest.mock('../contexts/MdmModuleContext', function () { return (__assign(__assign({}, jest.requireActual('../contexts/MdmModuleContext')), { useMdmMetadata: jest.fn(), useMdmPivotingAttributes: jest.fn() })); });
|
|
68
|
+
import { useMdmHiddenAttributes, useMdmMetadata, useMdmPivotingAttributes } from '../contexts/MdmModuleContext';
|
|
69
|
+
jest.mock('../contexts/MdmModuleContext', function () { return (__assign(__assign({}, jest.requireActual('../contexts/MdmModuleContext')), { useMdmMetadata: jest.fn(), useMdmPivotingAttributes: jest.fn(), useMdmHiddenAttributes: jest.fn() })); });
|
|
33
70
|
describe('ReadOnlyAttributesView tests', function () {
|
|
34
71
|
var metadata = {
|
|
35
72
|
entityTypes: [
|
|
@@ -203,8 +240,8 @@ describe('ReadOnlyAttributesView tests', function () {
|
|
|
203
240
|
var provider = component.find(PivotingAttributeContext.Provider);
|
|
204
241
|
expect(provider.prop('value')).toEqual(pivotingAttributes);
|
|
205
242
|
});
|
|
206
|
-
describe('
|
|
207
|
-
var
|
|
243
|
+
describe('rule based attributes', function () {
|
|
244
|
+
var metadata = {
|
|
208
245
|
entityTypes: [
|
|
209
246
|
{
|
|
210
247
|
uri: 'configuration/entityTypes/HCP',
|
|
@@ -228,93 +265,38 @@ describe('ReadOnlyAttributesView tests', function () {
|
|
|
228
265
|
name: 'Category4',
|
|
229
266
|
type: 'String',
|
|
230
267
|
uri: 'configuration/entityTypes/HCP/attributes/Category4'
|
|
231
|
-
}
|
|
232
|
-
],
|
|
233
|
-
ruleBasedAttributes: [
|
|
234
|
-
{
|
|
235
|
-
uri: 'configuration/entityTypes/HCP/ruleBasedAttributes/DynamicRule1',
|
|
236
|
-
label: 'Dynamic Rule 1',
|
|
237
|
-
description: 'Dynamic Attributes Rule 1',
|
|
238
|
-
name: 'DynamicRule1',
|
|
239
|
-
type: 'Dynamic',
|
|
240
|
-
controlFunction: {
|
|
241
|
-
expression: "listEquals(attributes.Category1.value, 'category1_value1') and listEquals(attributes.Category2.value, 'category2_value1', 'category2_value2')",
|
|
242
|
-
showAttributeURI: [
|
|
243
|
-
'configuration/entityTypes/HCP/attributes/Category3',
|
|
244
|
-
'configuration/entityTypes/HCP/attributes/Category4'
|
|
245
|
-
]
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
uri: 'configuration/entityTypes/HCP/ruleBasedAttributes/DynamicRule2',
|
|
250
|
-
label: 'Dynamic Rule 2',
|
|
251
|
-
description: 'Dynamic Attributes Rule 2',
|
|
252
|
-
name: 'DynamicRule2',
|
|
253
|
-
type: 'Dynamic',
|
|
254
|
-
controlFunction: {
|
|
255
|
-
expression: "listEquals(attributes.Category1.value, 'category1_value1')",
|
|
256
|
-
showAttributeURI: ['configuration/entityTypes/HCP/attributes/Category2']
|
|
257
|
-
}
|
|
258
268
|
},
|
|
259
269
|
{
|
|
260
|
-
|
|
261
|
-
label: '
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
270
|
+
name: 'Nested1',
|
|
271
|
+
label: 'Nested1',
|
|
272
|
+
type: 'Nested',
|
|
273
|
+
uri: 'configuration/entityTypes/HCP/attributes/Nested1',
|
|
274
|
+
attributes: [
|
|
275
|
+
{
|
|
276
|
+
name: 'NestedCategory1',
|
|
277
|
+
type: 'String',
|
|
278
|
+
uri: 'configuration/entityTypes/HCP/attributes/Nested1/attributes/NestedCategory1'
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
name: 'NestedCategory2',
|
|
282
|
+
type: 'String',
|
|
283
|
+
uri: 'configuration/entityTypes/HCP/attributes/Nested1/attributes/NestedCategory2'
|
|
284
|
+
}
|
|
285
|
+
]
|
|
269
286
|
}
|
|
270
287
|
]
|
|
271
288
|
}
|
|
272
289
|
]
|
|
273
290
|
};
|
|
274
291
|
var setUp = function (props) {
|
|
275
|
-
|
|
292
|
+
var user = userEvent.setup();
|
|
293
|
+
return __assign(__assign({}, render(React.createElement(ReadOnlyAttributesView, __assign({}, props)))), { user: user });
|
|
276
294
|
};
|
|
277
295
|
beforeAll(function () {
|
|
278
|
-
useMdmMetadata.mockReturnValue(
|
|
279
|
-
|
|
280
|
-
it('should hide attributes which does not fit dynamic rules', function () {
|
|
281
|
-
var entity = {
|
|
282
|
-
type: 'configuration/entityTypes/HCP',
|
|
283
|
-
uri: 'entities/uri_e',
|
|
284
|
-
attributes: {
|
|
285
|
-
Category1: [
|
|
286
|
-
{
|
|
287
|
-
uri: 'entities/uri_e/attributes/uri1',
|
|
288
|
-
value: 'category1_value1_diff'
|
|
289
|
-
}
|
|
290
|
-
],
|
|
291
|
-
Category2: [
|
|
292
|
-
{
|
|
293
|
-
uri: 'entities/uri_e/attributes/uri2',
|
|
294
|
-
value: 'category2_value1_diff'
|
|
295
|
-
}
|
|
296
|
-
],
|
|
297
|
-
Category3: [
|
|
298
|
-
{
|
|
299
|
-
uri: 'entities/uri_e/attributes/uri3',
|
|
300
|
-
value: 'category3_value1'
|
|
301
|
-
}
|
|
302
|
-
],
|
|
303
|
-
Category4: [
|
|
304
|
-
{
|
|
305
|
-
uri: 'entities/uri_e/attributes/uri4',
|
|
306
|
-
value: 'category4_value1'
|
|
307
|
-
}
|
|
308
|
-
]
|
|
309
|
-
}
|
|
310
|
-
};
|
|
311
|
-
setUp({ entity: entity });
|
|
312
|
-
expect(screen.getByText('category1_value1_diff')).toBeInTheDocument();
|
|
313
|
-
expect(screen.queryByText('category2_value1_diff')).not.toBeInTheDocument();
|
|
314
|
-
expect(screen.queryByText('category3_value1')).not.toBeInTheDocument();
|
|
315
|
-
expect(screen.queryByText('category4_value1')).not.toBeInTheDocument();
|
|
296
|
+
useMdmMetadata.mockReturnValue(metadata);
|
|
297
|
+
useMdmHiddenAttributes.mockReturnValue([]);
|
|
316
298
|
});
|
|
317
|
-
it('should
|
|
299
|
+
it('should hide attributes', function () {
|
|
318
300
|
var entity = {
|
|
319
301
|
type: 'configuration/entityTypes/HCP',
|
|
320
302
|
uri: 'entities/uri_e',
|
|
@@ -345,34 +327,61 @@ describe('ReadOnlyAttributesView tests', function () {
|
|
|
345
327
|
]
|
|
346
328
|
}
|
|
347
329
|
};
|
|
330
|
+
useMdmHiddenAttributes.mockReturnValue([
|
|
331
|
+
'configuration/entityTypes/HCP/attributes/Category2',
|
|
332
|
+
'configuration/entityTypes/HCP/attributes/Category3',
|
|
333
|
+
'configuration/entityTypes/HCP/attributes/Category4'
|
|
334
|
+
]);
|
|
348
335
|
setUp({ entity: entity });
|
|
349
336
|
expect(screen.getByText('category1_value1')).toBeInTheDocument();
|
|
350
|
-
expect(screen.
|
|
351
|
-
expect(screen.
|
|
352
|
-
expect(screen.
|
|
337
|
+
expect(screen.queryByText('category2_value1')).not.toBeInTheDocument();
|
|
338
|
+
expect(screen.queryByText('category3_value1')).not.toBeInTheDocument();
|
|
339
|
+
expect(screen.queryByText('category4_value1')).not.toBeInTheDocument();
|
|
353
340
|
});
|
|
354
|
-
it('should
|
|
355
|
-
var entity
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
uri: 'entities/uri_e
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
341
|
+
it('should hide nested attributes', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
342
|
+
var entity, user;
|
|
343
|
+
return __generator(this, function (_a) {
|
|
344
|
+
switch (_a.label) {
|
|
345
|
+
case 0:
|
|
346
|
+
entity = {
|
|
347
|
+
type: 'configuration/entityTypes/HCP',
|
|
348
|
+
uri: 'entities/uri_e',
|
|
349
|
+
attributes: {
|
|
350
|
+
Nested1: [
|
|
351
|
+
{
|
|
352
|
+
uri: 'entities/uri_e/attributes/nesteduri1',
|
|
353
|
+
value: {
|
|
354
|
+
NestedCategory1: [
|
|
355
|
+
{
|
|
356
|
+
ov: true,
|
|
357
|
+
uri: 'entities/uri_e/attributes/nesteduri1/attributes/nestedcaturi1',
|
|
358
|
+
value: 'nested_category1_value'
|
|
359
|
+
}
|
|
360
|
+
],
|
|
361
|
+
NestedCategory2: [
|
|
362
|
+
{
|
|
363
|
+
ov: true,
|
|
364
|
+
uri: 'entities/uri_e/attributes/nesteduri1/attributes/nestedcaturi2',
|
|
365
|
+
value: 'nested_category2_value1'
|
|
366
|
+
}
|
|
367
|
+
]
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
]
|
|
371
|
+
}
|
|
372
|
+
};
|
|
373
|
+
useMdmHiddenAttributes.mockReturnValue([
|
|
374
|
+
'configuration/entityTypes/HCP/attributes/Nested1/attributes/NestedCategory2'
|
|
375
|
+
]);
|
|
376
|
+
user = setUp({ entity: entity }).user;
|
|
377
|
+
return [4 /*yield*/, user.click(screen.getByTestId('arrow-expand-button'))];
|
|
378
|
+
case 1:
|
|
379
|
+
_a.sent();
|
|
380
|
+
expect(screen.getByText('nested_category1_value')).toBeInTheDocument();
|
|
381
|
+
expect(screen.queryByText('nested_category2_value1')).not.toBeInTheDocument();
|
|
382
|
+
return [2 /*return*/];
|
|
371
383
|
}
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
expect(screen.getByText('category1_value2')).toBeInTheDocument();
|
|
375
|
-
expect(screen.getByText('category4_value1')).toBeInTheDocument();
|
|
376
|
-
});
|
|
384
|
+
});
|
|
385
|
+
}); });
|
|
377
386
|
});
|
|
378
387
|
});
|
|
@@ -32,6 +32,7 @@ export type MdmModuleValuesContextProps = Partial<{
|
|
|
32
32
|
mode: Mode;
|
|
33
33
|
isViewMode: boolean;
|
|
34
34
|
isEditableMode: boolean;
|
|
35
|
+
hiddenAttributes: string[];
|
|
35
36
|
historyDiff: HistoryDiff;
|
|
36
37
|
historyMode: HistoryMode;
|
|
37
38
|
historySlice: HistorySlice;
|
|
@@ -114,6 +115,8 @@ export type MdmModuleActionsContextProps = Partial<{
|
|
|
114
115
|
errorsSet: (payload: AttributeError[]) => void;
|
|
115
116
|
addRelation: (id: string, connection: Connection) => void;
|
|
116
117
|
editRelation: (id: string, connection: Connection) => void;
|
|
118
|
+
updateHiddenAttributes: (uri: string, hiddenAttributes: string[]) => void;
|
|
119
|
+
resetHiddenAttributes: (uri: string) => void;
|
|
117
120
|
}>;
|
|
118
121
|
export type MdmModuleListenersContextProps = Partial<{
|
|
119
122
|
expandInvalidRelatonsListener: (callback: () => void) => (action: any) => void;
|
|
@@ -180,6 +183,8 @@ export declare const MdmModuleActionsContext: import("@fluentui/react-context-se
|
|
|
180
183
|
errorsSet: (payload: AttributeError[]) => void;
|
|
181
184
|
addRelation: (id: string, connection: Connection) => void;
|
|
182
185
|
editRelation: (id: string, connection: Connection) => void;
|
|
186
|
+
updateHiddenAttributes: (uri: string, hiddenAttributes: string[]) => void;
|
|
187
|
+
resetHiddenAttributes: (uri: string) => void;
|
|
183
188
|
}>>;
|
|
184
189
|
export declare const MdmModuleValuesContext: import("@fluentui/react-context-selector").Context<Partial<{
|
|
185
190
|
autoCloseInterval: number;
|
|
@@ -213,6 +218,7 @@ export declare const MdmModuleValuesContext: import("@fluentui/react-context-sel
|
|
|
213
218
|
mode: Mode;
|
|
214
219
|
isViewMode: boolean;
|
|
215
220
|
isEditableMode: boolean;
|
|
221
|
+
hiddenAttributes: string[];
|
|
216
222
|
historyDiff: HistoryDiff;
|
|
217
223
|
historyMode: HistoryMode;
|
|
218
224
|
historySlice: HistorySlice;
|
|
@@ -71,7 +71,7 @@ export declare const useMdmDependentLookupEditorContext: (attributeValue: Simple
|
|
|
71
71
|
};
|
|
72
72
|
export declare const useMdmGlobalSearchRequestOptions: (omittingFields?: string[]) => import("@reltio/mdm-sdk").GlobalSearchRequestOptions;
|
|
73
73
|
export declare const useMdmAuthoringItemsByEntityType: (entityTypeUri: string) => import("@reltio/mdm-sdk").AuthoringItem[];
|
|
74
|
-
export declare const useMdmAction: <T extends "openSearch" | "openHistoryEvent" | "openConsoleApp" | "addAttributes" | "modifyAttribute" | "removeAttribute" | "entityDeleted" | "entityCreated" | "errorDeactivated" | "requestNextPageOfAttributeValues" | "openEntity" | "setDefaultProfilePicForModifiedEntity" | "setDefaultProfilePicForEntity" | "dependentLookupsEditorTouched" | "openPivotingPerspective" | "lookupsLoaded" | "lookupsForTypeResolved" | "errorSet" | "setHistoryMode" | "modeUpdated" | "setHistoryEvent" | "clearHistoryEvent" | "clearHistoryDiff" | "setHistoryDiff" | "setHistorySlice" | "updateSearchNavigationDataFields" | "openPerspective" | "entityDeletionFinished" | "loadEntity" | "updateSearchNavigationDataOnMerge" | "lookupsListResolved" | "relationsLoaded" | "setInitialInfo" | "setRelationType" | "closeRelationEditor" | "openRelationEditor" | "setRelationEntity" | "errorsSet" | "addRelation" | "editRelation">(action: T) => Partial<{
|
|
74
|
+
export declare const useMdmAction: <T extends "openSearch" | "openHistoryEvent" | "openConsoleApp" | "addAttributes" | "modifyAttribute" | "removeAttribute" | "entityDeleted" | "entityCreated" | "errorDeactivated" | "requestNextPageOfAttributeValues" | "openEntity" | "setDefaultProfilePicForModifiedEntity" | "setDefaultProfilePicForEntity" | "dependentLookupsEditorTouched" | "openPivotingPerspective" | "lookupsLoaded" | "lookupsForTypeResolved" | "errorSet" | "setHistoryMode" | "modeUpdated" | "setHistoryEvent" | "clearHistoryEvent" | "clearHistoryDiff" | "setHistoryDiff" | "setHistorySlice" | "updateSearchNavigationDataFields" | "openPerspective" | "entityDeletionFinished" | "loadEntity" | "updateSearchNavigationDataOnMerge" | "lookupsListResolved" | "relationsLoaded" | "setInitialInfo" | "setRelationType" | "closeRelationEditor" | "openRelationEditor" | "setRelationEntity" | "errorsSet" | "addRelation" | "editRelation" | "updateHiddenAttributes" | "resetHiddenAttributes">(action: T) => Partial<{
|
|
75
75
|
openSearch: (payload: import("@reltio/mdm-sdk").SearchState) => void;
|
|
76
76
|
openHistoryEvent: (payload: {
|
|
77
77
|
entityUri: string;
|
|
@@ -131,9 +131,12 @@ export declare const useMdmAction: <T extends "openSearch" | "openHistoryEvent"
|
|
|
131
131
|
errorsSet: (payload: import("@reltio/mdm-sdk").AttributeError[]) => void;
|
|
132
132
|
addRelation: (id: string, connection: import("@reltio/mdm-sdk").Connection) => void;
|
|
133
133
|
editRelation: (id: string, connection: import("@reltio/mdm-sdk").Connection) => void;
|
|
134
|
+
updateHiddenAttributes: (uri: string, hiddenAttributes: string[]) => void;
|
|
135
|
+
resetHiddenAttributes: (uri: string) => void;
|
|
134
136
|
}>[T];
|
|
135
137
|
export declare const useMdmListener: <T extends "expandInvalidRelatonsListener" | "cleanseLoadingListener" | "searchNavigationListener">(listener: T) => Partial<{
|
|
136
138
|
expandInvalidRelatonsListener: (callback: () => void) => (action: any) => void;
|
|
137
139
|
cleanseLoadingListener: (callback: (value: boolean) => void) => (action: import("../..").AnyAction) => void;
|
|
138
140
|
searchNavigationListener: (action: import("../..").AnyAction, state: any, dispatch: (action: import("../..").AnyAction) => void) => void;
|
|
139
141
|
}>[T];
|
|
142
|
+
export declare const useMdmHiddenAttributes: (uri?: string) => any;
|
|
@@ -150,3 +150,6 @@ export var useMdmAction = function (action) {
|
|
|
150
150
|
export var useMdmListener = function (listener) {
|
|
151
151
|
return useMdmModuleListenersContext(function (context) { return context[listener]; });
|
|
152
152
|
};
|
|
153
|
+
export var useMdmHiddenAttributes = function (uri) {
|
|
154
|
+
return useMdmModuleValuesContext(function (context) { var _a, _b; return ((_a = context.hiddenAttributes) === null || _a === void 0 ? void 0 : _a[uri || ((_b = context.entity) === null || _b === void 0 ? void 0 : _b.uri)]) || []; });
|
|
155
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { MdmModuleProvider } from './provider';
|
|
2
|
-
export { useMdmAutoCloseInterval, useMdmUiError, useMdmWorkflowEnvironmentUrl, useMdmExportPath, useMdmAbsoluteImagePath, useMdmUiPath, useMdmDtssPath, useMdmServicesPath, useMdmWorkflowPath, useMdmImageServicePath, useMdmReltioPath, useMdmApiPath, useMdmCollaborationPath, useMdmImageAttributesFieldsOrder, useMdmShowEntityId, useMdmPivotingAttributes, useMdmDateMask, useMdmDateTimeMask, useMdmAttributesPresentation, useMdmMaxValuesInResponse, useMdmAttributesSortingStrategy, useMdmLookupAutocomplete, useMdmModifiedEntities, useMdmEntity, useMdmEntityUri, useMdmEntityWithDiff, useMdmEntityUriWithDataTenant, useMdmMode, useMdmIsViewMode, useMdmIsEditableMode, useMdmHistoryDiff, useMdmHistoryMode, useMdmHistorySlice, useMdmHistoryEvent, useMdmProfileLastLoadedTime, useMdmLookups, useMdmDependentLookups, useMdmMetadata, useMdmUser, useMdmUsername, useMdmUserRoles, useMdmTenantObject, useMdmTenant, useMdmTenantName, useMdmEnvironment, useMdmDataTenants, useMdmSearchNavigationData, useMdmSearchProviderData, useMdmIsCollaborationEnabled, useMdmIsWorkflowEnabled, useMdmProfileErrors, useMdmRelationsDrafts, useMdmModifiedEntityDefaultProfilePic, useMdmModifiedEntity, useMdmInitialConnectionTempEntity, useMdmInitialConnection, useMdmDependentLookupEditorState, useMdmActiveErrorsForAttributesPager, useMdmDependentLookupsStructureNode, useMdmAllRelationsToAddAndEdit, useMdmDependentLookupEditorContext, useMdmGlobalSearchRequestOptions, useMdmAuthoringItemsByEntityType, useMdmAction, useMdmListener, useMdmIsSourcesScreenEnabled } from './hooks';
|
|
2
|
+
export { useMdmAutoCloseInterval, useMdmUiError, useMdmWorkflowEnvironmentUrl, useMdmExportPath, useMdmAbsoluteImagePath, useMdmUiPath, useMdmDtssPath, useMdmServicesPath, useMdmWorkflowPath, useMdmImageServicePath, useMdmReltioPath, useMdmApiPath, useMdmCollaborationPath, useMdmImageAttributesFieldsOrder, useMdmShowEntityId, useMdmPivotingAttributes, useMdmDateMask, useMdmDateTimeMask, useMdmAttributesPresentation, useMdmMaxValuesInResponse, useMdmAttributesSortingStrategy, useMdmLookupAutocomplete, useMdmModifiedEntities, useMdmEntity, useMdmEntityUri, useMdmEntityWithDiff, useMdmEntityUriWithDataTenant, useMdmMode, useMdmIsViewMode, useMdmIsEditableMode, useMdmHistoryDiff, useMdmHistoryMode, useMdmHistorySlice, useMdmHistoryEvent, useMdmProfileLastLoadedTime, useMdmLookups, useMdmDependentLookups, useMdmMetadata, useMdmUser, useMdmUsername, useMdmUserRoles, useMdmTenantObject, useMdmTenant, useMdmTenantName, useMdmEnvironment, useMdmDataTenants, useMdmSearchNavigationData, useMdmSearchProviderData, useMdmIsCollaborationEnabled, useMdmIsWorkflowEnabled, useMdmProfileErrors, useMdmRelationsDrafts, useMdmModifiedEntityDefaultProfilePic, useMdmModifiedEntity, useMdmInitialConnectionTempEntity, useMdmInitialConnection, useMdmDependentLookupEditorState, useMdmActiveErrorsForAttributesPager, useMdmDependentLookupsStructureNode, useMdmAllRelationsToAddAndEdit, useMdmDependentLookupEditorContext, useMdmGlobalSearchRequestOptions, useMdmAuthoringItemsByEntityType, useMdmAction, useMdmListener, useMdmIsSourcesScreenEnabled, useMdmHiddenAttributes } from './hooks';
|
|
3
3
|
export type { MdmModuleActionsContextProps, MdmModuleValuesContextProps, MdmModuleListenersContextProps } from './context';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { MdmModuleProvider } from './provider';
|
|
2
|
-
export { useMdmAutoCloseInterval, useMdmUiError, useMdmWorkflowEnvironmentUrl, useMdmExportPath, useMdmAbsoluteImagePath, useMdmUiPath, useMdmDtssPath, useMdmServicesPath, useMdmWorkflowPath, useMdmImageServicePath, useMdmReltioPath, useMdmApiPath, useMdmCollaborationPath, useMdmImageAttributesFieldsOrder, useMdmShowEntityId, useMdmPivotingAttributes, useMdmDateMask, useMdmDateTimeMask, useMdmAttributesPresentation, useMdmMaxValuesInResponse, useMdmAttributesSortingStrategy, useMdmLookupAutocomplete, useMdmModifiedEntities, useMdmEntity, useMdmEntityUri, useMdmEntityWithDiff, useMdmEntityUriWithDataTenant, useMdmMode, useMdmIsViewMode, useMdmIsEditableMode, useMdmHistoryDiff, useMdmHistoryMode, useMdmHistorySlice, useMdmHistoryEvent, useMdmProfileLastLoadedTime, useMdmLookups, useMdmDependentLookups, useMdmMetadata, useMdmUser, useMdmUsername, useMdmUserRoles, useMdmTenantObject, useMdmTenant, useMdmTenantName, useMdmEnvironment, useMdmDataTenants, useMdmSearchNavigationData, useMdmSearchProviderData, useMdmIsCollaborationEnabled, useMdmIsWorkflowEnabled, useMdmProfileErrors, useMdmRelationsDrafts, useMdmModifiedEntityDefaultProfilePic, useMdmModifiedEntity, useMdmInitialConnectionTempEntity, useMdmInitialConnection, useMdmDependentLookupEditorState, useMdmActiveErrorsForAttributesPager, useMdmDependentLookupsStructureNode, useMdmAllRelationsToAddAndEdit, useMdmDependentLookupEditorContext, useMdmGlobalSearchRequestOptions, useMdmAuthoringItemsByEntityType, useMdmAction, useMdmListener, useMdmIsSourcesScreenEnabled } from './hooks';
|
|
2
|
+
export { useMdmAutoCloseInterval, useMdmUiError, useMdmWorkflowEnvironmentUrl, useMdmExportPath, useMdmAbsoluteImagePath, useMdmUiPath, useMdmDtssPath, useMdmServicesPath, useMdmWorkflowPath, useMdmImageServicePath, useMdmReltioPath, useMdmApiPath, useMdmCollaborationPath, useMdmImageAttributesFieldsOrder, useMdmShowEntityId, useMdmPivotingAttributes, useMdmDateMask, useMdmDateTimeMask, useMdmAttributesPresentation, useMdmMaxValuesInResponse, useMdmAttributesSortingStrategy, useMdmLookupAutocomplete, useMdmModifiedEntities, useMdmEntity, useMdmEntityUri, useMdmEntityWithDiff, useMdmEntityUriWithDataTenant, useMdmMode, useMdmIsViewMode, useMdmIsEditableMode, useMdmHistoryDiff, useMdmHistoryMode, useMdmHistorySlice, useMdmHistoryEvent, useMdmProfileLastLoadedTime, useMdmLookups, useMdmDependentLookups, useMdmMetadata, useMdmUser, useMdmUsername, useMdmUserRoles, useMdmTenantObject, useMdmTenant, useMdmTenantName, useMdmEnvironment, useMdmDataTenants, useMdmSearchNavigationData, useMdmSearchProviderData, useMdmIsCollaborationEnabled, useMdmIsWorkflowEnabled, useMdmProfileErrors, useMdmRelationsDrafts, useMdmModifiedEntityDefaultProfilePic, useMdmModifiedEntity, useMdmInitialConnectionTempEntity, useMdmInitialConnection, useMdmDependentLookupEditorState, useMdmActiveErrorsForAttributesPager, useMdmDependentLookupsStructureNode, useMdmAllRelationsToAddAndEdit, useMdmDependentLookupEditorContext, useMdmGlobalSearchRequestOptions, useMdmAuthoringItemsByEntityType, useMdmAction, useMdmListener, useMdmIsSourcesScreenEnabled, useMdmHiddenAttributes } from './hooks';
|
package/esm/hooks/index.d.ts
CHANGED
|
@@ -30,3 +30,4 @@ export { useExpandInvalidRelations } from './useExpandInvalidRelations';
|
|
|
30
30
|
export { useAutoFocus } from './useAutoFocus';
|
|
31
31
|
export { useRequestDCRReview } from './useRequestDCRReview';
|
|
32
32
|
export { useSavedSearchesRequest } from './useSavedSearchesRequest';
|
|
33
|
+
export { useHiddenAttributes } from './useHiddenAttributes/useHiddenAttributes';
|
package/esm/hooks/index.js
CHANGED
|
@@ -30,3 +30,4 @@ export { useExpandInvalidRelations } from './useExpandInvalidRelations';
|
|
|
30
30
|
export { useAutoFocus } from './useAutoFocus';
|
|
31
31
|
export { useRequestDCRReview } from './useRequestDCRReview';
|
|
32
32
|
export { useSavedSearchesRequest } from './useSavedSearchesRequest';
|
|
33
|
+
export { useHiddenAttributes } from './useHiddenAttributes/useHiddenAttributes';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { parseRuleBasedAttribute } from '@reltio/mdm-sdk';
|
|
2
|
+
type ParsedRuleBasedAttribute = ReturnType<typeof parseRuleBasedAttribute> & {
|
|
3
|
+
showAttributeURIs: string[];
|
|
4
|
+
};
|
|
5
|
+
export declare const findShowAttributeURIs: (changedAttributes: string[], parsedRules: ParsedRuleBasedAttribute[]) => string[];
|
|
6
|
+
export declare const findRulesToCheck: (showAttributeURIs: string[], parsedRules: ParsedRuleBasedAttribute[]) => ParsedRuleBasedAttribute[];
|
|
7
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { flatten, pipe, reduce, uniq } from 'ramda';
|
|
2
|
+
export var findShowAttributeURIs = function (changedAttributes, parsedRules) {
|
|
3
|
+
return pipe(reduce(function (changedShowAttributeURIs, _a) {
|
|
4
|
+
var controlAttributes = _a.controlAttributes, showAttributeURIs = _a.showAttributeURIs;
|
|
5
|
+
var hasChangedControlAttributes = (controlAttributes === null || controlAttributes === void 0 ? void 0 : controlAttributes.length) &&
|
|
6
|
+
controlAttributes.some(function (controlAttribute) { return changedAttributes.includes(controlAttribute); });
|
|
7
|
+
return hasChangedControlAttributes
|
|
8
|
+
? changedShowAttributeURIs.concat(showAttributeURIs)
|
|
9
|
+
: changedShowAttributeURIs;
|
|
10
|
+
}, []), flatten, uniq)(parsedRules);
|
|
11
|
+
};
|
|
12
|
+
export var findRulesToCheck = function (showAttributeURIs, parsedRules) {
|
|
13
|
+
return parsedRules.filter(function (_a) {
|
|
14
|
+
var ruleShowAttributeURIs = _a.showAttributeURIs;
|
|
15
|
+
return ruleShowAttributeURIs.some(function (showAttributeUri) { return showAttributeURIs.includes(showAttributeUri); });
|
|
16
|
+
});
|
|
17
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { attributeUriToSearchUri, getOvAttributeValuesByPathWithUri } from '@reltio/mdm-sdk';
|
|
2
|
+
import { flatten, isNil, join, pipe, pluck } from 'ramda';
|
|
3
|
+
import { useMemo, useRef } from 'react';
|
|
4
|
+
var getValues = function (controlAttribute, attributes) {
|
|
5
|
+
if (attributes === void 0) { attributes = {}; }
|
|
6
|
+
var searchUri = attributeUriToSearchUri(controlAttribute);
|
|
7
|
+
var attrPath = searchUri.replace('attributes.', '').split('.');
|
|
8
|
+
return flatten(getOvAttributeValuesByPathWithUri(attrPath, attributes));
|
|
9
|
+
};
|
|
10
|
+
var getValuesHash = pipe(pluck('value'), join('-'));
|
|
11
|
+
export var useChangedAttributes = function (attributes, controlAttributes) {
|
|
12
|
+
var previousAttributesValues = useRef();
|
|
13
|
+
var attributeValues = useMemo(function () {
|
|
14
|
+
return controlAttributes.reduce(function (values, controlAttribute) {
|
|
15
|
+
values[controlAttribute] = pipe(getValues, getValuesHash)(controlAttribute, attributes);
|
|
16
|
+
return values;
|
|
17
|
+
}, {}) || [];
|
|
18
|
+
}, [controlAttributes, attributes]);
|
|
19
|
+
var changedAttributes = useMemo(function () {
|
|
20
|
+
var attributeUris = Object.keys(attributeValues);
|
|
21
|
+
return previousAttributesValues.current
|
|
22
|
+
? attributeUris.reduce(function (changedAttributes, attributeUri) {
|
|
23
|
+
var attributeValue = attributeValues[attributeUri];
|
|
24
|
+
var previousAttributeValue = previousAttributesValues.current[attributeUri];
|
|
25
|
+
return isNil(previousAttributeValue) || previousAttributeValue !== attributeValue
|
|
26
|
+
? changedAttributes.concat(attributeUri)
|
|
27
|
+
: changedAttributes;
|
|
28
|
+
}, []) || []
|
|
29
|
+
: attributeUris;
|
|
30
|
+
}, [attributeValues]);
|
|
31
|
+
previousAttributesValues.current = attributeValues;
|
|
32
|
+
return changedAttributes;
|
|
33
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useHiddenAttributes: () => void;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { useEffect, useMemo } from 'react';
|
|
13
|
+
import { flatten, pipe, pluck, uniq, without } from 'ramda';
|
|
14
|
+
import { Mode, getRuleBasedAttributes, parseRuleBasedAttribute } from '@reltio/mdm-sdk';
|
|
15
|
+
import { useChangedAttributes } from './useChangedAttributes';
|
|
16
|
+
import { findRulesToCheck, findShowAttributeURIs } from './helpers';
|
|
17
|
+
import { useMdmHiddenAttributes, useMdmAction, useMdmEntity, useMdmMetadata, useMdmMode, useMdmModifiedEntity } from '../../contexts/MdmModuleContext/hooks';
|
|
18
|
+
export var useHiddenAttributes = function () {
|
|
19
|
+
var metadata = useMdmMetadata();
|
|
20
|
+
var mdmEntity = useMdmEntity();
|
|
21
|
+
var mode = useMdmMode();
|
|
22
|
+
var modifiedEntity = useMdmModifiedEntity(mdmEntity === null || mdmEntity === void 0 ? void 0 : mdmEntity.uri) || {};
|
|
23
|
+
var entity = mode === Mode.Viewing ? mdmEntity : modifiedEntity;
|
|
24
|
+
var entityUri = entity === null || entity === void 0 ? void 0 : entity.uri;
|
|
25
|
+
var updateHiddenAttributes = useMdmAction('updateHiddenAttributes');
|
|
26
|
+
var resetHiddenAttributes = useMdmAction('resetHiddenAttributes');
|
|
27
|
+
var hiddenAttributes = useMdmHiddenAttributes(entity === null || entity === void 0 ? void 0 : entity.uri);
|
|
28
|
+
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
|
+
var parsedRuleBasedAttributes = useMemo(function () {
|
|
30
|
+
return ruleBasedAttributes.map(function (rule) {
|
|
31
|
+
var _a;
|
|
32
|
+
return (__assign(__assign({}, parseRuleBasedAttribute(rule)), { showAttributeURIs: ((_a = rule === null || rule === void 0 ? void 0 : rule.controlFunction) === null || _a === void 0 ? void 0 : _a.showAttributeURI) || [] }));
|
|
33
|
+
});
|
|
34
|
+
}, [ruleBasedAttributes]);
|
|
35
|
+
var controlAttributes = useMemo(function () { return pipe(pluck('controlAttributes'), flatten, uniq)(parsedRuleBasedAttributes); }, [parsedRuleBasedAttributes]);
|
|
36
|
+
var changedAttributes = useChangedAttributes(entity === null || entity === void 0 ? void 0 : entity.attributes, controlAttributes);
|
|
37
|
+
var showAttributeURIs = useMemo(function () {
|
|
38
|
+
return changedAttributes.length ? findShowAttributeURIs(changedAttributes, parsedRuleBasedAttributes) : [];
|
|
39
|
+
}, [parsedRuleBasedAttributes, changedAttributes]);
|
|
40
|
+
var rulesToCheck = useMemo(function () {
|
|
41
|
+
return showAttributeURIs.length ? findRulesToCheck(showAttributeURIs, parsedRuleBasedAttributes) : [];
|
|
42
|
+
}, [parsedRuleBasedAttributes, showAttributeURIs]);
|
|
43
|
+
var addedHiddenAttributes = useMemo(function () {
|
|
44
|
+
return rulesToCheck.length
|
|
45
|
+
? rulesToCheck.reduce(function (hiddenAttributes, _a) {
|
|
46
|
+
var checkFn = _a.checkFn, showAttributeURIs = _a.showAttributeURIs;
|
|
47
|
+
return checkFn(entity) ? without(showAttributeURIs, hiddenAttributes) : hiddenAttributes;
|
|
48
|
+
}, showAttributeURIs)
|
|
49
|
+
: [];
|
|
50
|
+
}, [rulesToCheck, entity, showAttributeURIs]);
|
|
51
|
+
useEffect(function () {
|
|
52
|
+
if (entityUri && (addedHiddenAttributes.length || showAttributeURIs.length)) {
|
|
53
|
+
updateHiddenAttributes(entityUri, without(showAttributeURIs, hiddenAttributes).concat(addedHiddenAttributes));
|
|
54
|
+
}
|
|
55
|
+
}, [addedHiddenAttributes, showAttributeURIs, entityUri]);
|
|
56
|
+
useEffect(function () { return function () { return resetHiddenAttributes(entityUri); }; }, [entityUri]);
|
|
57
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|