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

feat: [DHIS2-18328] Handle log entries for occurredAt, scheduledAt and geometry #3881

Closed
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
7 changes: 0 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
## [101.16.2](https://github.com/dhis2/capture-app/compare/v101.16.1...v101.16.2) (2024-11-19)


### Bug Fixes

* [DHIS2-16994] Image and File DE and TEA not Displayed in Changelog ([#3837](https://github.com/dhis2/capture-app/issues/3837)) ([9327210](https://github.com/dhis2/capture-app/commit/932721045126e02379f56a85af4f6586b836b4c0))

## [101.16.1](https://github.com/dhis2/capture-app/compare/v101.16.0...v101.16.1) (2024-11-17)


Expand Down
10 changes: 2 additions & 8 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-07T11:57:59.094Z\n"
"PO-Revision-Date: 2024-11-07T11:57:59.094Z\n"
"POT-Creation-Date: 2024-11-04T18:45:47.626Z\n"
"PO-Revision-Date: 2024-11-04T18:45:47.626Z\n"

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

msgid "File"
msgstr "File"

msgid "Image"
msgstr "Image"

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

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "capture-app",
"homepage": ".",
"version": "101.16.2",
"version": "101.16.1",
"cacheVersion": "7",
"serverVersion": "38",
"license": "BSD-3-Clause",
Expand All @@ -10,7 +10,7 @@
"packages/rules-engine"
],
"dependencies": {
"@dhis2/rules-engine-javascript": "101.16.2",
"@dhis2/rules-engine-javascript": "101.16.1",
"@dhis2/app-runtime": "^3.9.3",
"@dhis2/d2-i18n": "^1.1.0",
"@dhis2/d2-icons": "^1.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/rules-engine/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dhis2/rules-engine-javascript",
"version": "101.16.2",
"version": "101.16.1",
"license": "BSD-3-Clause",
"main": "./build/cjs/index.js",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ 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 @@ -77,7 +76,6 @@ const EventDetailsSectionPlain = (props: Props) => {
const {
classes,
eventId,
eventData,
onOpenEditEvent,
showEditEvent,
programStage,
Expand Down Expand Up @@ -202,7 +200,6 @@ 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,7 +10,6 @@ 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, eventData, ...passOnProps }: Props) => {
export const EventChangelogWrapper = ({ formFoundation, eventId, ...passOnProps }: Props) => {
const dataItemDefinitions = useMemo(() => {
const elements = formFoundation.getElements();
const contextLabels = formFoundation.getLabels();
Expand Down Expand Up @@ -42,17 +42,26 @@ export const EventChangelogWrapper = ({ formFoundation, eventId, eventData, ...p
return acc;
}, {});

const additionalFields = {
geometry: {
id: 'geometry',
name: formFoundation.featureType,
type: formFoundation.featureType === 'Polygon' ?
dataElementTypes.POLYGON : dataElementTypes.COORDINATE,
},
};

return {
...fieldElementsById,
...fieldElementsContext,
...additionalFields,
};
}, [formFoundation]);

return (
<WidgetEventChangelog
{...passOnProps}
eventId={eventId}
eventData={eventData}
dataItemDefinitions={dataItemDefinitions}
/>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ type PassOnProps = {|
export type Props = {
...PassOnProps,
formFoundation: RenderFoundation,
eventData: Object,
};
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ 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,7 +9,6 @@ import { TrackedEntityChangelogWrapper } from './TrackedEntityChangelogWrapper';

export const OverflowMenuComponent = ({
trackedEntity,
trackedEntityData,
trackedEntityTypeName,
canWriteData,
canCascadeDeleteTei,
Expand Down Expand Up @@ -69,7 +68,6 @@ 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,7 +8,6 @@ export const OverflowMenu = ({
trackedEntityTypeName,
canWriteData,
trackedEntity,
trackedEntityData,
onDeleteSuccess,
displayChangelog,
teiId,
Expand All @@ -22,7 +21,6 @@ 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,7 +3,6 @@
export type Props = {|
trackedEntity: { trackedEntity: string },
trackedEntityTypeName: string,
trackedEntityData: Object,
canWriteData: boolean,
onDeleteSuccess?: () => void,
displayChangelog: boolean,
Expand All @@ -14,7 +13,6 @@ 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,14 +5,9 @@ import { useFormFoundation } from '../../DataEntry/hooks';
import { WidgetTrackedEntityChangelog } from '../../../WidgetsChangelog';
import type { Props } from './TrackedEntityChangelogWrapper.types';

export const TrackedEntityChangelogWrapper = ({ programAPI, teiId, setIsOpen, trackedEntityData, ...passOnProps }: Props) => {
export const TrackedEntityChangelogWrapper = ({ programAPI, teiId, setIsOpen, ...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 @@ -63,7 +58,6 @@ export const TrackedEntityChangelogWrapper = ({ programAPI, teiId, setIsOpen, tr
close={() => setIsOpen(false)}
programId={programAPI.id}
dataItemDefinitions={dataItemDefinitions}
trackedEntityData={transformedTrackedEntityData}
/>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ 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,7 +162,6 @@ 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,23 +5,20 @@ 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,20 +9,17 @@ 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,37 +1,33 @@
// @flow
import React from 'react';
import { Modal } from '@dhis2/ui';
import { useChangelogData, useListDataValues } from '../hooks';
import { useChangelogData } 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 {
rawRecords,
records,
pager,
isLoading: isChangelogLoading,
page,
pageSize,
isLoading,
setPage,
setPageSize,
sortDirection,
Expand All @@ -40,24 +36,10 @@ export const Changelog = ({
entityId,
entityType,
programId,
});

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

if (isChangelogLoading || isProcessingLoading) {
if (isLoading) {
return (
<Modal onClose={close}>
<LoadingMaskElementCenter />
Expand All @@ -69,7 +51,7 @@ export const Changelog = ({
<ChangelogComponent
isOpen={isOpen}
close={close}
records={processedRecords}
records={records}
pager={pager}
setPage={setPage}
setPageSize={setPageSize}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ type CreatedChange = {|
type: typeof CHANGE_TYPES.CREATED,
dataElement?: string,
attribute?: string,
property?: string,
currentValue: any,
|}

type UpdatedChange = {|
type: typeof CHANGE_TYPES.UPDATED,
dataElement?: string,
attribute?: string,
property?: string,
previousValue: any,
currentValue: any,
|}
Expand All @@ -21,6 +23,7 @@ type DeletedChange = {|
type: typeof CHANGE_TYPES.DELETED,
dataElement?: string,
attribute?: string,
property?: string,
previousValue: any,
|}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import React from 'react';
import log from 'loglevel';
import { Tag } from '@dhis2/ui';
import i18n from '@dhis2/d2-i18n';
import { CHANGE_TYPES } from '../../Changelog/Changelog.constants';
import { errorCreator } from '../../../../../../capture-core-utils';
import { CHANGE_TYPES } from '../../../Changelog/Changelog.constants';
import { errorCreator } from '../../../../../../../capture-core-utils';

type Config = {
label: string,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// @flow

export { ChangelogChangeCell } from './ChangelogChangeCell';
Loading
Loading