@reltio/components 1.4.1961 → 1.4.1963
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/AttributesView/AttributesView.test.js +76 -2
- package/cjs/ReadOnlyAttributesPager/components/EmptyRenderer/EmptyRenderer.js +29 -1
- package/cjs/ReadOnlyAttributesView/ReadOnlyAttributesView.js +3 -1
- package/esm/AttributesView/AttributesView.test.js +77 -3
- package/esm/ReadOnlyAttributesPager/components/EmptyRenderer/EmptyRenderer.js +6 -1
- package/esm/ReadOnlyAttributesView/ReadOnlyAttributesView.js +4 -2
- package/package.json +1 -1
|
@@ -10,6 +10,42 @@ var __assign = (this && this.__assign) || function () {
|
|
|
10
10
|
};
|
|
11
11
|
return __assign.apply(this, arguments);
|
|
12
12
|
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
13
49
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
50
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
51
|
};
|
|
@@ -19,6 +55,7 @@ var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
|
19
55
|
var AttributesView_1 = require("./AttributesView");
|
|
20
56
|
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
|
|
21
57
|
var react_2 = require("@testing-library/react");
|
|
58
|
+
var user_event_1 = __importDefault(require("@testing-library/user-event"));
|
|
22
59
|
describe('AttributesView tests', function () {
|
|
23
60
|
var entity = {
|
|
24
61
|
type: 'configuration/entityTypes/HCP',
|
|
@@ -70,7 +107,8 @@ describe('AttributesView tests', function () {
|
|
|
70
107
|
var mdmDefaultValues = {
|
|
71
108
|
metadata: metadata,
|
|
72
109
|
modifiedEntities: { 'entities/02ZRRE9': entity },
|
|
73
|
-
dependentLookups: { editors: {}, structure: {}, initedTypeUris: [] }
|
|
110
|
+
dependentLookups: { editors: {}, structure: {}, initedTypeUris: [] },
|
|
111
|
+
controlAttributes: ['configuration/entityTypes/HCP/attributes/Phone']
|
|
74
112
|
};
|
|
75
113
|
var setUp = function (props, mdmValues) {
|
|
76
114
|
if (props === void 0) { props = {}; }
|
|
@@ -79,7 +117,8 @@ describe('AttributesView tests', function () {
|
|
|
79
117
|
var children = _a.children;
|
|
80
118
|
return (react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: mdmValues, actions: actions }, children));
|
|
81
119
|
};
|
|
82
|
-
|
|
120
|
+
var user = user_event_1.default.setup();
|
|
121
|
+
return __assign(__assign({}, (0, react_2.render)(react_1.default.createElement(AttributesView_1.AttributesView, __assign({}, props)), { wrapper: Providers })), { user: user });
|
|
83
122
|
};
|
|
84
123
|
it('should render ReadOnlyAttributesView in read mode if mode is "viewing"', function () {
|
|
85
124
|
setUp({ mode: mdm_sdk_1.Mode.Viewing, entity: entity });
|
|
@@ -123,4 +162,39 @@ describe('AttributesView tests', function () {
|
|
|
123
162
|
expect(react_2.screen.getByText('Last Name')).toBeInTheDocument();
|
|
124
163
|
expect(react_2.screen.getByText('Phone')).toBeInTheDocument();
|
|
125
164
|
});
|
|
165
|
+
it('should render always visible attributes in read mode for entity without filled attributes', function () {
|
|
166
|
+
var alwaysVisible = [
|
|
167
|
+
'configuration/entityTypes/HCP/attributes/LastName',
|
|
168
|
+
'configuration/entityTypes/HCP/attributes/Phone'
|
|
169
|
+
];
|
|
170
|
+
var notFilledEntity = __assign(__assign({}, entity), { attributes: {} });
|
|
171
|
+
setUp({ mode: mdm_sdk_1.Mode.Viewing, entity: notFilledEntity, alwaysVisible: alwaysVisible });
|
|
172
|
+
expect(react_2.screen.getByText('Last Name')).toBeInTheDocument();
|
|
173
|
+
expect(react_2.screen.getByText('Phone')).toBeInTheDocument();
|
|
174
|
+
});
|
|
175
|
+
it('should show control attribute icon if an attribute is a always visible control attribute in view mode', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
176
|
+
var alwaysVisible, user, controlAttribute, icon, _a;
|
|
177
|
+
return __generator(this, function (_b) {
|
|
178
|
+
switch (_b.label) {
|
|
179
|
+
case 0:
|
|
180
|
+
alwaysVisible = [
|
|
181
|
+
'configuration/entityTypes/HCP/attributes/LastName',
|
|
182
|
+
'configuration/entityTypes/HCP/attributes/Phone'
|
|
183
|
+
];
|
|
184
|
+
user = setUp({ mode: mdm_sdk_1.Mode.Editing, entity: entity, alwaysVisible: alwaysVisible }).user;
|
|
185
|
+
expect(react_2.screen.getByText('Last Name')).toBeInTheDocument();
|
|
186
|
+
expect(react_2.screen.getByText('Phone')).toBeInTheDocument();
|
|
187
|
+
controlAttribute = react_2.screen.getByText('Phone').closest('div');
|
|
188
|
+
icon = (0, react_2.within)(controlAttribute).getByTestId('reltio-control-attribute-icon');
|
|
189
|
+
return [4 /*yield*/, user.hover(icon)];
|
|
190
|
+
case 1:
|
|
191
|
+
_b.sent();
|
|
192
|
+
_a = expect;
|
|
193
|
+
return [4 /*yield*/, react_2.screen.findByText('This is a control attribute. Changing this value will affect availability of other conditional attributes.')];
|
|
194
|
+
case 2:
|
|
195
|
+
_a.apply(void 0, [_b.sent()]).toBeInTheDocument();
|
|
196
|
+
return [2 /*return*/];
|
|
197
|
+
}
|
|
198
|
+
});
|
|
199
|
+
}); });
|
|
126
200
|
});
|
|
@@ -1,20 +1,48 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
29
|
exports.EmptyRenderer = void 0;
|
|
7
|
-
var react_1 =
|
|
30
|
+
var react_1 = __importStar(require("react"));
|
|
8
31
|
var classnames_1 = __importDefault(require("classnames"));
|
|
9
32
|
var AttributeTitle_1 = require("../../../AttributeTitle");
|
|
10
33
|
var DescriptionIcon_1 = require("../../../DescriptionIcon");
|
|
34
|
+
var ControlAttributeIcon_1 = require("../../../ControlAttributeIcon");
|
|
35
|
+
var MdmModuleContext_1 = require("../../../contexts/MdmModuleContext");
|
|
11
36
|
var styles_1 = require("../../styles");
|
|
12
37
|
var EmptyRenderer = function (_a) {
|
|
13
38
|
var attributeType = _a.attributeType, classes = _a.classes;
|
|
14
39
|
var styles = (0, styles_1.useEmptyStyles)();
|
|
15
40
|
var label = attributeType.label, description = attributeType.description;
|
|
41
|
+
var controlAttributes = (0, MdmModuleContext_1.useMdmControlAttributes)();
|
|
42
|
+
var isControlAttribute = (0, react_1.useMemo)(function () { return controlAttributes.includes(attributeType.uri); }, [controlAttributes, attributeType.uri]);
|
|
16
43
|
return (react_1.default.createElement("div", { "data-reltio-id": "reltio-empty-renderer", className: (0, classnames_1.default)(styles.titleRow, styles.wrapper) },
|
|
17
44
|
react_1.default.createElement(AttributeTitle_1.AttributeTitle, { label: label, className: (0, classnames_1.default)(styles.title, classes === null || classes === void 0 ? void 0 : classes.title), "data-reltio-id": "reltio-attribute-label" }),
|
|
45
|
+
isControlAttribute && react_1.default.createElement(ControlAttributeIcon_1.ControlAttributeIcon, null),
|
|
18
46
|
react_1.default.createElement(DescriptionIcon_1.DescriptionIcon, { description: description, className: styles.descriptionIcon })));
|
|
19
47
|
};
|
|
20
48
|
exports.EmptyRenderer = EmptyRenderer;
|
|
@@ -35,6 +35,7 @@ var Box_1 = __importDefault(require("@mui/material/Box"));
|
|
|
35
35
|
var Typography_1 = __importDefault(require("@mui/material/Typography"));
|
|
36
36
|
var PivotingAttributeContext_1 = require("../contexts/PivotingAttributeContext");
|
|
37
37
|
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
|
|
38
|
+
var AllwaysVisibleAttributesContext_1 = require("../contexts/AllwaysVisibleAttributesContext");
|
|
38
39
|
var BasicView_1 = require("../BasicView");
|
|
39
40
|
var FacetViewHeader_1 = require("../FacetViewHeader");
|
|
40
41
|
var ReadOnlyAttributesList_1 = require("../ReadOnlyAttributesList");
|
|
@@ -50,10 +51,11 @@ var ReadOnlyAttributesView = function (_a) {
|
|
|
50
51
|
var filteredAttrTypes = (0, react_1.useMemo)(function () { return (0, attributesView_1.getFilteredAttrTypes)(metadata, entity.type, includeUris, excludeUris); }, [excludeUris, includeUris, metadata, entity]);
|
|
51
52
|
var attributesCount = attributesCountProp || DEFAULT_ATTRIBUTES_COUNT;
|
|
52
53
|
var attributesList = (0, mdm_sdk_1.getAttributesListForReadMode)(filteredAttrTypes, entity);
|
|
54
|
+
var alwaysVisible = (0, react_1.useContext)(AllwaysVisibleAttributesContext_1.AlwaysVisibleAttributesContext);
|
|
53
55
|
var isShowAttributeList = attributesList.filter(function (_a) {
|
|
54
56
|
var values = _a.values;
|
|
55
57
|
return !(0, mdm_sdk_1.isEmptyValue)(values);
|
|
56
|
-
}).length > 0;
|
|
58
|
+
}).length > 0 || alwaysVisible.length > 0;
|
|
57
59
|
return isShowAttributeList || !(0, mdm_sdk_1.isEmptyValue)(caption) ? (react_1.default.createElement(PivotingAttributeContext_1.PivotingAttributeContext.Provider, { value: pivotingAttributes },
|
|
58
60
|
react_1.default.createElement(BasicView_1.BasicView, { className: className },
|
|
59
61
|
caption && react_1.default.createElement(FacetViewHeader_1.FacetViewHeader, { title: caption }),
|
|
@@ -9,11 +9,48 @@ 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
|
import React from 'react';
|
|
13
49
|
import { Mode } from '@reltio/mdm-sdk';
|
|
14
50
|
import { AttributesView } from './AttributesView';
|
|
15
51
|
import { MdmModuleProvider } from '../contexts/MdmModuleContext';
|
|
16
|
-
import { render, screen } from '@testing-library/react';
|
|
52
|
+
import { render, screen, within } from '@testing-library/react';
|
|
53
|
+
import userEvent from '@testing-library/user-event';
|
|
17
54
|
describe('AttributesView tests', function () {
|
|
18
55
|
var entity = {
|
|
19
56
|
type: 'configuration/entityTypes/HCP',
|
|
@@ -65,7 +102,8 @@ describe('AttributesView tests', function () {
|
|
|
65
102
|
var mdmDefaultValues = {
|
|
66
103
|
metadata: metadata,
|
|
67
104
|
modifiedEntities: { 'entities/02ZRRE9': entity },
|
|
68
|
-
dependentLookups: { editors: {}, structure: {}, initedTypeUris: [] }
|
|
105
|
+
dependentLookups: { editors: {}, structure: {}, initedTypeUris: [] },
|
|
106
|
+
controlAttributes: ['configuration/entityTypes/HCP/attributes/Phone']
|
|
69
107
|
};
|
|
70
108
|
var setUp = function (props, mdmValues) {
|
|
71
109
|
if (props === void 0) { props = {}; }
|
|
@@ -74,7 +112,8 @@ describe('AttributesView tests', function () {
|
|
|
74
112
|
var children = _a.children;
|
|
75
113
|
return (React.createElement(MdmModuleProvider, { values: mdmValues, actions: actions }, children));
|
|
76
114
|
};
|
|
77
|
-
|
|
115
|
+
var user = userEvent.setup();
|
|
116
|
+
return __assign(__assign({}, render(React.createElement(AttributesView, __assign({}, props)), { wrapper: Providers })), { user: user });
|
|
78
117
|
};
|
|
79
118
|
it('should render ReadOnlyAttributesView in read mode if mode is "viewing"', function () {
|
|
80
119
|
setUp({ mode: Mode.Viewing, entity: entity });
|
|
@@ -118,4 +157,39 @@ describe('AttributesView tests', function () {
|
|
|
118
157
|
expect(screen.getByText('Last Name')).toBeInTheDocument();
|
|
119
158
|
expect(screen.getByText('Phone')).toBeInTheDocument();
|
|
120
159
|
});
|
|
160
|
+
it('should render always visible attributes in read mode for entity without filled attributes', function () {
|
|
161
|
+
var alwaysVisible = [
|
|
162
|
+
'configuration/entityTypes/HCP/attributes/LastName',
|
|
163
|
+
'configuration/entityTypes/HCP/attributes/Phone'
|
|
164
|
+
];
|
|
165
|
+
var notFilledEntity = __assign(__assign({}, entity), { attributes: {} });
|
|
166
|
+
setUp({ mode: Mode.Viewing, entity: notFilledEntity, alwaysVisible: alwaysVisible });
|
|
167
|
+
expect(screen.getByText('Last Name')).toBeInTheDocument();
|
|
168
|
+
expect(screen.getByText('Phone')).toBeInTheDocument();
|
|
169
|
+
});
|
|
170
|
+
it('should show control attribute icon if an attribute is a always visible control attribute in view mode', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
171
|
+
var alwaysVisible, user, controlAttribute, icon, _a;
|
|
172
|
+
return __generator(this, function (_b) {
|
|
173
|
+
switch (_b.label) {
|
|
174
|
+
case 0:
|
|
175
|
+
alwaysVisible = [
|
|
176
|
+
'configuration/entityTypes/HCP/attributes/LastName',
|
|
177
|
+
'configuration/entityTypes/HCP/attributes/Phone'
|
|
178
|
+
];
|
|
179
|
+
user = setUp({ mode: Mode.Editing, entity: entity, alwaysVisible: alwaysVisible }).user;
|
|
180
|
+
expect(screen.getByText('Last Name')).toBeInTheDocument();
|
|
181
|
+
expect(screen.getByText('Phone')).toBeInTheDocument();
|
|
182
|
+
controlAttribute = screen.getByText('Phone').closest('div');
|
|
183
|
+
icon = within(controlAttribute).getByTestId('reltio-control-attribute-icon');
|
|
184
|
+
return [4 /*yield*/, user.hover(icon)];
|
|
185
|
+
case 1:
|
|
186
|
+
_b.sent();
|
|
187
|
+
_a = expect;
|
|
188
|
+
return [4 /*yield*/, screen.findByText('This is a control attribute. Changing this value will affect availability of other conditional attributes.')];
|
|
189
|
+
case 2:
|
|
190
|
+
_a.apply(void 0, [_b.sent()]).toBeInTheDocument();
|
|
191
|
+
return [2 /*return*/];
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
}); });
|
|
121
195
|
});
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
import classnames from 'classnames';
|
|
3
3
|
import { AttributeTitle } from '../../../AttributeTitle';
|
|
4
4
|
import { DescriptionIcon } from '../../../DescriptionIcon';
|
|
5
|
+
import { ControlAttributeIcon } from '../../../ControlAttributeIcon';
|
|
6
|
+
import { useMdmControlAttributes } from '../../../contexts/MdmModuleContext';
|
|
5
7
|
import { useEmptyStyles } from '../../styles';
|
|
6
8
|
export var EmptyRenderer = function (_a) {
|
|
7
9
|
var attributeType = _a.attributeType, classes = _a.classes;
|
|
8
10
|
var styles = useEmptyStyles();
|
|
9
11
|
var label = attributeType.label, description = attributeType.description;
|
|
12
|
+
var controlAttributes = useMdmControlAttributes();
|
|
13
|
+
var isControlAttribute = useMemo(function () { return controlAttributes.includes(attributeType.uri); }, [controlAttributes, attributeType.uri]);
|
|
10
14
|
return (React.createElement("div", { "data-reltio-id": "reltio-empty-renderer", className: classnames(styles.titleRow, styles.wrapper) },
|
|
11
15
|
React.createElement(AttributeTitle, { label: label, className: classnames(styles.title, classes === null || classes === void 0 ? void 0 : classes.title), "data-reltio-id": "reltio-attribute-label" }),
|
|
16
|
+
isControlAttribute && React.createElement(ControlAttributeIcon, null),
|
|
12
17
|
React.createElement(DescriptionIcon, { description: description, className: styles.descriptionIcon })));
|
|
13
18
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
1
|
+
import React, { useContext, useMemo } from 'react';
|
|
2
2
|
import { getAttributesListForReadMode, isEmptyValue } from '@reltio/mdm-sdk';
|
|
3
3
|
import classnames from 'classnames';
|
|
4
4
|
import i18n from 'ui-i18n';
|
|
@@ -6,6 +6,7 @@ import Box from '@mui/material/Box';
|
|
|
6
6
|
import Typography from '@mui/material/Typography';
|
|
7
7
|
import { PivotingAttributeContext } from '../contexts/PivotingAttributeContext';
|
|
8
8
|
import { useMdmMetadata, useMdmPivotingAttributes } from '../contexts/MdmModuleContext';
|
|
9
|
+
import { AlwaysVisibleAttributesContext } from '../contexts/AllwaysVisibleAttributesContext';
|
|
9
10
|
import { BasicView } from '../BasicView';
|
|
10
11
|
import { FacetViewHeader } from '../FacetViewHeader';
|
|
11
12
|
import { ReadOnlyAttributesList } from '../ReadOnlyAttributesList';
|
|
@@ -21,10 +22,11 @@ export var ReadOnlyAttributesView = function (_a) {
|
|
|
21
22
|
var filteredAttrTypes = useMemo(function () { return getFilteredAttrTypes(metadata, entity.type, includeUris, excludeUris); }, [excludeUris, includeUris, metadata, entity]);
|
|
22
23
|
var attributesCount = attributesCountProp || DEFAULT_ATTRIBUTES_COUNT;
|
|
23
24
|
var attributesList = getAttributesListForReadMode(filteredAttrTypes, entity);
|
|
25
|
+
var alwaysVisible = useContext(AlwaysVisibleAttributesContext);
|
|
24
26
|
var isShowAttributeList = attributesList.filter(function (_a) {
|
|
25
27
|
var values = _a.values;
|
|
26
28
|
return !isEmptyValue(values);
|
|
27
|
-
}).length > 0;
|
|
29
|
+
}).length > 0 || alwaysVisible.length > 0;
|
|
28
30
|
return isShowAttributeList || !isEmptyValue(caption) ? (React.createElement(PivotingAttributeContext.Provider, { value: pivotingAttributes },
|
|
29
31
|
React.createElement(BasicView, { className: className },
|
|
30
32
|
caption && React.createElement(FacetViewHeader, { title: caption }),
|