New: Release type options for Calendar page

This commit is contained in:
Bogdan 2025-05-29 23:44:23 +03:00
parent e7d76350ec
commit 9df2368601
7 changed files with 117 additions and 19 deletions

View file

@ -7,6 +7,9 @@ import { CalendarItem } from 'typings/Calendar';
interface CalendarOptions {
showMovieInformation: boolean;
showCinemaRelease: boolean;
showDigitalRelease: boolean;
showPhysicalRelease: boolean;
showCutoffUnmetIcon: boolean;
fullColorEvents: boolean;
}

View file

@ -48,9 +48,10 @@ function createMissingMovieIdsSelector() {
if (
!movie.movieFileId &&
inCinemas &&
moment(inCinemas).isAfter(start) &&
moment(inCinemas).isBefore(end) &&
isBefore(movie.inCinemas) &&
isBefore(inCinemas) &&
!queueDetails.some(
(details) => !!details.movie && details.movie.id === movie.id
)

View file

@ -21,27 +21,29 @@ function sort(items: CalendarEventModel[]) {
function createCalendarEventsConnector(date: string) {
return createSelector(
(state: AppState) => state.calendar.items,
(items) => {
(state: AppState) => state.calendar.options,
(items, options) => {
const { showCinemaRelease, showDigitalRelease, showPhysicalRelease } =
options;
const momentDate = moment(date);
const filtered = items.filter(
({ inCinemas, digitalRelease, physicalRelease }) => {
return (
(inCinemas && momentDate.isSame(moment(inCinemas), 'day')) ||
(digitalRelease &&
(showCinemaRelease &&
inCinemas &&
momentDate.isSame(moment(inCinemas), 'day')) ||
(showDigitalRelease &&
digitalRelease &&
momentDate.isSame(moment(digitalRelease), 'day')) ||
(physicalRelease &&
(showPhysicalRelease &&
physicalRelease &&
momentDate.isSame(moment(physicalRelease), 'day'))
);
}
);
return sort(
filtered.map((item) => ({
isGroup: false,
...item,
}))
);
return sort(filtered);
}
);
}

View file

@ -52,8 +52,14 @@ function CalendarEvent({
const { enableColorImpairedMode } = useSelector(createUISettingsSelector());
const { showMovieInformation, showCutoffUnmetIcon, fullColorEvents } =
useSelector((state: AppState) => state.calendar.options);
const {
showMovieInformation,
showCinemaRelease,
showDigitalRelease,
showPhysicalRelease,
showCutoffUnmetIcon,
fullColorEvents,
} = useSelector((state: AppState) => state.calendar.options);
const isDownloading = !!(queueItem || grabbed);
const statusStyle = getStatusStyle(
@ -70,20 +76,40 @@ function CalendarEvent({
const types = [];
if (inCinemas && momentDate.isSame(moment(inCinemas), 'day')) {
if (
showCinemaRelease &&
inCinemas &&
momentDate.isSame(moment(inCinemas), 'day')
) {
types.push('Cinemas');
}
if (digitalRelease && momentDate.isSame(moment(digitalRelease), 'day')) {
if (
showDigitalRelease &&
digitalRelease &&
momentDate.isSame(moment(digitalRelease), 'day')
) {
types.push('Digital');
}
if (physicalRelease && momentDate.isSame(moment(physicalRelease), 'day')) {
if (
showPhysicalRelease &&
physicalRelease &&
momentDate.isSame(moment(physicalRelease), 'day')
) {
types.push('Physical');
}
return types;
}, [date, inCinemas, digitalRelease, physicalRelease]);
}, [
date,
showCinemaRelease,
showDigitalRelease,
showPhysicalRelease,
inCinemas,
digitalRelease,
physicalRelease,
]);
return (
<div

View file

@ -33,8 +33,14 @@ function CalendarOptionsModalContent({
}: CalendarOptionsModalContentProps) {
const dispatch = useDispatch();
const { showMovieInformation, showCutoffUnmetIcon, fullColorEvents } =
useSelector((state: AppState) => state.calendar.options);
const {
showMovieInformation,
showCinemaRelease,
showDigitalRelease,
showPhysicalRelease,
showCutoffUnmetIcon,
fullColorEvents,
} = useSelector((state: AppState) => state.calendar.options);
const uiSettings = useSelector(createUISettingsSelector());
@ -96,6 +102,57 @@ function CalendarOptionsModalContent({
/>
</FormGroup>
<FormGroup>
<FormLabel>{translate('ShowCinemaRelease')}</FormLabel>
<FormInputGroup
type={inputTypes.CHECK}
name="showCinemaRelease"
value={showCinemaRelease}
helpText={translate('ShowCinemaReleaseCalendarHelpText')}
isDisabled={
showCinemaRelease &&
!showDigitalRelease &&
!showPhysicalRelease
}
onChange={handleOptionInputChange}
/>
</FormGroup>
<FormGroup>
<FormLabel>{translate('ShowDigitalRelease')}</FormLabel>
<FormInputGroup
type={inputTypes.CHECK}
name="showDigitalRelease"
value={showDigitalRelease}
helpText={translate('ShowDigitalReleaseCalendarHelpText')}
isDisabled={
!showCinemaRelease &&
showDigitalRelease &&
!showPhysicalRelease
}
onChange={handleOptionInputChange}
/>
</FormGroup>
<FormGroup>
<FormLabel>{translate('ShowPhysicalRelease')}</FormLabel>
<FormInputGroup
type={inputTypes.CHECK}
name="showPhysicalRelease"
value={showPhysicalRelease}
helpText={translate('ShowPhysicalReleaseCalendarHelpText')}
isDisabled={
!showCinemaRelease &&
!showDigitalRelease &&
showPhysicalRelease
}
onChange={handleOptionInputChange}
/>
</FormGroup>
<FormGroup>
<FormLabel>{translate('IconForCutoffUnmet')}</FormLabel>

View file

@ -43,6 +43,9 @@ export const defaultState = {
options: {
showMovieInformation: true,
showCinemaRelease: true,
showDigitalRelease: true,
showPhysicalRelease: true,
showCutoffUnmetIcon: false,
fullColorEvents: false
},

View file

@ -1762,10 +1762,14 @@
"ShortDateFormat": "Short Date Format",
"ShowAdvanced": "Show Advanced",
"ShowCertification": "Show Certification",
"ShowCinemaRelease": "Show Cinema Release",
"ShowCinemaReleaseCalendarHelpText": "Show cinema releases in the calendar events",
"ShowCinemaReleaseDate": "Show Cinema Release Date",
"ShowCinemaReleaseDatePosterHelpText": "Show cinema release date under poster",
"ShowCollectionDetails": "Show Collection Status",
"ShowDateAdded": "Show Date Added",
"ShowDigitalRelease": "Show Digital Release",
"ShowDigitalReleaseCalendarHelpText": "Show digital releases in the calendar events",
"ShowDigitalReleaseDate": "Show Digital Release Date",
"ShowDigitalReleaseDatePosterHelpText": "Show digital release date under poster",
"ShowGenres": "Show Genres",
@ -1777,6 +1781,8 @@
"ShowMovieInformationHelpText": "Show movie genres and certification",
"ShowOverview": "Show Overview",
"ShowPath": "Show Path",
"ShowPhysicalRelease": "Show Physical Release",
"ShowPhysicalReleaseCalendarHelpText": "Show physical releases in the calendar events",
"ShowPhysicalReleaseDate": "Show Physical Release Date",
"ShowPhysicalReleaseDatePosterHelpText": "Show physical release date under poster",
"ShowPosters": "Show Posters",