mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-22 15:39:11 +00:00
refactor: improve visibility of time-to-end
This commit is contained in:
committed by
Carlos Valente
parent
83b9fde45e
commit
b1bff22b84
@@ -25,6 +25,7 @@ export default function TimerPreview() {
|
|||||||
if (showTimerMessage) return 'Message';
|
if (showTimerMessage) return 'Message';
|
||||||
if (phase === TimerPhase.Pending) return 'Standby to start';
|
if (phase === TimerPhase.Pending) return 'Standby to start';
|
||||||
if (phase === TimerPhase.Overtime && data.endMessage) return 'Custom end message';
|
if (phase === TimerPhase.Overtime && data.endMessage) return 'Custom end message';
|
||||||
|
if (timerType === TimerType.TimeToEnd) return 'Time to end';
|
||||||
return 'Timer';
|
return 'Timer';
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ const EventBlockInner = (props: EventBlockInnerProps) => {
|
|||||||
delay={delay}
|
delay={delay}
|
||||||
timeStrategy={timeStrategy}
|
timeStrategy={timeStrategy}
|
||||||
linkStart={linkStart}
|
linkStart={linkStart}
|
||||||
|
timerType={timerType}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={style.titleSection}>
|
<div className={style.titleSection}>
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ const EventEditorTimes = (props: EventEditorTimesProps) => {
|
|||||||
timeStrategy={timeStrategy}
|
timeStrategy={timeStrategy}
|
||||||
linkStart={linkStart}
|
linkStart={linkStart}
|
||||||
delay={delay}
|
delay={delay}
|
||||||
|
timerType={timerType}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className={style.delayLabel}>{delayLabel}</div>
|
<div className={style.delayLabel}>{delayLabel}</div>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { IoLink } from '@react-icons/all-files/io5/IoLink';
|
|||||||
import { IoLockClosed } from '@react-icons/all-files/io5/IoLockClosed';
|
import { IoLockClosed } from '@react-icons/all-files/io5/IoLockClosed';
|
||||||
import { IoLockOpenOutline } from '@react-icons/all-files/io5/IoLockOpenOutline';
|
import { IoLockOpenOutline } from '@react-icons/all-files/io5/IoLockOpenOutline';
|
||||||
import { IoUnlink } from '@react-icons/all-files/io5/IoUnlink';
|
import { IoUnlink } from '@react-icons/all-files/io5/IoUnlink';
|
||||||
import { MaybeString, TimeStrategy } from 'ontime-types';
|
import { MaybeString, TimerType, TimeStrategy } from 'ontime-types';
|
||||||
|
|
||||||
import TimeInputWithButton from '../../../common/components/input/time-input/TimeInputWithButton';
|
import TimeInputWithButton from '../../../common/components/input/time-input/TimeInputWithButton';
|
||||||
import { useEventAction } from '../../../common/hooks/useEventAction';
|
import { useEventAction } from '../../../common/hooks/useEventAction';
|
||||||
@@ -22,12 +22,13 @@ interface EventBlockTimerProps {
|
|||||||
timeStrategy: TimeStrategy;
|
timeStrategy: TimeStrategy;
|
||||||
linkStart: MaybeString;
|
linkStart: MaybeString;
|
||||||
delay: number;
|
delay: number;
|
||||||
|
timerType: TimerType;
|
||||||
}
|
}
|
||||||
|
|
||||||
type TimeActions = 'timeStart' | 'timeEnd' | 'duration';
|
type TimeActions = 'timeStart' | 'timeEnd' | 'duration';
|
||||||
|
|
||||||
const TimeInputFlow = (props: EventBlockTimerProps) => {
|
const TimeInputFlow = (props: EventBlockTimerProps) => {
|
||||||
const { eventId, timeStart, timeEnd, duration, timeStrategy, linkStart, delay } = props;
|
const { eventId, timeStart, timeEnd, duration, timeStrategy, linkStart, delay, timerType } = props;
|
||||||
const { updateEvent, updateTimer } = useEventAction();
|
const { updateEvent, updateTimer } = useEventAction();
|
||||||
|
|
||||||
// In sync with EventEditorTimes
|
// In sync with EventEditorTimes
|
||||||
@@ -43,7 +44,15 @@ const TimeInputFlow = (props: EventBlockTimerProps) => {
|
|||||||
updateEvent({ id: eventId, linkStart: doLink ? 'true' : null });
|
updateEvent({ id: eventId, linkStart: doLink ? 'true' : null });
|
||||||
};
|
};
|
||||||
|
|
||||||
const overMidnight = timeStart > timeEnd;
|
const warnings = [];
|
||||||
|
if (timeStart > timeEnd) {
|
||||||
|
warnings.push('Over midnight');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (timerType === TimerType.TimeToEnd) {
|
||||||
|
warnings.push('Time to end');
|
||||||
|
}
|
||||||
|
|
||||||
const hasDelay = delay !== 0;
|
const hasDelay = delay !== 0;
|
||||||
|
|
||||||
const isLockedEnd = timeStrategy === TimeStrategy.LockEnd;
|
const isLockedEnd = timeStrategy === TimeStrategy.LockEnd;
|
||||||
@@ -110,9 +119,9 @@ const TimeInputFlow = (props: EventBlockTimerProps) => {
|
|||||||
</Tooltip>
|
</Tooltip>
|
||||||
</TimeInputWithButton>
|
</TimeInputWithButton>
|
||||||
|
|
||||||
{overMidnight && (
|
{warnings.length > 0 && (
|
||||||
<div className={style.timerNote}>
|
<div className={style.timerNote}>
|
||||||
<Tooltip label='Over midnight' openDelay={tooltipDelayFast} variant='ontime-ondark' shouldWrapChildren>
|
<Tooltip label={warnings.join(' - ')} openDelay={tooltipDelayFast} variant='ontime-ondark' shouldWrapChildren>
|
||||||
<IoAlertCircleOutline />
|
<IoAlertCircleOutline />
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user