@reltio/components 1.4.1889 → 1.4.1891
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/features/workflow/hooks/useWorkflowActions.d.ts +2 -2
- package/cjs/features/workflow/hooks/useWorkflowActions.js +6 -5
- package/cjs/hooks/useChangedAttributes/useChangedAttributes.d.ts +1 -1
- package/cjs/hooks/useChangedAttributes/useChangedAttributes.js +6 -4
- package/cjs/hooks/useHiddenAttributes/useHiddenAttributes.js +1 -1
- package/cjs/hooks/useHiddenAttributes/useHiddenAttributes.test.js +97 -1
- package/esm/features/workflow/hooks/useWorkflowActions.d.ts +2 -2
- package/esm/features/workflow/hooks/useWorkflowActions.js +6 -5
- package/esm/hooks/useChangedAttributes/useChangedAttributes.d.ts +1 -1
- package/esm/hooks/useChangedAttributes/useChangedAttributes.js +6 -4
- package/esm/hooks/useHiddenAttributes/useHiddenAttributes.js +1 -1
- package/esm/hooks/useHiddenAttributes/useHiddenAttributes.test.js +97 -1
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WorkflowTaskData } from '@reltio/mdm-sdk';
|
|
2
2
|
import { TaskAction } from '../types';
|
|
3
|
-
type
|
|
4
|
-
export declare const useWorkflowActions: (
|
|
3
|
+
type Task = Partial<Pick<WorkflowTaskData, 'taskId' | 'possibleActions' | 'assignee' | 'isOpen'>>;
|
|
4
|
+
export declare const useWorkflowActions: (task: Task, onActionSuccess?: (action: string) => void) => {
|
|
5
5
|
actions: TaskAction[];
|
|
6
6
|
actionRequestIsInProgress: boolean;
|
|
7
7
|
};
|
|
@@ -7,14 +7,15 @@ var errors_1 = require("../helpers/errors");
|
|
|
7
7
|
var common_1 = require("../helpers/common");
|
|
8
8
|
var WorkflowTasksContext_1 = require("../../../contexts/WorkflowTasksContext");
|
|
9
9
|
var MdmModuleContext_1 = require("../../../contexts/MdmModuleContext");
|
|
10
|
-
var useWorkflowActions = function (
|
|
11
|
-
var possibleActions = _a.possibleActions, assignee = _a.assignee, taskId = _a.taskId, isOpen = _a.isOpen;
|
|
12
|
-
var
|
|
10
|
+
var useWorkflowActions = function (task, onActionSuccess) {
|
|
11
|
+
var _a = task !== null && task !== void 0 ? task : {}, possibleActions = _a.possibleActions, assignee = _a.assignee, taskId = _a.taskId, isOpen = _a.isOpen;
|
|
12
|
+
var workflowTasks = (0, react_1.useContext)(WorkflowTasksContext_1.WorkflowTasksContext);
|
|
13
13
|
var workflowPath = (0, MdmModuleContext_1.useMdmWorkflowPath)();
|
|
14
14
|
var environment = (0, MdmModuleContext_1.useMdmWorkflowEnvironmentUrl)();
|
|
15
15
|
var tenant = (0, MdmModuleContext_1.useMdmTenant)();
|
|
16
16
|
var username = (0, MdmModuleContext_1.useMdmUsername)();
|
|
17
17
|
var _b = (0, react_1.useState)(false), actionRequestIsInProgress = _b[0], setActionRequestIsInProgress = _b[1];
|
|
18
|
+
var handleActionSuccess = onActionSuccess !== null && onActionSuccess !== void 0 ? onActionSuccess : workflowTasks === null || workflowTasks === void 0 ? void 0 : workflowTasks.onActionSuccess;
|
|
18
19
|
var performTaskAction = (0, react_1.useCallback)(function (action) { return function (comment) {
|
|
19
20
|
if (workflowPath && taskId) {
|
|
20
21
|
setActionRequestIsInProgress(true);
|
|
@@ -28,14 +29,14 @@ var useWorkflowActions = function (_a) {
|
|
|
28
29
|
processInstanceComment: processInstanceComment
|
|
29
30
|
})
|
|
30
31
|
.then(function () {
|
|
31
|
-
|
|
32
|
+
handleActionSuccess === null || handleActionSuccess === void 0 ? void 0 : handleActionSuccess(action);
|
|
32
33
|
})
|
|
33
34
|
.catch(errors_1.showWorkflowError)
|
|
34
35
|
.finally(function () {
|
|
35
36
|
setActionRequestIsInProgress(false);
|
|
36
37
|
});
|
|
37
38
|
}
|
|
38
|
-
}; }, [workflowPath, taskId, environment, tenant,
|
|
39
|
+
}; }, [workflowPath, taskId, environment, tenant, handleActionSuccess]);
|
|
39
40
|
var actions = (0, react_1.useMemo)(function () {
|
|
40
41
|
return username === assignee && (0, common_1.isOpenTask)(isOpen)
|
|
41
42
|
? (possibleActions || []).map(function (_a) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { RecordAttributesType } from '@reltio/mdm-sdk';
|
|
2
|
-
export declare const useChangedAttributes: (attributes: RecordAttributesType, controlAttributes: string[]) => string[];
|
|
2
|
+
export declare const useChangedAttributes: (entityUri: string, attributes: RecordAttributesType, controlAttributes: string[]) => string[];
|
|
@@ -11,17 +11,18 @@ var getValues = function (controlAttribute, attributes) {
|
|
|
11
11
|
return (0, ramda_1.flatten)((0, mdm_sdk_1.getOvAttributeValuesByPathWithUri)(attrPath, attributes));
|
|
12
12
|
};
|
|
13
13
|
var getValuesHash = (0, ramda_1.pipe)((0, ramda_1.pluck)('value'), (0, ramda_1.join)('-'));
|
|
14
|
-
var useChangedAttributes = function (attributes, controlAttributes) {
|
|
14
|
+
var useChangedAttributes = function (entityUri, attributes, controlAttributes) {
|
|
15
|
+
var previousEntityUri = (0, react_1.useRef)();
|
|
15
16
|
var previousAttributesValues = (0, react_1.useRef)();
|
|
16
17
|
var attributeValues = (0, react_1.useMemo)(function () {
|
|
17
18
|
return controlAttributes.reduce(function (values, controlAttribute) {
|
|
18
19
|
values[controlAttribute] = (0, ramda_1.pipe)(getValues, getValuesHash)(controlAttribute, attributes);
|
|
19
20
|
return values;
|
|
20
|
-
}, {})
|
|
21
|
+
}, {});
|
|
21
22
|
}, [controlAttributes, attributes]);
|
|
22
23
|
var changedAttributes = (0, react_1.useMemo)(function () {
|
|
23
24
|
var attributeUris = Object.keys(attributeValues);
|
|
24
|
-
return previousAttributesValues.current
|
|
25
|
+
return previousEntityUri.current === entityUri && previousAttributesValues.current
|
|
25
26
|
? attributeUris.reduce(function (changedAttributes, attributeUri) {
|
|
26
27
|
var attributeValue = attributeValues[attributeUri];
|
|
27
28
|
var previousAttributeValue = previousAttributesValues.current[attributeUri];
|
|
@@ -30,7 +31,8 @@ var useChangedAttributes = function (attributes, controlAttributes) {
|
|
|
30
31
|
: changedAttributes;
|
|
31
32
|
}, []) || []
|
|
32
33
|
: attributeUris;
|
|
33
|
-
}, [attributeValues]);
|
|
34
|
+
}, [entityUri, attributeValues]);
|
|
35
|
+
previousEntityUri.current = entityUri;
|
|
34
36
|
previousAttributesValues.current = attributeValues;
|
|
35
37
|
return changedAttributes;
|
|
36
38
|
};
|
|
@@ -38,7 +38,7 @@ var useHiddenAttributes = function () {
|
|
|
38
38
|
});
|
|
39
39
|
}, [ruleBasedAttributes]);
|
|
40
40
|
var newControlAttributes = (0, react_1.useMemo)(function () { return (0, ramda_1.pipe)((0, ramda_1.pluck)('controlAttributes'), ramda_1.flatten, ramda_1.uniq)(parsedRuleBasedAttributes); }, [parsedRuleBasedAttributes]);
|
|
41
|
-
var changedAttributes = (0, useChangedAttributes_1.useChangedAttributes)(entity === null || entity === void 0 ? void 0 : entity.attributes, newControlAttributes);
|
|
41
|
+
var changedAttributes = (0, useChangedAttributes_1.useChangedAttributes)(entityUri, entity === null || entity === void 0 ? void 0 : entity.attributes, newControlAttributes);
|
|
42
42
|
var showAttributeURIs = (0, react_1.useMemo)(function () {
|
|
43
43
|
return changedAttributes.length ? (0, helpers_1.findShowAttributeURIs)(changedAttributes, parsedRuleBasedAttributes) : [];
|
|
44
44
|
}, [parsedRuleBasedAttributes, changedAttributes]);
|
|
@@ -104,13 +104,22 @@ describe('useHiddenAttributes', function () {
|
|
|
104
104
|
]
|
|
105
105
|
};
|
|
106
106
|
var updateHiddenAttributes = jest.fn();
|
|
107
|
+
var resetHiddenAttributes = jest.fn();
|
|
107
108
|
var setUp = function () { return (0, react_hooks_1.renderHook)(useHiddenAttributes_1.useHiddenAttributes); };
|
|
108
109
|
beforeEach(function () {
|
|
109
110
|
MdmModuleContext_1.useMdmMetadata.mockReturnValue(metadata);
|
|
110
111
|
MdmModuleContext_1.useMdmEntity.mockReturnValue(null);
|
|
111
112
|
MdmModuleContext_1.useMdmModifiedEntity.mockReturnValue(null);
|
|
112
113
|
MdmModuleContext_1.useMdmMode.mockReturnValue(mdm_sdk_1.Mode.Viewing);
|
|
113
|
-
MdmModuleContext_1.useMdmAction.
|
|
114
|
+
MdmModuleContext_1.useMdmAction.mockImplementation(function (action) {
|
|
115
|
+
if (action === 'updateHiddenAttributes') {
|
|
116
|
+
return updateHiddenAttributes;
|
|
117
|
+
}
|
|
118
|
+
if (action === 'resetHiddenAttributes') {
|
|
119
|
+
return resetHiddenAttributes;
|
|
120
|
+
}
|
|
121
|
+
return jest.fn();
|
|
122
|
+
});
|
|
114
123
|
});
|
|
115
124
|
afterEach(function () {
|
|
116
125
|
jest.clearAllMocks();
|
|
@@ -367,4 +376,91 @@ describe('useHiddenAttributes', function () {
|
|
|
367
376
|
'configuration/entityTypes/HCP/attributes/Category2'
|
|
368
377
|
]);
|
|
369
378
|
});
|
|
379
|
+
it('does not reset hidden attributes when switching from viewing mode to editing', function () {
|
|
380
|
+
var entity = {
|
|
381
|
+
type: 'configuration/entityTypes/HCP',
|
|
382
|
+
uri: 'entities/uri_e',
|
|
383
|
+
attributes: {
|
|
384
|
+
Category1: [
|
|
385
|
+
{
|
|
386
|
+
uri: 'entities/uri_e/attributes/uri1',
|
|
387
|
+
value: 'category1_value1'
|
|
388
|
+
}
|
|
389
|
+
],
|
|
390
|
+
Category2: [
|
|
391
|
+
{
|
|
392
|
+
uri: 'entities/uri_e/attributes/uri2',
|
|
393
|
+
value: 'category2_value1'
|
|
394
|
+
}
|
|
395
|
+
],
|
|
396
|
+
Category3: [
|
|
397
|
+
{
|
|
398
|
+
uri: 'entities/uri_e/attributes/uri3',
|
|
399
|
+
value: 'category3_value1'
|
|
400
|
+
}
|
|
401
|
+
],
|
|
402
|
+
Category4: [
|
|
403
|
+
{
|
|
404
|
+
uri: 'entities/uri_e/attributes/uri4',
|
|
405
|
+
value: 'category4_value1'
|
|
406
|
+
}
|
|
407
|
+
]
|
|
408
|
+
}
|
|
409
|
+
};
|
|
410
|
+
MdmModuleContext_1.useMdmMode.mockReturnValue(mdm_sdk_1.Mode.Viewing);
|
|
411
|
+
MdmModuleContext_1.useMdmEntity.mockReturnValue(entity);
|
|
412
|
+
MdmModuleContext_1.useMdmModifiedEntity.mockReturnValue(null);
|
|
413
|
+
resetHiddenAttributes.mockClear();
|
|
414
|
+
var rerender = setUp().rerender;
|
|
415
|
+
expect(updateHiddenAttributes).toHaveBeenCalledWith(entity.uri, []);
|
|
416
|
+
MdmModuleContext_1.useMdmMode.mockReturnValue(mdm_sdk_1.Mode.Editing);
|
|
417
|
+
rerender();
|
|
418
|
+
expect(resetHiddenAttributes).not.toHaveBeenCalled();
|
|
419
|
+
resetHiddenAttributes.mockClear();
|
|
420
|
+
MdmModuleContext_1.useMdmModifiedEntity.mockReturnValue(entity);
|
|
421
|
+
rerender();
|
|
422
|
+
expect(resetHiddenAttributes).not.toHaveBeenCalled();
|
|
423
|
+
});
|
|
424
|
+
it('updates hidden attributes when saving new entity (switching from editing mode to viewing)', function () {
|
|
425
|
+
var entity = {
|
|
426
|
+
type: 'configuration/entityTypes/HCP',
|
|
427
|
+
uri: 'entities/uri_e_temporary',
|
|
428
|
+
attributes: {
|
|
429
|
+
Category1: [
|
|
430
|
+
{
|
|
431
|
+
uri: 'entities/uri_e/attributes/uri1',
|
|
432
|
+
value: 'category1_value1'
|
|
433
|
+
}
|
|
434
|
+
],
|
|
435
|
+
Category2: [
|
|
436
|
+
{
|
|
437
|
+
uri: 'entities/uri_e/attributes/uri2',
|
|
438
|
+
value: 'category2_value1'
|
|
439
|
+
}
|
|
440
|
+
],
|
|
441
|
+
Category3: [
|
|
442
|
+
{
|
|
443
|
+
uri: 'entities/uri_e/attributes/uri3',
|
|
444
|
+
value: 'category3_value1'
|
|
445
|
+
}
|
|
446
|
+
],
|
|
447
|
+
Category4: [
|
|
448
|
+
{
|
|
449
|
+
uri: 'entities/uri_e/attributes/uri4',
|
|
450
|
+
value: 'category4_value1'
|
|
451
|
+
}
|
|
452
|
+
]
|
|
453
|
+
}
|
|
454
|
+
};
|
|
455
|
+
MdmModuleContext_1.useMdmMode.mockReturnValue(mdm_sdk_1.Mode.Editing);
|
|
456
|
+
MdmModuleContext_1.useMdmEntity.mockReturnValue(null);
|
|
457
|
+
MdmModuleContext_1.useMdmModifiedEntity.mockReturnValue(entity);
|
|
458
|
+
var rerender = setUp().rerender;
|
|
459
|
+
expect(updateHiddenAttributes).toHaveBeenCalledWith(entity.uri, []);
|
|
460
|
+
MdmModuleContext_1.useMdmMode.mockReturnValue(mdm_sdk_1.Mode.Viewing);
|
|
461
|
+
MdmModuleContext_1.useMdmEntity.mockReturnValue(__assign(__assign({}, entity), { uri: 'entities/uri_e_permanent' }));
|
|
462
|
+
rerender();
|
|
463
|
+
expect(resetHiddenAttributes).toHaveBeenCalled();
|
|
464
|
+
expect(updateHiddenAttributes).toHaveBeenCalledWith('entities/uri_e_permanent', []);
|
|
465
|
+
});
|
|
370
466
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WorkflowTaskData } from '@reltio/mdm-sdk';
|
|
2
2
|
import { TaskAction } from '../types';
|
|
3
|
-
type
|
|
4
|
-
export declare const useWorkflowActions: (
|
|
3
|
+
type Task = Partial<Pick<WorkflowTaskData, 'taskId' | 'possibleActions' | 'assignee' | 'isOpen'>>;
|
|
4
|
+
export declare const useWorkflowActions: (task: Task, onActionSuccess?: (action: string) => void) => {
|
|
5
5
|
actions: TaskAction[];
|
|
6
6
|
actionRequestIsInProgress: boolean;
|
|
7
7
|
};
|
|
@@ -4,14 +4,15 @@ import { showWorkflowError } from '../helpers/errors';
|
|
|
4
4
|
import { isOpenTask } from '../helpers/common';
|
|
5
5
|
import { WorkflowTasksContext } from '../../../contexts/WorkflowTasksContext';
|
|
6
6
|
import { useMdmTenant, useMdmUsername, useMdmWorkflowEnvironmentUrl, useMdmWorkflowPath } from '../../../contexts/MdmModuleContext';
|
|
7
|
-
export var useWorkflowActions = function (
|
|
8
|
-
var possibleActions = _a.possibleActions, assignee = _a.assignee, taskId = _a.taskId, isOpen = _a.isOpen;
|
|
9
|
-
var
|
|
7
|
+
export var useWorkflowActions = function (task, onActionSuccess) {
|
|
8
|
+
var _a = task !== null && task !== void 0 ? task : {}, possibleActions = _a.possibleActions, assignee = _a.assignee, taskId = _a.taskId, isOpen = _a.isOpen;
|
|
9
|
+
var workflowTasks = useContext(WorkflowTasksContext);
|
|
10
10
|
var workflowPath = useMdmWorkflowPath();
|
|
11
11
|
var environment = useMdmWorkflowEnvironmentUrl();
|
|
12
12
|
var tenant = useMdmTenant();
|
|
13
13
|
var username = useMdmUsername();
|
|
14
14
|
var _b = useState(false), actionRequestIsInProgress = _b[0], setActionRequestIsInProgress = _b[1];
|
|
15
|
+
var handleActionSuccess = onActionSuccess !== null && onActionSuccess !== void 0 ? onActionSuccess : workflowTasks === null || workflowTasks === void 0 ? void 0 : workflowTasks.onActionSuccess;
|
|
15
16
|
var performTaskAction = useCallback(function (action) { return function (comment) {
|
|
16
17
|
if (workflowPath && taskId) {
|
|
17
18
|
setActionRequestIsInProgress(true);
|
|
@@ -25,14 +26,14 @@ export var useWorkflowActions = function (_a) {
|
|
|
25
26
|
processInstanceComment: processInstanceComment
|
|
26
27
|
})
|
|
27
28
|
.then(function () {
|
|
28
|
-
|
|
29
|
+
handleActionSuccess === null || handleActionSuccess === void 0 ? void 0 : handleActionSuccess(action);
|
|
29
30
|
})
|
|
30
31
|
.catch(showWorkflowError)
|
|
31
32
|
.finally(function () {
|
|
32
33
|
setActionRequestIsInProgress(false);
|
|
33
34
|
});
|
|
34
35
|
}
|
|
35
|
-
}; }, [workflowPath, taskId, environment, tenant,
|
|
36
|
+
}; }, [workflowPath, taskId, environment, tenant, handleActionSuccess]);
|
|
36
37
|
var actions = useMemo(function () {
|
|
37
38
|
return username === assignee && isOpenTask(isOpen)
|
|
38
39
|
? (possibleActions || []).map(function (_a) {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { RecordAttributesType } from '@reltio/mdm-sdk';
|
|
2
|
-
export declare const useChangedAttributes: (attributes: RecordAttributesType, controlAttributes: string[]) => string[];
|
|
2
|
+
export declare const useChangedAttributes: (entityUri: string, attributes: RecordAttributesType, controlAttributes: string[]) => string[];
|
|
@@ -8,17 +8,18 @@ var getValues = function (controlAttribute, attributes) {
|
|
|
8
8
|
return flatten(getOvAttributeValuesByPathWithUri(attrPath, attributes));
|
|
9
9
|
};
|
|
10
10
|
var getValuesHash = pipe(pluck('value'), join('-'));
|
|
11
|
-
export var useChangedAttributes = function (attributes, controlAttributes) {
|
|
11
|
+
export var useChangedAttributes = function (entityUri, attributes, controlAttributes) {
|
|
12
|
+
var previousEntityUri = useRef();
|
|
12
13
|
var previousAttributesValues = useRef();
|
|
13
14
|
var attributeValues = useMemo(function () {
|
|
14
15
|
return controlAttributes.reduce(function (values, controlAttribute) {
|
|
15
16
|
values[controlAttribute] = pipe(getValues, getValuesHash)(controlAttribute, attributes);
|
|
16
17
|
return values;
|
|
17
|
-
}, {})
|
|
18
|
+
}, {});
|
|
18
19
|
}, [controlAttributes, attributes]);
|
|
19
20
|
var changedAttributes = useMemo(function () {
|
|
20
21
|
var attributeUris = Object.keys(attributeValues);
|
|
21
|
-
return previousAttributesValues.current
|
|
22
|
+
return previousEntityUri.current === entityUri && previousAttributesValues.current
|
|
22
23
|
? attributeUris.reduce(function (changedAttributes, attributeUri) {
|
|
23
24
|
var attributeValue = attributeValues[attributeUri];
|
|
24
25
|
var previousAttributeValue = previousAttributesValues.current[attributeUri];
|
|
@@ -27,7 +28,8 @@ export var useChangedAttributes = function (attributes, controlAttributes) {
|
|
|
27
28
|
: changedAttributes;
|
|
28
29
|
}, []) || []
|
|
29
30
|
: attributeUris;
|
|
30
|
-
}, [attributeValues]);
|
|
31
|
+
}, [entityUri, attributeValues]);
|
|
32
|
+
previousEntityUri.current = entityUri;
|
|
31
33
|
previousAttributesValues.current = attributeValues;
|
|
32
34
|
return changedAttributes;
|
|
33
35
|
};
|
|
@@ -35,7 +35,7 @@ export var useHiddenAttributes = function () {
|
|
|
35
35
|
});
|
|
36
36
|
}, [ruleBasedAttributes]);
|
|
37
37
|
var newControlAttributes = useMemo(function () { return pipe(pluck('controlAttributes'), flatten, uniq)(parsedRuleBasedAttributes); }, [parsedRuleBasedAttributes]);
|
|
38
|
-
var changedAttributes = useChangedAttributes(entity === null || entity === void 0 ? void 0 : entity.attributes, newControlAttributes);
|
|
38
|
+
var changedAttributes = useChangedAttributes(entityUri, entity === null || entity === void 0 ? void 0 : entity.attributes, newControlAttributes);
|
|
39
39
|
var showAttributeURIs = useMemo(function () {
|
|
40
40
|
return changedAttributes.length ? findShowAttributeURIs(changedAttributes, parsedRuleBasedAttributes) : [];
|
|
41
41
|
}, [parsedRuleBasedAttributes, changedAttributes]);
|
|
@@ -102,13 +102,22 @@ describe('useHiddenAttributes', function () {
|
|
|
102
102
|
]
|
|
103
103
|
};
|
|
104
104
|
var updateHiddenAttributes = jest.fn();
|
|
105
|
+
var resetHiddenAttributes = jest.fn();
|
|
105
106
|
var setUp = function () { return renderHook(useHiddenAttributes); };
|
|
106
107
|
beforeEach(function () {
|
|
107
108
|
useMdmMetadata.mockReturnValue(metadata);
|
|
108
109
|
useMdmEntity.mockReturnValue(null);
|
|
109
110
|
useMdmModifiedEntity.mockReturnValue(null);
|
|
110
111
|
useMdmMode.mockReturnValue(Mode.Viewing);
|
|
111
|
-
useMdmAction.
|
|
112
|
+
useMdmAction.mockImplementation(function (action) {
|
|
113
|
+
if (action === 'updateHiddenAttributes') {
|
|
114
|
+
return updateHiddenAttributes;
|
|
115
|
+
}
|
|
116
|
+
if (action === 'resetHiddenAttributes') {
|
|
117
|
+
return resetHiddenAttributes;
|
|
118
|
+
}
|
|
119
|
+
return jest.fn();
|
|
120
|
+
});
|
|
112
121
|
});
|
|
113
122
|
afterEach(function () {
|
|
114
123
|
jest.clearAllMocks();
|
|
@@ -365,4 +374,91 @@ describe('useHiddenAttributes', function () {
|
|
|
365
374
|
'configuration/entityTypes/HCP/attributes/Category2'
|
|
366
375
|
]);
|
|
367
376
|
});
|
|
377
|
+
it('does not reset hidden attributes when switching from viewing mode to editing', function () {
|
|
378
|
+
var entity = {
|
|
379
|
+
type: 'configuration/entityTypes/HCP',
|
|
380
|
+
uri: 'entities/uri_e',
|
|
381
|
+
attributes: {
|
|
382
|
+
Category1: [
|
|
383
|
+
{
|
|
384
|
+
uri: 'entities/uri_e/attributes/uri1',
|
|
385
|
+
value: 'category1_value1'
|
|
386
|
+
}
|
|
387
|
+
],
|
|
388
|
+
Category2: [
|
|
389
|
+
{
|
|
390
|
+
uri: 'entities/uri_e/attributes/uri2',
|
|
391
|
+
value: 'category2_value1'
|
|
392
|
+
}
|
|
393
|
+
],
|
|
394
|
+
Category3: [
|
|
395
|
+
{
|
|
396
|
+
uri: 'entities/uri_e/attributes/uri3',
|
|
397
|
+
value: 'category3_value1'
|
|
398
|
+
}
|
|
399
|
+
],
|
|
400
|
+
Category4: [
|
|
401
|
+
{
|
|
402
|
+
uri: 'entities/uri_e/attributes/uri4',
|
|
403
|
+
value: 'category4_value1'
|
|
404
|
+
}
|
|
405
|
+
]
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
useMdmMode.mockReturnValue(Mode.Viewing);
|
|
409
|
+
useMdmEntity.mockReturnValue(entity);
|
|
410
|
+
useMdmModifiedEntity.mockReturnValue(null);
|
|
411
|
+
resetHiddenAttributes.mockClear();
|
|
412
|
+
var rerender = setUp().rerender;
|
|
413
|
+
expect(updateHiddenAttributes).toHaveBeenCalledWith(entity.uri, []);
|
|
414
|
+
useMdmMode.mockReturnValue(Mode.Editing);
|
|
415
|
+
rerender();
|
|
416
|
+
expect(resetHiddenAttributes).not.toHaveBeenCalled();
|
|
417
|
+
resetHiddenAttributes.mockClear();
|
|
418
|
+
useMdmModifiedEntity.mockReturnValue(entity);
|
|
419
|
+
rerender();
|
|
420
|
+
expect(resetHiddenAttributes).not.toHaveBeenCalled();
|
|
421
|
+
});
|
|
422
|
+
it('updates hidden attributes when saving new entity (switching from editing mode to viewing)', function () {
|
|
423
|
+
var entity = {
|
|
424
|
+
type: 'configuration/entityTypes/HCP',
|
|
425
|
+
uri: 'entities/uri_e_temporary',
|
|
426
|
+
attributes: {
|
|
427
|
+
Category1: [
|
|
428
|
+
{
|
|
429
|
+
uri: 'entities/uri_e/attributes/uri1',
|
|
430
|
+
value: 'category1_value1'
|
|
431
|
+
}
|
|
432
|
+
],
|
|
433
|
+
Category2: [
|
|
434
|
+
{
|
|
435
|
+
uri: 'entities/uri_e/attributes/uri2',
|
|
436
|
+
value: 'category2_value1'
|
|
437
|
+
}
|
|
438
|
+
],
|
|
439
|
+
Category3: [
|
|
440
|
+
{
|
|
441
|
+
uri: 'entities/uri_e/attributes/uri3',
|
|
442
|
+
value: 'category3_value1'
|
|
443
|
+
}
|
|
444
|
+
],
|
|
445
|
+
Category4: [
|
|
446
|
+
{
|
|
447
|
+
uri: 'entities/uri_e/attributes/uri4',
|
|
448
|
+
value: 'category4_value1'
|
|
449
|
+
}
|
|
450
|
+
]
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
useMdmMode.mockReturnValue(Mode.Editing);
|
|
454
|
+
useMdmEntity.mockReturnValue(null);
|
|
455
|
+
useMdmModifiedEntity.mockReturnValue(entity);
|
|
456
|
+
var rerender = setUp().rerender;
|
|
457
|
+
expect(updateHiddenAttributes).toHaveBeenCalledWith(entity.uri, []);
|
|
458
|
+
useMdmMode.mockReturnValue(Mode.Viewing);
|
|
459
|
+
useMdmEntity.mockReturnValue(__assign(__assign({}, entity), { uri: 'entities/uri_e_permanent' }));
|
|
460
|
+
rerender();
|
|
461
|
+
expect(resetHiddenAttributes).toHaveBeenCalled();
|
|
462
|
+
expect(updateHiddenAttributes).toHaveBeenCalledWith('entities/uri_e_permanent', []);
|
|
463
|
+
});
|
|
368
464
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reltio/components",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1891",
|
|
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.1824",
|
|
12
12
|
"classnames": "^2.2.5",
|
|
13
13
|
"d3-cloud": "^1.2.5",
|
|
14
14
|
"d3-geo": "^2.0.1",
|