Move rightpanel to separate view and vm
Signed-off-by: RMidhunSuresh <rmidhunsuresh@gmail.com>
This commit is contained in:
parent
7e6e4ecfab
commit
b74e4452dd
2 changed files with 38 additions and 0 deletions
28
src/domain/session/rightpanel/RightPanelViewModel.js
Normal file
28
src/domain/session/rightpanel/RightPanelViewModel.js
Normal file
|
@ -0,0 +1,28 @@
|
|||
import {ViewModel} from "../../ViewModel.js";
|
||||
import {RoomDetailsViewModel} from "./RoomDetailsViewModel.js";
|
||||
|
||||
export class RightPanelViewModel extends ViewModel {
|
||||
constructor(options) {
|
||||
super(options);
|
||||
this._room = options.room;
|
||||
this._setupNavigation();
|
||||
}
|
||||
|
||||
get roomDetailsViewModel() { return this._roomDetailsViewModel; }
|
||||
|
||||
_setupNavigation() {
|
||||
const details = this.navigation.observe("details");
|
||||
this.track(details.subscribe(() => this._toggleRoomDetailsPanel()));
|
||||
this._toggleRoomDetailsPanel();
|
||||
}
|
||||
|
||||
_toggleRoomDetailsPanel() {
|
||||
this._roomDetailsViewModel = this.disposeTracked(this._roomDetailsViewModel);
|
||||
const enable = !!this.navigation.path.get("details")?.value;
|
||||
if (enable) {
|
||||
const room = this._room;
|
||||
this._roomDetailsViewModel = this.track(new RoomDetailsViewModel(this.childOptions({room})));
|
||||
}
|
||||
this.emitChange("roomDetailsViewModel");
|
||||
}
|
||||
}
|
10
src/platform/web/ui/session/rightpanel/RightPanelView.js
Normal file
10
src/platform/web/ui/session/rightpanel/RightPanelView.js
Normal file
|
@ -0,0 +1,10 @@
|
|||
import {TemplateView} from "../../general/TemplateView.js";
|
||||
import {RoomDetailsView} from "./RoomDetailsView.js";
|
||||
|
||||
export class RightPanelView extends TemplateView {
|
||||
render(t, vm) {
|
||||
return t.div({ className: "RightPanelView"},
|
||||
t.mapView(vm => vm.roomDetailsViewModel, roomDetailsViewModel => roomDetailsViewModel ? new RoomDetailsView(roomDetailsViewModel) : null)
|
||||
);
|
||||
}
|
||||
}
|
Reference in a new issue