feat: duplicate groups

This commit is contained in:
Carlos Valente
2025-05-19 20:01:03 +02:00
committed by arc-alex
parent 11e0215530
commit 2f26f20db5
20 changed files with 448 additions and 88 deletions
@@ -1,10 +1,10 @@
import express from 'express';
import { getAll, deleteWithId, deleteAll } from './report.controller.js';
import { paramsMustHaveEventId } from '../rundown/rundown.validation.js';
import { paramsMustHaveEntryId } from '../rundown/rundown.validation.js';
export const router = express.Router();
router.get('/', getAll);
router.delete('/all', deleteAll);
router.delete('/:eventId', paramsMustHaveEventId, deleteWithId);
router.delete('/:eventId', paramsMustHaveEntryId, deleteWithId);
@@ -15,6 +15,7 @@ import {
groupEntries,
reorderEntry,
swapEvents,
cloneEntry,
} from '../../services/rundown-service/RundownService.js';
import { getEntryWithId, getCurrentRundown } from '../../services/rundown-service/rundownUtils.js';
@@ -120,7 +121,7 @@ export async function rundownSwap(req: Request, res: Response<MessageResponse |
export async function rundownApplyDelay(req: Request, res: Response<MessageResponse | ErrorResponse>) {
try {
await applyDelay(req.params.eventId);
await applyDelay(req.params.entryId);
res.status(200).send({ message: 'Delay applied' });
} catch (error) {
const message = getErrorMessage(error);
@@ -128,9 +129,19 @@ export async function rundownApplyDelay(req: Request, res: Response<MessageRespo
}
}
export async function rundownCloneEntry(req: Request, res: Response<Rundown | ErrorResponse>) {
try {
const newRundown = await cloneEntry(req.params.entryId);
res.status(200).send(newRundown);
} catch (error) {
const message = getErrorMessage(error);
res.status(400).send({ message });
}
}
export async function rundownDissolveBlock(req: Request, res: Response<Rundown | ErrorResponse>) {
try {
const newRundown = await dissolveBlock(req.params.eventId);
const newRundown = await dissolveBlock(req.params.entryId);
res.status(200).send(newRundown);
} catch (error) {
const message = getErrorMessage(error);
@@ -5,6 +5,7 @@ import {
rundownAddToBlock,
rundownApplyDelay,
rundownBatchPut,
rundownCloneEntry,
rundownDelete,
rundownDissolveBlock,
rundownGetAll,
@@ -16,7 +17,7 @@ import {
rundownSwap,
} from './rundown.controller.js';
import {
paramsMustHaveEventId,
paramsMustHaveEntryId,
rundownArrayOfIds,
rundownBatchPutValidator,
rundownPostValidator,
@@ -29,7 +30,7 @@ export const router = express.Router();
router.get('/', rundownGetAll);
router.get('/current', rundownGetCurrent);
router.get('/:eventId', paramsMustHaveEventId, rundownGetById); // not used in Ontime frontend
router.get('/:eventId', paramsMustHaveEntryId, rundownGetById); // not used in Ontime frontend
router.post('/', rundownPostValidator, rundownPost);
@@ -38,8 +39,9 @@ router.put('/batch', rundownBatchPutValidator, rundownBatchPut);
router.patch('/reorder/', rundownReorderValidator, rundownReorder);
router.patch('/swap', rundownSwapValidator, rundownSwap);
router.patch('/applydelay/:eventId', paramsMustHaveEventId, rundownApplyDelay);
router.post('/dissolve/:eventId', paramsMustHaveEventId, rundownDissolveBlock);
router.patch('/applydelay/:entryId', paramsMustHaveEntryId, rundownApplyDelay);
router.post('/clone/:entryId', paramsMustHaveEntryId, rundownCloneEntry);
router.post('/dissolve/:entryId', paramsMustHaveEntryId, rundownDissolveBlock);
router.post('/group', rundownArrayOfIds, rundownAddToBlock);
router.delete('/', rundownArrayOfIds, deletesEventById);
@@ -57,8 +57,8 @@ export const rundownSwapValidator = [
},
];
export const paramsMustHaveEventId = [
param('eventId').exists(),
export const paramsMustHaveEntryId = [
param('entryId').exists(),
(req: Request, res: Response, next: NextFunction) => {
const errors = validationResult(req);