mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-16 21:03:29 +00:00
3603b836f6
* refactor: typescript migration * chore: remove prop-types package * refactor: file structure * refactor: migrate ontime table to tanstack table 8 * refactor: rundown controller uses service as data source * refactor: convert to typescript * feat: caching store * refactor: add delay values to rundown * feat: toggle past visibility * chore: update tests * refactor: add extra fields to CSV * style: show skipped events * chore: add route to navigation menu * style: allow jumping to bottom * chore: add tests
84 lines
3.2 KiB
TypeScript
84 lines
3.2 KiB
TypeScript
import { Button, Checkbox, Switch } from '@chakra-ui/react';
|
|
import { Column } from '@tanstack/react-table';
|
|
import { OntimeRundownEntry } from 'ontime-types';
|
|
|
|
import { useCuesheetSettings } from '../store/CuesheetSettings';
|
|
|
|
import style from './CuesheetTableSettings.module.scss';
|
|
|
|
// reusable button styles
|
|
const buttonProps = {
|
|
size: 'sm',
|
|
variant: 'ontime-subtle',
|
|
};
|
|
|
|
interface CuesheetTableSettingsProps {
|
|
columns: Column<OntimeRundownEntry, unknown>[];
|
|
handleResetResizing: () => void;
|
|
handleResetReordering: () => void;
|
|
handleClearToggles: () => void;
|
|
}
|
|
|
|
export default function CuesheetTableSettings(props: CuesheetTableSettingsProps) {
|
|
const { columns, handleResetResizing, handleResetReordering, handleClearToggles } = props;
|
|
const showPrevious = useCuesheetSettings((state) => state.showPrevious);
|
|
const togglePreviousVisibility = useCuesheetSettings((state) => state.togglePreviousVisibility);
|
|
const showDelayBlock = useCuesheetSettings((state) => state.showDelayBlock);
|
|
const toggleDelayVisibility = useCuesheetSettings((state) => state.toggleDelayVisibility);
|
|
const showDelayedTimes = useCuesheetSettings((state) => state.showDelayedTimes);
|
|
const toggleDelayedTimes = useCuesheetSettings((state) => state.toggleDelayedTimes);
|
|
|
|
return (
|
|
<div className={style.tableSettings}>
|
|
<div className={style.leftPanel}>
|
|
<div className={style.sectionTitle}>Toggle column visibility</div>
|
|
<div className={style.options}>
|
|
{columns.map((column) => {
|
|
const columnHeader = column.columnDef.header;
|
|
const visible = column.getIsVisible();
|
|
return (
|
|
<label key={`${column.id}-${visible}`} className={style.option}>
|
|
<Checkbox
|
|
variant='ontime-ondark'
|
|
defaultChecked={visible}
|
|
onChange={column.getToggleVisibilityHandler()}
|
|
/>
|
|
{columnHeader}
|
|
</label>
|
|
);
|
|
})}
|
|
</div>
|
|
<div className={style.sectionTitle}>Table Options</div>
|
|
<div className={style.options}>
|
|
<label className={style.option}>
|
|
<Switch variant='ontime' size='sm' isChecked={showPrevious} onChange={() => togglePreviousVisibility()} />
|
|
Show past events
|
|
</label>
|
|
</div>
|
|
<div className={style.sectionTitle}>Delay Flow</div>
|
|
<div className={style.options}>
|
|
<label className={style.option}>
|
|
<Switch variant='ontime' size='sm' isChecked={showDelayedTimes} onChange={() => toggleDelayedTimes()} />
|
|
Show delayed times
|
|
</label>
|
|
<label className={style.option}>
|
|
<Switch variant='ontime' size='sm' isChecked={showDelayBlock} onChange={() => toggleDelayVisibility()} />
|
|
Show delay blocks
|
|
</label>
|
|
</div>
|
|
</div>
|
|
<div className={style.rightPanel}>
|
|
<Button onClick={handleClearToggles} {...buttonProps}>
|
|
Show All
|
|
</Button>
|
|
<Button onClick={handleResetResizing} {...buttonProps}>
|
|
Reset Resizing
|
|
</Button>
|
|
<Button onClick={handleResetReordering} {...buttonProps}>
|
|
Reset Reordering
|
|
</Button>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|