2021-03-28 22:24:24 +02:00
import options from "../../services/options.js" ;
2020-02-07 22:19:35 +01:00
import FlexContainer from "./flex_container.js" ;
2025-01-18 12:56:00 +02:00
import appContext , { type EventData } from "../../components/app_context.js" ;
import type Component from "../../components/component.js" ;
2020-02-04 22:46:17 +01:00
2025-01-18 12:56:00 +02:00
export default class LeftPaneContainer extends FlexContainer < Component > {
2025-05-18 10:22:49 +08:00
private currentLeftPaneVisible : boolean ;
2021-05-22 21:35:25 +02:00
constructor ( ) {
2025-01-09 18:07:02 +02:00
super ( "column" ) ;
2020-02-04 22:46:17 +01:00
2025-05-18 10:22:49 +08:00
this . currentLeftPaneVisible = options . is ( "leftPaneVisible" ) ;
2025-01-09 18:07:02 +02:00
this . id ( "left-pane" ) ;
this . css ( "height" , "100%" ) ;
2021-06-13 22:55:31 +02:00
this . collapsible ( ) ;
2020-02-04 22:46:17 +01:00
}
2020-02-08 21:54:39 +01:00
isEnabled() {
2025-05-18 10:22:49 +08:00
return super . isEnabled ( ) && this . currentLeftPaneVisible ;
2020-02-08 21:54:39 +01:00
}
2025-01-18 12:56:00 +02:00
entitiesReloadedEvent ( { loadResults } : EventData < "entitiesReloaded" > ) {
2025-05-09 22:31:16 +08:00
if ( loadResults . isOptionReloaded ( "leftPaneVisible" ) && document . hasFocus ( ) ) {
2025-05-18 10:22:49 +08:00
// options.is("leftPaneVisible") changed — it may or may not be the same as currentLeftPaneVisible, but as long as the window is focused, the left pane visibility should be toggled.
this . currentLeftPaneVisible = ! this . currentLeftPaneVisible ;
2023-01-31 22:35:01 +01:00
const visible = this . isEnabled ( ) ;
this . toggleInt ( visible ) ;
if ( visible ) {
2025-01-22 21:55:42 +02:00
this . triggerEvent ( "focusTree" , { } ) ;
2023-01-31 22:35:01 +01:00
} else {
2025-03-03 21:02:18 +01:00
this . triggerEvent ( "focusOnDetail" , { ntxId : appContext.tabManager.getActiveContext ( ) ? . ntxId } ) ;
2023-01-31 22:35:01 +01:00
}
2020-02-04 22:46:17 +01:00
}
}
2021-03-28 22:24:24 +02:00
}