mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-09 17:33:55 +00:00
feat: create group from entry selection
This commit is contained in:
committed by
Carlos Valente
parent
a8b52a48f7
commit
f1f7bad25e
@@ -12,6 +12,7 @@ import {
|
||||
deleteEvent,
|
||||
editEvent,
|
||||
dissolveBlock,
|
||||
groupEntries,
|
||||
reorderEntry,
|
||||
swapEvents,
|
||||
} from '../../services/rundown-service/RundownService.js';
|
||||
@@ -137,6 +138,16 @@ export async function rundownDissolveBlock(req: Request, res: Response<Rundown |
|
||||
}
|
||||
}
|
||||
|
||||
export async function rundownAddToBlock(req: Request, res: Response<Rundown | ErrorResponse>) {
|
||||
try {
|
||||
const newRundown = await groupEntries(req.body.ids);
|
||||
res.status(200).send(newRundown);
|
||||
} catch (error) {
|
||||
const message = getErrorMessage(error);
|
||||
res.status(400).send({ message });
|
||||
}
|
||||
}
|
||||
|
||||
export async function rundownDelete(_req: Request, res: Response<MessageResponse | ErrorResponse>) {
|
||||
try {
|
||||
await deleteAllEntries();
|
||||
|
||||
@@ -2,6 +2,7 @@ import express from 'express';
|
||||
|
||||
import {
|
||||
deletesEventById,
|
||||
rundownAddToBlock,
|
||||
rundownApplyDelay,
|
||||
rundownBatchPut,
|
||||
rundownDelete,
|
||||
@@ -39,6 +40,7 @@ router.patch('/reorder/', rundownReorderValidator, rundownReorder);
|
||||
router.patch('/swap', rundownSwapValidator, rundownSwap);
|
||||
router.patch('/applydelay/:eventId', paramsMustHaveEventId, rundownApplyDelay);
|
||||
router.post('/dissolve/:eventId', paramsMustHaveEventId, rundownDissolveBlock);
|
||||
router.post('/group', rundownArrayOfIds, rundownAddToBlock);
|
||||
|
||||
router.delete('/', rundownArrayOfIds, deletesEventById);
|
||||
router.delete('/all', rundownDelete);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user