feat: auto cue re-numbering (#2016)

* feat: update auto cue numbering

* feat: renumber from ui

* refactor: patchEntries is not used

* chore: format

* fix: correct cue at top of group

* fix: handle precision

* refactor dialog

* bump limit for performance time test

* extract type

* add class name to lable

* fix rebase

* refator: extract renumering logic

* chore: comments for getIntegerAndFraction function

* chore: add the for renumber mutation

* fix: fraction match precision

* refactor: small cleanup

* refactor: use more narrow validator

---------

Co-authored-by: alex-Arc <omnivox@LAPTOP-RC5SNBVV.localdomain>
This commit is contained in:
Alex Christoffer Rasmussen
2026-05-03 18:39:00 +02:00
committed by GitHub
parent ba1c3235b3
commit 1a08b39b8b
20 changed files with 554 additions and 144 deletions
@@ -38,6 +38,7 @@ import {
deleteById,
doesInvalidateMetadata,
getUniqueId,
IncrementNumber,
makeDeepClone,
} from './rundown.utils.js';
@@ -531,6 +532,40 @@ function ungroup(rundown: Rundown, group: OntimeGroup) {
}
}
/**
* Renumbers a range of events
*/
function renumber(
rundown: Rundown,
ids: EntryId[],
prefix: string,
start: IncrementNumber,
increment: IncrementNumber,
) {
const maxPrecision = Math.max(increment.precision, start.precision);
//scale both factions so they have matching precision
increment.faction = increment.faction * Math.pow(10, maxPrecision - increment.precision);
start.faction = start.faction * Math.pow(10, maxPrecision - start.precision);
for (let i = 0; i < ids.length; i++) {
const currentId = ids[i];
const currentEntry = rundown.entries[currentId];
if (!currentEntry || !isOntimeEvent(currentEntry)) throw new Error('A given id was not an event');
//note: we know this dose not handle role over from the fraction into the integer
const integer = String(start.integer + increment.integer * i);
const fraction = maxPrecision
? '.' + String(start.faction + increment.faction * i).padStart(maxPrecision, '0')
: '';
rundownMutation.edit(rundown, {
id: currentId,
cue: `${prefix}${integer}${fraction}`,
});
}
}
export const rundownMutation = {
add: addToRundown,
edit,
@@ -542,6 +577,7 @@ export const rundownMutation = {
clone,
group,
ungroup,
renumber,
};
/**