mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-21 06:59:09 +00:00
chore: improve convention entry <> event
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { EndAction, EntryCustomFields, OntimeEvent, SupportedEvent, TimerType, TimeStrategy } from 'ontime-types';
|
import { EndAction, EntryCustomFields, OntimeEvent, SupportedEntry, TimerType, TimeStrategy } from 'ontime-types';
|
||||||
|
|
||||||
import { cloneEvent } from '../eventsManager';
|
import { cloneEvent } from '../eventsManager';
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@ describe('cloneEvent()', () => {
|
|||||||
it('creates a stem from a given event', () => {
|
it('creates a stem from a given event', () => {
|
||||||
const original: OntimeEvent = {
|
const original: OntimeEvent = {
|
||||||
id: 'unique',
|
id: 'unique',
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
title: 'title',
|
title: 'title',
|
||||||
cue: 'cue',
|
cue: 'cue',
|
||||||
note: 'note',
|
note: 'note',
|
||||||
@@ -38,7 +38,7 @@ describe('cloneEvent()', () => {
|
|||||||
expect(cloned.custom).not.toBe(original.custom);
|
expect(cloned.custom).not.toBe(original.custom);
|
||||||
|
|
||||||
expect(cloned).toMatchObject({
|
expect(cloned).toMatchObject({
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
title: original.title,
|
title: original.title,
|
||||||
note: original.note,
|
note: original.note,
|
||||||
timeStart: original.timeStart,
|
timeStart: original.timeStart,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { OntimeEvent, SupportedEvent } from 'ontime-types';
|
import { OntimeEvent, SupportedEntry } from 'ontime-types';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Creates a safe duplicate of an event
|
* @description Creates a safe duplicate of an event
|
||||||
@@ -9,7 +9,7 @@ import { OntimeEvent, SupportedEvent } from 'ontime-types';
|
|||||||
type ClonedEvent = Omit<OntimeEvent, 'id' | 'cue'>;
|
type ClonedEvent = Omit<OntimeEvent, 'id' | 'cue'>;
|
||||||
export const cloneEvent = (event: OntimeEvent): ClonedEvent => {
|
export const cloneEvent = (event: OntimeEvent): ClonedEvent => {
|
||||||
return {
|
return {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
title: event.title,
|
title: event.title,
|
||||||
note: event.note,
|
note: event.note,
|
||||||
timeStart: event.timeStart,
|
timeStart: event.timeStart,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { KeyboardEvent, useState } from 'react';
|
import { KeyboardEvent, useState } from 'react';
|
||||||
import { Input, Modal, ModalBody, ModalContent, ModalFooter, ModalOverlay } from '@chakra-ui/react';
|
import { Input, Modal, ModalBody, ModalContent, ModalFooter, ModalOverlay } from '@chakra-ui/react';
|
||||||
import { useDebouncedCallback } from '@mantine/hooks';
|
import { useDebouncedCallback } from '@mantine/hooks';
|
||||||
import { SupportedEvent } from 'ontime-types';
|
import { SupportedEntry } from 'ontime-types';
|
||||||
|
|
||||||
import { useEventSelection } from '../../rundown/useEventSelection';
|
import { useEventSelection } from '../../rundown/useEventSelection';
|
||||||
|
|
||||||
@@ -67,9 +67,9 @@ export default function Finder(props: FinderProps) {
|
|||||||
{results.length > 0 &&
|
{results.length > 0 &&
|
||||||
results.map((entry, index) => {
|
results.map((entry, index) => {
|
||||||
const isSelected = selected === index;
|
const isSelected = selected === index;
|
||||||
const displayIndex = entry.type === SupportedEvent.Event ? entry.eventIndex : '-';
|
const displayIndex = entry.type === SupportedEntry.Event ? entry.eventIndex : '-';
|
||||||
const displayCue = entry.type === SupportedEvent.Event ? entry.cue : '';
|
const displayCue = entry.type === SupportedEntry.Event ? entry.cue : '';
|
||||||
const colour = entry.type === SupportedEvent.Event ? entry.colour : '';
|
const colour = entry.type === SupportedEntry.Event ? entry.colour : '';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li
|
<li
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
import { ChangeEvent, useEffect, useRef, useState } from 'react';
|
import { ChangeEvent, useEffect, useRef, useState } from 'react';
|
||||||
import { isOntimeBlock, isOntimeEvent, MaybeString, SupportedEvent } from 'ontime-types';
|
import { isOntimeBlock, isOntimeEvent, MaybeString, SupportedEntry } from 'ontime-types';
|
||||||
|
|
||||||
import { useFlatRundown } from '../../../common/hooks-query/useRundown';
|
import { useFlatRundown } from '../../../common/hooks-query/useRundown';
|
||||||
|
|
||||||
const maxResults = 12;
|
const maxResults = 12;
|
||||||
|
|
||||||
type FilterableBlock = {
|
type FilterableBlock = {
|
||||||
type: SupportedEvent.Block;
|
type: SupportedEntry.Block;
|
||||||
id: string;
|
id: string;
|
||||||
index: number;
|
index: number;
|
||||||
title: string;
|
title: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
type FilterableEvent = {
|
type FilterableEvent = {
|
||||||
type: SupportedEvent.Event;
|
type: SupportedEntry.Event;
|
||||||
id: string;
|
id: string;
|
||||||
index: number;
|
index: number;
|
||||||
eventIndex: number;
|
eventIndex: number;
|
||||||
@@ -59,7 +59,7 @@ export default function useFinder() {
|
|||||||
if (isOntimeEvent(event)) {
|
if (isOntimeEvent(event)) {
|
||||||
if (eventIndex === searchIndex) {
|
if (eventIndex === searchIndex) {
|
||||||
results.push({
|
results.push({
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
id: event.id,
|
id: event.id,
|
||||||
index: i,
|
index: i,
|
||||||
eventIndex,
|
eventIndex,
|
||||||
@@ -93,7 +93,7 @@ export default function useFinder() {
|
|||||||
if (event.cue.toLowerCase().includes(searchString)) {
|
if (event.cue.toLowerCase().includes(searchString)) {
|
||||||
remaining--;
|
remaining--;
|
||||||
results.push({
|
results.push({
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
id: event.id,
|
id: event.id,
|
||||||
index: i,
|
index: i,
|
||||||
eventIndex,
|
eventIndex,
|
||||||
@@ -126,7 +126,7 @@ export default function useFinder() {
|
|||||||
if (event.title.toLowerCase().includes(searchString)) {
|
if (event.title.toLowerCase().includes(searchString)) {
|
||||||
remaining--;
|
remaining--;
|
||||||
results.push({
|
results.push({
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
id: event.id,
|
id: event.id,
|
||||||
index: i,
|
index: i,
|
||||||
eventIndex,
|
eventIndex,
|
||||||
@@ -141,7 +141,7 @@ export default function useFinder() {
|
|||||||
if (event.title.toLowerCase().includes(searchString)) {
|
if (event.title.toLowerCase().includes(searchString)) {
|
||||||
remaining--;
|
remaining--;
|
||||||
results.push({
|
results.push({
|
||||||
type: SupportedEvent.Block,
|
type: SupportedEntry.Block,
|
||||||
id: event.id,
|
id: event.id,
|
||||||
index: i,
|
index: i,
|
||||||
title: event.title,
|
title: event.title,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { useCallback, useEffect, useRef, useState } from 'react';
|
import { useCallback, useEffect, useRef, useState } from 'react';
|
||||||
import { useSearchParams } from 'react-router-dom';
|
import { useSearchParams } from 'react-router-dom';
|
||||||
import { isOntimeEvent, OntimeEvent, SupportedEvent } from 'ontime-types';
|
import { isOntimeEvent, OntimeEvent, SupportedEntry } from 'ontime-types';
|
||||||
import { getFirstEventNormal, getLastEventNormal } from 'ontime-utils';
|
import { getFirstEventNormal, getLastEventNormal } from 'ontime-utils';
|
||||||
|
|
||||||
import EmptyPage from '../../common/components/state/EmptyPage';
|
import EmptyPage from '../../common/components/state/EmptyPage';
|
||||||
@@ -197,7 +197,7 @@ export default function Operator() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entry.type === SupportedEvent.Block) {
|
if (entry.type === SupportedEntry.Block) {
|
||||||
return <OperatorBlock key={entry.id} title={entry.title} />;
|
return <OperatorBlock key={entry.id} title={entry.title} />;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
isOntimeEvent,
|
isOntimeEvent,
|
||||||
OntimeEntry,
|
OntimeEntry,
|
||||||
Playback,
|
Playback,
|
||||||
SupportedEvent,
|
SupportedEntry,
|
||||||
} from 'ontime-types';
|
} from 'ontime-types';
|
||||||
import {
|
import {
|
||||||
getFirstNormal,
|
getFirstNormal,
|
||||||
@@ -84,7 +84,7 @@ export default function Rundown({ data }: RundownProps) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const cloneEntry = entries[copyId];
|
const cloneEntry = entries[copyId];
|
||||||
if (cloneEntry?.type === SupportedEvent.Event) {
|
if (cloneEntry?.type === SupportedEntry.Event) {
|
||||||
//if we don't have a cursor add the new event on top
|
//if we don't have a cursor add the new event on top
|
||||||
const newEvent = cloneEvent(cloneEntry);
|
const newEvent = cloneEvent(cloneEntry);
|
||||||
addEntry(newEvent, { after: adjustedCursor ?? undefined });
|
addEntry(newEvent, { after: adjustedCursor ?? undefined });
|
||||||
@@ -94,7 +94,7 @@ export default function Rundown({ data }: RundownProps) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const insertAtId = useCallback(
|
const insertAtId = useCallback(
|
||||||
(patch: Partial<OntimeEntry> & { type: SupportedEvent }, id: MaybeString, above = false) => {
|
(patch: Partial<OntimeEntry> & { type: SupportedEntry }, id: MaybeString, above = false) => {
|
||||||
const options: EventOptions =
|
const options: EventOptions =
|
||||||
id === null
|
id === null
|
||||||
? {}
|
? {}
|
||||||
@@ -202,14 +202,14 @@ export default function Rundown({ data }: RundownProps) {
|
|||||||
|
|
||||||
['mod + Backspace', () => deleteAtCursor(cursor), { preventDefault: true }],
|
['mod + Backspace', () => deleteAtCursor(cursor), { preventDefault: true }],
|
||||||
|
|
||||||
['alt + E', () => insertAtId({ type: SupportedEvent.Event }, cursor), { preventDefault: true }],
|
['alt + E', () => insertAtId({ type: SupportedEntry.Event }, cursor), { preventDefault: true }],
|
||||||
['alt + shift + E', () => insertAtId({ type: SupportedEvent.Event }, cursor, true), { preventDefault: true }],
|
['alt + shift + E', () => insertAtId({ type: SupportedEntry.Event }, cursor, true), { preventDefault: true }],
|
||||||
|
|
||||||
['alt + B', () => insertAtId({ type: SupportedEvent.Block }, cursor), { preventDefault: true }],
|
['alt + B', () => insertAtId({ type: SupportedEntry.Block }, cursor), { preventDefault: true }],
|
||||||
['alt + shift + B', () => insertAtId({ type: SupportedEvent.Block }, cursor, true), { preventDefault: true }],
|
['alt + shift + B', () => insertAtId({ type: SupportedEntry.Block }, cursor, true), { preventDefault: true }],
|
||||||
|
|
||||||
['alt + D', () => insertAtId({ type: SupportedEvent.Delay }, cursor), { preventDefault: true }],
|
['alt + D', () => insertAtId({ type: SupportedEntry.Delay }, cursor), { preventDefault: true }],
|
||||||
['alt + shift + D', () => insertAtId({ type: SupportedEvent.Delay }, cursor, true), { preventDefault: true }],
|
['alt + shift + D', () => insertAtId({ type: SupportedEntry.Delay }, cursor, true), { preventDefault: true }],
|
||||||
|
|
||||||
['mod + C', () => setEntryCopyId(cursor)],
|
['mod + C', () => setEntryCopyId(cursor)],
|
||||||
['mod + V', () => insertCopyAtId(cursor, entryCopyId)],
|
['mod + V', () => insertCopyAtId(cursor, entryCopyId)],
|
||||||
@@ -254,7 +254,7 @@ export default function Rundown({ data }: RundownProps) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (statefulEntries.length < 1) {
|
if (statefulEntries.length < 1) {
|
||||||
return <RundownEmpty handleAddNew={() => insertAtId({ type: SupportedEvent.Event }, cursor)} />;
|
return <RundownEmpty handleAddNew={() => insertAtId({ type: SupportedEntry.Event }, cursor)} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. gather presentation options
|
// 1. gather presentation options
|
||||||
@@ -292,7 +292,7 @@ export default function Rundown({ data }: RundownProps) {
|
|||||||
<BlockBlock data={entry} hasCursor={hasCursor}>
|
<BlockBlock data={entry} hasCursor={hasCursor}>
|
||||||
{entry.events.length === 0 && (
|
{entry.events.length === 0 && (
|
||||||
<BlockEmpty
|
<BlockEmpty
|
||||||
handleAddNew={() => insertAtId({ type: SupportedEvent.Event, parent: entry.id }, entry.id)}
|
handleAddNew={() => insertAtId({ type: SupportedEntry.Event, parent: entry.id }, entry.id)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{entry.events.map((eventId, nestedIndex) => {
|
{entry.events.map((eventId, nestedIndex) => {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {
|
|||||||
OntimeEntry,
|
OntimeEntry,
|
||||||
OntimeEvent,
|
OntimeEvent,
|
||||||
Playback,
|
Playback,
|
||||||
SupportedEvent,
|
SupportedEntry,
|
||||||
} from 'ontime-types';
|
} from 'ontime-types';
|
||||||
|
|
||||||
import { useEntryActions } from '../../common/hooks/useEntryAction';
|
import { useEntryActions } from '../../common/hooks/useEntryAction';
|
||||||
@@ -33,7 +33,7 @@ export type EventItemActions =
|
|||||||
| 'clear-report';
|
| 'clear-report';
|
||||||
|
|
||||||
interface RundownEntryProps {
|
interface RundownEntryProps {
|
||||||
type: SupportedEvent;
|
type: SupportedEntry;
|
||||||
isPast: boolean;
|
isPast: boolean;
|
||||||
data: OntimeEntry;
|
data: OntimeEntry;
|
||||||
loaded: boolean;
|
loaded: boolean;
|
||||||
@@ -86,7 +86,7 @@ export default function RundownEntry(props: RundownEntryProps) {
|
|||||||
const actionHandler = useMemoisedFn((action: EventItemActions, payload?: number | FieldValue) => {
|
const actionHandler = useMemoisedFn((action: EventItemActions, payload?: number | FieldValue) => {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case 'event': {
|
case 'event': {
|
||||||
const newEvent = { type: SupportedEvent.Event };
|
const newEvent = { type: SupportedEntry.Event };
|
||||||
const options = {
|
const options = {
|
||||||
after: data.id,
|
after: data.id,
|
||||||
lastEventId: previousEventId,
|
lastEventId: previousEventId,
|
||||||
@@ -94,23 +94,23 @@ export default function RundownEntry(props: RundownEntryProps) {
|
|||||||
return addEntry(newEvent, options);
|
return addEntry(newEvent, options);
|
||||||
}
|
}
|
||||||
case 'event-before': {
|
case 'event-before': {
|
||||||
const newEvent = { type: SupportedEvent.Event };
|
const newEvent = { type: SupportedEntry.Event };
|
||||||
const options = {
|
const options = {
|
||||||
after: previousEntryId,
|
after: previousEntryId,
|
||||||
};
|
};
|
||||||
return addEntry(newEvent, options);
|
return addEntry(newEvent, options);
|
||||||
}
|
}
|
||||||
case 'delay': {
|
case 'delay': {
|
||||||
return addEntry({ type: SupportedEvent.Delay }, { after: data.id });
|
return addEntry({ type: SupportedEntry.Delay }, { after: data.id });
|
||||||
}
|
}
|
||||||
case 'delay-before': {
|
case 'delay-before': {
|
||||||
return addEntry({ type: SupportedEvent.Delay }, { after: previousEntryId });
|
return addEntry({ type: SupportedEntry.Delay }, { after: previousEntryId });
|
||||||
}
|
}
|
||||||
case 'block': {
|
case 'block': {
|
||||||
return addEntry({ type: SupportedEvent.Block }, { after: data.id });
|
return addEntry({ type: SupportedEntry.Block }, { after: data.id });
|
||||||
}
|
}
|
||||||
case 'block-before': {
|
case 'block-before': {
|
||||||
return addEntry({ type: SupportedEvent.Block }, { after: previousEntryId });
|
return addEntry({ type: SupportedEntry.Block }, { after: previousEntryId });
|
||||||
}
|
}
|
||||||
case 'swap': {
|
case 'swap': {
|
||||||
const { value } = payload as FieldValue;
|
const { value } = payload as FieldValue;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { OntimeBlock, OntimeEvent, SupportedEvent } from 'ontime-types';
|
import { OntimeBlock, OntimeEvent, SupportedEntry } from 'ontime-types';
|
||||||
|
|
||||||
import { makeRundownMetadata } from '../rundown.utils';
|
import { makeRundownMetadata } from '../rundown.utils';
|
||||||
|
|
||||||
@@ -8,7 +8,7 @@ describe('makeRundownMetadata()', () => {
|
|||||||
const demoEvents = {
|
const demoEvents = {
|
||||||
'1': {
|
'1': {
|
||||||
id: '1',
|
id: '1',
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
parent: null,
|
parent: null,
|
||||||
timeStart: 0,
|
timeStart: 0,
|
||||||
timeEnd: 1,
|
timeEnd: 1,
|
||||||
@@ -20,12 +20,12 @@ describe('makeRundownMetadata()', () => {
|
|||||||
} as OntimeEvent,
|
} as OntimeEvent,
|
||||||
block: {
|
block: {
|
||||||
id: 'block',
|
id: 'block',
|
||||||
type: SupportedEvent.Block,
|
type: SupportedEntry.Block,
|
||||||
events: ['11, 12, 13'],
|
events: ['11, 12, 13'],
|
||||||
} as OntimeBlock,
|
} as OntimeBlock,
|
||||||
'11': {
|
'11': {
|
||||||
id: '11',
|
id: '11',
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
parent: 'block',
|
parent: 'block',
|
||||||
timeStart: 10,
|
timeStart: 10,
|
||||||
timeEnd: 11,
|
timeEnd: 11,
|
||||||
@@ -37,7 +37,7 @@ describe('makeRundownMetadata()', () => {
|
|||||||
} as OntimeEvent,
|
} as OntimeEvent,
|
||||||
'12': {
|
'12': {
|
||||||
id: '12',
|
id: '12',
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
parent: 'block',
|
parent: 'block',
|
||||||
timeStart: 11,
|
timeStart: 11,
|
||||||
timeEnd: 12,
|
timeEnd: 12,
|
||||||
@@ -49,7 +49,7 @@ describe('makeRundownMetadata()', () => {
|
|||||||
} as OntimeEvent,
|
} as OntimeEvent,
|
||||||
'13': {
|
'13': {
|
||||||
id: '13',
|
id: '13',
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
parent: 'block',
|
parent: 'block',
|
||||||
timeStart: 12,
|
timeStart: 12,
|
||||||
timeEnd: 13,
|
timeEnd: 13,
|
||||||
@@ -61,7 +61,7 @@ describe('makeRundownMetadata()', () => {
|
|||||||
} as OntimeEvent,
|
} as OntimeEvent,
|
||||||
'2': {
|
'2': {
|
||||||
id: '2',
|
id: '2',
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
parent: null,
|
parent: null,
|
||||||
timeStart: 20,
|
timeStart: 20,
|
||||||
timeEnd: 21,
|
timeEnd: 21,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { memo, useRef } from 'react';
|
import { memo, useRef } from 'react';
|
||||||
import { IoAdd } from 'react-icons/io5';
|
import { IoAdd } from 'react-icons/io5';
|
||||||
import { Button } from '@chakra-ui/react';
|
import { Button } from '@chakra-ui/react';
|
||||||
import { MaybeString, SupportedEvent } from 'ontime-types';
|
import { MaybeString, SupportedEntry } from 'ontime-types';
|
||||||
|
|
||||||
import { useEntryActions } from '../../../common/hooks/useEntryAction';
|
import { useEntryActions } from '../../../common/hooks/useEntryAction';
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ function QuickAddBlock(props: QuickAddBlockProps) {
|
|||||||
const addEvent = () => {
|
const addEvent = () => {
|
||||||
addEntry(
|
addEntry(
|
||||||
{
|
{
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
parent: parentBlock ?? null,
|
parent: parentBlock ?? null,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -39,7 +39,7 @@ function QuickAddBlock(props: QuickAddBlockProps) {
|
|||||||
const addDelay = () => {
|
const addDelay = () => {
|
||||||
addEntry(
|
addEntry(
|
||||||
// TODO(v4): add delays to blocks
|
// TODO(v4): add delays to blocks
|
||||||
{ type: SupportedEvent.Delay },
|
{ type: SupportedEntry.Delay },
|
||||||
{
|
{
|
||||||
lastEventId: previousEventId,
|
lastEventId: previousEventId,
|
||||||
after: previousEventId,
|
after: previousEventId,
|
||||||
@@ -52,7 +52,7 @@ function QuickAddBlock(props: QuickAddBlockProps) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
addEntry(
|
addEntry(
|
||||||
{ type: SupportedEvent.Block },
|
{ type: SupportedEntry.Block },
|
||||||
{
|
{
|
||||||
lastEventId: previousEventId,
|
lastEventId: previousEventId,
|
||||||
after: previousEventId,
|
after: previousEventId,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
Runtime,
|
Runtime,
|
||||||
Settings,
|
Settings,
|
||||||
SimpleTimerState,
|
SimpleTimerState,
|
||||||
SupportedEvent,
|
SupportedEntry,
|
||||||
TimerType,
|
TimerType,
|
||||||
ViewSettings,
|
ViewSettings,
|
||||||
} from 'ontime-types';
|
} from 'ontime-types';
|
||||||
@@ -63,7 +63,7 @@ const withData = <P extends WithDataProps>(Component: ComponentType<P>) => {
|
|||||||
|
|
||||||
const publicEvents = useMemo(() => {
|
const publicEvents = useMemo(() => {
|
||||||
if (Array.isArray(rundownData)) {
|
if (Array.isArray(rundownData)) {
|
||||||
return rundownData.filter((e) => e.type === SupportedEvent.Event && e.title && e.isPublic);
|
return rundownData.filter((e) => e.type === SupportedEntry.Event && e.title && e.isPublic);
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
}, [rundownData]);
|
}, [rundownData]);
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
ProjectData,
|
ProjectData,
|
||||||
Runtime,
|
Runtime,
|
||||||
Settings,
|
Settings,
|
||||||
SupportedEvent,
|
SupportedEntry,
|
||||||
TimerPhase,
|
TimerPhase,
|
||||||
} from 'ontime-types';
|
} from 'ontime-types';
|
||||||
|
|
||||||
@@ -63,7 +63,7 @@ export default function Countdown(props: CountdownProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let followThis: OntimeEvent | null = null;
|
let followThis: OntimeEvent | null = null;
|
||||||
const events: OntimeEvent[] = [...backstageEvents].filter((event) => event.type === SupportedEvent.Event);
|
const events: OntimeEvent[] = [...backstageEvents].filter((event) => event.type === SupportedEntry.Event);
|
||||||
|
|
||||||
if (eventId !== null) {
|
if (eventId !== null) {
|
||||||
followThis = events.find((event) => event.id === eventId) || null;
|
followThis = events.find((event) => event.id === eventId) || null;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
import { OntimeEntry, OntimeEvent, SupportedEvent } from 'ontime-types';
|
import { OntimeEntry, OntimeEvent, SupportedEntry } from 'ontime-types';
|
||||||
|
|
||||||
import Empty from '../../../common/components/state/Empty';
|
import Empty from '../../../common/components/state/Empty';
|
||||||
import { formatTime } from '../../../common/utils/time';
|
import { formatTime } from '../../../common/utils/time';
|
||||||
@@ -19,7 +19,7 @@ export default function CountdownSelect(props: CountdownSelectProps) {
|
|||||||
const { events } = props;
|
const { events } = props;
|
||||||
const { getLocalizedString } = useTranslation();
|
const { getLocalizedString } = useTranslation();
|
||||||
|
|
||||||
const filteredEvents = events.filter((event: OntimeEntry) => event.type === SupportedEvent.Event) as OntimeEvent[];
|
const filteredEvents = events.filter((event: OntimeEntry) => event.type === SupportedEntry.Event) as OntimeEvent[];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='event-select' data-testid='countdown__select'>
|
<div className='event-select' data-testid='countdown__select'>
|
||||||
|
|||||||
+3
-3
@@ -1,6 +1,6 @@
|
|||||||
import { IoAdd, IoArrowDown, IoArrowUp, IoDuplicateOutline, IoOptions, IoTrash } from 'react-icons/io5';
|
import { IoAdd, IoArrowDown, IoArrowUp, IoDuplicateOutline, IoOptions, IoTrash } from 'react-icons/io5';
|
||||||
import { MenuDivider, MenuItem, MenuList } from '@chakra-ui/react';
|
import { MenuDivider, MenuItem, MenuList } from '@chakra-ui/react';
|
||||||
import { isOntimeEvent, SupportedEvent } from 'ontime-types';
|
import { isOntimeEvent, SupportedEntry } from 'ontime-types';
|
||||||
|
|
||||||
import { useEntryActions } from '../../../../common/hooks/useEntryAction';
|
import { useEntryActions } from '../../../../common/hooks/useEntryAction';
|
||||||
import { cloneEvent } from '../../../../common/utils/eventsManager';
|
import { cloneEvent } from '../../../../common/utils/eventsManager';
|
||||||
@@ -35,10 +35,10 @@ export default function CuesheetTableMenuActions(props: CuesheetTableMenuActions
|
|||||||
Edit ...
|
Edit ...
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuDivider />
|
<MenuDivider />
|
||||||
<MenuItem icon={<IoAdd />} onClick={() => addEntry({ type: SupportedEvent.Event }, { before: eventId })}>
|
<MenuItem icon={<IoAdd />} onClick={() => addEntry({ type: SupportedEntry.Event }, { before: eventId })}>
|
||||||
Add event above
|
Add event above
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem icon={<IoAdd />} onClick={() => addEntry({ type: SupportedEvent.Event }, { after: eventId })}>
|
<MenuItem icon={<IoAdd />} onClick={() => addEntry({ type: SupportedEntry.Event }, { after: eventId })}>
|
||||||
Add event below
|
Add event below
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem icon={<IoDuplicateOutline />} onClick={handleCloneEvent}>
|
<MenuItem icon={<IoDuplicateOutline />} onClick={handleCloneEvent}>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { DatabaseModel, EndAction, SupportedEvent, TimeStrategy, TimerType } from 'ontime-types';
|
import { DatabaseModel, EndAction, SupportedEntry, TimeStrategy, TimerType } from 'ontime-types';
|
||||||
|
|
||||||
export const demoDb: DatabaseModel = {
|
export const demoDb: DatabaseModel = {
|
||||||
rundowns: {
|
rundowns: {
|
||||||
@@ -40,7 +40,7 @@ export const demoDb: DatabaseModel = {
|
|||||||
],
|
],
|
||||||
entries: {
|
entries: {
|
||||||
block: {
|
block: {
|
||||||
type: SupportedEvent.Block,
|
type: SupportedEntry.Block,
|
||||||
events: ['32d31', '21cd2', '0b371', '3cd28', 'e457f'],
|
events: ['32d31', '21cd2', '0b371', '3cd28', 'e457f'],
|
||||||
id: 'block',
|
id: 'block',
|
||||||
title: 'Test Block',
|
title: 'Test Block',
|
||||||
@@ -59,7 +59,7 @@ export const demoDb: DatabaseModel = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
'32d31': {
|
'32d31': {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
id: '32d31',
|
id: '32d31',
|
||||||
cue: 'SF1.01',
|
cue: 'SF1.01',
|
||||||
title: 'Albania',
|
title: 'Albania',
|
||||||
@@ -88,7 +88,7 @@ export const demoDb: DatabaseModel = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
'21cd2': {
|
'21cd2': {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
id: '21cd2',
|
id: '21cd2',
|
||||||
cue: 'SF1.02',
|
cue: 'SF1.02',
|
||||||
title: 'Latvia',
|
title: 'Latvia',
|
||||||
@@ -117,7 +117,7 @@ export const demoDb: DatabaseModel = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
'0b371': {
|
'0b371': {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
id: '0b371',
|
id: '0b371',
|
||||||
cue: 'SF1.03',
|
cue: 'SF1.03',
|
||||||
title: 'Lithuania',
|
title: 'Lithuania',
|
||||||
@@ -146,7 +146,7 @@ export const demoDb: DatabaseModel = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
'3cd28': {
|
'3cd28': {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
id: '3cd28',
|
id: '3cd28',
|
||||||
cue: 'SF1.04',
|
cue: 'SF1.04',
|
||||||
title: 'Switzerland',
|
title: 'Switzerland',
|
||||||
@@ -175,7 +175,7 @@ export const demoDb: DatabaseModel = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
e457f: {
|
e457f: {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
id: 'e457f',
|
id: 'e457f',
|
||||||
cue: 'SF1.05',
|
cue: 'SF1.05',
|
||||||
title: 'Slovenia',
|
title: 'Slovenia',
|
||||||
@@ -206,7 +206,7 @@ export const demoDb: DatabaseModel = {
|
|||||||
/// <----- BLOCK
|
/// <----- BLOCK
|
||||||
'01e85': {
|
'01e85': {
|
||||||
// TODO: this should be a marker type
|
// TODO: this should be a marker type
|
||||||
type: SupportedEvent.Block,
|
type: SupportedEntry.Block,
|
||||||
id: '01e85',
|
id: '01e85',
|
||||||
title: 'Lunch break',
|
title: 'Lunch break',
|
||||||
note: '',
|
note: '',
|
||||||
@@ -222,7 +222,7 @@ export const demoDb: DatabaseModel = {
|
|||||||
numEvents: 0,
|
numEvents: 0,
|
||||||
},
|
},
|
||||||
'1c420': {
|
'1c420': {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
id: '1c420',
|
id: '1c420',
|
||||||
cue: 'SF1.06',
|
cue: 'SF1.06',
|
||||||
title: 'Ukraine',
|
title: 'Ukraine',
|
||||||
@@ -251,7 +251,7 @@ export const demoDb: DatabaseModel = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
b7737: {
|
b7737: {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
id: 'b7737',
|
id: 'b7737',
|
||||||
cue: 'SF1.07',
|
cue: 'SF1.07',
|
||||||
title: 'Bulgaria',
|
title: 'Bulgaria',
|
||||||
@@ -280,7 +280,7 @@ export const demoDb: DatabaseModel = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
d3a80: {
|
d3a80: {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
id: 'd3a80',
|
id: 'd3a80',
|
||||||
cue: 'SF1.08',
|
cue: 'SF1.08',
|
||||||
title: 'Netherlands',
|
title: 'Netherlands',
|
||||||
@@ -309,7 +309,7 @@ export const demoDb: DatabaseModel = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
'8276c': {
|
'8276c': {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
id: '8276c',
|
id: '8276c',
|
||||||
cue: 'SF1.09',
|
cue: 'SF1.09',
|
||||||
title: 'Moldova',
|
title: 'Moldova',
|
||||||
@@ -338,7 +338,7 @@ export const demoDb: DatabaseModel = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
'2340b': {
|
'2340b': {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
id: '2340b',
|
id: '2340b',
|
||||||
cue: 'SF1.10',
|
cue: 'SF1.10',
|
||||||
title: 'Portugal',
|
title: 'Portugal',
|
||||||
@@ -369,7 +369,7 @@ export const demoDb: DatabaseModel = {
|
|||||||
/// <----- BLOCK
|
/// <----- BLOCK
|
||||||
cb90b: {
|
cb90b: {
|
||||||
// TODO: This should be a marker type
|
// TODO: This should be a marker type
|
||||||
type: SupportedEvent.Block,
|
type: SupportedEntry.Block,
|
||||||
id: 'cb90b',
|
id: 'cb90b',
|
||||||
title: 'Afternoon break',
|
title: 'Afternoon break',
|
||||||
note: '',
|
note: '',
|
||||||
@@ -385,7 +385,7 @@ export const demoDb: DatabaseModel = {
|
|||||||
numEvents: 0,
|
numEvents: 0,
|
||||||
},
|
},
|
||||||
'503c4': {
|
'503c4': {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
id: '503c4',
|
id: '503c4',
|
||||||
cue: 'SF1.11',
|
cue: 'SF1.11',
|
||||||
title: 'Croatia',
|
title: 'Croatia',
|
||||||
@@ -414,7 +414,7 @@ export const demoDb: DatabaseModel = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
'5e965': {
|
'5e965': {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
id: '5e965',
|
id: '5e965',
|
||||||
cue: 'SF1.12',
|
cue: 'SF1.12',
|
||||||
title: 'Denmark',
|
title: 'Denmark',
|
||||||
@@ -443,7 +443,7 @@ export const demoDb: DatabaseModel = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
bab4a: {
|
bab4a: {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
id: 'bab4a',
|
id: 'bab4a',
|
||||||
cue: 'SF1.13',
|
cue: 'SF1.13',
|
||||||
title: 'Austria',
|
title: 'Austria',
|
||||||
@@ -472,7 +472,7 @@ export const demoDb: DatabaseModel = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
d3eb1: {
|
d3eb1: {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
id: 'd3eb1',
|
id: 'd3eb1',
|
||||||
cue: 'SF1.14',
|
cue: 'SF1.14',
|
||||||
title: 'Greece',
|
title: 'Greece',
|
||||||
|
|||||||
@@ -3,13 +3,13 @@ import {
|
|||||||
OntimeBlock,
|
OntimeBlock,
|
||||||
OntimeDelay,
|
OntimeDelay,
|
||||||
OntimeEvent,
|
OntimeEvent,
|
||||||
SupportedEvent,
|
SupportedEntry,
|
||||||
TimeStrategy,
|
TimeStrategy,
|
||||||
TimerType,
|
TimerType,
|
||||||
} from 'ontime-types';
|
} from 'ontime-types';
|
||||||
|
|
||||||
export const event: Omit<OntimeEvent, 'id' | 'cue'> = {
|
export const event: Omit<OntimeEvent, 'id' | 'cue'> = {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
title: '',
|
title: '',
|
||||||
note: '',
|
note: '',
|
||||||
endAction: EndAction.None,
|
endAction: EndAction.None,
|
||||||
@@ -35,12 +35,12 @@ export const event: Omit<OntimeEvent, 'id' | 'cue'> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const delay: Omit<OntimeDelay, 'id'> = {
|
export const delay: Omit<OntimeDelay, 'id'> = {
|
||||||
type: SupportedEvent.Delay,
|
type: SupportedEntry.Delay,
|
||||||
duration: 0,
|
duration: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
export const block: Omit<OntimeBlock, 'id'> = {
|
export const block: Omit<OntimeBlock, 'id'> = {
|
||||||
type: SupportedEvent.Block,
|
type: SupportedEntry.Block,
|
||||||
title: '',
|
title: '',
|
||||||
note: '',
|
note: '',
|
||||||
events: [],
|
events: [],
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
import { SupportedEvent, OntimeEvent, OntimeDelay, OntimeBlock, Rundown } from 'ontime-types';
|
import { SupportedEntry, OntimeEvent, OntimeDelay, OntimeBlock, Rundown } from 'ontime-types';
|
||||||
import { defaultRundown } from '../../../models/dataModel.js';
|
import { defaultRundown } from '../../../models/dataModel.js';
|
||||||
|
|
||||||
const baseEvent = {
|
const baseEvent = {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
skip: false,
|
skip: false,
|
||||||
revision: 1,
|
revision: 1,
|
||||||
};
|
};
|
||||||
|
|
||||||
const baseBlock = {
|
const baseBlock = {
|
||||||
type: SupportedEvent.Block,
|
type: SupportedEntry.Block,
|
||||||
events: [],
|
events: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ export function makeOntimeEvent(patch: Partial<OntimeEvent>): OntimeEvent {
|
|||||||
* Utility to create a delay event
|
* Utility to create a delay event
|
||||||
*/
|
*/
|
||||||
export function makeOntimeDelay(patch: Partial<OntimeDelay>): OntimeDelay {
|
export function makeOntimeDelay(patch: Partial<OntimeDelay>): OntimeDelay {
|
||||||
return { id: 'delay', type: SupportedEvent.Delay, duration: 0, ...patch } as OntimeDelay;
|
return { id: 'delay', type: SupportedEntry.Delay, duration: 0, ...patch } as OntimeDelay;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { OntimeEvent, SupportedEvent } from 'ontime-types';
|
import { OntimeEvent, SupportedEntry } from 'ontime-types';
|
||||||
import { MILLIS_PER_HOUR } from 'ontime-utils';
|
import { MILLIS_PER_HOUR } from 'ontime-utils';
|
||||||
|
|
||||||
import { apply } from '../delayUtils.js';
|
import { apply } from '../delayUtils.js';
|
||||||
@@ -72,7 +72,7 @@ describe('apply()', () => {
|
|||||||
expect(testRundown.entries).toMatchObject({
|
expect(testRundown.entries).toMatchObject({
|
||||||
'1': {
|
'1': {
|
||||||
id: '1',
|
id: '1',
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
timeStart: 0,
|
timeStart: 0,
|
||||||
timeEnd: 100,
|
timeEnd: 100,
|
||||||
duration: 100,
|
duration: 100,
|
||||||
@@ -80,7 +80,7 @@ describe('apply()', () => {
|
|||||||
} as OntimeEvent,
|
} as OntimeEvent,
|
||||||
'2': {
|
'2': {
|
||||||
id: '2',
|
id: '2',
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
timeStart: 50,
|
timeStart: 50,
|
||||||
timeEnd: 100,
|
timeEnd: 100,
|
||||||
duration: 50,
|
duration: 50,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { CustomFields, OntimeEvent, SupportedEvent, TimeStrategy } from 'ontime-types';
|
import { CustomFields, OntimeEvent, SupportedEntry, TimeStrategy } from 'ontime-types';
|
||||||
import { MILLIS_PER_HOUR, MILLIS_PER_MINUTE, dayInMs } from 'ontime-utils';
|
import { MILLIS_PER_HOUR, MILLIS_PER_MINUTE, dayInMs } from 'ontime-utils';
|
||||||
|
|
||||||
import { demoDb } from '../../../models/demoProject.js';
|
import { demoDb } from '../../../models/demoProject.js';
|
||||||
@@ -75,9 +75,9 @@ describe('generate()', () => {
|
|||||||
const initResult = generate(rundown, {});
|
const initResult = generate(rundown, {});
|
||||||
expect(initResult.order.length).toBe(3);
|
expect(initResult.order.length).toBe(3);
|
||||||
expect(initResult.order).toStrictEqual(['1', '2', '3']);
|
expect(initResult.order).toStrictEqual(['1', '2', '3']);
|
||||||
expect(initResult.entries['1'].type).toBe(SupportedEvent.Event);
|
expect(initResult.entries['1'].type).toBe(SupportedEntry.Event);
|
||||||
expect(initResult.entries['2'].type).toBe(SupportedEvent.Block);
|
expect(initResult.entries['2'].type).toBe(SupportedEntry.Block);
|
||||||
expect(initResult.entries['3'].type).toBe(SupportedEvent.Delay);
|
expect(initResult.entries['3'].type).toBe(SupportedEntry.Delay);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('calculates delays versions of a given rundown', () => {
|
it('calculates delays versions of a given rundown', () => {
|
||||||
@@ -541,7 +541,7 @@ describe('generate() v4', () => {
|
|||||||
expect(generatedRundown.totalDelay).toBe(0);
|
expect(generatedRundown.totalDelay).toBe(0);
|
||||||
expect(generatedRundown.entries).toMatchObject({
|
expect(generatedRundown.entries).toMatchObject({
|
||||||
'1': {
|
'1': {
|
||||||
type: SupportedEvent.Block,
|
type: SupportedEntry.Block,
|
||||||
events: ['100', '200', '300'],
|
events: ['100', '200', '300'],
|
||||||
startTime: 100,
|
startTime: 100,
|
||||||
endTime: 400,
|
endTime: 400,
|
||||||
@@ -549,9 +549,9 @@ describe('generate() v4', () => {
|
|||||||
isFirstLinked: false,
|
isFirstLinked: false,
|
||||||
numEvents: 3,
|
numEvents: 3,
|
||||||
},
|
},
|
||||||
'100': { type: SupportedEvent.Event, parent: '1' },
|
'100': { type: SupportedEntry.Event, parent: '1' },
|
||||||
'200': { type: SupportedEvent.Event, parent: '1' },
|
'200': { type: SupportedEntry.Event, parent: '1' },
|
||||||
'300': { type: SupportedEvent.Event, parent: '1' },
|
'300': { type: SupportedEntry.Event, parent: '1' },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -580,9 +580,9 @@ describe('generate() v4', () => {
|
|||||||
expect(generatedRundown.totalDuration).toBe(1200);
|
expect(generatedRundown.totalDuration).toBe(1200);
|
||||||
expect(generatedRundown.totalDelay).toBe(0);
|
expect(generatedRundown.totalDelay).toBe(0);
|
||||||
expect(generatedRundown.entries).toMatchObject({
|
expect(generatedRundown.entries).toMatchObject({
|
||||||
'0': { type: SupportedEvent.Event, parent: null },
|
'0': { type: SupportedEntry.Event, parent: null },
|
||||||
'1': {
|
'1': {
|
||||||
type: SupportedEvent.Block,
|
type: SupportedEntry.Block,
|
||||||
events: ['101', '102', '103'],
|
events: ['101', '102', '103'],
|
||||||
startTime: 100,
|
startTime: 100,
|
||||||
endTime: 400,
|
endTime: 400,
|
||||||
@@ -594,7 +594,7 @@ describe('generate() v4', () => {
|
|||||||
'102': { parent: '1' },
|
'102': { parent: '1' },
|
||||||
'103': { parent: '1' },
|
'103': { parent: '1' },
|
||||||
'2': {
|
'2': {
|
||||||
type: SupportedEvent.Block,
|
type: SupportedEntry.Block,
|
||||||
events: ['201', '202', '203'],
|
events: ['201', '202', '203'],
|
||||||
startTime: 500,
|
startTime: 500,
|
||||||
endTime: 800,
|
endTime: 800,
|
||||||
@@ -606,7 +606,7 @@ describe('generate() v4', () => {
|
|||||||
'202': { id: '202', timeStart: 600, timeEnd: 700, duration: 100 },
|
'202': { id: '202', timeStart: 600, timeEnd: 700, duration: 100 },
|
||||||
'203': { id: '203', timeStart: 700, timeEnd: 800, duration: 100 },
|
'203': { id: '203', timeStart: 700, timeEnd: 800, duration: 100 },
|
||||||
'3': {
|
'3': {
|
||||||
type: SupportedEvent.Block,
|
type: SupportedEntry.Block,
|
||||||
events: ['301', '302', '303'],
|
events: ['301', '302', '303'],
|
||||||
startTime: 900,
|
startTime: 900,
|
||||||
endTime: 1200,
|
endTime: 1200,
|
||||||
@@ -685,7 +685,7 @@ describe('edit() mutation', () => {
|
|||||||
expect(newEvent).toMatchObject({
|
expect(newEvent).toMatchObject({
|
||||||
id: 'mock',
|
id: 'mock',
|
||||||
cue: 'patched',
|
cue: 'patched',
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -707,9 +707,9 @@ describe('batchEdit() mutation', () => {
|
|||||||
const { newRundown } = batchEdit({ rundown, eventIds, patch });
|
const { newRundown } = batchEdit({ rundown, eventIds, patch });
|
||||||
|
|
||||||
expect(newRundown.entries).toMatchObject({
|
expect(newRundown.entries).toMatchObject({
|
||||||
'1': { id: '1', type: SupportedEvent.Event, cue: 'newData' },
|
'1': { id: '1', type: SupportedEntry.Event, cue: 'newData' },
|
||||||
'2': { id: '2', type: SupportedEvent.Event, cue: 'data2' },
|
'2': { id: '2', type: SupportedEntry.Event, cue: 'data2' },
|
||||||
'3': { id: '3', type: SupportedEvent.Event, cue: 'newData' },
|
'3': { id: '3', type: SupportedEntry.Event, cue: 'newData' },
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { CustomFields, EndAction, OntimeEvent, SupportedEvent, TimeStrategy, TimerType } from 'ontime-types';
|
import { CustomFields, EndAction, OntimeEvent, SupportedEntry, TimeStrategy, TimerType } from 'ontime-types';
|
||||||
import {
|
import {
|
||||||
addToCustomAssignment,
|
addToCustomAssignment,
|
||||||
calculateDayOffset,
|
calculateDayOffset,
|
||||||
@@ -38,7 +38,7 @@ describe('handleCustomField()', () => {
|
|||||||
const customFieldChangelog = {};
|
const customFieldChangelog = {};
|
||||||
|
|
||||||
const event = makeOntimeEvent({
|
const event = makeOntimeEvent({
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
id: '2',
|
id: '2',
|
||||||
timeStart: 0,
|
timeStart: 0,
|
||||||
linkStart: true,
|
linkStart: true,
|
||||||
@@ -73,7 +73,7 @@ describe('handleCustomField()', () => {
|
|||||||
const customFieldChangelog = { sound: 'video' };
|
const customFieldChangelog = { sound: 'video' };
|
||||||
|
|
||||||
const event = makeOntimeEvent({
|
const event = makeOntimeEvent({
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
id: '2',
|
id: '2',
|
||||||
timeStart: 0,
|
timeStart: 0,
|
||||||
linkStart: true,
|
linkStart: true,
|
||||||
@@ -108,7 +108,7 @@ describe('handleCustomField()', () => {
|
|||||||
const customFieldChangelog = { field1: 'newField1' };
|
const customFieldChangelog = { field1: 'newField1' };
|
||||||
|
|
||||||
const mutableEvent = makeOntimeEvent({
|
const mutableEvent = makeOntimeEvent({
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
id: 'event1',
|
id: 'event1',
|
||||||
custom: {
|
custom: {
|
||||||
field1: 'value1',
|
field1: 'value1',
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { EndAction, OntimeEvent, SupportedEvent, TimeStrategy, TimerType } from 'ontime-types';
|
import { EndAction, OntimeEvent, SupportedEntry, TimeStrategy, TimerType } from 'ontime-types';
|
||||||
import { millisToString } from 'ontime-utils';
|
import { millisToString } from 'ontime-utils';
|
||||||
|
|
||||||
import { getA1Notation, cellRequestFromEvent } from '../sheetUtils.js';
|
import { getA1Notation, cellRequestFromEvent } from '../sheetUtils.js';
|
||||||
@@ -21,7 +21,7 @@ describe('getA1Notation()', () => {
|
|||||||
describe('cellRequestFromEvent()', () => {
|
describe('cellRequestFromEvent()', () => {
|
||||||
test('string to string', () => {
|
test('string to string', () => {
|
||||||
const event: OntimeEvent = {
|
const event: OntimeEvent = {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
cue: '1',
|
cue: '1',
|
||||||
title: 'Fancy',
|
title: 'Fancy',
|
||||||
note: 'Blue button on the right',
|
note: 'Blue button on the right',
|
||||||
@@ -70,7 +70,7 @@ describe('cellRequestFromEvent()', () => {
|
|||||||
|
|
||||||
test('number to timer', () => {
|
test('number to timer', () => {
|
||||||
const event: OntimeEvent = {
|
const event: OntimeEvent = {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
cue: '1',
|
cue: '1',
|
||||||
title: 'Fancy',
|
title: 'Fancy',
|
||||||
note: 'Blue button on the right',
|
note: 'Blue button on the right',
|
||||||
@@ -121,7 +121,7 @@ describe('cellRequestFromEvent()', () => {
|
|||||||
|
|
||||||
test('boolean to TRUE', () => {
|
test('boolean to TRUE', () => {
|
||||||
const event: OntimeEvent = {
|
const event: OntimeEvent = {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
cue: '1',
|
cue: '1',
|
||||||
title: 'Fancy',
|
title: 'Fancy',
|
||||||
note: 'Blue button on the right',
|
note: 'Blue button on the right',
|
||||||
@@ -171,7 +171,7 @@ describe('cellRequestFromEvent()', () => {
|
|||||||
|
|
||||||
test('spacing in metadata', () => {
|
test('spacing in metadata', () => {
|
||||||
const event: OntimeEvent = {
|
const event: OntimeEvent = {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
cue: '1',
|
cue: '1',
|
||||||
title: 'Fancy',
|
title: 'Fancy',
|
||||||
note: 'Blue button on the right',
|
note: 'Blue button on the right',
|
||||||
@@ -207,7 +207,7 @@ describe('cellRequestFromEvent()', () => {
|
|||||||
|
|
||||||
test('metadata offset from zero', () => {
|
test('metadata offset from zero', () => {
|
||||||
const event: OntimeEvent = {
|
const event: OntimeEvent = {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
cue: '1',
|
cue: '1',
|
||||||
title: 'Fancy',
|
title: 'Fancy',
|
||||||
note: 'Blue button on the right',
|
note: 'Blue button on the right',
|
||||||
@@ -244,7 +244,7 @@ describe('cellRequestFromEvent()', () => {
|
|||||||
|
|
||||||
test('sheet setup', () => {
|
test('sheet setup', () => {
|
||||||
const event: OntimeEvent = {
|
const event: OntimeEvent = {
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
cue: '1',
|
cue: '1',
|
||||||
title: 'Fancy',
|
title: 'Fancy',
|
||||||
note: 'Blue button on the right',
|
note: 'Blue button on the right',
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/* eslint-disable no-console -- we are mocking the console */
|
/* eslint-disable no-console -- we are mocking the console */
|
||||||
import { assertType, vi } from 'vitest';
|
import { assertType, vi } from 'vitest';
|
||||||
|
|
||||||
import { CustomFields, DatabaseModel, OntimeEvent, SupportedEvent, TimerType } from 'ontime-types';
|
import { CustomFields, DatabaseModel, OntimeEvent, SupportedEntry, TimerType } from 'ontime-types';
|
||||||
import { ImportMap, MILLIS_PER_MINUTE } from 'ontime-utils';
|
import { ImportMap, MILLIS_PER_MINUTE } from 'ontime-utils';
|
||||||
|
|
||||||
import { dbModel } from '../../models/dataModel.js';
|
import { dbModel } from '../../models/dataModel.js';
|
||||||
@@ -537,7 +537,7 @@ describe('parseExcel()', () => {
|
|||||||
const firstEvent = result.rundown.entries[result.rundown.order[0]];
|
const firstEvent = result.rundown.entries[result.rundown.order[0]];
|
||||||
|
|
||||||
expect(result.rundown.order.length).toBe(2);
|
expect(result.rundown.order.length).toBe(2);
|
||||||
expect((firstEvent as OntimeEvent).type).toBe(SupportedEvent.Block);
|
expect((firstEvent as OntimeEvent).type).toBe(SupportedEntry.Block);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('imports as events if there is no timer type column', () => {
|
it('imports as events if there is no timer type column', () => {
|
||||||
@@ -553,12 +553,12 @@ describe('parseExcel()', () => {
|
|||||||
|
|
||||||
expect(result.rundown.order.length).toBe(2);
|
expect(result.rundown.order.length).toBe(2);
|
||||||
expect(firstEvent).toMatchObject({
|
expect(firstEvent).toMatchObject({
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
timerType: TimerType.CountDown,
|
timerType: TimerType.CountDown,
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(secondEvent).toMatchObject({
|
expect(secondEvent).toMatchObject({
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
timerType: TimerType.CountDown,
|
timerType: TimerType.CountDown,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -580,9 +580,9 @@ describe('parseExcel()', () => {
|
|||||||
const secondEvent = result.rundown.entries[result.rundown.order[1]];
|
const secondEvent = result.rundown.entries[result.rundown.order[1]];
|
||||||
const thirdEvent = result.rundown.entries[result.rundown.order[2]];
|
const thirdEvent = result.rundown.entries[result.rundown.order[2]];
|
||||||
expect(result.rundown.order.length).toBe(3);
|
expect(result.rundown.order.length).toBe(3);
|
||||||
expect(firstEvent).toMatchObject({ title: 'first', type: SupportedEvent.Event, timerType: TimerType.CountDown });
|
expect(firstEvent).toMatchObject({ title: 'first', type: SupportedEntry.Event, timerType: TimerType.CountDown });
|
||||||
expect(secondEvent).toMatchObject({ title: 'second', type: SupportedEvent.Event, timerType: TimerType.CountDown });
|
expect(secondEvent).toMatchObject({ title: 'second', type: SupportedEntry.Event, timerType: TimerType.CountDown });
|
||||||
expect(thirdEvent).toMatchObject({ title: 'third', type: SupportedEvent.Event, timerType: TimerType.CountUp });
|
expect(thirdEvent).toMatchObject({ title: 'third', type: SupportedEntry.Event, timerType: TimerType.CountUp });
|
||||||
});
|
});
|
||||||
|
|
||||||
it('am/pm conversion to 24h', () => {
|
it('am/pm conversion to 24h', () => {
|
||||||
@@ -697,7 +697,7 @@ describe('parseExcel()', () => {
|
|||||||
linkStart: false,
|
linkStart: false,
|
||||||
},
|
},
|
||||||
BLOCK: {
|
BLOCK: {
|
||||||
type: SupportedEvent.Block,
|
type: SupportedEntry.Block,
|
||||||
},
|
},
|
||||||
E: {
|
E: {
|
||||||
linkStart: true,
|
linkStart: true,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { CustomFields, OntimeBlock, OntimeEvent, Rundown, Settings, SupportedEvent, URLPreset } from 'ontime-types';
|
import { CustomFields, OntimeBlock, OntimeEvent, Rundown, Settings, SupportedEntry, URLPreset } from 'ontime-types';
|
||||||
|
|
||||||
import { defaultRundown } from '../../models/dataModel.js';
|
import { defaultRundown } from '../../models/dataModel.js';
|
||||||
|
|
||||||
@@ -56,8 +56,8 @@ describe('parseRundown()', () => {
|
|||||||
order: ['1', '2', '3', '4'],
|
order: ['1', '2', '3', '4'],
|
||||||
flatOrder: ['1', '2', '3', '4'],
|
flatOrder: ['1', '2', '3', '4'],
|
||||||
entries: {
|
entries: {
|
||||||
'1': { id: '1', type: SupportedEvent.Event, title: 'test', skip: false } as OntimeEvent, // OK
|
'1': { id: '1', type: SupportedEntry.Event, title: 'test', skip: false } as OntimeEvent, // OK
|
||||||
'2': { id: '1', type: SupportedEvent.Block, title: 'test 2', skip: false } as OntimeBlock, // duplicate ID
|
'2': { id: '1', type: SupportedEntry.Block, title: 'test 2', skip: false } as OntimeBlock, // duplicate ID
|
||||||
'3': {} as OntimeEvent, // no data
|
'3': {} as OntimeEvent, // no data
|
||||||
'4': { id: '4', title: 'test 2', skip: false } as OntimeEvent, // no type
|
'4': { id: '4', title: 'test 2', skip: false } as OntimeEvent, // no type
|
||||||
},
|
},
|
||||||
@@ -72,7 +72,7 @@ describe('parseRundown()', () => {
|
|||||||
expect(parsedRundown.entries).toMatchObject({
|
expect(parsedRundown.entries).toMatchObject({
|
||||||
'1': {
|
'1': {
|
||||||
id: '1',
|
id: '1',
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
title: 'test',
|
title: 'test',
|
||||||
skip: false,
|
skip: false,
|
||||||
},
|
},
|
||||||
@@ -88,9 +88,9 @@ describe('parseRundown()', () => {
|
|||||||
flatOrder: ['1', '2'],
|
flatOrder: ['1', '2'],
|
||||||
entries: {
|
entries: {
|
||||||
// @ts-expect-error -- testing external data which could be incorrect
|
// @ts-expect-error -- testing external data which could be incorrect
|
||||||
'1': { id: '1', type: SupportedEvent.Event, cue: 101 } as OntimeEvent,
|
'1': { id: '1', type: SupportedEntry.Event, cue: 101 } as OntimeEvent,
|
||||||
// @ts-expect-error -- testing external data which could be incorrect
|
// @ts-expect-error -- testing external data which could be incorrect
|
||||||
'2': { id: '2', type: SupportedEvent.Event, cue: 101.1 } as OntimeEvent,
|
'2': { id: '2', type: SupportedEntry.Event, cue: 101.1 } as OntimeEvent,
|
||||||
},
|
},
|
||||||
revision: 1,
|
revision: 1,
|
||||||
} as Rundown;
|
} as Rundown;
|
||||||
@@ -114,8 +114,8 @@ describe('parseRundown()', () => {
|
|||||||
order: ['1', '1'],
|
order: ['1', '1'],
|
||||||
flatOrder: ['1', '1'],
|
flatOrder: ['1', '1'],
|
||||||
entries: {
|
entries: {
|
||||||
'1': { id: '1', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', type: SupportedEvent.Event } as OntimeEvent,
|
'2': { id: '2', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
},
|
},
|
||||||
revision: 1,
|
revision: 1,
|
||||||
} as Rundown;
|
} as Rundown;
|
||||||
@@ -132,8 +132,8 @@ describe('parseRundown()', () => {
|
|||||||
order: ['1', '2'],
|
order: ['1', '2'],
|
||||||
flatOrder: ['1', '2'],
|
flatOrder: ['1', '2'],
|
||||||
entries: {
|
entries: {
|
||||||
'1': { id: '1', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', type: SupportedEvent.Event } as OntimeEvent,
|
'2': { id: '2', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
},
|
},
|
||||||
revision: 1,
|
revision: 1,
|
||||||
} as Rundown;
|
} as Rundown;
|
||||||
@@ -161,8 +161,8 @@ describe('parseRundown()', () => {
|
|||||||
order: ['1', '2', '3', '4'],
|
order: ['1', '2', '3', '4'],
|
||||||
flatOrder: ['1', '2', '3', '4'],
|
flatOrder: ['1', '2', '3', '4'],
|
||||||
entries: {
|
entries: {
|
||||||
'1': { id: '1', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', type: SupportedEvent.Event } as OntimeEvent,
|
'2': { id: '2', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'not-mentioned': {} as OntimeEvent,
|
'not-mentioned': {} as OntimeEvent,
|
||||||
},
|
},
|
||||||
revision: 1,
|
revision: 1,
|
||||||
@@ -180,8 +180,8 @@ describe('parseRundown()', () => {
|
|||||||
order: ['1', '2', '3', '4'],
|
order: ['1', '2', '3', '4'],
|
||||||
flatOrder: ['1', '2', '3', '4'],
|
flatOrder: ['1', '2', '3', '4'],
|
||||||
entries: {
|
entries: {
|
||||||
'1': { id: '1', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', type: SupportedEvent.Event } as OntimeEvent,
|
'2': { id: '2', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'not-mentioned': {} as OntimeEvent,
|
'not-mentioned': {} as OntimeEvent,
|
||||||
},
|
},
|
||||||
revision: 1,
|
revision: 1,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
OntimeBlock,
|
OntimeBlock,
|
||||||
OntimeEvent,
|
OntimeEvent,
|
||||||
Rundown,
|
Rundown,
|
||||||
SupportedEvent,
|
SupportedEntry,
|
||||||
TimerType,
|
TimerType,
|
||||||
TimeStrategy,
|
TimeStrategy,
|
||||||
} from 'ontime-types';
|
} from 'ontime-types';
|
||||||
@@ -232,10 +232,10 @@ export const parseExcel = (
|
|||||||
const maybeTimeType = makeString(column, '');
|
const maybeTimeType = makeString(column, '');
|
||||||
if (maybeTimeType === 'block') {
|
if (maybeTimeType === 'block') {
|
||||||
// we leave this as a clue for the object filtering later on
|
// we leave this as a clue for the object filtering later on
|
||||||
entry.type = SupportedEvent.Block;
|
entry.type = SupportedEntry.Block;
|
||||||
} else if (maybeTimeType === '' || maybeTimeType === 'event' || isKnownTimerType(maybeTimeType)) {
|
} else if (maybeTimeType === '' || maybeTimeType === 'event' || isKnownTimerType(maybeTimeType)) {
|
||||||
// @ts-expect-error -- we leave this as a clue for the object filtering later on
|
// @ts-expect-error -- we leave this as a clue for the object filtering later on
|
||||||
entry.type = SupportedEvent.Event;
|
entry.type = SupportedEntry.Event;
|
||||||
entry.timerType = validateTimerType(maybeTimeType);
|
entry.timerType = validateTimerType(maybeTimeType);
|
||||||
} else {
|
} else {
|
||||||
// if it is not a block or a known type, we dont import it
|
// if it is not a block or a known type, we dont import it
|
||||||
@@ -320,7 +320,7 @@ export const parseExcel = (
|
|||||||
const event = {
|
const event = {
|
||||||
...entry,
|
...entry,
|
||||||
custom: { ...entryCustomFields },
|
custom: { ...entryCustomFields },
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
} as OntimeEvent;
|
} as OntimeEvent;
|
||||||
|
|
||||||
if (timerTypeIndex === null) {
|
if (timerTypeIndex === null) {
|
||||||
@@ -407,7 +407,7 @@ export function createPatch(originalEvent: OntimeEvent, patchEvent: Partial<Onti
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
id: originalEvent.id,
|
id: originalEvent.id,
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
title: makeString(patchEvent.title, originalEvent.title),
|
title: makeString(patchEvent.title, originalEvent.title),
|
||||||
timeStart,
|
timeStart,
|
||||||
timeEnd,
|
timeEnd,
|
||||||
|
|||||||
@@ -2,24 +2,24 @@ import type { EndAction, EntryCustomFields, MaybeNumber, TimerType, TimeStrategy
|
|||||||
|
|
||||||
export type EntryId = string;
|
export type EntryId = string;
|
||||||
|
|
||||||
export enum SupportedEvent {
|
export enum SupportedEntry {
|
||||||
Event = 'event',
|
Event = 'event',
|
||||||
Delay = 'delay',
|
Delay = 'delay',
|
||||||
Block = 'block',
|
Block = 'block',
|
||||||
}
|
}
|
||||||
|
|
||||||
export type OntimeBaseEvent = {
|
export type OntimeBaseEvent = {
|
||||||
type: SupportedEvent;
|
type: SupportedEntry;
|
||||||
id: EntryId;
|
id: EntryId;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type OntimeDelay = OntimeBaseEvent & {
|
export type OntimeDelay = OntimeBaseEvent & {
|
||||||
type: SupportedEvent.Delay;
|
type: SupportedEntry.Delay;
|
||||||
duration: number;
|
duration: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type OntimeBlock = OntimeBaseEvent & {
|
export type OntimeBlock = OntimeBaseEvent & {
|
||||||
type: SupportedEvent.Block;
|
type: SupportedEntry.Block;
|
||||||
title: string;
|
title: string;
|
||||||
note: string;
|
note: string;
|
||||||
events: EntryId[];
|
events: EntryId[];
|
||||||
@@ -36,7 +36,7 @@ export type OntimeBlock = OntimeBaseEvent & {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type OntimeEvent = OntimeBaseEvent & {
|
export type OntimeEvent = OntimeBaseEvent & {
|
||||||
type: SupportedEvent.Event;
|
type: SupportedEntry.Event;
|
||||||
cue: string;
|
cue: string;
|
||||||
title: string;
|
title: string;
|
||||||
note: string;
|
note: string;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export {
|
|||||||
type OntimeEvent,
|
type OntimeEvent,
|
||||||
type PlayableEvent,
|
type PlayableEvent,
|
||||||
type TimeField,
|
type TimeField,
|
||||||
SupportedEvent,
|
SupportedEntry as SupportedEntry,
|
||||||
} from './definitions/core/OntimeEvent.type.js';
|
} from './definitions/core/OntimeEvent.type.js';
|
||||||
export type {
|
export type {
|
||||||
OntimeEntryCommonKeys,
|
OntimeEntryCommonKeys,
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import type { AutomationOutput, HTTPOutput, OntimeAction, OSCOutput } from '../definitions/core/Automation.type.js';
|
import type { AutomationOutput, HTTPOutput, OntimeAction, OSCOutput } from '../definitions/core/Automation.type.js';
|
||||||
import type { OntimeBlock, OntimeDelay, OntimeEvent, PlayableEvent } from '../definitions/core/OntimeEvent.type.js';
|
import type { OntimeBlock, OntimeDelay, OntimeEvent, PlayableEvent } from '../definitions/core/OntimeEvent.type.js';
|
||||||
import { SupportedEvent } from '../definitions/core/OntimeEvent.type.js';
|
import { SupportedEntry } from '../definitions/core/OntimeEvent.type.js';
|
||||||
import type { OntimeEntry } from '../definitions/core/Rundown.type.js';
|
import type { OntimeEntry } from '../definitions/core/Rundown.type.js';
|
||||||
import { type TimerLifeCycle, timerLifecycleValues } from '../definitions/core/TimerLifecycle.type.js';
|
import { type TimerLifeCycle, timerLifecycleValues } from '../definitions/core/TimerLifecycle.type.js';
|
||||||
|
|
||||||
type MaybeEvent = OntimeEntry | Partial<OntimeEntry> | null | undefined;
|
type MaybeEvent = OntimeEntry | Partial<OntimeEntry> | null | undefined;
|
||||||
|
|
||||||
export function isOntimeEvent(event: MaybeEvent): event is OntimeEvent {
|
export function isOntimeEvent(event: MaybeEvent): event is OntimeEvent {
|
||||||
return event?.type === SupportedEvent.Event;
|
return event?.type === SupportedEntry.Event;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isPlayableEvent(event: OntimeEvent): event is PlayableEvent {
|
export function isPlayableEvent(event: OntimeEvent): event is PlayableEvent {
|
||||||
@@ -15,11 +15,11 @@ export function isPlayableEvent(event: OntimeEvent): event is PlayableEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isOntimeDelay(event: MaybeEvent): event is OntimeDelay {
|
export function isOntimeDelay(event: MaybeEvent): event is OntimeDelay {
|
||||||
return event?.type === SupportedEvent.Delay;
|
return event?.type === SupportedEntry.Delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isOntimeBlock(event: MaybeEvent): event is OntimeBlock {
|
export function isOntimeBlock(event: MaybeEvent): event is OntimeBlock {
|
||||||
return event?.type === SupportedEvent.Block;
|
return event?.type === SupportedEntry.Block;
|
||||||
}
|
}
|
||||||
|
|
||||||
type AnyKeys<T> = keyof T;
|
type AnyKeys<T> = keyof T;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { OntimeDelay, OntimeEntry, OntimeEvent, RundownEntries } from 'ontime-types';
|
import type { OntimeDelay, OntimeEntry, OntimeEvent, RundownEntries } from 'ontime-types';
|
||||||
import { SupportedEvent } from 'ontime-types';
|
import { SupportedEntry } from 'ontime-types';
|
||||||
|
|
||||||
import { getCueCandidate, getIncrement, sanitiseCue } from './cueUtils.js';
|
import { getCueCandidate, getIncrement, sanitiseCue } from './cueUtils.js';
|
||||||
|
|
||||||
@@ -37,8 +37,8 @@ describe('getCueCandidate()', () => {
|
|||||||
describe('in the beginning of the rundown', () => {
|
describe('in the beginning of the rundown', () => {
|
||||||
it('names cue as 1 if next event does not collide', () => {
|
it('names cue as 1 if next event does not collide', () => {
|
||||||
const entries: RundownEntries = {
|
const entries: RundownEntries = {
|
||||||
'1': { id: '1', cue: '10', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', cue: '10', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', cue: '11', type: SupportedEvent.Event } as OntimeEvent,
|
'2': { id: '2', cue: '11', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
};
|
};
|
||||||
const cue = getCueCandidate(entries, ['1', '2']);
|
const cue = getCueCandidate(entries, ['1', '2']);
|
||||||
expect(cue).toBe('1');
|
expect(cue).toBe('1');
|
||||||
@@ -46,8 +46,8 @@ describe('getCueCandidate()', () => {
|
|||||||
|
|
||||||
it('creates decimal stem if next cue is 1', () => {
|
it('creates decimal stem if next cue is 1', () => {
|
||||||
const entries: RundownEntries = {
|
const entries: RundownEntries = {
|
||||||
'1': { id: '1', cue: '1', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', cue: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', cue: '10', type: SupportedEvent.Event } as OntimeEvent,
|
'2': { id: '2', cue: '10', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
};
|
};
|
||||||
const cue = getCueCandidate(entries, ['1', '2']);
|
const cue = getCueCandidate(entries, ['1', '2']);
|
||||||
expect(cue).toBe('0.1');
|
expect(cue).toBe('0.1');
|
||||||
@@ -57,8 +57,8 @@ describe('getCueCandidate()', () => {
|
|||||||
describe('in the middle of the rundown', () => {
|
describe('in the middle of the rundown', () => {
|
||||||
it('names cue as an increment if next event has different stem (case of numbers)', () => {
|
it('names cue as an increment if next event has different stem (case of numbers)', () => {
|
||||||
const entries: RundownEntries = {
|
const entries: RundownEntries = {
|
||||||
'1': { id: '1', cue: '1', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', cue: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', cue: '10', type: SupportedEvent.Event } as OntimeEvent,
|
'2': { id: '2', cue: '10', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
};
|
};
|
||||||
const cue = getCueCandidate(entries, ['1', '2'], '1');
|
const cue = getCueCandidate(entries, ['1', '2'], '1');
|
||||||
expect(cue).toBe('2');
|
expect(cue).toBe('2');
|
||||||
@@ -66,11 +66,11 @@ describe('getCueCandidate()', () => {
|
|||||||
|
|
||||||
it('names cue as an increment if next event has different stem (case of letters)', () => {
|
it('names cue as an increment if next event has different stem (case of letters)', () => {
|
||||||
const entries: RundownEntries = {
|
const entries: RundownEntries = {
|
||||||
'1': { id: '1', cue: 'Presenter', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', cue: 'Presenter', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': {
|
'2': {
|
||||||
id: '2',
|
id: '2',
|
||||||
cue: 'Interval',
|
cue: 'Interval',
|
||||||
type: SupportedEvent.Event,
|
type: SupportedEntry.Event,
|
||||||
} as OntimeEntry,
|
} as OntimeEntry,
|
||||||
};
|
};
|
||||||
const cue = getCueCandidate(entries, ['1', '2'], '1');
|
const cue = getCueCandidate(entries, ['1', '2'], '1');
|
||||||
@@ -79,8 +79,8 @@ describe('getCueCandidate()', () => {
|
|||||||
|
|
||||||
it('creates decimal stem if next cue has same stem (case of numbers)', () => {
|
it('creates decimal stem if next cue has same stem (case of numbers)', () => {
|
||||||
const entries: RundownEntries = {
|
const entries: RundownEntries = {
|
||||||
'1': { id: '1', cue: '1', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', cue: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', cue: '2', type: SupportedEvent.Event } as OntimeEvent,
|
'2': { id: '2', cue: '2', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
};
|
};
|
||||||
const cue = getCueCandidate(entries, ['1', '2'], '1');
|
const cue = getCueCandidate(entries, ['1', '2'], '1');
|
||||||
expect(cue).toBe('1.1');
|
expect(cue).toBe('1.1');
|
||||||
@@ -88,8 +88,8 @@ describe('getCueCandidate()', () => {
|
|||||||
|
|
||||||
it('creates decimal stem if next cue has same stem (case of letters)', () => {
|
it('creates decimal stem if next cue has same stem (case of letters)', () => {
|
||||||
const entries: RundownEntries = {
|
const entries: RundownEntries = {
|
||||||
'1': { id: '1', cue: 'Presenter1', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', cue: 'Presenter1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', cue: 'Presenter2', type: SupportedEvent.Event } as OntimeEvent,
|
'2': { id: '2', cue: 'Presenter2', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
};
|
};
|
||||||
const cue = getCueCandidate(entries, ['1', '2'], '1');
|
const cue = getCueCandidate(entries, ['1', '2'], '1');
|
||||||
expect(cue).toBe('Presenter1.1');
|
expect(cue).toBe('Presenter1.1');
|
||||||
@@ -99,8 +99,8 @@ describe('getCueCandidate()', () => {
|
|||||||
describe('considers edge cases', () => {
|
describe('considers edge cases', () => {
|
||||||
it('previousEvent might not be a cue', () => {
|
it('previousEvent might not be a cue', () => {
|
||||||
const entries: RundownEntries = {
|
const entries: RundownEntries = {
|
||||||
'1': { id: '1', cue: '10', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', cue: '10', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', type: SupportedEvent.Delay } as OntimeDelay,
|
'2': { id: '2', type: SupportedEntry.Delay } as OntimeDelay,
|
||||||
};
|
};
|
||||||
const cue = getCueCandidate(entries, ['1', '2'], '2');
|
const cue = getCueCandidate(entries, ['1', '2'], '2');
|
||||||
expect(cue).toBe('11');
|
expect(cue).toBe('11');
|
||||||
@@ -109,8 +109,8 @@ describe('getCueCandidate()', () => {
|
|||||||
|
|
||||||
it('there might not be events before', () => {
|
it('there might not be events before', () => {
|
||||||
const entries: RundownEntries = {
|
const entries: RundownEntries = {
|
||||||
'1': { id: '1', type: SupportedEvent.Delay } as OntimeDelay,
|
'1': { id: '1', type: SupportedEntry.Delay } as OntimeDelay,
|
||||||
'2': { id: '2', type: SupportedEvent.Delay } as OntimeDelay,
|
'2': { id: '2', type: SupportedEntry.Delay } as OntimeDelay,
|
||||||
};
|
};
|
||||||
const cue = getCueCandidate(entries, ['1', '2'], '2');
|
const cue = getCueCandidate(entries, ['1', '2'], '2');
|
||||||
expect(cue).toBe('1');
|
expect(cue).toBe('1');
|
||||||
@@ -121,8 +121,8 @@ describe('findCueName() with mixed events', () => {
|
|||||||
describe('in the beginning of the rundown', () => {
|
describe('in the beginning of the rundown', () => {
|
||||||
it('names cue as 1 if next event does not collide', () => {
|
it('names cue as 1 if next event does not collide', () => {
|
||||||
const entries: RundownEntries = {
|
const entries: RundownEntries = {
|
||||||
'1': { id: '1', cue: '10', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', cue: '10', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', cue: '11', type: SupportedEvent.Event } as OntimeEvent,
|
'2': { id: '2', cue: '11', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
};
|
};
|
||||||
const cue = getCueCandidate(entries, ['1', '2']);
|
const cue = getCueCandidate(entries, ['1', '2']);
|
||||||
expect(cue).toBe('1');
|
expect(cue).toBe('1');
|
||||||
@@ -130,8 +130,8 @@ describe('findCueName() with mixed events', () => {
|
|||||||
|
|
||||||
it('creates decimal stem if next cue is 1', () => {
|
it('creates decimal stem if next cue is 1', () => {
|
||||||
const entries: RundownEntries = {
|
const entries: RundownEntries = {
|
||||||
'1': { id: '1', cue: '1', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', cue: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', cue: '10', type: SupportedEvent.Event } as OntimeEvent,
|
'2': { id: '2', cue: '10', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
};
|
};
|
||||||
const cue = getCueCandidate(entries, ['1', '2']);
|
const cue = getCueCandidate(entries, ['1', '2']);
|
||||||
expect(cue).toBe('0.1');
|
expect(cue).toBe('0.1');
|
||||||
@@ -141,8 +141,8 @@ describe('findCueName() with mixed events', () => {
|
|||||||
describe('in the middle of the rundown', () => {
|
describe('in the middle of the rundown', () => {
|
||||||
it('names cue as an increment if next event has different stem (case of numbers)', () => {
|
it('names cue as an increment if next event has different stem (case of numbers)', () => {
|
||||||
const entries: RundownEntries = {
|
const entries: RundownEntries = {
|
||||||
'1': { id: '1', cue: '1', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', cue: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', cue: '10', type: SupportedEvent.Event } as OntimeEvent,
|
'2': { id: '2', cue: '10', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
};
|
};
|
||||||
const cue = getCueCandidate(entries, ['1', '2'], '1');
|
const cue = getCueCandidate(entries, ['1', '2'], '1');
|
||||||
expect(cue).toBe('2');
|
expect(cue).toBe('2');
|
||||||
@@ -150,8 +150,8 @@ describe('findCueName() with mixed events', () => {
|
|||||||
|
|
||||||
it('names cue as an increment if next event has different stem (case of letters)', () => {
|
it('names cue as an increment if next event has different stem (case of letters)', () => {
|
||||||
const entries: RundownEntries = {
|
const entries: RundownEntries = {
|
||||||
'1': { id: '1', cue: 'Presenter', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', cue: 'Presenter', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', cue: 'Interval', type: SupportedEvent.Event } as OntimeEvent,
|
'2': { id: '2', cue: 'Interval', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
};
|
};
|
||||||
const cue = getCueCandidate(entries, ['1', '2'], '1');
|
const cue = getCueCandidate(entries, ['1', '2'], '1');
|
||||||
expect(cue).toBe('Presenter2');
|
expect(cue).toBe('Presenter2');
|
||||||
@@ -159,8 +159,8 @@ describe('findCueName() with mixed events', () => {
|
|||||||
|
|
||||||
it('creates decimal stem if next cue has same stem (case of numbers)', () => {
|
it('creates decimal stem if next cue has same stem (case of numbers)', () => {
|
||||||
const entries: RundownEntries = {
|
const entries: RundownEntries = {
|
||||||
'1': { id: '1', cue: '1', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', cue: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', cue: '2', type: SupportedEvent.Event } as OntimeEvent,
|
'2': { id: '2', cue: '2', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
};
|
};
|
||||||
const cue = getCueCandidate(entries, ['1', '2'], '1');
|
const cue = getCueCandidate(entries, ['1', '2'], '1');
|
||||||
expect(cue).toBe('1.1');
|
expect(cue).toBe('1.1');
|
||||||
@@ -168,8 +168,8 @@ describe('findCueName() with mixed events', () => {
|
|||||||
|
|
||||||
it('creates decimal stem if next cue has same stem (case of letters)', () => {
|
it('creates decimal stem if next cue has same stem (case of letters)', () => {
|
||||||
const entries: RundownEntries = {
|
const entries: RundownEntries = {
|
||||||
'1': { id: '1', cue: 'Presenter1', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', cue: 'Presenter1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', cue: 'Presenter2', type: SupportedEvent.Event } as OntimeEvent,
|
'2': { id: '2', cue: 'Presenter2', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
};
|
};
|
||||||
const cue = getCueCandidate(entries, ['1', '2'], '1');
|
const cue = getCueCandidate(entries, ['1', '2'], '1');
|
||||||
expect(cue).toBe('Presenter1.1');
|
expect(cue).toBe('Presenter1.1');
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import type { OntimeBlock, OntimeDelay, OntimeEntry, OntimeEvent } from 'ontime-types';
|
import type { OntimeBlock, OntimeDelay, OntimeEntry, OntimeEvent } from 'ontime-types';
|
||||||
import { SupportedEvent } from 'ontime-types';
|
import { SupportedEntry } from 'ontime-types';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getLastEvent,
|
getLastEvent,
|
||||||
@@ -16,9 +16,9 @@ describe('getNext()', () => {
|
|||||||
it('returns the next event of type event', () => {
|
it('returns the next event of type event', () => {
|
||||||
const testRundown = {
|
const testRundown = {
|
||||||
entries: {
|
entries: {
|
||||||
'1': { id: '1', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', type: SupportedEvent.Event } as OntimeEvent,
|
'2': { id: '2', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'3': { id: '3', type: SupportedEvent.Event } as OntimeEvent,
|
'3': { id: '3', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
},
|
},
|
||||||
order: ['1', '2', '3'],
|
order: ['1', '2', '3'],
|
||||||
};
|
};
|
||||||
@@ -31,10 +31,10 @@ describe('getNext()', () => {
|
|||||||
it('returns any type of OntimeEntry ', () => {
|
it('returns any type of OntimeEntry ', () => {
|
||||||
const testRundown = {
|
const testRundown = {
|
||||||
entries: {
|
entries: {
|
||||||
'1': { id: '1', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', type: SupportedEvent.Delay } as OntimeDelay,
|
'2': { id: '2', type: SupportedEntry.Delay } as OntimeDelay,
|
||||||
'3': { id: '3', type: SupportedEvent.Block } as OntimeBlock,
|
'3': { id: '3', type: SupportedEntry.Block } as OntimeBlock,
|
||||||
'4': { id: '4', type: SupportedEvent.Event } as OntimeEvent,
|
'4': { id: '4', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
},
|
},
|
||||||
order: ['1', '2', '3', '4'],
|
order: ['1', '2', '3', '4'],
|
||||||
};
|
};
|
||||||
@@ -47,9 +47,9 @@ describe('getNext()', () => {
|
|||||||
it('returns null if none found', () => {
|
it('returns null if none found', () => {
|
||||||
const testRundown = {
|
const testRundown = {
|
||||||
entries: {
|
entries: {
|
||||||
'1': { id: '1', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', type: SupportedEvent.Event } as OntimeEvent,
|
'2': { id: '2', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'3': { id: '3', type: SupportedEvent.Event } as OntimeEvent,
|
'3': { id: '3', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
},
|
},
|
||||||
order: ['1', '2', '3'],
|
order: ['1', '2', '3'],
|
||||||
};
|
};
|
||||||
@@ -62,9 +62,9 @@ describe('getNext()', () => {
|
|||||||
describe('getNextEvent()', () => {
|
describe('getNextEvent()', () => {
|
||||||
it('returns the next event of type event', () => {
|
it('returns the next event of type event', () => {
|
||||||
const testRundown = [
|
const testRundown = [
|
||||||
{ id: '1', type: SupportedEvent.Event } as OntimeEvent,
|
{ id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
{ id: '2', type: SupportedEvent.Event } as OntimeEvent,
|
{ id: '2', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
{ id: '3', type: SupportedEvent.Event } as OntimeEvent,
|
{ id: '3', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
];
|
];
|
||||||
|
|
||||||
const { nextEvent, nextIndex } = getNextEvent(testRundown, '1');
|
const { nextEvent, nextIndex } = getNextEvent(testRundown, '1');
|
||||||
@@ -74,10 +74,10 @@ describe('getNextEvent()', () => {
|
|||||||
|
|
||||||
it('ignores other event types', () => {
|
it('ignores other event types', () => {
|
||||||
const testRundown = [
|
const testRundown = [
|
||||||
{ id: '1', type: SupportedEvent.Event } as OntimeEvent,
|
{ id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
{ id: '2', type: SupportedEvent.Delay } as OntimeDelay,
|
{ id: '2', type: SupportedEntry.Delay } as OntimeDelay,
|
||||||
{ id: '3', type: SupportedEvent.Block } as OntimeBlock,
|
{ id: '3', type: SupportedEntry.Block } as OntimeBlock,
|
||||||
{ id: '4', type: SupportedEvent.Event } as OntimeEvent,
|
{ id: '4', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
];
|
];
|
||||||
|
|
||||||
const { nextEvent, nextIndex } = getNextEvent(testRundown, '1');
|
const { nextEvent, nextIndex } = getNextEvent(testRundown, '1');
|
||||||
@@ -87,9 +87,9 @@ describe('getNextEvent()', () => {
|
|||||||
|
|
||||||
it('returns null if none found', () => {
|
it('returns null if none found', () => {
|
||||||
const testRundown = [
|
const testRundown = [
|
||||||
{ id: '1', type: SupportedEvent.Event } as OntimeEvent,
|
{ id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
{ id: '2', type: SupportedEvent.Delay } as OntimeDelay,
|
{ id: '2', type: SupportedEntry.Delay } as OntimeDelay,
|
||||||
{ id: '3', type: SupportedEvent.Block } as OntimeBlock,
|
{ id: '3', type: SupportedEntry.Block } as OntimeBlock,
|
||||||
];
|
];
|
||||||
|
|
||||||
const { nextEvent, nextIndex } = getNextEvent(testRundown, '1');
|
const { nextEvent, nextIndex } = getNextEvent(testRundown, '1');
|
||||||
@@ -102,9 +102,9 @@ describe('getPrevious()', () => {
|
|||||||
it('returns the previous event of type event', () => {
|
it('returns the previous event of type event', () => {
|
||||||
const testRundown = {
|
const testRundown = {
|
||||||
entries: {
|
entries: {
|
||||||
'1': { id: '1', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', type: SupportedEvent.Event } as OntimeEvent,
|
'2': { id: '2', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'3': { id: '3', type: SupportedEvent.Event } as OntimeEvent,
|
'3': { id: '3', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
},
|
},
|
||||||
order: ['1', '2', '3'],
|
order: ['1', '2', '3'],
|
||||||
};
|
};
|
||||||
@@ -117,10 +117,10 @@ describe('getPrevious()', () => {
|
|||||||
it('allow other event types', () => {
|
it('allow other event types', () => {
|
||||||
const testRundown = {
|
const testRundown = {
|
||||||
entries: {
|
entries: {
|
||||||
'1': { id: '1', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', type: SupportedEvent.Delay } as OntimeDelay,
|
'2': { id: '2', type: SupportedEntry.Delay } as OntimeDelay,
|
||||||
'3': { id: '3', type: SupportedEvent.Block } as OntimeBlock,
|
'3': { id: '3', type: SupportedEntry.Block } as OntimeBlock,
|
||||||
'4': { id: '4', type: SupportedEvent.Event } as OntimeEvent,
|
'4': { id: '4', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
},
|
},
|
||||||
order: ['1', '2', '3', '4'],
|
order: ['1', '2', '3', '4'],
|
||||||
};
|
};
|
||||||
@@ -133,8 +133,8 @@ describe('getPrevious()', () => {
|
|||||||
it('returns null if none found', () => {
|
it('returns null if none found', () => {
|
||||||
const testRundown = {
|
const testRundown = {
|
||||||
entries: {
|
entries: {
|
||||||
'2': { id: '2', type: SupportedEvent.Event } as OntimeEvent,
|
'2': { id: '2', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'3': { id: '3', type: SupportedEvent.Event } as OntimeEvent,
|
'3': { id: '3', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
},
|
},
|
||||||
order: ['1', '2', '3'],
|
order: ['1', '2', '3'],
|
||||||
};
|
};
|
||||||
@@ -149,9 +149,9 @@ describe('getPreviousEvent()', () => {
|
|||||||
it('returns the previous event of type event', () => {
|
it('returns the previous event of type event', () => {
|
||||||
const testRundown = {
|
const testRundown = {
|
||||||
entries: {
|
entries: {
|
||||||
'1': { id: '1', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', type: SupportedEvent.Event } as OntimeEvent,
|
'2': { id: '2', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'3': { id: '3', type: SupportedEvent.Event } as OntimeEvent,
|
'3': { id: '3', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
},
|
},
|
||||||
order: ['1', '2', '3'],
|
order: ['1', '2', '3'],
|
||||||
};
|
};
|
||||||
@@ -164,10 +164,10 @@ describe('getPreviousEvent()', () => {
|
|||||||
it('ignores other event types', () => {
|
it('ignores other event types', () => {
|
||||||
const testRundown = {
|
const testRundown = {
|
||||||
entries: {
|
entries: {
|
||||||
'1': { id: '1', type: SupportedEvent.Event } as OntimeEvent,
|
'1': { id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
'2': { id: '2', type: SupportedEvent.Delay } as OntimeDelay,
|
'2': { id: '2', type: SupportedEntry.Delay } as OntimeDelay,
|
||||||
'3': { id: '3', type: SupportedEvent.Block } as OntimeBlock,
|
'3': { id: '3', type: SupportedEntry.Block } as OntimeBlock,
|
||||||
'4': { id: '4', type: SupportedEvent.Event } as OntimeEvent,
|
'4': { id: '4', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
},
|
},
|
||||||
order: ['1', '2', '3', '4'],
|
order: ['1', '2', '3', '4'],
|
||||||
};
|
};
|
||||||
@@ -180,9 +180,9 @@ describe('getPreviousEvent()', () => {
|
|||||||
it('returns null if none found', () => {
|
it('returns null if none found', () => {
|
||||||
const testRundown = {
|
const testRundown = {
|
||||||
entries: {
|
entries: {
|
||||||
'2': { id: '2', type: SupportedEvent.Delay } as OntimeDelay,
|
'2': { id: '2', type: SupportedEntry.Delay } as OntimeDelay,
|
||||||
'3': { id: '3', type: SupportedEvent.Block } as OntimeBlock,
|
'3': { id: '3', type: SupportedEntry.Block } as OntimeBlock,
|
||||||
'4': { id: '4', type: SupportedEvent.Event } as OntimeEvent,
|
'4': { id: '4', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
},
|
},
|
||||||
order: ['2', '3', '4'],
|
order: ['2', '3', '4'],
|
||||||
};
|
};
|
||||||
@@ -244,10 +244,10 @@ describe('swapEventData', () => {
|
|||||||
describe('getLastEvent', () => {
|
describe('getLastEvent', () => {
|
||||||
it('returns the last event of type event', () => {
|
it('returns the last event of type event', () => {
|
||||||
const testRundown: OntimeEntry[] = [
|
const testRundown: OntimeEntry[] = [
|
||||||
{ id: '1', type: SupportedEvent.Event } as OntimeEvent,
|
{ id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
{ id: '2', type: SupportedEvent.Delay } as OntimeDelay,
|
{ id: '2', type: SupportedEntry.Delay } as OntimeDelay,
|
||||||
{ id: '3', type: SupportedEvent.Event } as OntimeEvent,
|
{ id: '3', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
{ id: '4', type: SupportedEvent.Block } as OntimeBlock,
|
{ id: '4', type: SupportedEntry.Block } as OntimeBlock,
|
||||||
];
|
];
|
||||||
|
|
||||||
const { lastEvent } = getLastEvent(testRundown);
|
const { lastEvent } = getLastEvent(testRundown);
|
||||||
@@ -255,7 +255,7 @@ describe('getLastEvent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('handles rundowns with a single event', () => {
|
it('handles rundowns with a single event', () => {
|
||||||
const testRundown: OntimeEntry[] = [{ id: '1', type: SupportedEvent.Event } as OntimeEvent];
|
const testRundown: OntimeEntry[] = [{ id: '1', type: SupportedEntry.Event } as OntimeEvent];
|
||||||
const { lastEvent } = getLastEvent(testRundown);
|
const { lastEvent } = getLastEvent(testRundown);
|
||||||
expect(lastEvent?.id).toBe('1');
|
expect(lastEvent?.id).toBe('1');
|
||||||
});
|
});
|
||||||
@@ -263,10 +263,10 @@ describe('getLastEvent', () => {
|
|||||||
describe('getLastNormal', () => {
|
describe('getLastNormal', () => {
|
||||||
it('returns the last entry', () => {
|
it('returns the last entry', () => {
|
||||||
const entries = {
|
const entries = {
|
||||||
4: { id: '4', type: SupportedEvent.Block } as OntimeBlock,
|
4: { id: '4', type: SupportedEntry.Block } as OntimeBlock,
|
||||||
1: { id: '1', type: SupportedEvent.Event } as OntimeEvent,
|
1: { id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
3: { id: '3', type: SupportedEvent.Event } as OntimeEvent,
|
3: { id: '3', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
2: { id: '2', type: SupportedEvent.Delay } as OntimeDelay,
|
2: { id: '2', type: SupportedEntry.Delay } as OntimeDelay,
|
||||||
};
|
};
|
||||||
|
|
||||||
const order = ['1', '2', '3', '4'];
|
const order = ['1', '2', '3', '4'];
|
||||||
@@ -277,7 +277,7 @@ describe('getLastEvent', () => {
|
|||||||
|
|
||||||
it('handles rundowns with a single event', () => {
|
it('handles rundowns with a single event', () => {
|
||||||
const entries = {
|
const entries = {
|
||||||
1: { id: '1', type: SupportedEvent.Event } as OntimeEvent,
|
1: { id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
};
|
};
|
||||||
|
|
||||||
const lastEvent = getLastNormal(entries, ['1']);
|
const lastEvent = getLastNormal(entries, ['1']);
|
||||||
@@ -286,8 +286,8 @@ describe('getLastEvent', () => {
|
|||||||
|
|
||||||
it('handles empty order', () => {
|
it('handles empty order', () => {
|
||||||
const testRundown = {
|
const testRundown = {
|
||||||
1: { id: '1', type: SupportedEvent.Event } as OntimeEvent,
|
1: { id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
2: { id: '2', type: SupportedEvent.Event } as OntimeEvent,
|
2: { id: '2', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
};
|
};
|
||||||
|
|
||||||
const lastEntry = getLastNormal(testRundown, []);
|
const lastEntry = getLastNormal(testRundown, []);
|
||||||
@@ -303,14 +303,14 @@ describe('getLastEvent', () => {
|
|||||||
describe('getPreviousBlock()', () => {
|
describe('getPreviousBlock()', () => {
|
||||||
const testRundown = {
|
const testRundown = {
|
||||||
entries: {
|
entries: {
|
||||||
a: { id: 'a', type: SupportedEvent.Event } as OntimeEvent,
|
a: { id: 'a', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
b: { id: 'b', type: SupportedEvent.Event } as OntimeEvent,
|
b: { id: 'b', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
c: { id: 'c', type: SupportedEvent.Event } as OntimeEvent,
|
c: { id: 'c', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
d: { id: 'd', type: SupportedEvent.Delay } as OntimeDelay,
|
d: { id: 'd', type: SupportedEntry.Delay } as OntimeDelay,
|
||||||
e: { id: 'e', type: SupportedEvent.Block } as OntimeBlock,
|
e: { id: 'e', type: SupportedEntry.Block } as OntimeBlock,
|
||||||
f: { id: 'f', type: SupportedEvent.Event } as OntimeEvent,
|
f: { id: 'f', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
g: { id: 'g', type: SupportedEvent.Block } as OntimeBlock,
|
g: { id: 'g', type: SupportedEntry.Block } as OntimeBlock,
|
||||||
h: { id: 'h', type: SupportedEvent.Event } as OntimeEvent,
|
h: { id: 'h', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
},
|
},
|
||||||
order: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],
|
order: ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h'],
|
||||||
};
|
};
|
||||||
@@ -331,7 +331,7 @@ describe('getLastEvent', () => {
|
|||||||
it('also works on index 0', () => {
|
it('also works on index 0', () => {
|
||||||
testRundown.order.unshift('0');
|
testRundown.order.unshift('0');
|
||||||
// @ts-expect-error -- we are adding an event to the rundown
|
// @ts-expect-error -- we are adding an event to the rundown
|
||||||
testRundown.entries['0'] = { id: '0', type: SupportedEvent.Block } as OntimeBlock;
|
testRundown.entries['0'] = { id: '0', type: SupportedEntry.Block } as OntimeBlock;
|
||||||
const block = getPreviousBlock(testRundown, 'a');
|
const block = getPreviousBlock(testRundown, 'a');
|
||||||
expect(block?.id).toBe('0');
|
expect(block?.id).toBe('0');
|
||||||
});
|
});
|
||||||
@@ -339,11 +339,11 @@ describe('getLastEvent', () => {
|
|||||||
it('returns the parent block if nested event', () => {
|
it('returns the parent block if nested event', () => {
|
||||||
const testRundown = {
|
const testRundown = {
|
||||||
entries: {
|
entries: {
|
||||||
1: { id: '1', type: SupportedEvent.Event } as OntimeEvent,
|
1: { id: '1', type: SupportedEntry.Event } as OntimeEvent,
|
||||||
block: { id: 'block', type: SupportedEvent.Block, events: ['21', '22', '23'] } as OntimeBlock,
|
block: { id: 'block', type: SupportedEntry.Block, events: ['21', '22', '23'] } as OntimeBlock,
|
||||||
21: { id: '21', type: SupportedEvent.Event, parent: 'block' } as OntimeEvent,
|
21: { id: '21', type: SupportedEntry.Event, parent: 'block' } as OntimeEvent,
|
||||||
22: { id: '22', type: SupportedEvent.Event, parent: 'block' } as OntimeEvent,
|
22: { id: '22', type: SupportedEntry.Event, parent: 'block' } as OntimeEvent,
|
||||||
23: { id: '23', type: SupportedEvent.Event, parent: 'block' } as OntimeEvent,
|
23: { id: '23', type: SupportedEntry.Event, parent: 'block' } as OntimeEvent,
|
||||||
},
|
},
|
||||||
order: ['1', 'block'],
|
order: ['1', 'block'],
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user