From f842d5baf4417eb8755e8c517966f9c3ae05af22 Mon Sep 17 00:00:00 2001 From: cv <34649812+cpvalente@users.noreply.github.com> Date: Sat, 2 Sep 2023 13:15:37 +0200 Subject: [PATCH] feat: allow configuring fields --- .../view-params-editor/constants.ts | 22 +++++++++ .../client/src/features/operator/Operator.tsx | 19 +++++-- .../operator/operator-event/OperatorEvent.tsx | 49 +++++++++++++------ 3 files changed, 72 insertions(+), 18 deletions(-) diff --git a/apps/client/src/common/components/view-params-editor/constants.ts b/apps/client/src/common/components/view-params-editor/constants.ts index 2407369cfb..a3cebc54ed 100644 --- a/apps/client/src/common/components/view-params-editor/constants.ts +++ b/apps/client/src/common/components/view-params-editor/constants.ts @@ -219,6 +219,28 @@ export const getOperatorOptions = (userFields: UserFields): ParamField[] => { description: 'Whether to events that have passed', type: 'boolean', }, + { + id: 'main', + title: 'Main data field', + description: 'Field to be shown in the first line of text', + type: 'option', + values: { + title: 'Title', + subtitle: 'Subtitle', + presenter: 'Presenter', + }, + }, + { + id: 'secondary', + title: 'Secondary data field', + description: 'Field to be shown in the second line of text', + type: 'option', + values: { + title: 'Title', + subtitle: 'Subtitle', + presenter: 'Presenter', + }, + }, { id: 'subscribe', title: 'Highlight Field', diff --git a/apps/client/src/features/operator/Operator.tsx b/apps/client/src/features/operator/Operator.tsx index 938cf95af9..edee9d37b8 100644 --- a/apps/client/src/features/operator/Operator.tsx +++ b/apps/client/src/features/operator/Operator.tsx @@ -1,6 +1,6 @@ import { useEffect, useRef, useState } from 'react'; import { useSearchParams } from 'react-router-dom'; -import { isOntimeEvent, SupportedEvent, UserFields } from 'ontime-types'; +import { isOntimeEvent, OntimeEvent, SupportedEvent, UserFields } from 'ontime-types'; import { getFirstEvent, getLastEvent } from 'ontime-utils'; import NavigationMenu from '../../common/components/navigation-menu/NavigationMenu'; @@ -23,6 +23,7 @@ import style from './Operator.module.scss'; const selectedOffset = 50; +type TitleFields = Pick; export default function Operator() { const { data, status } = useRundown(); const { data: userFields, status: userFieldsStatus } = useUserFields(); @@ -91,6 +92,8 @@ export default function Operator() { // get fields which the user subscribed to const subscribe = searchParams.get('subscribe') as keyof UserFields | null; + const main = searchParams.get('main') as keyof TitleFields | null; + const secondary = searchParams.get('secondary') as keyof TitleFields | null; const subscribedAlias = subscribe ? userFields[subscribe] : ''; const showSeconds = isStringBoolean(searchParams.get('showseconds')); @@ -129,13 +132,23 @@ export default function Operator() { return null; } + const mainField = main ? entry?.[main] || entry.title : entry.title; + const secondaryField = secondary ? entry?.[secondary] || entry.subtitle : entry.subtitle; + const subscribedData = (subscribe ? entry?.[subscribe] : undefined) || ''; + return ( {cue} - {data.title} + {main} {start} - {end} - {data.subtitle} + {secondary} - - {isSelected ? : formatTime(data.duration, { showSeconds: true, format: 'hh:mm:ss' })} + + {isSelected ? : formatTime(duration, { showSeconds: true, format: 'hh:mm:ss' })}
- {subscribedData && ( + {subscribed && ( <> {subscribedAlias} - {subscribedData} + {subscribed} )}