diff --git a/apps/client/src/features/rundown/__tests__/rundown.utils.test.ts b/apps/client/src/features/rundown/__tests__/rundown.utils.test.ts index ebc612d09..e91bd0149 100644 --- a/apps/client/src/features/rundown/__tests__/rundown.utils.test.ts +++ b/apps/client/src/features/rundown/__tests__/rundown.utils.test.ts @@ -1,4 +1,4 @@ -import { OntimeBlock, OntimeEvent, RundownEntries, SupportedEntry } from 'ontime-types'; +import { OntimeBlock, OntimeDelay, OntimeEvent, RundownEntries, SupportedEntry } from 'ontime-types'; import { makeRundownMetadata, makeSortableList } from '../rundown.utils'; @@ -21,7 +21,7 @@ describe('makeRundownMetadata()', () => { block: { id: 'block', type: SupportedEntry.Block, - events: ['11', '12', '13'], + events: ['11', 'delay', '12', '13'], colour: 'red', } as OntimeBlock, '11': { @@ -36,6 +36,12 @@ describe('makeRundownMetadata()', () => { skip: false, linkStart: false, } as OntimeEvent, + delay: { + id: 'delay', + type: SupportedEntry.Delay, + parent: 'block', + duration: 0, + } as OntimeDelay, '12': { id: '12', type: SupportedEntry.Event, @@ -136,10 +142,25 @@ describe('makeRundownMetadata()', () => { groupColour: 'red', }); + expect(process(demoEvents['delay'])).toMatchObject({ + previousEvent: demoEvents['11'], + latestEvent: demoEvents['11'], + previousEntryId: demoEvents['11'].id, + thisId: demoEvents['delay'].id, + eventIndex: 2, + isPast: true, + isNextDay: false, + totalGap: 10, + isLinkedToLoaded: false, + isLoaded: false, + groupId: 'block', + groupColour: 'red', + }); + expect(process(demoEvents['12'])).toMatchObject({ previousEvent: demoEvents['11'], latestEvent: demoEvents['12'], - previousEntryId: demoEvents['11'].id, + previousEntryId: demoEvents['delay'].id, thisId: demoEvents['12'].id, eventIndex: 3, isPast: false, diff --git a/apps/server/src/services/rundown-service/RundownService.ts b/apps/server/src/services/rundown-service/RundownService.ts index 08112275d..117fc4c6f 100644 --- a/apps/server/src/services/rundown-service/RundownService.ts +++ b/apps/server/src/services/rundown-service/RundownService.ts @@ -203,6 +203,11 @@ export async function reorderEntry(eventId: EntryId, from: number, to: number): return newRundown; } +/** + * Applies a delay into the rundown effectively changing the schedule + * The applied delay is deleted + * @param delayId + */ export async function applyDelay(delayId: EntryId) { const scopedMutation = cache.mutateCache(cache.applyDelay); await scopedMutation({ delayId }); diff --git a/apps/server/src/services/rundown-service/rundownCache.utils.ts b/apps/server/src/services/rundown-service/rundownCache.utils.ts index cebe7d979..08e58e74a 100644 --- a/apps/server/src/services/rundown-service/rundownCache.utils.ts +++ b/apps/server/src/services/rundown-service/rundownCache.utils.ts @@ -275,6 +275,7 @@ function processEntry( } else if (isOntimeDelay(currentEntry)) { // !!! this must happen after handling the links processedData.totalDelay += currentEntry.duration; + currentEntry.parent = childOfBlock; } if (!childOfBlock) { diff --git a/packages/types/src/definitions/core/Rundown.type.ts b/packages/types/src/definitions/core/Rundown.type.ts index 94be1caa5..1f76f38ac 100644 --- a/packages/types/src/definitions/core/Rundown.type.ts +++ b/packages/types/src/definitions/core/Rundown.type.ts @@ -6,7 +6,8 @@ export type RundownEntries = Record; // we need to create a manual union type since keys cannot be used in type unions export type OntimeEntryCommonKeys = keyof OntimeEvent | keyof OntimeDelay | keyof OntimeBlock; -export type ProjectRundowns = Record; +type RundownId = string; +export type ProjectRundowns = Record; export type Rundown = { id: string;