Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: [DHIS2-18569] Relationship widget limited to 50 entries #3927

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export const FEATURES = Object.freeze({
trackedEntitiesCSV: 'trackedEntitiesCSV',
newAocApiSeparator: 'newAocApiSeparator',
newEntityFilterQueryParam: 'newEntityFilterQueryParam',
newRelationshipQueryParam: 'newRelationshipQueryParam',
});

// The first minor version that supports the feature
Expand All @@ -26,6 +27,7 @@ const MINOR_VERSION_SUPPORT = Object.freeze({
[FEATURES.trackedEntitiesCSV]: 40,
[FEATURES.newAocApiSeparator]: 41,
[FEATURES.newEntityFilterQueryParam]: 41,
[FEATURES.newRelationshipQueryParam]: 41,
});

export const hasAPISupportForFeature = (minorVersion: string | number, featureName: string) =>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow
import { useMemo } from 'react';
import { handleAPIResponse, REQUESTED_ENTITIES } from 'capture-core/utils/api';
import { featureAvailable, FEATURES } from 'capture-core-utils';
import { useApiDataQuery } from '../../../../utils/reactQueryHelpers';
import type { InputRelationshipData, RelationshipTypes } from '../Types';
import { determineLinkedEntity } from '../RelationshipsWidget/useGroupedLinkedEntities';
Expand All @@ -20,14 +21,21 @@ type Props = {|
type ReturnData = Array<InputRelationshipData>;

export const useRelationships = ({ entityId, searchMode, relationshipTypes }: Props) => {
const query = useMemo(() => ({
resource: 'tracker/relationships',
params: {
// $FlowFixMe - searchMode should be a valid key of RelationshipSearchEntities
[searchMode]: entityId,
fields: 'relationship,relationshipType,createdAt,from[trackedEntity[trackedEntity,attributes,program,orgUnit,trackedEntityType],event[event,dataValues,program,orgUnit,orgUnitName,status,createdAt]],to[trackedEntity[trackedEntity,attributes,program,orgUnit,trackedEntityType],event[event,dataValues,program,orgUnit,orgUnitName,status,createdAt]]',
},
}), [entityId, searchMode]);
const query = useMemo(() => {
const supportForFeature = featureAvailable(FEATURES.newRelationshipQueryParam);

return {
resource: 'tracker/relationships',
params: {
// $FlowFixMe - searchMode should be a valid key of RelationshipSearchEntities
[searchMode]: entityId,
fields: 'relationship,relationshipType,createdAt,from[trackedEntity[trackedEntity,attributes,program,orgUnit,trackedEntityType],event[event,dataValues,program,orgUnit,orgUnitName,status,createdAt]],to[trackedEntity[trackedEntity,attributes,program,orgUnit,trackedEntityType],event[event,dataValues,program,orgUnit,orgUnitName,status,createdAt]]',
...(supportForFeature
? { paging: false }
: { skipPaging: true }),
},
};
}, [entityId, searchMode]);

return useApiDataQuery<ReturnData>(
['relationships', entityId],
Expand Down
Loading