2021-06-03 23:34:40 +02:00
|
|
|
import FlexContainer from "./flex_container.js";
|
2021-06-05 14:01:21 +02:00
|
|
|
import splitService from "../../services/resizer.js";
|
2025-01-05 12:21:01 +02:00
|
|
|
import RightPanelWidget from "../right_panel_widget.js";
|
|
|
|
|
|
|
|
export default class RightPaneContainer extends FlexContainer<RightPanelWidget> {
|
|
|
|
|
|
|
|
private rightPaneHidden: boolean;
|
2021-06-03 23:34:40 +02:00
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super('column');
|
|
|
|
|
|
|
|
this.id('right-pane');
|
|
|
|
this.css('height', '100%');
|
2021-06-13 22:55:31 +02:00
|
|
|
this.collapsible();
|
2024-01-28 08:58:40 +01:00
|
|
|
|
|
|
|
this.rightPaneHidden = false;
|
2021-06-03 23:34:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
isEnabled() {
|
2022-05-30 17:45:59 +02:00
|
|
|
return super.isEnabled()
|
2024-01-28 08:58:40 +01:00
|
|
|
&& !this.rightPaneHidden
|
2022-05-30 17:45:59 +02:00
|
|
|
&& this.children.length > 0
|
|
|
|
&& !!this.children.find(ch => ch.isEnabled() && ch.canBeShown());
|
2021-06-03 23:34:40 +02:00
|
|
|
}
|
|
|
|
|
2025-01-05 12:21:01 +02:00
|
|
|
handleEventInChildren(name: string, data: unknown) {
|
2021-06-03 23:34:40 +02:00
|
|
|
const promise = super.handleEventInChildren(name, data);
|
|
|
|
|
|
|
|
if (['activeContextChanged', 'noteSwitchedAndActivated', 'noteSwitched'].includes(name)) {
|
2023-06-30 11:18:34 +02:00
|
|
|
// the right pane is displayed only if some child widget is active,
|
2021-06-03 23:34:40 +02:00
|
|
|
// we'll reevaluate the visibility based on events which are probable to cause visibility change
|
2023-06-30 11:18:34 +02:00
|
|
|
// but these events need to be finished and only then we check
|
2022-06-23 23:03:35 +02:00
|
|
|
if (promise) {
|
2023-01-24 16:24:51 +01:00
|
|
|
promise.then(() => this.reEvaluateRightPaneVisibilityCommand());
|
2022-06-23 23:03:35 +02:00
|
|
|
}
|
|
|
|
else {
|
2023-01-24 16:24:51 +01:00
|
|
|
this.reEvaluateRightPaneVisibilityCommand();
|
2022-06-23 23:03:35 +02:00
|
|
|
}
|
2021-06-03 23:34:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return promise;
|
|
|
|
}
|
2022-05-30 17:45:59 +02:00
|
|
|
|
2023-01-24 16:24:51 +01:00
|
|
|
reEvaluateRightPaneVisibilityCommand() {
|
2022-05-30 17:45:59 +02:00
|
|
|
const oldToggle = !this.isHiddenInt();
|
|
|
|
const newToggle = this.isEnabled();
|
|
|
|
|
|
|
|
if (oldToggle !== newToggle) {
|
|
|
|
this.toggleInt(newToggle);
|
|
|
|
|
|
|
|
splitService.setupRightPaneResizer();
|
|
|
|
}
|
|
|
|
}
|
2024-01-28 08:58:40 +01:00
|
|
|
|
|
|
|
toggleRightPaneEvent() {
|
|
|
|
this.rightPaneHidden = !this.rightPaneHidden;
|
|
|
|
|
|
|
|
this.reEvaluateRightPaneVisibilityCommand();
|
|
|
|
}
|
2021-06-03 23:34:40 +02:00
|
|
|
}
|