diff --git a/apps/client/src/common/hooks/useEntryAction.ts b/apps/client/src/common/hooks/useEntryAction.ts index fc040b3a7..c47e65226 100644 --- a/apps/client/src/common/hooks/useEntryAction.ts +++ b/apps/client/src/common/hooks/useEntryAction.ts @@ -16,6 +16,7 @@ import { TimeStrategy, isOntimeEvent, isOntimeGroup, + isOntimeMilestone, } from 'ontime-types'; import { MILLIS_PER_SECOND, @@ -82,6 +83,7 @@ function useEntryActionsForRundown(scopedRundownId: string | undefined) { defaultDangerTime, defaultTimerType, defaultEndAction, + inheritGroupColour, } = useEditorSettings(); const resolveCurrentRundownQueryKey = useCallback(() => { @@ -239,6 +241,14 @@ function useEntryActionsForRundown(scopedRundownId: string | undefined) { } } + if (inheritGroupColour && (isOntimeEvent(newEntry) || isOntimeMilestone(newEntry)) && !newEntry.colour) { + const parentId = resolveInsertParent(rundownData, newEntry); + const maybeParent = parentId ? rundownData.entries[parentId] : null; + if (maybeParent && isOntimeGroup(maybeParent)) { + newEntry.colour = maybeParent.colour; + } + } + try { await addEntryMutation([rundownId, newEntry]); } catch (error) { @@ -254,6 +264,7 @@ function useEntryActionsForRundown(scopedRundownId: string | undefined) { defaultTimerType, defaultEndAction, defaultTimeStrategy, + inheritGroupColour, addEntryMutation, ], ); diff --git a/apps/client/src/common/stores/editorSettings.ts b/apps/client/src/common/stores/editorSettings.ts index 5a678d39e..bedebf976 100644 --- a/apps/client/src/common/stores/editorSettings.ts +++ b/apps/client/src/common/stores/editorSettings.ts @@ -12,8 +12,10 @@ type EditorSettingsStore = { defaultDangerTime: string; defaultTimerType: TimerType; defaultEndAction: EndAction; + inheritGroupColour: boolean; setDefaultDuration: (defaultDuration: string) => void; setLinkPrevious: (linkPrevious: boolean) => void; + setInheritGroupColour: (inheritGroupColour: boolean) => void; setTimeStrategy: (timeStrategy: TimeStrategy) => void; setWarnTime: (warnTime: string) => void; setDangerTime: (dangerTime: string) => void; @@ -29,6 +31,7 @@ export const editorSettingsDefaults = { dangerTime: '00:01:00', // 60000 same as backend timerType: TimerType.CountDown, endAction: EndAction.None, + inheritGroupColour: false, }; enum EditorSettingsKeys { @@ -39,6 +42,7 @@ enum EditorSettingsKeys { DefaultDangerTime = 'ontime-default-danger-time', DefaultTimerType = 'ontime-default-timer-type', DefaultEndAction = 'ontime-default-end-action', + InheritGroupColour = 'ontime-inherit-group-colour', } export const useEditorSettings = create((set) => { @@ -59,6 +63,10 @@ export const useEditorSettings = create((set) => { localStorage.getItem(EditorSettingsKeys.DefaultEndAction), editorSettingsDefaults.endAction, ), + inheritGroupColour: booleanFromLocalStorage( + EditorSettingsKeys.InheritGroupColour, + editorSettingsDefaults.inheritGroupColour, + ), setDefaultDuration: (defaultDuration) => set(() => { @@ -97,5 +105,10 @@ export const useEditorSettings = create((set) => { localStorage.setItem(EditorSettingsKeys.DefaultEndAction, String(defaultEndAction)); return { defaultEndAction }; }), + setInheritGroupColour: (inheritGroupColour) => + set(() => { + localStorage.setItem(EditorSettingsKeys.InheritGroupColour, String(inheritGroupColour)); + return { inheritGroupColour }; + }), }; }); diff --git a/apps/client/src/features/app-settings/panel/manage-panel/RundownDefaultSettings.tsx b/apps/client/src/features/app-settings/panel/manage-panel/RundownDefaultSettings.tsx index 0e8f7c4cd..b9dcf7f1a 100644 --- a/apps/client/src/features/app-settings/panel/manage-panel/RundownDefaultSettings.tsx +++ b/apps/client/src/features/app-settings/panel/manage-panel/RundownDefaultSettings.tsx @@ -16,6 +16,7 @@ export default function RundownDefaultSettings() { defaultDangerTime, defaultTimerType, defaultEndAction, + inheritGroupColour, setDefaultDuration, setLinkPrevious, setTimeStrategy, @@ -23,6 +24,7 @@ export default function RundownDefaultSettings() { setDangerTime, setDefaultTimerType, setDefaultEndAction, + setInheritGroupColour, } = useEditorSettings((state) => state); const durationInMs = parseUserTime(defaultDuration); @@ -44,6 +46,13 @@ export default function RundownDefaultSettings() { /> + + + +