@reltio/components 1.4.2256 → 1.4.2257
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/AttributesView/AttributesView.test.js +8 -2
- package/EditModeAttributesPager/components/SpecialRenderer/SpecialRenderer.js +5 -2
- package/cjs/AttributesView/AttributesView.test.js +8 -2
- package/cjs/EditModeAttributesPager/components/SpecialRenderer/SpecialRenderer.js +4 -1
- package/package.json +1 -1
|
@@ -47,6 +47,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
47
47
|
};
|
|
48
48
|
import React from 'react';
|
|
49
49
|
import { Mode } from '@reltio/mdm-sdk';
|
|
50
|
+
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
|
|
51
|
+
import { AdapterMoment } from '@mui/x-date-pickers/AdapterMoment';
|
|
50
52
|
import { AttributesView } from './AttributesView';
|
|
51
53
|
import { MdmModuleProvider } from '../contexts/MdmModuleContext';
|
|
52
54
|
import { render, screen, within } from '@testing-library/react';
|
|
@@ -110,7 +112,8 @@ describe('AttributesView tests', function () {
|
|
|
110
112
|
if (mdmValues === void 0) { mdmValues = mdmDefaultValues; }
|
|
111
113
|
var Providers = function (_a) {
|
|
112
114
|
var children = _a.children;
|
|
113
|
-
return (React.createElement(
|
|
115
|
+
return (React.createElement(LocalizationProvider, { dateAdapter: AdapterMoment },
|
|
116
|
+
React.createElement(MdmModuleProvider, { values: mdmValues, actions: actions }, children)));
|
|
114
117
|
};
|
|
115
118
|
var user = userEvent.setup();
|
|
116
119
|
return __assign(__assign({}, render(React.createElement(AttributesView, __assign({}, props)), { wrapper: Providers })), { user: user });
|
|
@@ -151,11 +154,14 @@ describe('AttributesView tests', function () {
|
|
|
151
154
|
it('should render always visible attributes in editing mode', function () {
|
|
152
155
|
var alwaysVisible = [
|
|
153
156
|
'configuration/entityTypes/HCP/attributes/LastName',
|
|
154
|
-
'configuration/entityTypes/HCP/attributes/Phone'
|
|
157
|
+
'configuration/entityTypes/HCP/attributes/Phone',
|
|
158
|
+
'startDate'
|
|
155
159
|
];
|
|
156
160
|
setUp({ mode: Mode.Editing, entity: entity, alwaysVisible: alwaysVisible });
|
|
157
161
|
expect(screen.getByText('Last Name')).toBeInTheDocument();
|
|
158
162
|
expect(screen.getByText('Phone')).toBeInTheDocument();
|
|
163
|
+
expect(screen.getByText('Start date')).toBeInTheDocument();
|
|
164
|
+
expect(screen.queryByText('End date')).not.toBeInTheDocument();
|
|
159
165
|
});
|
|
160
166
|
it('should render always visible attributes in read mode for entity without filled attributes', function () {
|
|
161
167
|
var alwaysVisible = [
|
|
@@ -20,7 +20,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
}
|
|
21
21
|
return t;
|
|
22
22
|
};
|
|
23
|
-
import React, { useCallback, useRef, useState } from 'react';
|
|
23
|
+
import React, { useCallback, useContext, useMemo, useRef, useState } from 'react';
|
|
24
24
|
import { createNewAttribute, EntityAttrTypes, isEditableMode as checkIsEditableMode, isEmptyValue, isActivenessAttrType } from '@reltio/mdm-sdk';
|
|
25
25
|
import classnames from 'classnames';
|
|
26
26
|
import { pipe, T } from 'ramda';
|
|
@@ -33,6 +33,7 @@ import { RolesEditor } from '../../../RolesEditor';
|
|
|
33
33
|
import { TagsEditor } from '../../../TagsEditor';
|
|
34
34
|
import { HasDeletionsContext } from '../../../contexts/HasDeletionsContext';
|
|
35
35
|
import { withContext } from '../../../HOCs/withContext';
|
|
36
|
+
import { AlwaysVisibleAttributesContext } from '../../../contexts/AlwaysVisibleAttributesContext';
|
|
36
37
|
import { useScrollToAttribute } from '../../../hooks/useScrollToAttribute';
|
|
37
38
|
import { useStyles } from '../../styles';
|
|
38
39
|
var SpecialRenderer = function (_a) {
|
|
@@ -52,7 +53,9 @@ var SpecialRenderer = function (_a) {
|
|
|
52
53
|
updateHasDeletions
|
|
53
54
|
]);
|
|
54
55
|
var isEmptyValues = isEmptyValue(values);
|
|
55
|
-
var
|
|
56
|
+
var alwaysVisibleAttributes = useContext(AlwaysVisibleAttributesContext);
|
|
57
|
+
var isAlwaysVisible = useMemo(function () { return alwaysVisibleAttributes === null || alwaysVisibleAttributes === void 0 ? void 0 : alwaysVisibleAttributes.includes(attributeType.uri); }, [attributeType.uri, alwaysVisibleAttributes]);
|
|
58
|
+
var showEmpty = ((!hasDeletions && showEmptyEditors) || isAlwaysVisible) && isEmptyValues;
|
|
56
59
|
var emptyEditorValue = useRef(createNewAttribute({
|
|
57
60
|
parentUri: parentUri,
|
|
58
61
|
attributeType: attributeType
|
|
@@ -52,6 +52,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
var react_1 = __importDefault(require("react"));
|
|
54
54
|
var mdm_sdk_1 = require("@reltio/mdm-sdk");
|
|
55
|
+
var LocalizationProvider_1 = require("@mui/x-date-pickers/LocalizationProvider");
|
|
56
|
+
var AdapterMoment_1 = require("@mui/x-date-pickers/AdapterMoment");
|
|
55
57
|
var AttributesView_1 = require("./AttributesView");
|
|
56
58
|
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
|
|
57
59
|
var react_2 = require("@testing-library/react");
|
|
@@ -115,7 +117,8 @@ describe('AttributesView tests', function () {
|
|
|
115
117
|
if (mdmValues === void 0) { mdmValues = mdmDefaultValues; }
|
|
116
118
|
var Providers = function (_a) {
|
|
117
119
|
var children = _a.children;
|
|
118
|
-
return (react_1.default.createElement(
|
|
120
|
+
return (react_1.default.createElement(LocalizationProvider_1.LocalizationProvider, { dateAdapter: AdapterMoment_1.AdapterMoment },
|
|
121
|
+
react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: mdmValues, actions: actions }, children)));
|
|
119
122
|
};
|
|
120
123
|
var user = user_event_1.default.setup();
|
|
121
124
|
return __assign(__assign({}, (0, react_2.render)(react_1.default.createElement(AttributesView_1.AttributesView, __assign({}, props)), { wrapper: Providers })), { user: user });
|
|
@@ -156,11 +159,14 @@ describe('AttributesView tests', function () {
|
|
|
156
159
|
it('should render always visible attributes in editing mode', function () {
|
|
157
160
|
var alwaysVisible = [
|
|
158
161
|
'configuration/entityTypes/HCP/attributes/LastName',
|
|
159
|
-
'configuration/entityTypes/HCP/attributes/Phone'
|
|
162
|
+
'configuration/entityTypes/HCP/attributes/Phone',
|
|
163
|
+
'startDate'
|
|
160
164
|
];
|
|
161
165
|
setUp({ mode: mdm_sdk_1.Mode.Editing, entity: entity, alwaysVisible: alwaysVisible });
|
|
162
166
|
expect(react_2.screen.getByText('Last Name')).toBeInTheDocument();
|
|
163
167
|
expect(react_2.screen.getByText('Phone')).toBeInTheDocument();
|
|
168
|
+
expect(react_2.screen.getByText('Start date')).toBeInTheDocument();
|
|
169
|
+
expect(react_2.screen.queryByText('End date')).not.toBeInTheDocument();
|
|
164
170
|
});
|
|
165
171
|
it('should render always visible attributes in read mode for entity without filled attributes', function () {
|
|
166
172
|
var alwaysVisible = [
|
|
@@ -61,6 +61,7 @@ var RolesEditor_1 = require("../../../RolesEditor");
|
|
|
61
61
|
var TagsEditor_1 = require("../../../TagsEditor");
|
|
62
62
|
var HasDeletionsContext_1 = require("../../../contexts/HasDeletionsContext");
|
|
63
63
|
var withContext_1 = require("../../../HOCs/withContext");
|
|
64
|
+
var AlwaysVisibleAttributesContext_1 = require("../../../contexts/AlwaysVisibleAttributesContext");
|
|
64
65
|
var useScrollToAttribute_1 = require("../../../hooks/useScrollToAttribute");
|
|
65
66
|
var styles_1 = require("../../styles");
|
|
66
67
|
var SpecialRenderer = function (_a) {
|
|
@@ -80,7 +81,9 @@ var SpecialRenderer = function (_a) {
|
|
|
80
81
|
updateHasDeletions
|
|
81
82
|
]);
|
|
82
83
|
var isEmptyValues = (0, mdm_sdk_1.isEmptyValue)(values);
|
|
83
|
-
var
|
|
84
|
+
var alwaysVisibleAttributes = (0, react_1.useContext)(AlwaysVisibleAttributesContext_1.AlwaysVisibleAttributesContext);
|
|
85
|
+
var isAlwaysVisible = (0, react_1.useMemo)(function () { return alwaysVisibleAttributes === null || alwaysVisibleAttributes === void 0 ? void 0 : alwaysVisibleAttributes.includes(attributeType.uri); }, [attributeType.uri, alwaysVisibleAttributes]);
|
|
86
|
+
var showEmpty = ((!hasDeletions && showEmptyEditors) || isAlwaysVisible) && isEmptyValues;
|
|
84
87
|
var emptyEditorValue = (0, react_1.useRef)((0, mdm_sdk_1.createNewAttribute)({
|
|
85
88
|
parentUri: parentUri,
|
|
86
89
|
attributeType: attributeType
|