From 1ff6d36ec3012616d662d7fcfe24c92424496785 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Wed, 7 Oct 2020 12:31:52 +0200 Subject: [PATCH] add grid toggle button to left panel --- src/domain/session/leftpanel/LeftPanelViewModel.js | 12 +++++++++++- src/ui/web/session/leftpanel/LeftPanelView.js | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/domain/session/leftpanel/LeftPanelViewModel.js b/src/domain/session/leftpanel/LeftPanelViewModel.js index 50864b4c..fe5ce05b 100644 --- a/src/domain/session/leftpanel/LeftPanelViewModel.js +++ b/src/domain/session/leftpanel/LeftPanelViewModel.js @@ -23,7 +23,8 @@ import {ApplyMap} from "../../../observable/map/ApplyMap.js"; export class LeftPanelViewModel extends ViewModel { constructor(options) { super(options); - const {rooms, openRoom} = options; + const {rooms, openRoom, gridEnabled} = options; + this._gridEnabled = gridEnabled; const roomTileVMs = rooms.mapValues((room, emitChange) => { return new RoomTileViewModel({ room, @@ -35,6 +36,15 @@ export class LeftPanelViewModel extends ViewModel { this._roomList = this._roomListFilterMap.sortValues((a, b) => a.compare(b)); } + get gridEnabled() { + return this._gridEnabled.get(); + } + + toggleGrid() { + this._gridEnabled.set(!this._gridEnabled.get()); + this.emitChange("gridEnabled"); + } + get roomList() { return this._roomList; } diff --git a/src/ui/web/session/leftpanel/LeftPanelView.js b/src/ui/web/session/leftpanel/LeftPanelView.js index f262e954..d7c588ad 100644 --- a/src/ui/web/session/leftpanel/LeftPanelView.js +++ b/src/ui/web/session/leftpanel/LeftPanelView.js @@ -40,7 +40,8 @@ export class LeftPanelView extends TemplateView { t.button({onClick: () => { filterInput.value = ""; vm.clearFilter(); - }}, vm.i18n`Clear`) + }}, vm.i18n`Clear`), + t.button({onClick: () => vm.toggleGrid()}, vm => vm.gridEnabled ? "Single" : "Grid") ]), t.view(new ListView( {