From 41704d5923bcf99eaae9370e2d452a25fcae12df Mon Sep 17 00:00:00 2001 From: Jan Date: Wed, 3 Jan 2024 14:28:58 +0100 Subject: [PATCH] CM-406: get head from jsonExt (#35) * CM-406: add change log fe for group * CM-406: get head from jsonExt * CM-406: refetch on head change --------- Co-authored-by: Jan --- src/components/GroupHistorySearcher.js | 25 ++++++++++++++--------- src/components/GroupIndividualSearcher.js | 3 +++ src/translations/en.json | 3 ++- 3 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/components/GroupHistorySearcher.js b/src/components/GroupHistorySearcher.js index 09866ba..510641e 100644 --- a/src/components/GroupHistorySearcher.js +++ b/src/components/GroupHistorySearcher.js @@ -32,24 +32,29 @@ function GroupHistorySearcher({ 'groupHistory.head', 'groupHistory.dateUpdated', 'groupHistory.version', - 'groupHistory.jsonExt', + 'groupHistory.members', ]; const itemFormatters = () => [ - (groupHistory) => groupHistory.id, - (groupHistory) => `${groupHistory?.head?.firstName} ${groupHistory?.head?.lastName}`, - (groupHistory) => (groupHistory.dateUpdated - ? formatDateFromISO(groupHistory.dateUpdated) : EMPTY_STRING - ), - (groupHistory) => groupHistory.version, - (groupHistory) => groupHistory.jsonExt, + (groupHistory) => groupHistory?.id || EMPTY_STRING, + (groupHistory) => { + const jsonExt = groupHistory?.jsonExt ? JSON.parse(groupHistory.jsonExt) : null; + return jsonExt?.head ?? EMPTY_STRING; + }, + (groupHistory) => (groupHistory?.dateUpdated + ? formatDateFromISO(groupHistory.dateUpdated) + : EMPTY_STRING), + (groupHistory) => groupHistory?.version || EMPTY_STRING, + (groupHistory) => { + const jsonExt = groupHistory?.jsonExt ? JSON.parse(groupHistory.jsonExt) : null; + return jsonExt?.members ?? EMPTY_STRING; + }, ]; const rowIdentifier = (groupHistory) => groupHistory.id; const sorts = () => [ - ['id', false], - ['head', false], + ['id', true], ['dateUpdated', true], ['version', true], ]; diff --git a/src/components/GroupIndividualSearcher.js b/src/components/GroupIndividualSearcher.js index fbe9ce8..1111671 100644 --- a/src/components/GroupIndividualSearcher.js +++ b/src/components/GroupIndividualSearcher.js @@ -67,6 +67,7 @@ function GroupIndividualSearcher({ const [deletedGroupIndividualUuids, setDeletedGroupIndividualUuids] = useState([]); const prevSubmittingMutationRef = useRef(); const [updatedGroupIndividuals, setUpdatedGroupIndividuals] = useState([]); + const [refetch, setRefetch] = useState(null); function groupIndividualUpdatePageUrl(groupIndividual) { return `${modulesManager.getRef('individual.route.individual')}/${groupIndividual.individual?.id}`; @@ -156,6 +157,7 @@ function GroupIndividualSearcher({ id: editedGroupIndividual?.individual?.id, }), ); + setRefetch(editedGroupIndividual?.individual?.id); } }; @@ -265,6 +267,7 @@ function GroupIndividualSearcher({ return (