mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-20 14:39:06 +00:00
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:
committed by
GitHub
parent
ba1c3235b3
commit
1a08b39b8b
@@ -50,9 +50,12 @@ type CompleteEntry<T> =
|
||||
*/
|
||||
export function generateEvent<
|
||||
T extends Partial<OntimeEvent> | Partial<OntimeDelay> | Partial<OntimeGroup> | Partial<OntimeMilestone>,
|
||||
>(rundown: Rundown, eventData: T, afterId: EntryId | null): CompleteEntry<T> {
|
||||
>(rundown: Rundown, eventData: T, afterId: EntryId | null, parent?: EntryId): CompleteEntry<T> {
|
||||
if (isOntimeEvent(eventData)) {
|
||||
return createEvent(eventData, getCueCandidate(rundown.entries, rundown.order, afterId)) as CompleteEntry<T>;
|
||||
return createEvent(
|
||||
eventData,
|
||||
getCueCandidate(rundown.entries, rundown.flatOrder, afterId, parent),
|
||||
) as CompleteEntry<T>;
|
||||
}
|
||||
|
||||
const id = eventData.id || getUniqueId(rundown);
|
||||
@@ -470,3 +473,30 @@ export function duplicateRundown(rundown: Rundown, newTitle: string): Rundown {
|
||||
|
||||
return newRundown;
|
||||
}
|
||||
|
||||
export type IncrementNumber = {
|
||||
integer: number;
|
||||
faction: number;
|
||||
precision: number;
|
||||
};
|
||||
|
||||
/**
|
||||
* Parses a decimal string into integer part, fractional digits as an integer, and fractional digit count.
|
||||
* Splits on the first `.` only
|
||||
*
|
||||
* @param value - Numeric string, e.g. `"123"` or `"123.456"`.
|
||||
* @returns `integer` whole part, `faction` digits after the point as a number (0 when no fraction), `precision` digit count after `.`.
|
||||
* @throws {Error} When the integer or fractional segment is not parseable as number
|
||||
*/
|
||||
export function getIntegerAndFraction(value: string): IncrementNumber {
|
||||
const [integerStr, factionStr] = value.split('.', 2);
|
||||
const integer = parseInt(integerStr);
|
||||
const precision = (factionStr ?? '').length;
|
||||
const faction = precision === 0 ? 0 : parseInt(factionStr);
|
||||
if (isNaN(integer) || isNaN(faction)) throw new Error('input can not be converted to a number');
|
||||
return {
|
||||
integer,
|
||||
faction,
|
||||
precision,
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user