+
}
- onClick={() => toggleSettings()}
+ onClick={showEditFormDrawer}
/>
diff --git a/apps/client/src/views/cuesheet/cuesheet.options.ts b/apps/client/src/views/cuesheet/cuesheet.options.ts
index c57bc6e2a..82568c5d4 100644
--- a/apps/client/src/views/cuesheet/cuesheet.options.ts
+++ b/apps/client/src/views/cuesheet/cuesheet.options.ts
@@ -1,19 +1,90 @@
-import { OntimeEntryCommonKeys, OntimeEvent } from 'ontime-types';
+import { useMemo } from 'react';
+import { useSearchParams } from 'react-router-dom';
+
+import { ViewOption } from '../../common/components/view-params-editor/types';
+import { isStringBoolean } from '../../features/viewers/common/viewUtils';
/**
- * @description set default column order
+ * In the specific case of the cuesheet options
+ * we save the user preferences in the local storage
*/
-export const defaultColumnOrder: OntimeEntryCommonKeys[] = [
- 'isPublic',
- 'cue',
- 'timeStart',
- 'timeEnd',
- 'duration',
- 'title',
- 'note',
+export const cuesheetOptions: ViewOption[] = [
+ { section: 'Table options' },
+ {
+ id: 'hideTableSeconds',
+ title: 'Hide seconds in table',
+ description: 'Whether to hide seconds in the time fields displayed in the table',
+ type: 'boolean',
+ defaultValue: false,
+ },
+ {
+ id: 'followSelected',
+ title: 'Follow selected event',
+ description: 'Whether the view should automatically scroll to the selected event',
+ type: 'boolean',
+ defaultValue: false,
+ },
+ {
+ id: 'hidePast',
+ title: 'Hide Past Events',
+ description: 'Whether to hide events that have passed',
+ type: 'boolean',
+ defaultValue: false,
+ },
+ {
+ id: 'hideIndexColumn',
+ title: 'Hide index column',
+ description: 'Whether the hide the event indexes in the table',
+ type: 'boolean',
+ defaultValue: false,
+ },
+ { section: 'Delay flow' },
+ {
+ id: 'showDelayedTimes',
+ title: 'Show delayed times',
+ description: 'Whether the time fields should include delays',
+ type: 'boolean',
+ defaultValue: false,
+ },
+ {
+ id: 'hideDelays',
+ title: 'Hide delays',
+ description: 'Whether to hide the rows containing scheduled delays',
+ type: 'boolean',
+ defaultValue: false,
+ },
];
+type CuesheetOptions = {
+ hideTableSeconds: boolean;
+ followSelected: boolean;
+ hidePast: boolean;
+ hideIndexColumn: boolean;
+ showDelayedTimes: boolean;
+ hideDelays: boolean;
+};
+
/**
- * @description set default hidden columns
+ * Utility extract the view options from URL Params
+ * the names and fallbacks are manually matched with cuesheetOptions
*/
-export const defaultHiddenColumns: (keyof OntimeEvent)[] = [];
+export function getOptionsFromParams(searchParams: URLSearchParams): CuesheetOptions {
+ // we manually make an object that matches the key above
+ return {
+ hideTableSeconds: isStringBoolean(searchParams.get('hideTableSeconds')),
+ followSelected: isStringBoolean(searchParams.get('followSelected')),
+ hidePast: isStringBoolean(searchParams.get('hidePast')),
+ hideIndexColumn: isStringBoolean(searchParams.get('hideIndexColumn')),
+ showDelayedTimes: isStringBoolean(searchParams.get('showDelayedTimes')),
+ hideDelays: isStringBoolean(searchParams.get('hideDelays')),
+ };
+}
+
+/**
+ * Hook exposes the cuesheet view options
+ */
+export function useCuesheetOptions(): CuesheetOptions {
+ const [searchParams] = useSearchParams();
+ const options = useMemo(() => getOptionsFromParams(searchParams), [searchParams]);
+ return options;
+}
diff --git a/apps/client/src/views/cuesheet/cuesheetCols.tsx b/apps/client/src/views/cuesheet/cuesheetCols.tsx
index 460d7061d..f82a55561 100644
--- a/apps/client/src/views/cuesheet/cuesheetCols.tsx
+++ b/apps/client/src/views/cuesheet/cuesheetCols.tsx
@@ -8,7 +8,7 @@ import RunningTime from '../../features/viewers/common/running-time/RunningTime'
import MultiLineCell from './cuesheet-table-elements/MultiLineCell';
import SingleLineCell from './cuesheet-table-elements/SingleLineCell';
-import { useCuesheetSettings } from './store/cuesheetSettingsStore';
+import { useCuesheetOptions } from './cuesheet.options';
import style from './Cuesheet.module.scss';
@@ -35,27 +35,26 @@ function MakePublic({ row, column, table }: CellContext
) {
- const showDelayedTimes = useCuesheetSettings((state) => state.showDelayedTimes);
- const hideSeconds = useCuesheetSettings((state) => state.hideSeconds);
+ const { showDelayedTimes, hideTableSeconds } = useCuesheetOptions();
const cellValue = (getValue() as number | null) ?? 0;
const delayValue = (original as OntimeEvent)?.delay ?? 0;
return (
-
+
{delayValue !== 0 && showDelayedTimes && (
-
+
)}
);
}
function MakeDuration({ getValue }: CellContext) {
- const hideSeconds = useCuesheetSettings((state) => state.hideSeconds);
+ const { hideTableSeconds } = useCuesheetOptions();
const cellValue = (getValue() as number | null) ?? 0;
- return ;
+ return ;
}
function MakeMultiLineField({ row, column, table }: CellContext) {
diff --git a/apps/client/src/views/cuesheet/store/cuesheetSettingsStore.tsx b/apps/client/src/views/cuesheet/store/cuesheetSettingsStore.tsx
deleted file mode 100644
index f9eb5d0fb..000000000
--- a/apps/client/src/views/cuesheet/store/cuesheetSettingsStore.tsx
+++ /dev/null
@@ -1,85 +0,0 @@
-import { create } from 'zustand';
-
-import { booleanFromLocalStorage } from '../../../common/utils/localStorage';
-
-interface CuesheetSettingsStore {
- showSettings: boolean;
- showIndexColumn: boolean;
- followSelected: boolean;
- showPrevious: boolean;
- showDelayBlock: boolean;
- showDelayedTimes: boolean;
- hideSeconds: boolean;
-
- toggleSettings: (newValue?: boolean) => void;
- toggleFollow: (newValue?: boolean) => void;
- togglePreviousVisibility: (newValue?: boolean) => void;
- toggleIndexColumn: (newValue?: boolean) => void;
- toggleDelayVisibility: (newValue?: boolean) => void;
- toggleDelayedTimes: (newValue?: boolean) => void;
- toggleSecondsVisibility: (newValue?: boolean) => void;
-}
-
-function toggle(oldValue: boolean, value?: boolean) {
- if (typeof value === 'undefined') {
- return !oldValue;
- }
- return value;
-}
-
-enum CuesheetKeys {
- Follow = 'ontime-cuesheet-follow-selected',
- DelayVisibility = 'ontime-cuesheet-show-delay',
- PreviousVisibility = 'ontime-cuesheet-show-previous',
- ColumnIndex = 'ontime-cuesheet-show-index-column',
- DelayedTimes = 'ontime-cuesheet-show-delayed',
- Seconds = 'ontime-cuesheet-hide-sceconds',
-}
-
-export const useCuesheetSettings = create()((set) => ({
- showSettings: false,
- showIndexColumn: booleanFromLocalStorage(CuesheetKeys.ColumnIndex, true),
- followSelected: booleanFromLocalStorage(CuesheetKeys.Follow, false),
- showPrevious: booleanFromLocalStorage(CuesheetKeys.PreviousVisibility, true),
- showDelayBlock: booleanFromLocalStorage(CuesheetKeys.DelayVisibility, true),
- showDelayedTimes: booleanFromLocalStorage(CuesheetKeys.DelayedTimes, false),
- hideSeconds: booleanFromLocalStorage(CuesheetKeys.Seconds, false),
-
- toggleSettings: (newValue?: boolean) => set((state) => ({ showSettings: toggle(state.showSettings, newValue) })),
- toggleFollow: (newValue?: boolean) =>
- set((state) => {
- const followSelected = toggle(state.followSelected, newValue);
- localStorage.setItem(CuesheetKeys.Follow, String(followSelected));
- return { followSelected };
- }),
- toggleIndexColumn: (newValue?: boolean) =>
- set((state) => {
- const showIndexColumn = toggle(state.showIndexColumn, newValue);
- localStorage.setItem(CuesheetKeys.ColumnIndex, String(showIndexColumn));
- return { showIndexColumn };
- }),
- togglePreviousVisibility: (newValue?: boolean) =>
- set((state) => {
- const showPrevious = toggle(state.showPrevious, newValue);
- localStorage.setItem(CuesheetKeys.PreviousVisibility, String(showPrevious));
- return { showPrevious };
- }),
- toggleDelayVisibility: (newValue?: boolean) =>
- set((state) => {
- const showDelayBlock = toggle(state.showDelayBlock, newValue);
- localStorage.setItem(CuesheetKeys.DelayVisibility, String(showDelayBlock));
- return { showDelayBlock };
- }),
- toggleDelayedTimes: (newValue?: boolean) =>
- set((state) => {
- const showDelayedTimes = toggle(state.showDelayedTimes, newValue);
- localStorage.setItem(CuesheetKeys.DelayedTimes, String(showDelayedTimes));
- return { showDelayedTimes };
- }),
- toggleSecondsVisibility: (newValue?: boolean) =>
- set((state) => {
- const hideSeconds = toggle(state.hideSeconds, newValue);
- localStorage.setItem(CuesheetKeys.Seconds, String(hideSeconds));
- return { hideSeconds };
- }),
-}));