mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-22 15:39:11 +00:00
hide seconds toggle in cuesheet (#1272)
This commit is contained in:
committed by
GitHub
parent
8ef807d6cb
commit
b73b529c00
@@ -29,10 +29,12 @@ function CuesheetTableSettings(props: CuesheetTableSettingsProps) {
|
|||||||
showPrevious,
|
showPrevious,
|
||||||
togglePreviousVisibility,
|
togglePreviousVisibility,
|
||||||
showDelayBlock,
|
showDelayBlock,
|
||||||
|
hideSeconds,
|
||||||
showDelayedTimes,
|
showDelayedTimes,
|
||||||
toggleIndexColumn,
|
toggleIndexColumn,
|
||||||
toggleDelayedTimes,
|
toggleDelayedTimes,
|
||||||
toggleDelayVisibility,
|
toggleDelayVisibility,
|
||||||
|
toggleSecondsVisibility,
|
||||||
} = useCuesheetSettings();
|
} = useCuesheetSettings();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -80,6 +82,10 @@ function CuesheetTableSettings(props: CuesheetTableSettingsProps) {
|
|||||||
<Switch variant='ontime' size='sm' isChecked={showDelayBlock} onChange={() => toggleDelayVisibility()} />
|
<Switch variant='ontime' size='sm' isChecked={showDelayBlock} onChange={() => toggleDelayVisibility()} />
|
||||||
Show delay blocks
|
Show delay blocks
|
||||||
</label>
|
</label>
|
||||||
|
<label className={style.option}>
|
||||||
|
<Switch variant='ontime' size='sm' isChecked={hideSeconds} onChange={() => toggleSecondsVisibility()} />
|
||||||
|
Hide seconds
|
||||||
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={style.rightPanel}>
|
<div className={style.rightPanel}>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { useCallback } from 'react';
|
|||||||
import { IoCheckmark } from '@react-icons/all-files/io5/IoCheckmark';
|
import { IoCheckmark } from '@react-icons/all-files/io5/IoCheckmark';
|
||||||
import { CellContext, ColumnDef } from '@tanstack/react-table';
|
import { CellContext, ColumnDef } from '@tanstack/react-table';
|
||||||
import { CustomFields, isOntimeEvent, OntimeEvent, OntimeRundownEntry } from 'ontime-types';
|
import { CustomFields, isOntimeEvent, OntimeEvent, OntimeRundownEntry } from 'ontime-types';
|
||||||
import { millisToString } from 'ontime-utils';
|
|
||||||
|
|
||||||
import DelayIndicator from '../../common/components/delay-indicator/DelayIndicator';
|
import DelayIndicator from '../../common/components/delay-indicator/DelayIndicator';
|
||||||
import RunningTime from '../viewers/common/running-time/RunningTime';
|
import RunningTime from '../viewers/common/running-time/RunningTime';
|
||||||
@@ -19,20 +18,28 @@ function makePublic(row: CellContext<OntimeRundownEntry, unknown>) {
|
|||||||
|
|
||||||
function MakeTimer({ getValue, row: { original } }: CellContext<OntimeRundownEntry, unknown>) {
|
function MakeTimer({ getValue, row: { original } }: CellContext<OntimeRundownEntry, unknown>) {
|
||||||
const showDelayedTimes = useCuesheetSettings((state) => state.showDelayedTimes);
|
const showDelayedTimes = useCuesheetSettings((state) => state.showDelayedTimes);
|
||||||
|
const hideSeconds = useCuesheetSettings((state) => state.hideSeconds);
|
||||||
const cellValue = (getValue() as number | null) ?? 0;
|
const cellValue = (getValue() as number | null) ?? 0;
|
||||||
const delayValue = (original as OntimeEvent)?.delay ?? 0;
|
const delayValue = (original as OntimeEvent)?.delay ?? 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span className={style.time}>
|
<span className={style.time}>
|
||||||
<DelayIndicator delayValue={delayValue} />
|
<DelayIndicator delayValue={delayValue} />
|
||||||
<RunningTime value={cellValue} />
|
<RunningTime value={cellValue} hideSeconds={hideSeconds} />
|
||||||
{delayValue !== 0 && showDelayedTimes && (
|
{delayValue !== 0 && showDelayedTimes && (
|
||||||
<RunningTime className={style.delayedTime} value={cellValue + delayValue} />
|
<RunningTime className={style.delayedTime} value={cellValue + delayValue} hideSeconds={hideSeconds} />
|
||||||
)}
|
)}
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function MakeDuration({ getValue }: CellContext<OntimeRundownEntry, unknown>) {
|
||||||
|
const hideSeconds = useCuesheetSettings((state) => state.hideSeconds);
|
||||||
|
const cellValue = (getValue() as number | null) ?? 0;
|
||||||
|
|
||||||
|
return <RunningTime value={cellValue} hideSeconds={hideSeconds} />;
|
||||||
|
}
|
||||||
|
|
||||||
function MakeCustomField({ row, column, table }: CellContext<OntimeRundownEntry, unknown>) {
|
function MakeCustomField({ row, column, table }: CellContext<OntimeRundownEntry, unknown>) {
|
||||||
const update = useCallback(
|
const update = useCallback(
|
||||||
(newValue: string) => {
|
(newValue: string) => {
|
||||||
@@ -97,7 +104,7 @@ export function makeCuesheetColumns(customFields: CustomFields): ColumnDef<Ontim
|
|||||||
accessorKey: 'duration',
|
accessorKey: 'duration',
|
||||||
id: 'duration',
|
id: 'duration',
|
||||||
header: 'Duration',
|
header: 'Duration',
|
||||||
cell: (row) => millisToString(row.getValue() as number | null),
|
cell: MakeDuration,
|
||||||
size: 75,
|
size: 75,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ interface CuesheetSettings {
|
|||||||
showPrevious: boolean;
|
showPrevious: boolean;
|
||||||
showDelayBlock: boolean;
|
showDelayBlock: boolean;
|
||||||
showDelayedTimes: boolean;
|
showDelayedTimes: boolean;
|
||||||
|
hideSeconds: boolean;
|
||||||
|
|
||||||
toggleSettings: (newValue?: boolean) => void;
|
toggleSettings: (newValue?: boolean) => void;
|
||||||
toggleFollow: (newValue?: boolean) => void;
|
toggleFollow: (newValue?: boolean) => void;
|
||||||
@@ -16,6 +17,7 @@ interface CuesheetSettings {
|
|||||||
toggleIndexColumn: (newValue?: boolean) => void;
|
toggleIndexColumn: (newValue?: boolean) => void;
|
||||||
toggleDelayVisibility: (newValue?: boolean) => void;
|
toggleDelayVisibility: (newValue?: boolean) => void;
|
||||||
toggleDelayedTimes: (newValue?: boolean) => void;
|
toggleDelayedTimes: (newValue?: boolean) => void;
|
||||||
|
toggleSecondsVisibility: (newValue?: boolean) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggle(oldValue: boolean, value?: boolean) {
|
function toggle(oldValue: boolean, value?: boolean) {
|
||||||
@@ -31,6 +33,7 @@ enum CuesheetKeys {
|
|||||||
PreviousVisibility = 'ontime-cuesheet-show-previous',
|
PreviousVisibility = 'ontime-cuesheet-show-previous',
|
||||||
ColumnIndex = 'ontime-cuesheet-show-index-column',
|
ColumnIndex = 'ontime-cuesheet-show-index-column',
|
||||||
DelayedTimes = 'ontime-cuesheet-show-delayed',
|
DelayedTimes = 'ontime-cuesheet-show-delayed',
|
||||||
|
Seconds = 'ontime-cuesheet-hide-sceconds',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useCuesheetSettings = create<CuesheetSettings>()((set) => ({
|
export const useCuesheetSettings = create<CuesheetSettings>()((set) => ({
|
||||||
@@ -40,6 +43,7 @@ export const useCuesheetSettings = create<CuesheetSettings>()((set) => ({
|
|||||||
showPrevious: booleanFromLocalStorage(CuesheetKeys.PreviousVisibility, true),
|
showPrevious: booleanFromLocalStorage(CuesheetKeys.PreviousVisibility, true),
|
||||||
showDelayBlock: booleanFromLocalStorage(CuesheetKeys.DelayVisibility, true),
|
showDelayBlock: booleanFromLocalStorage(CuesheetKeys.DelayVisibility, true),
|
||||||
showDelayedTimes: booleanFromLocalStorage(CuesheetKeys.DelayedTimes, false),
|
showDelayedTimes: booleanFromLocalStorage(CuesheetKeys.DelayedTimes, false),
|
||||||
|
hideSeconds: booleanFromLocalStorage(CuesheetKeys.Seconds, false),
|
||||||
|
|
||||||
toggleSettings: (newValue?: boolean) => set((state) => ({ showSettings: toggle(state.showSettings, newValue) })),
|
toggleSettings: (newValue?: boolean) => set((state) => ({ showSettings: toggle(state.showSettings, newValue) })),
|
||||||
toggleFollow: (newValue?: boolean) =>
|
toggleFollow: (newValue?: boolean) =>
|
||||||
@@ -72,4 +76,10 @@ export const useCuesheetSettings = create<CuesheetSettings>()((set) => ({
|
|||||||
localStorage.setItem(CuesheetKeys.DelayedTimes, String(showDelayedTimes));
|
localStorage.setItem(CuesheetKeys.DelayedTimes, String(showDelayedTimes));
|
||||||
return { showDelayedTimes };
|
return { showDelayedTimes };
|
||||||
}),
|
}),
|
||||||
|
toggleSecondsVisibility: (newValue?: boolean) =>
|
||||||
|
set((state) => {
|
||||||
|
const hideSeconds = toggle(state.hideSeconds, newValue);
|
||||||
|
localStorage.setItem(CuesheetKeys.Seconds, String(hideSeconds));
|
||||||
|
return { hideSeconds };
|
||||||
|
}),
|
||||||
}));
|
}));
|
||||||
|
|||||||
Reference in New Issue
Block a user