@reltio/components 1.4.1849 → 1.4.1851
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/SaveSegmentDialog/SaveSegmentDialog.d.ts +8 -0
- package/cjs/SaveSegmentDialog/SaveSegmentDialog.js +129 -0
- package/cjs/SaveSegmentDialog/SaveSegmentDialog.test.d.ts +1 -0
- package/cjs/SaveSegmentDialog/SaveSegmentDialog.test.js +214 -0
- package/cjs/SaveSegmentDialog/index.d.ts +1 -0
- package/cjs/SaveSegmentDialog/index.js +5 -0
- package/cjs/SaveSegmentDialog/styles.d.ts +1 -0
- package/cjs/SaveSegmentDialog/styles.js +15 -0
- 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/cjs/hooks/useSavedSearchesRequest/index.d.ts +1 -0
- package/cjs/hooks/useSavedSearchesRequest/index.js +5 -0
- package/cjs/hooks/useSavedSearchesRequest/requests.d.ts +6 -0
- package/cjs/hooks/useSavedSearchesRequest/requests.js +72 -0
- package/cjs/hooks/useSavedSearchesRequest/useSavedSearchesRequest.d.ts +76 -0
- package/cjs/hooks/useSavedSearchesRequest/useSavedSearchesRequest.js +255 -0
- package/cjs/hooks/useSavedSearchesRequest/useSavedSearchesRequest.test.d.ts +1 -0
- package/cjs/hooks/useSavedSearchesRequest/useSavedSearchesRequest.test.js +743 -0
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +3 -1
- 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/SaveSegmentDialog/SaveSegmentDialog.d.ts +8 -0
- package/esm/SaveSegmentDialog/SaveSegmentDialog.js +99 -0
- package/esm/SaveSegmentDialog/SaveSegmentDialog.test.d.ts +1 -0
- package/esm/SaveSegmentDialog/SaveSegmentDialog.test.js +209 -0
- package/esm/SaveSegmentDialog/index.d.ts +1 -0
- package/esm/SaveSegmentDialog/index.js +1 -0
- package/esm/SaveSegmentDialog/styles.d.ts +1 -0
- package/esm/SaveSegmentDialog/styles.js +12 -0
- 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/esm/hooks/useSavedSearchesRequest/index.d.ts +1 -0
- package/esm/hooks/useSavedSearchesRequest/index.js +1 -0
- package/esm/hooks/useSavedSearchesRequest/requests.d.ts +6 -0
- package/esm/hooks/useSavedSearchesRequest/requests.js +68 -0
- package/esm/hooks/useSavedSearchesRequest/useSavedSearchesRequest.d.ts +76 -0
- package/esm/hooks/useSavedSearchesRequest/useSavedSearchesRequest.js +251 -0
- package/esm/hooks/useSavedSearchesRequest/useSavedSearchesRequest.test.d.ts +1 -0
- package/esm/hooks/useSavedSearchesRequest/useSavedSearchesRequest.test.js +738 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/package.json +2 -2
- package/cjs/hooks/useSavedSearchesRequest.d.ts +0 -23
- package/cjs/hooks/useSavedSearchesRequest.js +0 -224
- package/esm/hooks/useSavedSearchesRequest.d.ts +0 -23
- package/esm/hooks/useSavedSearchesRequest.js +0 -220
|
@@ -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 {};
|
|
@@ -0,0 +1,368 @@
|
|
|
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 { assocPath } from 'ramda';
|
|
13
|
+
import { renderHook } from '@testing-library/react-hooks';
|
|
14
|
+
import { Mode } from '@reltio/mdm-sdk';
|
|
15
|
+
import { useMdmAction, useMdmEntity, useMdmMetadata, useMdmModifiedEntity, useMdmMode } from '../../contexts/MdmModuleContext/hooks';
|
|
16
|
+
import { useHiddenAttributes } from './useHiddenAttributes';
|
|
17
|
+
jest.mock('../../contexts/MdmModuleContext/hooks', function () { return (__assign(__assign({}, jest.requireActual('../../contexts/MdmModuleContext/hooks')), { useMdmAction: jest.fn(), useMdmMetadata: jest.fn(), useMdmEntity: jest.fn().mockReturnValue({}), useMdmModifiedEntity: jest.fn(), useMdmMode: jest.fn() })); });
|
|
18
|
+
describe('useHiddenAttributes', function () {
|
|
19
|
+
var metadata = {
|
|
20
|
+
entityTypes: [
|
|
21
|
+
{
|
|
22
|
+
uri: 'configuration/entityTypes/HCP',
|
|
23
|
+
attributes: [
|
|
24
|
+
{
|
|
25
|
+
name: 'Category1',
|
|
26
|
+
type: 'String',
|
|
27
|
+
uri: 'configuration/entityTypes/HCP/attributes/Category1'
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: 'Category2',
|
|
31
|
+
type: 'String',
|
|
32
|
+
uri: 'configuration/entityTypes/HCP/attributes/Category2'
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
name: 'Category3',
|
|
36
|
+
type: 'String',
|
|
37
|
+
uri: 'configuration/entityTypes/HCP/attributes/Category3'
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: 'Category4',
|
|
41
|
+
type: 'String',
|
|
42
|
+
uri: 'configuration/entityTypes/HCP/attributes/Category4'
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
name: 'Nested1',
|
|
46
|
+
label: 'Nested1',
|
|
47
|
+
type: 'Nested',
|
|
48
|
+
uri: 'configuration/entityTypes/HCP/attributes/Nested1',
|
|
49
|
+
attributes: [
|
|
50
|
+
{
|
|
51
|
+
name: 'NestedCategory1',
|
|
52
|
+
type: 'String',
|
|
53
|
+
uri: 'configuration/entityTypes/HCP/attributes/Nested1/attributes/NestedCategory1'
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'NestedCategory2',
|
|
57
|
+
type: 'String',
|
|
58
|
+
uri: 'configuration/entityTypes/HCP/attributes/Nested1/attributes/NestedCategory2'
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
ruleBasedAttributes: [
|
|
64
|
+
{
|
|
65
|
+
uri: 'configuration/entityTypes/HCP/ruleBasedAttributes/DynamicRule1',
|
|
66
|
+
label: 'Dynamic Rule 1',
|
|
67
|
+
description: 'Dynamic Attributes Rule 1',
|
|
68
|
+
name: 'DynamicRule1',
|
|
69
|
+
type: 'Dynamic',
|
|
70
|
+
controlFunction: {
|
|
71
|
+
expression: "listEquals(attributes.Category1.value, 'category1_value1') and listEquals(attributes.Category2.value, 'category2_value1', 'category2_value2')",
|
|
72
|
+
showAttributeURI: [
|
|
73
|
+
'configuration/entityTypes/HCP/attributes/Category3',
|
|
74
|
+
'configuration/entityTypes/HCP/attributes/Category4'
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
uri: 'configuration/entityTypes/HCP/ruleBasedAttributes/DynamicRule2',
|
|
80
|
+
label: 'Dynamic Rule 2',
|
|
81
|
+
description: 'Dynamic Attributes Rule 2',
|
|
82
|
+
name: 'DynamicRule2',
|
|
83
|
+
type: 'Dynamic',
|
|
84
|
+
controlFunction: {
|
|
85
|
+
expression: "listEquals(attributes.Category1.value, 'category1_value1')",
|
|
86
|
+
showAttributeURI: ['configuration/entityTypes/HCP/attributes/Category2']
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
uri: 'configuration/entityTypes/HCP/ruleBasedAttributes/DynamicRule3',
|
|
91
|
+
label: 'Dynamic Rule 3',
|
|
92
|
+
description: 'Dynamic Attributes Rule 3',
|
|
93
|
+
name: 'DynamicRule3',
|
|
94
|
+
type: 'Dynamic',
|
|
95
|
+
controlFunction: {
|
|
96
|
+
expression: "listEquals(attributes.Category1.value, 'category1_value2')",
|
|
97
|
+
showAttributeURI: ['configuration/entityTypes/HCP/attributes/Category4']
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
};
|
|
104
|
+
var updateHiddenAttributes = jest.fn();
|
|
105
|
+
var setUp = function () { return renderHook(useHiddenAttributes); };
|
|
106
|
+
beforeEach(function () {
|
|
107
|
+
useMdmMetadata.mockReturnValue(metadata);
|
|
108
|
+
useMdmEntity.mockReturnValue(null);
|
|
109
|
+
useMdmModifiedEntity.mockReturnValue(null);
|
|
110
|
+
useMdmMode.mockReturnValue(Mode.Viewing);
|
|
111
|
+
useMdmAction.mockReturnValue(updateHiddenAttributes);
|
|
112
|
+
});
|
|
113
|
+
afterEach(function () {
|
|
114
|
+
jest.clearAllMocks();
|
|
115
|
+
});
|
|
116
|
+
it('should hide attributes if there is no satisfied dynamic rules', function () {
|
|
117
|
+
var entity = {
|
|
118
|
+
type: 'configuration/entityTypes/HCP',
|
|
119
|
+
uri: 'entities/uri_e',
|
|
120
|
+
attributes: {
|
|
121
|
+
Category1: [
|
|
122
|
+
{
|
|
123
|
+
uri: 'entities/uri_e/attributes/uri1',
|
|
124
|
+
value: 'category1_value1_diff'
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
Category2: [
|
|
128
|
+
{
|
|
129
|
+
uri: 'entities/uri_e/attributes/uri2',
|
|
130
|
+
value: 'category2_value1_diff'
|
|
131
|
+
}
|
|
132
|
+
],
|
|
133
|
+
Category3: [
|
|
134
|
+
{
|
|
135
|
+
uri: 'entities/uri_e/attributes/uri3',
|
|
136
|
+
value: 'category3_value1'
|
|
137
|
+
}
|
|
138
|
+
],
|
|
139
|
+
Category4: [
|
|
140
|
+
{
|
|
141
|
+
uri: 'entities/uri_e/attributes/uri4',
|
|
142
|
+
value: 'category4_value1'
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
useMdmEntity.mockReturnValue(entity);
|
|
148
|
+
setUp();
|
|
149
|
+
expect(updateHiddenAttributes).toHaveBeenCalledWith(entity.uri, [
|
|
150
|
+
'configuration/entityTypes/HCP/attributes/Category3',
|
|
151
|
+
'configuration/entityTypes/HCP/attributes/Category4',
|
|
152
|
+
'configuration/entityTypes/HCP/attributes/Category2'
|
|
153
|
+
]);
|
|
154
|
+
});
|
|
155
|
+
it('should not hide attributes if there is a satisfied dynamic rule', function () {
|
|
156
|
+
var entity = {
|
|
157
|
+
type: 'configuration/entityTypes/HCP',
|
|
158
|
+
uri: 'entities/uri_e',
|
|
159
|
+
attributes: {
|
|
160
|
+
Category1: [
|
|
161
|
+
{
|
|
162
|
+
uri: 'entities/uri_e/attributes/uri1',
|
|
163
|
+
value: 'category1_value1'
|
|
164
|
+
}
|
|
165
|
+
],
|
|
166
|
+
Category2: [
|
|
167
|
+
{
|
|
168
|
+
uri: 'entities/uri_e/attributes/uri2',
|
|
169
|
+
value: 'category2_value1'
|
|
170
|
+
}
|
|
171
|
+
],
|
|
172
|
+
Category3: [
|
|
173
|
+
{
|
|
174
|
+
uri: 'entities/uri_e/attributes/uri3',
|
|
175
|
+
value: 'category3_value1'
|
|
176
|
+
}
|
|
177
|
+
],
|
|
178
|
+
Category4: [
|
|
179
|
+
{
|
|
180
|
+
uri: 'entities/uri_e/attributes/uri4',
|
|
181
|
+
value: 'category4_value1'
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
useMdmEntity.mockReturnValue(entity);
|
|
187
|
+
setUp();
|
|
188
|
+
expect(updateHiddenAttributes).toHaveBeenCalledWith(entity.uri, []);
|
|
189
|
+
});
|
|
190
|
+
it('should not hide attributes if at least one rule allows to show the attribute from showAttributeURI', function () {
|
|
191
|
+
var entity = {
|
|
192
|
+
type: 'configuration/entityTypes/HCP',
|
|
193
|
+
uri: 'entities/uri_e',
|
|
194
|
+
attributes: {
|
|
195
|
+
Category1: [
|
|
196
|
+
{
|
|
197
|
+
uri: 'entities/uri_e/attributes/uri1',
|
|
198
|
+
value: 'category1_value2'
|
|
199
|
+
}
|
|
200
|
+
],
|
|
201
|
+
Category4: [
|
|
202
|
+
{
|
|
203
|
+
uri: 'entities/uri_e/attributes/uri4',
|
|
204
|
+
value: 'category4_value1'
|
|
205
|
+
}
|
|
206
|
+
]
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
var newMetadata = {
|
|
210
|
+
entityTypes: [
|
|
211
|
+
__assign(__assign({}, metadata.entityTypes[0]), { ruleBasedAttributes: [
|
|
212
|
+
metadata.entityTypes[0].ruleBasedAttributes[0],
|
|
213
|
+
metadata.entityTypes[0].ruleBasedAttributes[2]
|
|
214
|
+
] })
|
|
215
|
+
]
|
|
216
|
+
};
|
|
217
|
+
useMdmMetadata.mockReturnValue(newMetadata);
|
|
218
|
+
useMdmEntity.mockReturnValue(entity);
|
|
219
|
+
setUp();
|
|
220
|
+
expect(updateHiddenAttributes).toHaveBeenCalledWith(entity.uri, [
|
|
221
|
+
'configuration/entityTypes/HCP/attributes/Category3'
|
|
222
|
+
]);
|
|
223
|
+
});
|
|
224
|
+
it('should hide nested attributes if there are no rules allow to show the attribute from showAttributeURI', function () {
|
|
225
|
+
var entity = {
|
|
226
|
+
type: 'configuration/entityTypes/HCP',
|
|
227
|
+
uri: 'entities/uri_e',
|
|
228
|
+
attributes: {
|
|
229
|
+
Nested1: [
|
|
230
|
+
{
|
|
231
|
+
uri: 'entities/uri_e/attributes/nesteduri1',
|
|
232
|
+
value: {
|
|
233
|
+
NestedCategory1: [
|
|
234
|
+
{
|
|
235
|
+
ov: true,
|
|
236
|
+
uri: 'entities/uri_e/attributes/nesteduri1/attributes/nestedcaturi1',
|
|
237
|
+
value: 'nested_category1_value_diff'
|
|
238
|
+
}
|
|
239
|
+
],
|
|
240
|
+
NestedCategory2: [
|
|
241
|
+
{
|
|
242
|
+
ov: true,
|
|
243
|
+
uri: 'entities/uri_e/attributes/nesteduri1/attributes/nestedcaturi2',
|
|
244
|
+
value: 'nested_category2_value1'
|
|
245
|
+
}
|
|
246
|
+
]
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
]
|
|
250
|
+
}
|
|
251
|
+
};
|
|
252
|
+
var nestedRuleBasedAttribute = {
|
|
253
|
+
uri: 'configuration/entityTypes/HCP/ruleBasedAttributes/DynamicRuleNested',
|
|
254
|
+
label: 'Dynamic Rule nested',
|
|
255
|
+
description: 'Dynamic Attributes Rule nested',
|
|
256
|
+
name: 'DynamicRuleNested',
|
|
257
|
+
type: 'Dynamic',
|
|
258
|
+
controlFunction: {
|
|
259
|
+
expression: "listEquals(attributes.Nested1.value.NestedCategory1, 'nested_category1_value1')",
|
|
260
|
+
showAttributeURI: ['configuration/entityTypes/HCP/attributes/Nested1/attributes/NestedCategory2']
|
|
261
|
+
}
|
|
262
|
+
};
|
|
263
|
+
var newMetadata = {
|
|
264
|
+
entityTypes: [
|
|
265
|
+
__assign(__assign({}, metadata.entityTypes[0]), { ruleBasedAttributes: [nestedRuleBasedAttribute] })
|
|
266
|
+
]
|
|
267
|
+
};
|
|
268
|
+
useMdmMetadata.mockReturnValue(newMetadata);
|
|
269
|
+
useMdmEntity.mockReturnValue(entity);
|
|
270
|
+
setUp();
|
|
271
|
+
expect(updateHiddenAttributes).toHaveBeenCalledWith(entity.uri, [
|
|
272
|
+
'configuration/entityTypes/HCP/attributes/Nested1/attributes/NestedCategory2'
|
|
273
|
+
]);
|
|
274
|
+
});
|
|
275
|
+
it('should correctly show/hide attributes in edit mode while changing the entity', function () {
|
|
276
|
+
var entity = {
|
|
277
|
+
type: 'configuration/entityTypes/HCP',
|
|
278
|
+
uri: 'entities/uri_e',
|
|
279
|
+
attributes: {
|
|
280
|
+
Category1: [
|
|
281
|
+
{
|
|
282
|
+
uri: 'entities/uri_e/attributes/uri1',
|
|
283
|
+
value: 'category1_value1_diff'
|
|
284
|
+
}
|
|
285
|
+
],
|
|
286
|
+
Category2: [
|
|
287
|
+
{
|
|
288
|
+
uri: 'entities/uri_e/attributes/uri2',
|
|
289
|
+
value: 'category2_value1_diff'
|
|
290
|
+
}
|
|
291
|
+
],
|
|
292
|
+
Category3: [
|
|
293
|
+
{
|
|
294
|
+
uri: 'entities/uri_e/attributes/uri3',
|
|
295
|
+
value: 'category3_value1'
|
|
296
|
+
}
|
|
297
|
+
],
|
|
298
|
+
Category4: [
|
|
299
|
+
{
|
|
300
|
+
uri: 'entities/uri_e/attributes/uri4',
|
|
301
|
+
value: 'category4_value1'
|
|
302
|
+
}
|
|
303
|
+
]
|
|
304
|
+
}
|
|
305
|
+
};
|
|
306
|
+
useMdmMode.mockReturnValue(Mode.Editing);
|
|
307
|
+
useMdmEntity.mockReturnValue(entity);
|
|
308
|
+
useMdmModifiedEntity.mockReturnValue(entity);
|
|
309
|
+
var rerender = setUp().rerender;
|
|
310
|
+
expect(updateHiddenAttributes).toHaveBeenCalledWith(entity.uri, [
|
|
311
|
+
'configuration/entityTypes/HCP/attributes/Category3',
|
|
312
|
+
'configuration/entityTypes/HCP/attributes/Category4',
|
|
313
|
+
'configuration/entityTypes/HCP/attributes/Category2'
|
|
314
|
+
]);
|
|
315
|
+
// change the entity to satisfy the rules
|
|
316
|
+
var changedEntity1 = assocPath(['attributes', 'Category1'], [
|
|
317
|
+
{
|
|
318
|
+
uri: 'entities/uri_e/attributes/uri1',
|
|
319
|
+
value: 'category1_value1'
|
|
320
|
+
}
|
|
321
|
+
], entity);
|
|
322
|
+
updateHiddenAttributes.mockClear();
|
|
323
|
+
useMdmModifiedEntity.mockReturnValue(changedEntity1);
|
|
324
|
+
rerender();
|
|
325
|
+
expect(updateHiddenAttributes).toHaveBeenCalledWith(entity.uri, [
|
|
326
|
+
'configuration/entityTypes/HCP/attributes/Category3',
|
|
327
|
+
'configuration/entityTypes/HCP/attributes/Category4'
|
|
328
|
+
]);
|
|
329
|
+
var changedEntity2 = assocPath(['attributes', 'Category2'], [
|
|
330
|
+
{
|
|
331
|
+
uri: 'entities/uri_e/attributes/uri2',
|
|
332
|
+
value: 'category2_value1'
|
|
333
|
+
}
|
|
334
|
+
], changedEntity1);
|
|
335
|
+
updateHiddenAttributes.mockClear();
|
|
336
|
+
useMdmModifiedEntity.mockReturnValue(changedEntity2);
|
|
337
|
+
rerender();
|
|
338
|
+
expect(updateHiddenAttributes).toHaveBeenCalledWith(entity.uri, []);
|
|
339
|
+
// change the entity to not satisfy the rules
|
|
340
|
+
var changedEntity3 = assocPath(['attributes', 'Category2'], [
|
|
341
|
+
{
|
|
342
|
+
uri: 'entities/uri_e/attributes/uri2',
|
|
343
|
+
value: 'category2_value1_diff'
|
|
344
|
+
}
|
|
345
|
+
], changedEntity2);
|
|
346
|
+
updateHiddenAttributes.mockClear();
|
|
347
|
+
useMdmModifiedEntity.mockReturnValue(changedEntity3);
|
|
348
|
+
rerender();
|
|
349
|
+
expect(updateHiddenAttributes).toHaveBeenCalledWith(entity.uri, [
|
|
350
|
+
'configuration/entityTypes/HCP/attributes/Category3',
|
|
351
|
+
'configuration/entityTypes/HCP/attributes/Category4'
|
|
352
|
+
]);
|
|
353
|
+
var changedEntity4 = assocPath(['attributes', 'Category1'], [
|
|
354
|
+
{
|
|
355
|
+
uri: 'entities/uri_e/attributes/uri1',
|
|
356
|
+
value: 'category1_value1_diff'
|
|
357
|
+
}
|
|
358
|
+
], changedEntity3);
|
|
359
|
+
updateHiddenAttributes.mockClear();
|
|
360
|
+
useMdmModifiedEntity.mockReturnValue(changedEntity4);
|
|
361
|
+
rerender();
|
|
362
|
+
expect(updateHiddenAttributes).toHaveBeenCalledWith(entity.uri, [
|
|
363
|
+
'configuration/entityTypes/HCP/attributes/Category3',
|
|
364
|
+
'configuration/entityTypes/HCP/attributes/Category4',
|
|
365
|
+
'configuration/entityTypes/HCP/attributes/Category2'
|
|
366
|
+
]);
|
|
367
|
+
});
|
|
368
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useSavedSearchesRequest } from './useSavedSearchesRequest';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useSavedSearchesRequest } from './useSavedSearchesRequest';
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
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;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { getTotalsForQuery, promiseAllSettled, replacePlaceholdersInQuery } from '@reltio/mdm-sdk';
|
|
38
|
+
export var getTotalsForSavedSearches = function (savedSearches, queryEstimatorEnabled, signal) { return __awaiter(void 0, void 0, void 0, function () {
|
|
39
|
+
var totalRequests, totalResults, entries;
|
|
40
|
+
return __generator(this, function (_a) {
|
|
41
|
+
switch (_a.label) {
|
|
42
|
+
case 0:
|
|
43
|
+
totalRequests = savedSearches.map(function (search) {
|
|
44
|
+
return getTotalsForQuery(replacePlaceholdersInQuery(search.query), queryEstimatorEnabled, signal);
|
|
45
|
+
});
|
|
46
|
+
return [4 /*yield*/, promiseAllSettled(totalRequests)];
|
|
47
|
+
case 1:
|
|
48
|
+
totalResults = _a.sent();
|
|
49
|
+
entries = totalResults
|
|
50
|
+
.map(function (_a, index) {
|
|
51
|
+
var status = _a.status, value = _a.value, reason = _a.reason;
|
|
52
|
+
switch (status) {
|
|
53
|
+
case 'fulfilled': {
|
|
54
|
+
var uri = savedSearches[index].uri;
|
|
55
|
+
return [uri, { count: value.total }];
|
|
56
|
+
}
|
|
57
|
+
case 'rejected': {
|
|
58
|
+
console.warn(reason);
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
})
|
|
64
|
+
.filter(Boolean);
|
|
65
|
+
return [2 /*return*/, Object.fromEntries(entries)];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}); };
|