feat: create group from entry selection

This commit is contained in:
Carlos Valente
2025-05-17 15:17:00 +02:00
committed by arc-alex
parent ea54953298
commit 11e0215530
11 changed files with 240 additions and 30 deletions
@@ -1,7 +1,7 @@
import { OntimeEvent, SupportedEntry, TimeStrategy } from 'ontime-types';
import { OntimeBlock, OntimeEvent, SupportedEntry, TimeStrategy } from 'ontime-types';
import { generateId, validateEndAction, validateTimerType, validateTimes } from 'ontime-utils';
import { event as eventDef } from '../../models/eventsDefinition.js';
import { event as eventDef, block as blockDef } from '../../models/eventsDefinition.js';
import { makeString } from '../../utils/parserUtils.js';
export function createPatch(originalEvent: OntimeEvent, patchEvent: Partial<OntimeEvent>): OntimeEvent {
@@ -68,6 +68,32 @@ export const createEvent = (eventArgs: Partial<OntimeEvent>, eventIndex: number
return event;
};
/**
* Creates a new block from an optional patch
*/
export function createBlock(patch?: Partial<OntimeBlock>): OntimeBlock {
if (!patch) {
return { ...blockDef, id: generateId() };
}
return {
id: patch.id ?? generateId(),
type: SupportedEntry.Block,
title: patch.title ?? '',
note: patch.note ?? '',
events: patch.events ?? [],
skip: patch.skip ?? false,
colour: makeString(patch.colour, ''),
custom: patch.custom ?? {},
revision: 0,
startTime: null,
endTime: null,
duration: 0,
isFirstLinked: false,
numEvents: patch.events?.length ?? 0,
};
}
/**
* Function infers strategy for a patch with only partial timer data
* @param end