mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-07 15:29:10 +00:00
feat: count to group completion
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { OntimeDelay, OntimeEvent, OntimeGroup, SupportedEntry } from 'ontime-types';
|
||||
import { OntimeDelay, OntimeEvent, OntimeGroup, SupportedEntry, TimerType } from 'ontime-types';
|
||||
|
||||
import { initRundownMetadata } from '../rundownMetadata';
|
||||
import { getFlatRundownMetadata, initRundownMetadata } from '../rundownMetadata';
|
||||
|
||||
describe('initRundownMetadata()', () => {
|
||||
it('processes nested rundown data', () => {
|
||||
@@ -300,3 +300,36 @@ describe('initRundownMetadata()', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('getFlatRundownMetadata()', () => {
|
||||
it('exposes group timer settings on a group and its events', () => {
|
||||
const group = {
|
||||
id: 'group',
|
||||
type: SupportedEntry.Group,
|
||||
entries: ['event'],
|
||||
colour: 'red',
|
||||
useGroupTimer: true,
|
||||
timerType: TimerType.CountUp,
|
||||
} as OntimeGroup;
|
||||
const event = {
|
||||
id: 'event',
|
||||
type: SupportedEntry.Event,
|
||||
parent: group.id,
|
||||
timeStart: 0,
|
||||
timeEnd: 1,
|
||||
duration: 1,
|
||||
dayOffset: 0,
|
||||
gap: 0,
|
||||
skip: false,
|
||||
linkStart: false,
|
||||
} as OntimeEvent;
|
||||
|
||||
const flat = getFlatRundownMetadata(
|
||||
{ entries: { [group.id]: group, [event.id]: event }, flatOrder: [group.id, event.id] },
|
||||
null,
|
||||
);
|
||||
|
||||
expect(flat[0]).toMatchObject({ groupUsesTimer: true, groupTimerType: TimerType.CountUp });
|
||||
expect(flat[1]).toMatchObject({ groupUsesTimer: true, groupTimerType: TimerType.CountUp });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -3,9 +3,11 @@ import {
|
||||
OntimeDelay,
|
||||
OntimeEntry,
|
||||
OntimeEvent,
|
||||
OntimeGroup,
|
||||
OntimeMilestone,
|
||||
PlayableEvent,
|
||||
Rundown,
|
||||
TimerType,
|
||||
isOntimeEvent,
|
||||
isOntimeGroup,
|
||||
isPlayableEvent,
|
||||
@@ -29,7 +31,11 @@ export type RundownMetadata = {
|
||||
isFirstAfterGroup: boolean;
|
||||
};
|
||||
|
||||
export type ExtendedEntry<T extends OntimeEntry = OntimeEntry> = T & RundownMetadata;
|
||||
export type ExtendedEntry<T extends OntimeEntry = OntimeEntry> = T &
|
||||
RundownMetadata & {
|
||||
groupUsesTimer?: boolean;
|
||||
groupTimerType?: TimerType;
|
||||
};
|
||||
|
||||
export const lastMetadataKey = 'LAST';
|
||||
|
||||
@@ -65,10 +71,23 @@ export function getFlatRundownMetadata(
|
||||
): ExtendedEntry[] {
|
||||
const { process } = initRundownMetadata(selectedEventId);
|
||||
const flatRundown: ExtendedEntry[] = [];
|
||||
let activeGroup: OntimeGroup | null = null;
|
||||
|
||||
for (const id of data.flatOrder) {
|
||||
const entry = data.entries[id];
|
||||
const extendedEntry = { ...entry, ...process(entry) };
|
||||
if (isOntimeGroup(entry)) {
|
||||
activeGroup = entry;
|
||||
} else if (entry.parent !== activeGroup?.id) {
|
||||
activeGroup = null;
|
||||
}
|
||||
|
||||
const timerGroup = isOntimeGroup(entry) ? entry : activeGroup;
|
||||
const extendedEntry = {
|
||||
...entry,
|
||||
...process(entry),
|
||||
groupUsesTimer: timerGroup?.useGroupTimer ?? false,
|
||||
groupTimerType: timerGroup?.timerType,
|
||||
};
|
||||
flatRundown.push(extendedEntry);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user