11import * as React from 'react'
2- // @ts -expect-error No types available
3- import * as VelocityReact from 'velocity-react'
42import { i18nTranslator } from '../i18n'
53import { translateMessage } from '@sofie-automation/corelib/dist/TranslatableMessage'
64import { doUserAction , UserAction } from '../../lib/clientUserAction'
@@ -22,7 +20,7 @@ import {
2220import { useTranslation } from 'react-i18next'
2321import { useTracker } from '../../lib/ReactMeteorData/ReactMeteorData'
2422import _ from 'underscore'
25- import { Segments } from '../../collections'
23+ import { Segments , PieceInstances } from '../../collections'
2624import { UIPartInstances , UIParts } from '../Collections'
2725import { useSelection } from '../RundownView/SelectedElementsContext'
2826import { DBSegment } from '@sofie-automation/corelib/dist/dataModel/Segment'
@@ -46,75 +44,81 @@ export function PropertiesPanel(): JSX.Element {
4644 }
4745 } , [ ] )
4846
47+ const pieceInstance = useTracker (
48+ ( ) => PieceInstances . findOne ( { _id : selectedElement . elementId } ) ,
49+ [ selectedElement ?. elementId ]
50+ )
51+
4952 const partInstance = useTracker (
50- ( ) => UIPartInstances . findOne ( { _id : selectedElement . elementId } ) ,
51- [ selectedElement . elementId ]
53+ ( ) => UIPartInstances . findOne ( { _id : pieceInstance ? pieceInstance . partInstanceId : selectedElement . elementId } ) ,
54+ [ selectedElement ? .elementId ]
5255 )
5356 const part = useTracker ( ( ) => UIParts . findOne ( { _id : partInstance ?. part . _id } ) , [ partInstance ?. part . _id ] )
5457
5558 const segment : DBSegment | undefined = useTracker (
5659 ( ) => Segments . findOne ( { _id : part ? part . segmentId : selectedElement . elementId } ) ,
57- [ selectedElement . elementId ]
60+ [ selectedElement ? .elementId ]
5861 )
5962 const rundownId = part ? part . rundownId : segment ?. rundownId
6063
6164 if ( ! rundownId ) return < > </ >
6265
6366 return (
6467 < div className = "propertiespanel-pop-up" >
65- { selectedElement . type === 'partInstance' && (
66- < >
67- < div className = "propertiespanel-pop-up__header" >
68- { part ?. userEditOperations &&
69- part . userEditOperations . map ( ( operation ) => {
70- if ( operation . type === UserEditingType . FORM || ! operation . svgIcon || ! operation . isActive ) return null
68+ { selectedElement . type === 'partInstance' ||
69+ ( selectedElement . type === 'pieceInstance' && (
70+ < >
71+ < div className = "propertiespanel-pop-up__header" >
72+ { part ?. userEditOperations &&
73+ part . userEditOperations . map ( ( operation ) => {
74+ if ( operation . type === UserEditingType . FORM || ! operation . svgIcon || ! operation . isActive ) return null
7175
72- return (
73- < div
74- key = { operation . id }
75- className = "svg"
76- dangerouslySetInnerHTML = { {
77- __html : operation . svgIcon ,
78- } }
79- > </ div >
80- )
81- } ) }
82- PART : { String ( part ?. title ) }
83- </ div >
84- < div className = "propertiespanel-pop-up__contents" >
85- { segment &&
86- part ?. _id &&
87- part . userEditOperations ?. map ( ( userEditOperation , i ) => {
88- switch ( userEditOperation . type ) {
89- case UserEditingType . ACTION :
90- return (
91- < EditingTypeAction
92- key = { i }
93- userEditOperation = { userEditOperation }
94- segment = { segment }
95- part = { part }
96- rundownId = { rundownId }
97- />
98- )
99- case UserEditingType . FORM :
100- return (
101- < EditingTypeChangeSource
102- key = { i }
103- userEditOperation = { userEditOperation }
104- segment = { segment }
105- part = { part }
106- rundownId = { rundownId }
107- />
108- )
109- default :
110- assertNever ( userEditOperation )
111- return null
112- }
113- } ) }
114- < hr />
115- </ div >
116- </ >
117- ) }
76+ return (
77+ < div
78+ key = { operation . id }
79+ className = "svg"
80+ dangerouslySetInnerHTML = { {
81+ __html : operation . svgIcon ,
82+ } }
83+ > </ div >
84+ )
85+ } ) }
86+ PART : { String ( part ?. title ) }
87+ </ div >
88+ < div className = "propertiespanel-pop-up__contents" >
89+ { segment &&
90+ part ?. _id &&
91+ part . userEditOperations ?. map ( ( userEditOperation , i ) => {
92+ switch ( userEditOperation . type ) {
93+ case UserEditingType . ACTION :
94+ return (
95+ < EditingTypeAction
96+ key = { i }
97+ userEditOperation = { userEditOperation }
98+ segment = { segment }
99+ part = { part }
100+ rundownId = { rundownId }
101+ />
102+ )
103+ case UserEditingType . FORM :
104+ return (
105+ < EditingTypeChangeSource
106+ key = { i }
107+ userEditOperation = { userEditOperation }
108+ segment = { segment }
109+ part = { part }
110+ rundownId = { rundownId }
111+ />
112+ )
113+ default :
114+ assertNever ( userEditOperation )
115+ return null
116+ }
117+ } ) }
118+ < hr />
119+ </ div >
120+ </ >
121+ ) ) }
118122 { selectedElement . type === 'segment' && (
119123 < >
120124 < div className = "propertiespanel-pop-up__header" >
@@ -305,7 +309,7 @@ function EditingTypeChangeSource(props: {
305309 enum : string [ ]
306310 tsEnumNames : string [ ]
307311 }
308- let groups : UserEditingGroupingType [ ] = clone ( props . userEditOperation . grouping ) || [ ]
312+ const groups : UserEditingGroupingType [ ] = clone ( props . userEditOperation . grouping ) || [ ]
309313 const numberOfEmptySlots = 14 - groups . length
310314 for ( let i = 0 ; i < numberOfEmptySlots ; i ++ ) {
311315 groups . push ( { } )
0 commit comments