Skip to content

Commit edaafbe

Browse files
committed
Merge branch 'scheduling-endtime-display' of Arnei/opencast-admin-interface into main
Pull request #1158 Fix end time date display for scheduling
2 parents 16e30fc + 7462b51 commit edaafbe

File tree

4 files changed

+30
-48
lines changed

4 files changed

+30
-48
lines changed

src/components/events/partials/ModalTabsAndPages/EventDetailsSchedulingTab.tsx

+7-9
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import { Recording } from "../../../../slices/recordingSlice";
4747
import { useTranslation } from "react-i18next";
4848
import WizardNavigationButtons from "../../../shared/wizard/WizardNavigationButtons";
4949
import SchedulingTime from "../wizards/scheduling/SchedulingTime";
50-
import SchedulingEndDateDisplay from "../wizards/scheduling/SchedulingEndDateDisplay";
5150
import SchedulingLocation from "../wizards/scheduling/SchedulingLocation";
5251
import SchedulingInputs from "../wizards/scheduling/SchedulingInputs";
5352
import SchedulingConflicts from "../wizards/scheduling/SchedulingConflicts";
@@ -431,16 +430,15 @@ const EventDetailsSchedulingTab = ({
431430
checkConflictsWrapper
432431
)
433432
}}
433+
date={
434+
hasAccessRole &&
435+
(new Date(formik.values.scheduleEndDate).getDate() !==
436+
new Date(formik.values.scheduleStartDate).getDate())
437+
? formik.values.scheduleEndDate
438+
: undefined
439+
}
434440
/>
435441
)}
436-
{hasAccessRole &&
437-
formik.values.scheduleEndDate.toString() !==
438-
formik.values.scheduleStartDate.toString() && (
439-
<SchedulingEndDateDisplay
440-
scheduleEndDate={formik.values.scheduleEndDate}
441-
/>
442-
)
443-
}
444442
{!hasAccessRole && (
445443
<tr>
446444
<td>

src/components/events/partials/ModalTabsAndPages/NewSourcePage.tsx

+7-10
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ import { checkConflicts, UploadAssetsTrack } from "../../../../slices/eventSlice
4444
import ModalContentTable from "../../../shared/modals/ModalContentTable";
4545
import ButtonLikeAnchor from "../../../shared/ButtonLikeAnchor";
4646
import SchedulingTime from "../wizards/scheduling/SchedulingTime";
47-
import SchedulingEndDateDisplay from "../wizards/scheduling/SchedulingEndDateDisplay";
4847
import SchedulingLocation from "../wizards/scheduling/SchedulingLocation";
4948
import SchedulingInputs from "../wizards/scheduling/SchedulingInputs";
5049
import SchedulingConflicts from "../wizards/scheduling/SchedulingConflicts";
@@ -599,17 +598,15 @@ const Schedule = <T extends {
599598
);
600599
}
601600
}}
601+
date={
602+
formik.values.sourceMode === "SCHEDULE_SINGLE" &&
603+
(new Date(formik.values.scheduleEndDate).getDate() !==
604+
new Date(formik.values.scheduleStartDate).getDate())
605+
? formik.values.scheduleEndDate
606+
: undefined
607+
}
602608
/>
603609

604-
{/* display end date if on different day to start date, only if this is current source mode */}
605-
{formik.values.sourceMode === "SCHEDULE_SINGLE" &&
606-
formik.values.scheduleEndDate.toString() !==
607-
formik.values.scheduleStartDate.toString() && (
608-
<SchedulingEndDateDisplay
609-
scheduleEndDate={formik.values.scheduleEndDate}
610-
/>
611-
)}
612-
613610
<SchedulingLocation
614611
location={formik.values.location}
615612
inputDevices={inputDevices}

src/components/events/partials/wizards/scheduling/SchedulingEndDateDisplay.tsx

-28
This file was deleted.

src/components/events/partials/wizards/scheduling/SchedulingTime.tsx

+16-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next";
33
import DropDown from "../../../../shared/DropDown";
44
import { hours, minutes } from "../../../../../configs/modalConfig";
55
import { formatTimeForDropdown } from "../../../../../utils/dropDownUtils";
6+
import { getCurrentLanguageInformation } from "../../../../../utils/utils";
67
import { ParseKeys } from "i18next";
78

89
const SchedulingTime = ({
@@ -13,7 +14,8 @@ const SchedulingTime = ({
1314
hourPlaceholder,
1415
minutePlaceholder,
1516
callbackHour,
16-
callbackMinute
17+
callbackMinute,
18+
date
1719
}: {
1820
hour: string,
1921
minute: string,
@@ -23,8 +25,11 @@ const SchedulingTime = ({
2325
minutePlaceholder: ParseKeys
2426
callbackHour: (value: string) => void
2527
callbackMinute: (value: string) => void
28+
date?: string | Date
2629
}) => {
2730
const { t } = useTranslation();
31+
// Get info about the current language and its date locale
32+
const currentLanguage = getCurrentLanguageInformation();
2833

2934
return (
3035
<tr>
@@ -65,6 +70,16 @@ const SchedulingTime = ({
6570
disabled={disabled}
6671
customCSS={{width: 70}}
6772
/>
73+
74+
{/* Displays given date. Can be used to signify which date the
75+
scheduling time belong to*/}
76+
{date &&
77+
<span style={{ marginLeft: "10px" }}>
78+
{new Date(date).toLocaleDateString(
79+
currentLanguage ? currentLanguage.dateLocale.code : undefined
80+
)}
81+
</span>
82+
}
6883
</td>
6984
</tr>
7085
)

0 commit comments

Comments
 (0)