@reltio/components 1.4.2220 → 1.4.2221
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/SimpleAttributeEditor/SimpleAttributeEditor.js +4 -1
- package/SimpleAttributeEditor/SimpleAttributeEditor.test.js +40 -3
- package/cjs/SimpleAttributeEditor/SimpleAttributeEditor.js +4 -1
- package/cjs/SimpleAttributeEditor/SimpleAttributeEditor.test.js +40 -3
- package/cjs/contexts/AuthoringPerspectiveViewContext/index.d.ts +2 -0
- package/cjs/contexts/AuthoringPerspectiveViewContext/index.js +9 -0
- package/contexts/AuthoringPerspectiveViewContext/index.d.ts +2 -0
- package/contexts/AuthoringPerspectiveViewContext/index.js +3 -0
- package/package.json +1 -1
|
@@ -47,6 +47,7 @@ import { DependentLookupAutopopulationContext } from '../contexts/DependentLooku
|
|
|
47
47
|
import { useStyles } from './styles';
|
|
48
48
|
import { AddressAutoCompleteContext } from '../contexts/AutoCompleteContext';
|
|
49
49
|
import { AttributeValueContext } from '../contexts/AttributeValueContext';
|
|
50
|
+
import { AuthoringPerspectiveViewContext } from '../contexts/AuthoringPerspectiveViewContext';
|
|
50
51
|
var AsyncMountPlaceholder = function () {
|
|
51
52
|
var styles = useStyles();
|
|
52
53
|
return React.createElement("div", { className: styles.placeholder });
|
|
@@ -112,8 +113,10 @@ var SimpleAttributeEditor = function (_a) {
|
|
|
112
113
|
var hasError = !!errorMessage;
|
|
113
114
|
var deletedProps = deleted ? { disabled: true, isCrossedOut: true } : {};
|
|
114
115
|
var isProfilePerspectiveView = useContext(ProfilePerspectiveViewContext);
|
|
116
|
+
var isAuthoringPerspectiveView = useContext(AuthoringPerspectiveViewContext);
|
|
117
|
+
var isEntityPerspectiveView = isProfilePerspectiveView || isAuthoringPerspectiveView;
|
|
115
118
|
var autopopulationContextValue = useAutopopulationContextValue({
|
|
116
|
-
enabled:
|
|
119
|
+
enabled: isEntityPerspectiveView && isDependentLookupAttrType(attributeType),
|
|
117
120
|
attributeTypeUri: attributeType === null || attributeType === void 0 ? void 0 : attributeType.uri,
|
|
118
121
|
valueUri: attributeValue.uri
|
|
119
122
|
}).autopopulationContextValue;
|
|
@@ -54,6 +54,7 @@ import { ProfilePerspectiveViewContext } from '../contexts/ProfilePerspectiveVie
|
|
|
54
54
|
import { ScrollType, ScrollToElementContext } from '../contexts/ScrollToElementContext';
|
|
55
55
|
import { MdmModuleProvider, useMdmDependentLookupEditorContext } from '../contexts/MdmModuleContext';
|
|
56
56
|
import { AlwaysVisibleAttributesContext } from '../contexts/AlwaysVisibleAttributesContext';
|
|
57
|
+
import { AuthoringPerspectiveViewContext } from '../contexts/AuthoringPerspectiveViewContext';
|
|
57
58
|
import { useAutopopulationContextValue } from './useAutopopulationContextValue';
|
|
58
59
|
import { useScrollToAttributeError } from '../hooks/useScrollToAttributeError';
|
|
59
60
|
import { useAsyncMount } from '../hooks/useAsyncMount';
|
|
@@ -105,7 +106,7 @@ describe('SimpleAttributeEditor', function () {
|
|
|
105
106
|
onDeactivateError: jest.fn()
|
|
106
107
|
};
|
|
107
108
|
var setUp = function (_a) {
|
|
108
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? {} : _c, _d = _b.error, error = _d === void 0 ? null : _d, _e = _b.isProfilePerspective, isProfilePerspective = _e === void 0 ? false : _e, _f = _b.alwaysVisibleAttributes, alwaysVisibleAttributes =
|
|
109
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? {} : _c, _d = _b.error, error = _d === void 0 ? null : _d, _e = _b.isProfilePerspective, isProfilePerspective = _e === void 0 ? false : _e, _f = _b.isAuthoringPerspective, isAuthoringPerspective = _f === void 0 ? false : _f, _g = _b.alwaysVisibleAttributes, alwaysVisibleAttributes = _g === void 0 ? [] : _g;
|
|
109
110
|
var user = userEvent.setup();
|
|
110
111
|
var scrollToElementContextValue = getScrollToElementContextValue(error);
|
|
111
112
|
var Providers = function (_a) {
|
|
@@ -113,7 +114,8 @@ describe('SimpleAttributeEditor', function () {
|
|
|
113
114
|
return (React.createElement(MdmModuleProvider, { values: mdmValues },
|
|
114
115
|
React.createElement(AlwaysVisibleAttributesContext.Provider, { value: alwaysVisibleAttributes },
|
|
115
116
|
React.createElement(ProfilePerspectiveViewContext.Provider, { value: isProfilePerspective },
|
|
116
|
-
React.createElement(
|
|
117
|
+
React.createElement(AuthoringPerspectiveViewContext.Provider, { value: isAuthoringPerspective },
|
|
118
|
+
React.createElement(ScrollToElementContext.Provider, { value: scrollToElementContextValue }, children))))));
|
|
117
119
|
};
|
|
118
120
|
return __assign({ user: user, scrollToElementContextValue: scrollToElementContextValue }, render(React.createElement(SimpleAttributeEditor, __assign({}, defaultProps, props)), { wrapper: Providers }));
|
|
119
121
|
};
|
|
@@ -348,7 +350,7 @@ describe('SimpleAttributeEditor', function () {
|
|
|
348
350
|
uri: 'configuration/entityTypes/HCA/attributes/InternalCustomer',
|
|
349
351
|
dependentLookupCode: 'Code'
|
|
350
352
|
};
|
|
351
|
-
it('should call getDependentLookupEditorContext selector with correct arguments', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
353
|
+
it('should call getDependentLookupEditorContext selector with correct arguments for profile perspective', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
352
354
|
return __generator(this, function (_a) {
|
|
353
355
|
switch (_a.label) {
|
|
354
356
|
case 0:
|
|
@@ -366,6 +368,24 @@ describe('SimpleAttributeEditor', function () {
|
|
|
366
368
|
}
|
|
367
369
|
});
|
|
368
370
|
}); });
|
|
371
|
+
it('should call getDependentLookupEditorContext selector with correct arguments for authoring perspective', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
372
|
+
return __generator(this, function (_a) {
|
|
373
|
+
switch (_a.label) {
|
|
374
|
+
case 0:
|
|
375
|
+
setUp({ props: { attributeType: attributeType }, isAuthoringPerspective: true });
|
|
376
|
+
return [4 /*yield*/, act(function () { return Promise.resolve(); })];
|
|
377
|
+
case 1:
|
|
378
|
+
_a.sent();
|
|
379
|
+
expect(useMdmDependentLookupEditorContext).toHaveBeenCalledWith(defaultProps.attributeValue, attributeType);
|
|
380
|
+
expect(useAutopopulationContextValue).toHaveBeenCalledWith({
|
|
381
|
+
enabled: true,
|
|
382
|
+
attributeTypeUri: attributeType.uri,
|
|
383
|
+
valueUri: defaultProps.attributeValue.uri
|
|
384
|
+
});
|
|
385
|
+
return [2 /*return*/];
|
|
386
|
+
}
|
|
387
|
+
});
|
|
388
|
+
}); });
|
|
369
389
|
it('should call useAutopopulationContextValue with enabled: false if component is outside of Profile perspective', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
370
390
|
return __generator(this, function (_a) {
|
|
371
391
|
switch (_a.label) {
|
|
@@ -383,6 +403,23 @@ describe('SimpleAttributeEditor', function () {
|
|
|
383
403
|
}
|
|
384
404
|
});
|
|
385
405
|
}); });
|
|
406
|
+
it('should call useAutopopulationContextValue with enabled: false if component is outside of authoring perspective', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
407
|
+
return __generator(this, function (_a) {
|
|
408
|
+
switch (_a.label) {
|
|
409
|
+
case 0:
|
|
410
|
+
setUp({ props: { attributeType: attributeType }, isAuthoringPerspective: false });
|
|
411
|
+
return [4 /*yield*/, act(function () { return Promise.resolve(); })];
|
|
412
|
+
case 1:
|
|
413
|
+
_a.sent();
|
|
414
|
+
expect(useAutopopulationContextValue).toHaveBeenCalledWith({
|
|
415
|
+
enabled: false,
|
|
416
|
+
attributeTypeUri: attributeType.uri,
|
|
417
|
+
valueUri: defaultProps.attributeValue.uri
|
|
418
|
+
});
|
|
419
|
+
return [2 /*return*/];
|
|
420
|
+
}
|
|
421
|
+
});
|
|
422
|
+
}); });
|
|
386
423
|
it('should render dependent lookup editor with applied result of getDependentLookupEditorContext', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
387
424
|
var dlEditorContext, input;
|
|
388
425
|
return __generator(this, function (_a) {
|
|
@@ -75,6 +75,7 @@ var DependentLookupAutopopulationContext_1 = require("../contexts/DependentLooku
|
|
|
75
75
|
var styles_1 = require("./styles");
|
|
76
76
|
var AutoCompleteContext_1 = require("../contexts/AutoCompleteContext");
|
|
77
77
|
var AttributeValueContext_1 = require("../contexts/AttributeValueContext");
|
|
78
|
+
var AuthoringPerspectiveViewContext_1 = require("../contexts/AuthoringPerspectiveViewContext");
|
|
78
79
|
var AsyncMountPlaceholder = function () {
|
|
79
80
|
var styles = (0, styles_1.useStyles)();
|
|
80
81
|
return react_1.default.createElement("div", { className: styles.placeholder });
|
|
@@ -140,8 +141,10 @@ var SimpleAttributeEditor = function (_a) {
|
|
|
140
141
|
var hasError = !!errorMessage;
|
|
141
142
|
var deletedProps = deleted ? { disabled: true, isCrossedOut: true } : {};
|
|
142
143
|
var isProfilePerspectiveView = (0, react_1.useContext)(ProfilePerspectiveViewContext_1.ProfilePerspectiveViewContext);
|
|
144
|
+
var isAuthoringPerspectiveView = (0, react_1.useContext)(AuthoringPerspectiveViewContext_1.AuthoringPerspectiveViewContext);
|
|
145
|
+
var isEntityPerspectiveView = isProfilePerspectiveView || isAuthoringPerspectiveView;
|
|
143
146
|
var autopopulationContextValue = (0, useAutopopulationContextValue_1.useAutopopulationContextValue)({
|
|
144
|
-
enabled:
|
|
147
|
+
enabled: isEntityPerspectiveView && (0, mdm_sdk_1.isDependentLookupAttrType)(attributeType),
|
|
145
148
|
attributeTypeUri: attributeType === null || attributeType === void 0 ? void 0 : attributeType.uri,
|
|
146
149
|
valueUri: attributeValue.uri
|
|
147
150
|
}).autopopulationContextValue;
|
|
@@ -59,6 +59,7 @@ var ProfilePerspectiveViewContext_1 = require("../contexts/ProfilePerspectiveVie
|
|
|
59
59
|
var ScrollToElementContext_1 = require("../contexts/ScrollToElementContext");
|
|
60
60
|
var MdmModuleContext_1 = require("../contexts/MdmModuleContext");
|
|
61
61
|
var AlwaysVisibleAttributesContext_1 = require("../contexts/AlwaysVisibleAttributesContext");
|
|
62
|
+
var AuthoringPerspectiveViewContext_1 = require("../contexts/AuthoringPerspectiveViewContext");
|
|
62
63
|
var useAutopopulationContextValue_1 = require("./useAutopopulationContextValue");
|
|
63
64
|
var useScrollToAttributeError_1 = require("../hooks/useScrollToAttributeError");
|
|
64
65
|
var useAsyncMount_1 = require("../hooks/useAsyncMount");
|
|
@@ -110,7 +111,7 @@ describe('SimpleAttributeEditor', function () {
|
|
|
110
111
|
onDeactivateError: jest.fn()
|
|
111
112
|
};
|
|
112
113
|
var setUp = function (_a) {
|
|
113
|
-
var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? {} : _c, _d = _b.error, error = _d === void 0 ? null : _d, _e = _b.isProfilePerspective, isProfilePerspective = _e === void 0 ? false : _e, _f = _b.alwaysVisibleAttributes, alwaysVisibleAttributes =
|
|
114
|
+
var _b = _a === void 0 ? {} : _a, _c = _b.props, props = _c === void 0 ? {} : _c, _d = _b.error, error = _d === void 0 ? null : _d, _e = _b.isProfilePerspective, isProfilePerspective = _e === void 0 ? false : _e, _f = _b.isAuthoringPerspective, isAuthoringPerspective = _f === void 0 ? false : _f, _g = _b.alwaysVisibleAttributes, alwaysVisibleAttributes = _g === void 0 ? [] : _g;
|
|
114
115
|
var user = user_event_1.default.setup();
|
|
115
116
|
var scrollToElementContextValue = getScrollToElementContextValue(error);
|
|
116
117
|
var Providers = function (_a) {
|
|
@@ -118,7 +119,8 @@ describe('SimpleAttributeEditor', function () {
|
|
|
118
119
|
return (react_1.default.createElement(MdmModuleContext_1.MdmModuleProvider, { values: mdmValues },
|
|
119
120
|
react_1.default.createElement(AlwaysVisibleAttributesContext_1.AlwaysVisibleAttributesContext.Provider, { value: alwaysVisibleAttributes },
|
|
120
121
|
react_1.default.createElement(ProfilePerspectiveViewContext_1.ProfilePerspectiveViewContext.Provider, { value: isProfilePerspective },
|
|
121
|
-
react_1.default.createElement(
|
|
122
|
+
react_1.default.createElement(AuthoringPerspectiveViewContext_1.AuthoringPerspectiveViewContext.Provider, { value: isAuthoringPerspective },
|
|
123
|
+
react_1.default.createElement(ScrollToElementContext_1.ScrollToElementContext.Provider, { value: scrollToElementContextValue }, children))))));
|
|
122
124
|
};
|
|
123
125
|
return __assign({ user: user, scrollToElementContextValue: scrollToElementContextValue }, (0, react_2.render)(react_1.default.createElement(SimpleAttributeEditor_1.default, __assign({}, defaultProps, props)), { wrapper: Providers }));
|
|
124
126
|
};
|
|
@@ -353,7 +355,7 @@ describe('SimpleAttributeEditor', function () {
|
|
|
353
355
|
uri: 'configuration/entityTypes/HCA/attributes/InternalCustomer',
|
|
354
356
|
dependentLookupCode: 'Code'
|
|
355
357
|
};
|
|
356
|
-
it('should call getDependentLookupEditorContext selector with correct arguments', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
358
|
+
it('should call getDependentLookupEditorContext selector with correct arguments for profile perspective', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
357
359
|
return __generator(this, function (_a) {
|
|
358
360
|
switch (_a.label) {
|
|
359
361
|
case 0:
|
|
@@ -371,6 +373,24 @@ describe('SimpleAttributeEditor', function () {
|
|
|
371
373
|
}
|
|
372
374
|
});
|
|
373
375
|
}); });
|
|
376
|
+
it('should call getDependentLookupEditorContext selector with correct arguments for authoring perspective', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
377
|
+
return __generator(this, function (_a) {
|
|
378
|
+
switch (_a.label) {
|
|
379
|
+
case 0:
|
|
380
|
+
setUp({ props: { attributeType: attributeType }, isAuthoringPerspective: true });
|
|
381
|
+
return [4 /*yield*/, (0, react_2.act)(function () { return Promise.resolve(); })];
|
|
382
|
+
case 1:
|
|
383
|
+
_a.sent();
|
|
384
|
+
expect(MdmModuleContext_1.useMdmDependentLookupEditorContext).toHaveBeenCalledWith(defaultProps.attributeValue, attributeType);
|
|
385
|
+
expect(useAutopopulationContextValue_1.useAutopopulationContextValue).toHaveBeenCalledWith({
|
|
386
|
+
enabled: true,
|
|
387
|
+
attributeTypeUri: attributeType.uri,
|
|
388
|
+
valueUri: defaultProps.attributeValue.uri
|
|
389
|
+
});
|
|
390
|
+
return [2 /*return*/];
|
|
391
|
+
}
|
|
392
|
+
});
|
|
393
|
+
}); });
|
|
374
394
|
it('should call useAutopopulationContextValue with enabled: false if component is outside of Profile perspective', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
375
395
|
return __generator(this, function (_a) {
|
|
376
396
|
switch (_a.label) {
|
|
@@ -388,6 +408,23 @@ describe('SimpleAttributeEditor', function () {
|
|
|
388
408
|
}
|
|
389
409
|
});
|
|
390
410
|
}); });
|
|
411
|
+
it('should call useAutopopulationContextValue with enabled: false if component is outside of authoring perspective', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
412
|
+
return __generator(this, function (_a) {
|
|
413
|
+
switch (_a.label) {
|
|
414
|
+
case 0:
|
|
415
|
+
setUp({ props: { attributeType: attributeType }, isAuthoringPerspective: false });
|
|
416
|
+
return [4 /*yield*/, (0, react_2.act)(function () { return Promise.resolve(); })];
|
|
417
|
+
case 1:
|
|
418
|
+
_a.sent();
|
|
419
|
+
expect(useAutopopulationContextValue_1.useAutopopulationContextValue).toHaveBeenCalledWith({
|
|
420
|
+
enabled: false,
|
|
421
|
+
attributeTypeUri: attributeType.uri,
|
|
422
|
+
valueUri: defaultProps.attributeValue.uri
|
|
423
|
+
});
|
|
424
|
+
return [2 /*return*/];
|
|
425
|
+
}
|
|
426
|
+
});
|
|
427
|
+
}); });
|
|
391
428
|
it('should render dependent lookup editor with applied result of getDependentLookupEditorContext', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
392
429
|
var dlEditorContext, input;
|
|
393
430
|
return __generator(this, function (_a) {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.AuthoringPerspectiveViewContext = void 0;
|
|
7
|
+
var react_1 = __importDefault(require("react"));
|
|
8
|
+
exports.AuthoringPerspectiveViewContext = react_1.default.createContext(false);
|
|
9
|
+
exports.AuthoringPerspectiveViewContext.displayName = 'AuthoringPerspectiveViewContext';
|