mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-17 13:23:35 +00:00
Custom for timer title (#1055)
This commit is contained in:
committed by
GitHub
parent
0e32b3a3af
commit
f405e65c55
@@ -5,8 +5,8 @@ import { capitaliseFirstLetter } from '../../../features/viewers/common/viewUtil
|
|||||||
import { ParamField } from './types';
|
import { ParamField } from './types';
|
||||||
|
|
||||||
const makeOptionsFromCustomFields = (customFields: CustomFields, additionalOptions?: Record<string, string>) => {
|
const makeOptionsFromCustomFields = (customFields: CustomFields, additionalOptions?: Record<string, string>) => {
|
||||||
const customFieldOptions = Object.keys(customFields).reduce((acc, key) => {
|
const customFieldOptions = Object.entries(customFields).reduce((acc, [key, value]) => {
|
||||||
return { ...acc, [`custom-${key}`]: `Custom: ${capitaliseFirstLetter(key)}` };
|
return { ...acc, [`custom-${key}`]: `Custom: ${value.label}` };
|
||||||
}, additionalOptions ?? {});
|
}, additionalOptions ?? {});
|
||||||
return customFieldOptions;
|
return customFieldOptions;
|
||||||
};
|
};
|
||||||
@@ -111,6 +111,7 @@ export const getClockOptions = (timeFormat: string): ParamField[] => [
|
|||||||
];
|
];
|
||||||
|
|
||||||
export const getTimerOptions = (timeFormat: string, customFields: CustomFields): ParamField[] => {
|
export const getTimerOptions = (timeFormat: string, customFields: CustomFields): ParamField[] => {
|
||||||
|
const mainOptions = makeOptionsFromCustomFields(customFields, { title: 'Title' });
|
||||||
const secondaryOptions = makeOptionsFromCustomFields(customFields, { note: 'Note' });
|
const secondaryOptions = makeOptionsFromCustomFields(customFields, { note: 'Note' });
|
||||||
return [
|
return [
|
||||||
getTimeOption(timeFormat),
|
getTimeOption(timeFormat),
|
||||||
@@ -123,6 +124,14 @@ export const getTimerOptions = (timeFormat: string, customFields: CustomFields):
|
|||||||
type: 'boolean',
|
type: 'boolean',
|
||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'main',
|
||||||
|
title: 'Main text',
|
||||||
|
description: 'Select the data source for the main text',
|
||||||
|
type: 'option',
|
||||||
|
values: mainOptions,
|
||||||
|
defaultValue: 'Title',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'secondary-src',
|
id: 'secondary-src',
|
||||||
title: 'Secondary text',
|
title: 'Secondary text',
|
||||||
|
|||||||
@@ -106,6 +106,10 @@ export default function Timer(props: TimerProps) {
|
|||||||
const secondaryTextNow = getPropertyValue(eventNow, secondarySource);
|
const secondaryTextNow = getPropertyValue(eventNow, secondarySource);
|
||||||
const secondaryTextNext = getPropertyValue(eventNext, secondarySource);
|
const secondaryTextNext = getPropertyValue(eventNext, secondarySource);
|
||||||
|
|
||||||
|
const main = searchParams.get('main');
|
||||||
|
const mainFieldNow = (main ? getPropertyValue(eventNow, main) : eventNow?.title) ?? '';
|
||||||
|
const mainFieldNext = (main ? getPropertyValue(eventNext, main) : eventNext?.title) ?? '';
|
||||||
|
|
||||||
const showOverlay = pres.text !== '' && pres.visible;
|
const showOverlay = pres.text !== '' && pres.visible;
|
||||||
const isPlaying = time.playback !== Playback.Pause;
|
const isPlaying = time.playback !== Playback.Pause;
|
||||||
|
|
||||||
@@ -215,7 +219,7 @@ export default function Timer(props: TimerProps) {
|
|||||||
animate='visible'
|
animate='visible'
|
||||||
exit='exit'
|
exit='exit'
|
||||||
>
|
>
|
||||||
<TitleCard label='now' title={eventNow.title} secondary={secondaryTextNow} />
|
<TitleCard label='now' title={mainFieldNow} secondary={secondaryTextNow} />
|
||||||
</motion.div>
|
</motion.div>
|
||||||
)}
|
)}
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
@@ -230,7 +234,7 @@ export default function Timer(props: TimerProps) {
|
|||||||
animate='visible'
|
animate='visible'
|
||||||
exit='exit'
|
exit='exit'
|
||||||
>
|
>
|
||||||
<TitleCard label='next' title={eventNext.title} secondary={secondaryTextNext} />
|
<TitleCard label='next' title={mainFieldNext} secondary={secondaryTextNext} />
|
||||||
</motion.div>
|
</motion.div>
|
||||||
)}
|
)}
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
|
|||||||
Reference in New Issue
Block a user