mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-20 22:49:18 +00:00
refactor: visibility options
This commit is contained in:
committed by
Carlos Valente
parent
430b72c1d0
commit
c9ef2465f8
@@ -40,7 +40,7 @@ export default function CuesheetTable(props: CuesheetTableProps) {
|
|||||||
|
|
||||||
const { updateEvent, updateTimer } = useEventAction();
|
const { updateEvent, updateTimer } = useEventAction();
|
||||||
const { selectedEventId } = useSelectedEventId();
|
const { selectedEventId } = useSelectedEventId();
|
||||||
const { followSelected, hideDelays, hidePast, hideIndexColumn } = useCuesheetOptions();
|
const { followSelected, hideDelays, hidePast } = useCuesheetOptions();
|
||||||
const { columnVisibility, columnOrder, columnSizing, resetColumnOrder, setColumnVisibility, setColumnSizing } =
|
const { columnVisibility, columnOrder, columnSizing, resetColumnOrder, setColumnVisibility, setColumnSizing } =
|
||||||
useColumnManager(columns);
|
useColumnManager(columns);
|
||||||
|
|
||||||
@@ -115,7 +115,7 @@ export default function CuesheetTable(props: CuesheetTableProps) {
|
|||||||
/>
|
/>
|
||||||
<div ref={tableContainerRef} className={style.cuesheetContainer}>
|
<div ref={tableContainerRef} className={style.cuesheetContainer}>
|
||||||
<table className={style.cuesheet} id='cuesheet'>
|
<table className={style.cuesheet} id='cuesheet'>
|
||||||
<CuesheetHeader headerGroups={headerGroups} showIndexColumn={!hideIndexColumn} />
|
<CuesheetHeader headerGroups={headerGroups} />
|
||||||
<tbody>
|
<tbody>
|
||||||
{rowModel.rows.map((row, index) => {
|
{rowModel.rows.map((row, index) => {
|
||||||
const key = row.original.id;
|
const key = row.original.id;
|
||||||
@@ -168,7 +168,6 @@ export default function CuesheetTable(props: CuesheetTableProps) {
|
|||||||
selectedRef={isSelected ? selectedRef : undefined}
|
selectedRef={isSelected ? selectedRef : undefined}
|
||||||
skip={entry.skip}
|
skip={entry.skip}
|
||||||
colour={entry.colour}
|
colour={entry.colour}
|
||||||
showIndexColumn={!hideIndexColumn}
|
|
||||||
>
|
>
|
||||||
{row.getVisibleCells().map((cell) => {
|
{row.getVisibleCells().map((cell) => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
+5
-4
@@ -3,6 +3,7 @@ import { flexRender, HeaderGroup } from '@tanstack/react-table';
|
|||||||
import { OntimeRundownEntry } from 'ontime-types';
|
import { OntimeRundownEntry } from 'ontime-types';
|
||||||
|
|
||||||
import { getAccessibleColour } from '../../../../common/utils/styleUtils';
|
import { getAccessibleColour } from '../../../../common/utils/styleUtils';
|
||||||
|
import { useCuesheetOptions } from '../../cuesheet.options';
|
||||||
|
|
||||||
import { SortableCell } from './SortableCell';
|
import { SortableCell } from './SortableCell';
|
||||||
|
|
||||||
@@ -10,11 +11,11 @@ import style from '../CuesheetTable.module.scss';
|
|||||||
|
|
||||||
interface CuesheetHeaderProps {
|
interface CuesheetHeaderProps {
|
||||||
headerGroups: HeaderGroup<OntimeRundownEntry>[];
|
headerGroups: HeaderGroup<OntimeRundownEntry>[];
|
||||||
showIndexColumn: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function CuesheetHeader(props: CuesheetHeaderProps) {
|
export default function CuesheetHeader(props: CuesheetHeaderProps) {
|
||||||
const { headerGroups, showIndexColumn } = props;
|
const { headerGroups } = props;
|
||||||
|
const { hideIndexColumn, showActionMenu } = useCuesheetOptions();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<thead className={style.tableHeader}>
|
<thead className={style.tableHeader}>
|
||||||
@@ -23,8 +24,8 @@ export default function CuesheetHeader(props: CuesheetHeaderProps) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<tr key={headerGroup.id}>
|
<tr key={headerGroup.id}>
|
||||||
<th className={style.actionColumn} />
|
{showActionMenu && <th className={style.actionColumn} />}
|
||||||
<th className={style.indexColumn}>{showIndexColumn && '#'}</th>
|
{!hideIndexColumn && <th className={style.indexColumn}>#</th>}
|
||||||
<SortableContext key={key} items={headerGroup.headers} strategy={horizontalListSortingStrategy}>
|
<SortableContext key={key} items={headerGroup.headers} strategy={horizontalListSortingStrategy}>
|
||||||
{headerGroup.headers.map((header) => {
|
{headerGroup.headers.map((header) => {
|
||||||
const width = header.getSize();
|
const width = header.getSize();
|
||||||
|
|||||||
+19
-14
@@ -4,12 +4,12 @@ import { IoEllipsisHorizontal } from '@react-icons/all-files/io5/IoEllipsisHoriz
|
|||||||
import Color from 'color';
|
import Color from 'color';
|
||||||
|
|
||||||
import { cx, getAccessibleColour } from '../../../../common/utils/styleUtils';
|
import { cx, getAccessibleColour } from '../../../../common/utils/styleUtils';
|
||||||
|
import { useCuesheetOptions } from '../../cuesheet.options';
|
||||||
|
|
||||||
import style from '../CuesheetTable.module.scss';
|
import style from '../CuesheetTable.module.scss';
|
||||||
|
|
||||||
interface EventRowProps {
|
interface EventRowProps {
|
||||||
eventIndex: number;
|
eventIndex: number;
|
||||||
showIndexColumn: boolean;
|
|
||||||
isPast?: boolean;
|
isPast?: boolean;
|
||||||
selectedRef?: MutableRefObject<HTMLTableRowElement | null>;
|
selectedRef?: MutableRefObject<HTMLTableRowElement | null>;
|
||||||
skip?: boolean;
|
skip?: boolean;
|
||||||
@@ -17,7 +17,8 @@ interface EventRowProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function EventRow(props: PropsWithChildren<EventRowProps>) {
|
function EventRow(props: PropsWithChildren<EventRowProps>) {
|
||||||
const { children, eventIndex, isPast, selectedRef, skip, colour, showIndexColumn } = props;
|
const { children, eventIndex, isPast, selectedRef, skip, colour } = props;
|
||||||
|
const { hideIndexColumn, showActionMenu } = useCuesheetOptions();
|
||||||
const ownRef = useRef<HTMLTableRowElement>(null);
|
const ownRef = useRef<HTMLTableRowElement>(null);
|
||||||
const [isVisible, setIsVisible] = useState(false);
|
const [isVisible, setIsVisible] = useState(false);
|
||||||
|
|
||||||
@@ -57,18 +58,22 @@ function EventRow(props: PropsWithChildren<EventRowProps>) {
|
|||||||
style={{ opacity: `${isPast ? '0.2' : '1'}` }}
|
style={{ opacity: `${isPast ? '0.2' : '1'}` }}
|
||||||
ref={selectedRef ?? ownRef}
|
ref={selectedRef ?? ownRef}
|
||||||
>
|
>
|
||||||
<td className={style.actionColumn}>
|
{showActionMenu && (
|
||||||
<MenuButton
|
<td className={style.actionColumn}>
|
||||||
as={IconButton}
|
<MenuButton
|
||||||
size='sm'
|
as={IconButton}
|
||||||
aria-label='Options'
|
size='sm'
|
||||||
icon={<IoEllipsisHorizontal />}
|
aria-label='Options'
|
||||||
variant='ontime-subtle'
|
icon={<IoEllipsisHorizontal />}
|
||||||
/>
|
variant='ontime-subtle'
|
||||||
</td>
|
/>
|
||||||
<td className={style.indexColumn} style={{ backgroundColor, color: mutedText }}>
|
</td>
|
||||||
{showIndexColumn && eventIndex}
|
)}
|
||||||
</td>
|
{!hideIndexColumn && (
|
||||||
|
<td className={style.indexColumn} style={{ backgroundColor, color: mutedText }}>
|
||||||
|
{eventIndex}
|
||||||
|
</td>
|
||||||
|
)}
|
||||||
{isVisible ? children : null}
|
{isVisible ? children : null}
|
||||||
</tr>
|
</tr>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,6 +10,13 @@ import { isStringBoolean } from '../../features/viewers/common/viewUtils';
|
|||||||
*/
|
*/
|
||||||
export const cuesheetOptions: ViewOption[] = [
|
export const cuesheetOptions: ViewOption[] = [
|
||||||
{ section: 'Table options' },
|
{ section: 'Table options' },
|
||||||
|
{
|
||||||
|
id: 'showActionMenu',
|
||||||
|
title: 'Show action menu',
|
||||||
|
description: 'Whether to show the action menu for every row in the table',
|
||||||
|
type: 'boolean',
|
||||||
|
defaultValue: false,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'hideTableSeconds',
|
id: 'hideTableSeconds',
|
||||||
title: 'Hide seconds in table',
|
title: 'Hide seconds in table',
|
||||||
@@ -56,6 +63,7 @@ export const cuesheetOptions: ViewOption[] = [
|
|||||||
];
|
];
|
||||||
|
|
||||||
type CuesheetOptions = {
|
type CuesheetOptions = {
|
||||||
|
showActionMenu: boolean;
|
||||||
hideTableSeconds: boolean;
|
hideTableSeconds: boolean;
|
||||||
followSelected: boolean;
|
followSelected: boolean;
|
||||||
hidePast: boolean;
|
hidePast: boolean;
|
||||||
@@ -71,6 +79,7 @@ type CuesheetOptions = {
|
|||||||
export function getOptionsFromParams(searchParams: URLSearchParams): CuesheetOptions {
|
export function getOptionsFromParams(searchParams: URLSearchParams): CuesheetOptions {
|
||||||
// we manually make an object that matches the key above
|
// we manually make an object that matches the key above
|
||||||
return {
|
return {
|
||||||
|
showActionMenu: isStringBoolean(searchParams.get('showActionMenu')),
|
||||||
hideTableSeconds: isStringBoolean(searchParams.get('hideTableSeconds')),
|
hideTableSeconds: isStringBoolean(searchParams.get('hideTableSeconds')),
|
||||||
followSelected: isStringBoolean(searchParams.get('followSelected')),
|
followSelected: isStringBoolean(searchParams.get('followSelected')),
|
||||||
hidePast: isStringBoolean(searchParams.get('hidePast')),
|
hidePast: isStringBoolean(searchParams.get('hidePast')),
|
||||||
|
|||||||
Reference in New Issue
Block a user