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-16994] Image and File DE and TEA not Displayed in Changelog #3837

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
02f2536
feat: temp
henrikmv Oct 9, 2024
1e14e25
fix: revert clienttolist changes
henrikmv Oct 9, 2024
6cd1a7d
fix: code clean up
henrikmv Oct 9, 2024
94d61f3
feat: temp
henrikmv Oct 9, 2024
1464867
fix: wrong else statement
henrikmv Oct 10, 2024
9a5dbda
feat: add link for image and file data element
henrikmv Oct 11, 2024
41b9ed1
fix: image and file for tea
henrikmv Oct 13, 2024
c546e9c
fix: show only latest image and file
henrikmv Oct 13, 2024
05a6059
fix: revert change
henrikmv Oct 13, 2024
6cfeb66
fix: update islatestvalue to check for fieldid
henrikmv Oct 14, 2024
72b9d50
Merge branch 'master' of https://github.com/dhis2/capture-app into hv…
henrikmv Oct 16, 2024
eceb19e
feat: temp
henrikmv Oct 18, 2024
8389805
fix: caching
henrikmv Oct 22, 2024
45b10e9
Merge branch 'master' of https://github.com/dhis2/capture-app into hv…
henrikmv Oct 22, 2024
5781035
fix: ensure text utilizes space without overflow
henrikmv Oct 23, 2024
56748b7
fix: add try catch to all query calls
henrikmv Oct 25, 2024
877d489
fix: use storagestatus to find latest value
henrikmv Oct 28, 2024
d8a92bf
fix: string improvement
henrikmv Oct 28, 2024
9a2c8c2
Revert "fix: string improvement"
henrikmv Oct 28, 2024
a849f28
Revert "fix: use storagestatus to find latest value"
henrikmv Nov 4, 2024
2b4cb96
feat: temp
henrikmv Nov 5, 2024
8217a68
Merge branch 'master' of https://github.com/dhis2/capture-app into hv…
henrikmv Nov 5, 2024
292ff79
feat: compare with event data to find latest value
henrikmv Nov 5, 2024
df7011f
feat: image and file for event and tracked entity
henrikmv Nov 6, 2024
4276fbf
fix: performance
henrikmv Nov 6, 2024
c80b635
fix: review comments
henrikmv Nov 7, 2024
94b3aca
fix: review comments
henrikmv Nov 11, 2024
879f45d
Merge branch 'master' of https://github.com/dhis2/capture-app into hv…
henrikmv Nov 11, 2024
04590c3
fix: latest value not shown
henrikmv Nov 12, 2024
dd12732
fix: missing question mark
henrikmv Nov 12, 2024
69f0075
Merge branch 'master' of https://github.com/dhis2/capture-app into hv…
henrikmv Nov 13, 2024
87b7387
Merge branch 'master' into hv/fix/DHIS2-16994_ImageAndFileDEAndTEANot…
henrikmv Nov 13, 2024
32adfb3
Merge branch 'master' of https://github.com/dhis2/capture-app into hv…
henrikmv Nov 14, 2024
9d54e47
Merge branch 'hv/fix/DHIS2-16994_ImageAndFileDEAndTEANotDisplayedInCh…
henrikmv Nov 14, 2024
94b5994
Merge branch 'master' of https://github.com/dhis2/capture-app into hv…
henrikmv Nov 18, 2024
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
10 changes: 8 additions & 2 deletions i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2024-11-04T18:45:47.626Z\n"
"PO-Revision-Date: 2024-11-04T18:45:47.626Z\n"
"POT-Creation-Date: 2024-11-07T11:57:59.094Z\n"
"PO-Revision-Date: 2024-11-07T11:57:59.094Z\n"

msgid "Choose one or more dates..."
msgstr "Choose one or more dates..."
Expand Down Expand Up @@ -1547,6 +1547,12 @@ msgstr "Change"
msgid "Value"
msgstr "Value"

msgid "File"
msgstr "File"

msgid "Image"
msgstr "Image"

msgid "New {{trackedEntityTypeName}} relationship"
msgstr "New {{trackedEntityTypeName}} relationship"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const getStyles = () => ({
type Props = {
showEditEvent: ?boolean,
eventId: string,
eventData: Object,
onOpenEditEvent: (orgUnit: Object, programCategory: ?ProgramCategory) => void,
programStage: ProgramStage,
eventAccess: { read: boolean, write: boolean },
Expand All @@ -76,6 +77,7 @@ const EventDetailsSectionPlain = (props: Props) => {
const {
classes,
eventId,
eventData,
onOpenEditEvent,
showEditEvent,
programStage,
Expand Down Expand Up @@ -200,6 +202,7 @@ const EventDetailsSectionPlain = (props: Props) => {
<EventChangelogWrapper
isOpen
setIsOpen={setChangeLogIsOpen}
eventData={eventData}
eventId={eventId}
formFoundation={programStage.stageForm}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import type { ProgramCategory } from '../../../WidgetEventSchedule/CategoryOptio
const mapStateToProps = (state: ReduxState) => ({
showEditEvent: state.viewEventPage.eventDetailsSection && state.viewEventPage.eventDetailsSection.showEditEvent,
eventId: state.viewEventPage.eventId,
eventData: state.viewEventPage.loadedValues?.eventContainer?.values || {},
programId: state.currentSelections.programId,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { dataElementTypes } from '../../../metaData';
import type { Props } from './EventChangelogWrapper.types';
import { WidgetEventChangelog } from '../../WidgetsChangelog';

export const EventChangelogWrapper = ({ formFoundation, eventId, ...passOnProps }: Props) => {
export const EventChangelogWrapper = ({ formFoundation, eventId, eventData, ...passOnProps }: Props) => {
const dataItemDefinitions = useMemo(() => {
const elements = formFoundation.getElements();
const contextLabels = formFoundation.getLabels();
Expand Down Expand Up @@ -52,6 +52,7 @@ export const EventChangelogWrapper = ({ formFoundation, eventId, ...passOnProps
<WidgetEventChangelog
{...passOnProps}
eventId={eventId}
eventData={eventData}
dataItemDefinitions={dataItemDefinitions}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ type PassOnProps = {|
export type Props = {
...PassOnProps,
formFoundation: RenderFoundation,
eventData: Object,
};
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export const WidgetEventEditPlain = ({
isOpen
setIsOpen={setChangeLogIsOpen}
eventId={loadedValues.eventContainer.id}
eventData={loadedValues.eventContainer.values}
formFoundation={formFoundation}
/>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { TrackedEntityChangelogWrapper } from './TrackedEntityChangelogWrapper';

export const OverflowMenuComponent = ({
trackedEntity,
trackedEntityData,
trackedEntityTypeName,
canWriteData,
canCascadeDeleteTei,
Expand Down Expand Up @@ -68,6 +69,7 @@ export const OverflowMenuComponent = ({
programAPI={programAPI}
isOpen={changelogIsOpen}
setIsOpen={setChangelogIsOpen}
trackedEntityData={trackedEntityData}
/>
)}
</>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const OverflowMenu = ({
trackedEntityTypeName,
canWriteData,
trackedEntity,
trackedEntityData,
onDeleteSuccess,
displayChangelog,
teiId,
Expand All @@ -21,6 +22,7 @@ export const OverflowMenu = ({
canWriteData={canWriteData}
canCascadeDeleteTei={hasAuthority}
trackedEntity={trackedEntity}
trackedEntityData={trackedEntityData}
onDeleteSuccess={onDeleteSuccess}
displayChangelog={displayChangelog}
teiId={teiId}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
export type Props = {|
trackedEntity: { trackedEntity: string },
trackedEntityTypeName: string,
trackedEntityData: Object,
canWriteData: boolean,
onDeleteSuccess?: () => void,
displayChangelog: boolean,
Expand All @@ -13,6 +14,7 @@ export type Props = {|
export type PlainProps = {|
trackedEntity: { trackedEntity: string },
trackedEntityTypeName: string,
trackedEntityData: Object,
canWriteData: boolean,
canCascadeDeleteTei: boolean,
onDeleteSuccess?: () => void,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ import { useFormFoundation } from '../../DataEntry/hooks';
import { WidgetTrackedEntityChangelog } from '../../../WidgetsChangelog';
import type { Props } from './TrackedEntityChangelogWrapper.types';

export const TrackedEntityChangelogWrapper = ({ programAPI, teiId, setIsOpen, ...passOnProps }: Props) => {
export const TrackedEntityChangelogWrapper = ({ programAPI, teiId, setIsOpen, trackedEntityData, ...passOnProps }: Props) => {
const formFoundation: RenderFoundation = useFormFoundation(programAPI);

const transformedTrackedEntityData = trackedEntityData.reduce((acc, item) => {
acc[item.attribute] = item.value;
return acc;
}, {});

const dataItemDefinitions = useMemo(() => {
if (!Object.keys(formFoundation)?.length) return {};
const elements = formFoundation.getElements();
Expand Down Expand Up @@ -58,6 +63,7 @@ export const TrackedEntityChangelogWrapper = ({ programAPI, teiId, setIsOpen, ..
close={() => setIsOpen(false)}
programId={programAPI.id}
dataItemDefinitions={dataItemDefinitions}
trackedEntityData={transformedTrackedEntityData}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ type PassOnProps = {|
teiId: string,
isOpen: boolean,
setIsOpen: (boolean | boolean => boolean) => void,
trackedEntityData: Object,
|}

export type Props = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ const WidgetProfilePlain = ({
trackedEntity={trackedEntity}
onDeleteSuccess={onDeleteSuccess}
displayChangelog={displayChangelog}
trackedEntityData={clientAttributesWithSubvalues}
teiId={teiId}
programAPI={program}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,23 @@ import { Changelog, CHANGELOG_ENTITY_TYPES } from '../common/Changelog';

type Props = {
eventId: string,
eventData: Object,
dataItemDefinitions: ItemDefinitions,
isOpen: boolean,
setIsOpen: (boolean | boolean => boolean) => void,
}

export const WidgetEventChangelog = ({
eventId,
eventData,
setIsOpen,
...passOnProps
}: Props) => (
<Changelog
{...passOnProps}
close={() => setIsOpen(false)}
entityId={eventId}
entityData={eventData}
entityType={CHANGELOG_ENTITY_TYPES.EVENT}
/>
);
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@ type Props = {
dataItemDefinitions: ItemDefinitions,
isOpen: boolean,
close: () => void,
trackedEntityData: Object,
}

export const WidgetTrackedEntityChangelog = ({
teiId,
programId,
close,
trackedEntityData,
...passOnProps
}: Props) => (
<Changelog
{...passOnProps}
close={close}
entityData={trackedEntityData}
entityId={teiId}
programId={programId}
entityType={CHANGELOG_ENTITY_TYPES.TRACKED_ENTITY}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
// @flow
import React from 'react';
import { Modal } from '@dhis2/ui';
import { useChangelogData } from '../hooks';
import { useChangelogData, useListDataValues } from '../hooks';
import { ChangelogComponent } from './Changelog.component';
import { CHANGELOG_ENTITY_TYPES } from './index';
import { LoadingMaskElementCenter } from '../../../LoadingMasks';
import type { ItemDefinitions } from './Changelog.types';

type Props = {
entityId: string,
entityData: Object,
entityType: $Values<typeof CHANGELOG_ENTITY_TYPES>,
isOpen: boolean,
close: () => void,
dataItemDefinitions: ItemDefinitions,
programId?: string,
}
};

export const Changelog = ({
entityId,
entityData,
entityType,
programId,
isOpen,
close,
dataItemDefinitions,
}: Props) => {
const {
records,
rawRecords,
pager,
isLoading,
isLoading: isChangelogLoading,
page,
pageSize,
setPage,
setPageSize,
sortDirection,
Expand All @@ -36,10 +40,24 @@ export const Changelog = ({
entityId,
entityType,
programId,
});

const {
processedRecords,
isLoading: isProcessingLoading,
} = useListDataValues({
rawRecords,
dataItemDefinitions,
entityId,
entityData,
entityType,
programId,
sortDirection,
page,
pageSize,
});

if (isLoading) {
if (isChangelogLoading || isProcessingLoading) {
return (
<Modal onClose={close}>
<LoadingMaskElementCenter />
Expand All @@ -51,7 +69,7 @@ export const Changelog = ({
<ChangelogComponent
isOpen={isOpen}
close={close}
records={records}
records={processedRecords}
pager={pager}
setPage={setPage}
setPageSize={setPageSize}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,43 +14,36 @@ type Props = {
container: string,
previousValue: string,
currentValue: string,
updatePreviousValue: string,
updateCurrentValue: string,
updateArrow: string,
arrow: string,
}
}

const styles = {
container: {
alignItems: 'center',
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
whiteSpace: 'normal',
height: '100%',
},
previousValue: {
color: colors.grey700,
wordBreak: 'break-word',
},
currentValue: {
color: colors.grey900,
wordBreak: 'break-word',
},
updatePreviousValue: {
color: colors.grey700,
maxWidth: '45%',
},
updateCurrentValue: {
color: colors.grey900,
maxWidth: '45%',
},
updateArrow: {
display: 'inline-flex',
alignItems: 'center',
margin: `${spacers.dp4}`,
arrow: {
margin: `0 ${spacers.dp4}`,
},
};

const Updated = ({ previousValue, currentValue, classes }) => (
<div className={classes.container}>
<span className={classes.updatePreviousValue}>{previousValue}</span>
<span className={classes.updateArrow}><IconArrowRight16 /></span>
<span className={classes.updateCurrentValue}>{currentValue}</span>
<div className={classes.previousValue}>{previousValue}</div>
<div className={classes.arrow}><IconArrowRight16 /></div>
<div className={classes.currentValue}>{currentValue}</div>
</div>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@ type Props = {
},
classes: {
dataItemColumn: string,
valueColumn: string,
},
};

const styles = {
dataItemColumn: { wordWrap: 'break-word', hyphens: 'auto' },
valueColumn: { wordWrap: 'break-word' },
};

const ChangelogTableRowPlain = ({ record, classes }: Props) => (
Expand All @@ -28,7 +26,7 @@ const ChangelogTableRowPlain = ({ record, classes }: Props) => (
<DataTableCell>{record.user}</DataTableCell>
<DataTableCell className={classes.dataItemColumn}>{record.dataItemLabel}</DataTableCell>
<DataTableCell><ChangelogChangeCell changeType={record.changeType} /></DataTableCell>
<DataTableCell className={classes.valueColumn}><ChangelogValueCell {...record} /></DataTableCell>
<DataTableCell><ChangelogValueCell {...record} /></DataTableCell>
</DataTableRow>
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// @flow

export { useChangelogData } from './useChangelogData';
export { useListDataValues } from './useListDataValues';
Loading
Loading