add grid toggle button to left panel

This commit is contained in:
Bruno Windels 2020-10-07 12:31:52 +02:00
parent 7955462dda
commit 1ff6d36ec3
2 changed files with 13 additions and 2 deletions

View File

@ -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;
}

View File

@ -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(
{