@@ -25,6 +25,7 @@ import { useTracker } from '../../lib/ReactMeteorData/ReactMeteorData'
2525import _ from 'underscore'
2626import { Segments } from '../../collections'
2727import { UIParts } from '../Collections'
28+ import { useSelection } from '../RundownView/SelectedElementsContext'
2829
2930/**
3031 * Propertiespanel PopUp props.
@@ -36,7 +37,11 @@ interface Props {
3637 contextMenuContext : IContextMenuContext | null
3738}
3839
39- export function PropertiesPanel ( props : Props ) {
40+ export function PropertiesPanel ( props : Props ) : JSX . Element {
41+ const { listSelectedElements } = useSelection ( )
42+ console . log ( 'listSelectedElements' , listSelectedElements ( ) )
43+ const selectedElement = listSelectedElements ( ) ?. [ 0 ]
44+
4045 const { t } = useTranslation ( )
4146
4247 React . useEffect ( ( ) => {
@@ -50,23 +55,17 @@ export function PropertiesPanel(props: Props) {
5055 } , [ ] )
5156
5257 const rundownId = props . contextMenuContext ?. segment ?. rundownId
53- const part = useTracker (
54- ( ) => UIParts . findOne ( { _id : props . contextMenuContext ?. part ?. instance . part ?. _id } ) ,
55- [ props . contextMenuContext ?. part ?. instance . part ] ,
56- props . contextMenuContext ?. part ?. instance . part
57- )
58+ const part = useTracker ( ( ) => UIParts . findOne ( { _id : selectedElement . elementId } ) , [ selectedElement . elementId ] )
5859
60+ console . log ( 'Context Segment id' , props . contextMenuContext ?. segment ?. _id )
5961 const segment = useTracker (
60- ( ) => Segments . findOne ( { rundownId : rundownId , _id : props . contextMenuContext ?. segment ?. _id } ) ,
61- [ props . contextMenuContext ?. segment ] ,
62- props . contextMenuContext ?. segment
62+ ( ) => Segments . findOne ( { rundownId : rundownId , _id : selectedElement . elementId } ) ,
63+ [ selectedElement . elementId ]
6364 )
6465
65- const isPartSelected = getTimePosition ( props . contextMenuContext || { } )
66-
6766 return (
6867 < div className = "propertiespanel-pop-up" >
69- { isPartSelected && (
68+ { selectedElement . type === 'partInstance' && (
7069 < >
7170 < div className = "propertiespanel-pop-up__header" >
7271 { part ?. userEditOperations &&
@@ -86,8 +85,7 @@ export function PropertiesPanel(props: Props) {
8685 PART : { String ( part ?. title ) }
8786 </ div >
8887 < div className = "propertiespanel-pop-up__contents" >
89- { isPartSelected &&
90- segment &&
88+ { segment &&
9189 part ?. _id &&
9290 part . userEditOperations ?. map ( ( userEditOperation , i ) => {
9391 switch ( userEditOperation . type ) {
@@ -116,7 +114,7 @@ export function PropertiesPanel(props: Props) {
116114 </ div >
117115 </ >
118116 ) }
119- { ! isPartSelected && (
117+ { selectedElement . type === 'segment' && (
120118 < >
121119 < div className = "propertiespanel-pop-up__header" >
122120 { segment ?. userEditOperations &&
@@ -180,9 +178,10 @@ export function PropertiesPanel(props: Props) {
180178 pieceExternalId : undefined ,
181179 } ,
182180 {
183- id : isPartSelected
184- ? DefaultUserOperationsTypes . REVERT_PART
185- : DefaultUserOperationsTypes . REVERT_SEGMENT ,
181+ id :
182+ selectedElement . type === 'partInstance'
183+ ? DefaultUserOperationsTypes . REVERT_PART
184+ : DefaultUserOperationsTypes . REVERT_SEGMENT ,
186185 }
187186 )
188187 )
0 commit comments