mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-19 22:24:11 +00:00
chore: improve convention entry <> event
This commit is contained in:
@@ -10,7 +10,7 @@ import {
|
||||
isOntimeEvent,
|
||||
OntimeEntry,
|
||||
Playback,
|
||||
SupportedEvent,
|
||||
SupportedEntry,
|
||||
} from 'ontime-types';
|
||||
import {
|
||||
getFirstNormal,
|
||||
@@ -84,7 +84,7 @@ export default function Rundown({ data }: RundownProps) {
|
||||
return;
|
||||
}
|
||||
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
|
||||
const newEvent = cloneEvent(cloneEntry);
|
||||
addEntry(newEvent, { after: adjustedCursor ?? undefined });
|
||||
@@ -94,7 +94,7 @@ export default function Rundown({ data }: RundownProps) {
|
||||
);
|
||||
|
||||
const insertAtId = useCallback(
|
||||
(patch: Partial<OntimeEntry> & { type: SupportedEvent }, id: MaybeString, above = false) => {
|
||||
(patch: Partial<OntimeEntry> & { type: SupportedEntry }, id: MaybeString, above = false) => {
|
||||
const options: EventOptions =
|
||||
id === null
|
||||
? {}
|
||||
@@ -202,14 +202,14 @@ export default function Rundown({ data }: RundownProps) {
|
||||
|
||||
['mod + Backspace', () => deleteAtCursor(cursor), { preventDefault: true }],
|
||||
|
||||
['alt + E', () => insertAtId({ type: SupportedEvent.Event }, cursor), { preventDefault: true }],
|
||||
['alt + shift + E', () => insertAtId({ type: SupportedEvent.Event }, cursor, true), { preventDefault: true }],
|
||||
['alt + E', () => insertAtId({ type: SupportedEntry.Event }, cursor), { preventDefault: true }],
|
||||
['alt + shift + E', () => insertAtId({ type: SupportedEntry.Event }, cursor, true), { preventDefault: true }],
|
||||
|
||||
['alt + B', () => insertAtId({ type: SupportedEvent.Block }, cursor), { preventDefault: true }],
|
||||
['alt + shift + B', () => insertAtId({ type: SupportedEvent.Block }, cursor, true), { preventDefault: true }],
|
||||
['alt + B', () => insertAtId({ type: SupportedEntry.Block }, cursor), { preventDefault: true }],
|
||||
['alt + shift + B', () => insertAtId({ type: SupportedEntry.Block }, cursor, true), { preventDefault: true }],
|
||||
|
||||
['alt + D', () => insertAtId({ type: SupportedEvent.Delay }, cursor), { preventDefault: true }],
|
||||
['alt + shift + D', () => insertAtId({ type: SupportedEvent.Delay }, cursor, true), { preventDefault: true }],
|
||||
['alt + D', () => insertAtId({ type: SupportedEntry.Delay }, cursor), { preventDefault: true }],
|
||||
['alt + shift + D', () => insertAtId({ type: SupportedEntry.Delay }, cursor, true), { preventDefault: true }],
|
||||
|
||||
['mod + C', () => setEntryCopyId(cursor)],
|
||||
['mod + V', () => insertCopyAtId(cursor, entryCopyId)],
|
||||
@@ -254,7 +254,7 @@ export default function Rundown({ data }: RundownProps) {
|
||||
};
|
||||
|
||||
if (statefulEntries.length < 1) {
|
||||
return <RundownEmpty handleAddNew={() => insertAtId({ type: SupportedEvent.Event }, cursor)} />;
|
||||
return <RundownEmpty handleAddNew={() => insertAtId({ type: SupportedEntry.Event }, cursor)} />;
|
||||
}
|
||||
|
||||
// 1. gather presentation options
|
||||
@@ -292,7 +292,7 @@ export default function Rundown({ data }: RundownProps) {
|
||||
<BlockBlock data={entry} hasCursor={hasCursor}>
|
||||
{entry.events.length === 0 && (
|
||||
<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) => {
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
OntimeEntry,
|
||||
OntimeEvent,
|
||||
Playback,
|
||||
SupportedEvent,
|
||||
SupportedEntry,
|
||||
} from 'ontime-types';
|
||||
|
||||
import { useEntryActions } from '../../common/hooks/useEntryAction';
|
||||
@@ -33,7 +33,7 @@ export type EventItemActions =
|
||||
| 'clear-report';
|
||||
|
||||
interface RundownEntryProps {
|
||||
type: SupportedEvent;
|
||||
type: SupportedEntry;
|
||||
isPast: boolean;
|
||||
data: OntimeEntry;
|
||||
loaded: boolean;
|
||||
@@ -86,7 +86,7 @@ export default function RundownEntry(props: RundownEntryProps) {
|
||||
const actionHandler = useMemoisedFn((action: EventItemActions, payload?: number | FieldValue) => {
|
||||
switch (action) {
|
||||
case 'event': {
|
||||
const newEvent = { type: SupportedEvent.Event };
|
||||
const newEvent = { type: SupportedEntry.Event };
|
||||
const options = {
|
||||
after: data.id,
|
||||
lastEventId: previousEventId,
|
||||
@@ -94,23 +94,23 @@ export default function RundownEntry(props: RundownEntryProps) {
|
||||
return addEntry(newEvent, options);
|
||||
}
|
||||
case 'event-before': {
|
||||
const newEvent = { type: SupportedEvent.Event };
|
||||
const newEvent = { type: SupportedEntry.Event };
|
||||
const options = {
|
||||
after: previousEntryId,
|
||||
};
|
||||
return addEntry(newEvent, options);
|
||||
}
|
||||
case 'delay': {
|
||||
return addEntry({ type: SupportedEvent.Delay }, { after: data.id });
|
||||
return addEntry({ type: SupportedEntry.Delay }, { after: data.id });
|
||||
}
|
||||
case 'delay-before': {
|
||||
return addEntry({ type: SupportedEvent.Delay }, { after: previousEntryId });
|
||||
return addEntry({ type: SupportedEntry.Delay }, { after: previousEntryId });
|
||||
}
|
||||
case 'block': {
|
||||
return addEntry({ type: SupportedEvent.Block }, { after: data.id });
|
||||
return addEntry({ type: SupportedEntry.Block }, { after: data.id });
|
||||
}
|
||||
case 'block-before': {
|
||||
return addEntry({ type: SupportedEvent.Block }, { after: previousEntryId });
|
||||
return addEntry({ type: SupportedEntry.Block }, { after: previousEntryId });
|
||||
}
|
||||
case 'swap': {
|
||||
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';
|
||||
|
||||
@@ -8,7 +8,7 @@ describe('makeRundownMetadata()', () => {
|
||||
const demoEvents = {
|
||||
'1': {
|
||||
id: '1',
|
||||
type: SupportedEvent.Event,
|
||||
type: SupportedEntry.Event,
|
||||
parent: null,
|
||||
timeStart: 0,
|
||||
timeEnd: 1,
|
||||
@@ -20,12 +20,12 @@ describe('makeRundownMetadata()', () => {
|
||||
} as OntimeEvent,
|
||||
block: {
|
||||
id: 'block',
|
||||
type: SupportedEvent.Block,
|
||||
type: SupportedEntry.Block,
|
||||
events: ['11, 12, 13'],
|
||||
} as OntimeBlock,
|
||||
'11': {
|
||||
id: '11',
|
||||
type: SupportedEvent.Event,
|
||||
type: SupportedEntry.Event,
|
||||
parent: 'block',
|
||||
timeStart: 10,
|
||||
timeEnd: 11,
|
||||
@@ -37,7 +37,7 @@ describe('makeRundownMetadata()', () => {
|
||||
} as OntimeEvent,
|
||||
'12': {
|
||||
id: '12',
|
||||
type: SupportedEvent.Event,
|
||||
type: SupportedEntry.Event,
|
||||
parent: 'block',
|
||||
timeStart: 11,
|
||||
timeEnd: 12,
|
||||
@@ -49,7 +49,7 @@ describe('makeRundownMetadata()', () => {
|
||||
} as OntimeEvent,
|
||||
'13': {
|
||||
id: '13',
|
||||
type: SupportedEvent.Event,
|
||||
type: SupportedEntry.Event,
|
||||
parent: 'block',
|
||||
timeStart: 12,
|
||||
timeEnd: 13,
|
||||
@@ -61,7 +61,7 @@ describe('makeRundownMetadata()', () => {
|
||||
} as OntimeEvent,
|
||||
'2': {
|
||||
id: '2',
|
||||
type: SupportedEvent.Event,
|
||||
type: SupportedEntry.Event,
|
||||
parent: null,
|
||||
timeStart: 20,
|
||||
timeEnd: 21,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { memo, useRef } from 'react';
|
||||
import { IoAdd } from 'react-icons/io5';
|
||||
import { Button } from '@chakra-ui/react';
|
||||
import { MaybeString, SupportedEvent } from 'ontime-types';
|
||||
import { MaybeString, SupportedEntry } from 'ontime-types';
|
||||
|
||||
import { useEntryActions } from '../../../common/hooks/useEntryAction';
|
||||
|
||||
@@ -24,7 +24,7 @@ function QuickAddBlock(props: QuickAddBlockProps) {
|
||||
const addEvent = () => {
|
||||
addEntry(
|
||||
{
|
||||
type: SupportedEvent.Event,
|
||||
type: SupportedEntry.Event,
|
||||
parent: parentBlock ?? null,
|
||||
},
|
||||
{
|
||||
@@ -39,7 +39,7 @@ function QuickAddBlock(props: QuickAddBlockProps) {
|
||||
const addDelay = () => {
|
||||
addEntry(
|
||||
// TODO(v4): add delays to blocks
|
||||
{ type: SupportedEvent.Delay },
|
||||
{ type: SupportedEntry.Delay },
|
||||
{
|
||||
lastEventId: previousEventId,
|
||||
after: previousEventId,
|
||||
@@ -52,7 +52,7 @@ function QuickAddBlock(props: QuickAddBlockProps) {
|
||||
return;
|
||||
}
|
||||
addEntry(
|
||||
{ type: SupportedEvent.Block },
|
||||
{ type: SupportedEntry.Block },
|
||||
{
|
||||
lastEventId: previousEventId,
|
||||
after: previousEventId,
|
||||
|
||||
Reference in New Issue
Block a user