Skip to content

Commit

Permalink
fix: temp
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikmv committed Dec 7, 2024
1 parent c93d7b6 commit 8fb93ca
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 49 deletions.
7 changes: 2 additions & 5 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-12-07T11:18:04.373Z\n"
"PO-Revision-Date: 2024-12-07T11:18:04.373Z\n"
"POT-Creation-Date: 2024-12-07T12:32:56.041Z\n"
"PO-Revision-Date: 2024-12-07T12:32:56.041Z\n"

msgid "Choose one or more dates..."
msgstr "Choose one or more dates..."
Expand Down Expand Up @@ -1349,9 +1349,6 @@ msgstr[1] "There are {{count}} scheduled events in {{orgUnitName}} on this day."
msgid "Schedule date / Due date"
msgstr "Schedule date / Due date"

msgid "Scheduling an event in {{stageName}} for {{programName}} in {{orgUnitName}}"
msgstr "Scheduling an event in {{stageName}} for {{programName}} in {{orgUnitName}}"

msgid "Schedule info"
msgstr "Schedule info"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
}

.orgUnitLabel {
padding-top: 3px;
padding-top: 13px;
}

.selectLabel {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
// @flow
import React from 'react';
import React, { type ComponentType } from 'react';
import i18n from '@dhis2/d2-i18n';
import { DateField,
import withStyles from '@material-ui/core/styles/withStyles';
import { spacersNum } from '@dhis2/ui';
import {
DateField,
withDefaultFieldContainer,
withLabel,
withDisplayMessages,
withInternalChangeHandler,
} from 'capture-core/components/FormFields/New';

import type { Props } from './scheduleDate.types';
import labelTypeClasses from './dataEntryFieldLabels.module.css';
import { InfoBox } from '../InfoBox';
import { convertStringToDateFormat } from '../../../utils/converters/date';



Check failure on line 20 in src/core_modules/capture-core/components/WidgetEventSchedule/ScheduleDate/ScheduleDate.component.js

View workflow job for this annotation

GitHub Actions / lint

More than 2 blank lines not allowed
const LabelledRequiredDateField = withDefaultFieldContainer()(
withLabel({
onGetCustomFieldLabeClass: () => labelTypeClasses.dateLabel,
Expand All @@ -23,30 +30,43 @@ const LabelledRequiredDateField = withDefaultFieldContainer()(
),
);

type Props = {
scheduleDate: ?string,
setScheduleDate: (dateString: ?string) => void,
hideDueDate?: boolean,
const styles = {
container: {
display: 'flex',
marginTop: spacersNum.dp4,
},
};

export const ScheduleDate = ({
const ScheduleDatePlain = ({
scheduleDate,
serverScheduleDate,
setScheduleDate,
orgUnit,
serverSuggestedScheduleDate,
eventCountInOrgUnit,
classes,
hideDueDate,
}: Props) => (
<>
{!hideDueDate && (
<LabelledRequiredDateField
label={i18n.t('Schedule date / Due date')}
required
value={scheduleDate}
width="100%"
calendarWidth={350}
onSetFocus={() => { }}
onFocus={() => { }}
onRemoveFocus={() => { }}
onBlur={(e) => { setScheduleDate(convertStringToDateFormat(e)); }}
/>
)}
</>
);
}: Props) => (<>
{!hideDueDate && <div className={classes.container}>
<LabelledRequiredDateField
label={i18n.t('Schedule date / Due date')}
required
value={scheduleDate}
width="100%"
calendarWidth={350}
onSetFocus={() => { }}
onFocus={() => { }}
onRemoveFocus={() => { }}
onBlur={(e) => { setScheduleDate(convertStringToDateFormat(e)); }}
/>
</div>}
<InfoBox
scheduleDate={serverScheduleDate}
suggestedScheduleDate={serverSuggestedScheduleDate}
eventCountInOrgUnit={eventCountInOrgUnit}
orgUnitName={orgUnit?.name}
hideDueDate={hideDueDate}
/>
</>);

export const ScheduleDate: ComponentType<$Diff<Props, CssClasses>> = (withStyles(styles)(ScheduleDatePlain));
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import type { Props } from './scheduleText.types';
export const ScheduleText = ({ orgUnitName, stageName, programName }: Props) => (
<InfoIconText>
<span>
{ i18n.t('Scheduling an event in {{stageName}} for {{programName}} in {{orgUnitName}}',
{ orgUnitName, stageName, programName, interpolation: { escapeValue: false } })}
{i18n.t(
orgUnitName
? 'Scheduling an event in {{stageName}} for {{programName}} in {{orgUnitName}}'
: 'Scheduling an event in {{stageName}} for {{programName}}',
{ orgUnitName, stageName, programName, interpolation: { escapeValue: false } },
)}
</span>
</InfoIconText>
);

Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,25 @@ const WidgetEventSchedulePlain = ({
dataTest="schedule-section"
sectionName={i18n.t('Schedule info')}
>
<div className={classes.fieldWrapper}>
<div className={classes.fieldContent}>
<ScheduleOrgUnit
orgUnit={orgUnit}
onSelectOrgUnit={onSelectOrgUnit}
onDeselectOrgUnit={onDeselectOrgUnit}
{...passOnProps}
/>
<ScheduleDate
programId={programId}
stageId={stageId}
orgUnit={orgUnit}
scheduleDate={scheduleDate}
serverSuggestedScheduleDate={serverSuggestedScheduleDate}
{...passOnProps}
/>
</div>
</div>

<ScheduleDate
programId={programId}
stageId={stageId}
scheduleDate={scheduleDate}
serverSuggestedScheduleDate={serverSuggestedScheduleDate}
{...passOnProps}
/>

<ScheduleOrgUnit
orgUnit={orgUnit}
onSelectOrgUnit={onSelectOrgUnit}
onDeselectOrgUnit={onDeselectOrgUnit}
{...passOnProps}
/>
</DataSection>
{programCategory && <DataSection
dataTest="category-options-section"
Expand Down Expand Up @@ -151,7 +155,7 @@ const WidgetEventSchedulePlain = ({
<ScheduleText
programName={programName}
stageName={stageName}
orgUnitName={orgUnit?.name || ''}
orgUnitName={orgUnit?.name}
/>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,13 @@ export const WidgetEventSchedule = ({
initialScheduleDate,
...passOnProps,
});
const orgUnitInitial = { id: initialOrgUnitId, name: useOrgUnitNameWithAncestors(initialOrgUnitId).displayName } || undefined;
const orgUnit = useOrgUnitNameWithAncestors(initialOrgUnitId);
const orgUnitInitial = initialOrgUnitId && orgUnit?.displayName
? { id: initialOrgUnitId, name: orgUnit.displayName } : undefined;
const { currentUser, noteId } = useNoteDetails();
const [scheduleDate, setScheduleDate] = useState('');
const [scheduledOrgUnit, setScheduledOrgUnit] = useState(orgUnitInitial);
console.log('scheduledOrgUnit', scheduledOrgUnit);
const convertFn = pipe(convertFormToClient, convertClientToServer);
const serverScheduleDate = convertFn(scheduleDate, dataElementTypes.DATE);
const serverSuggestedScheduleDate = convertFn(suggestedScheduleDate, dataElementTypes.DATE);
Expand Down

0 comments on commit 8fb93ca

Please sign in to comment.