2020-10-07 15:54:44 +05:30
|
|
|
/*
|
2020-10-19 18:25:01 +05:30
|
|
|
Copyright 2020 The Matrix.org Foundation C.I.C.
|
2020-10-07 15:54:44 +05:30
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
import {RoomView} from "./room/RoomView.js";
|
2021-04-21 20:55:59 +05:30
|
|
|
import {InviteView} from "./room/InviteView.js";
|
2020-10-07 15:54:44 +05:30
|
|
|
import {TemplateView} from "../general/TemplateView.js";
|
2020-10-08 19:44:59 +05:30
|
|
|
import {StaticView} from "../general/StaticView.js";
|
2020-10-07 15:54:44 +05:30
|
|
|
|
|
|
|
export class RoomGridView extends TemplateView {
|
|
|
|
render(t, vm) {
|
2020-10-07 17:48:35 +05:30
|
|
|
const children = [];
|
2020-10-08 17:47:43 +05:30
|
|
|
for (let i = 0; i < (vm.height * vm.width); i+=1) {
|
|
|
|
children.push(t.div({
|
2020-10-12 21:19:06 +05:30
|
|
|
onClick: () => vm.focusTile(i),
|
|
|
|
onFocusin: () => vm.focusTile(i),
|
2020-10-08 17:47:43 +05:30
|
|
|
className: {
|
|
|
|
"container": true,
|
|
|
|
[`tile${i}`]: true,
|
|
|
|
"focused": vm => vm.focusIndex === i
|
|
|
|
},
|
2021-04-21 19:18:41 +05:30
|
|
|
}, t.mapView(vm => vm.roomViewModelAt(i), roomVM => {
|
2020-10-08 17:47:43 +05:30
|
|
|
if (roomVM) {
|
2021-04-21 20:55:59 +05:30
|
|
|
if (roomVM.kind === "invite") {
|
|
|
|
return new InviteView(roomVM);
|
|
|
|
} else {
|
|
|
|
return new RoomView(roomVM);
|
|
|
|
}
|
2020-10-08 17:47:43 +05:30
|
|
|
} else {
|
2020-10-08 19:44:59 +05:30
|
|
|
return new StaticView(t => t.div({className: "room-placeholder"}, [
|
|
|
|
t.h2({className: "focused"}, vm.i18n`Select a room on the left`),
|
|
|
|
t.h2({className: "unfocused"}, vm.i18n`Click to select this tile`),
|
|
|
|
]));
|
2020-10-08 17:47:43 +05:30
|
|
|
}
|
|
|
|
})));
|
2020-10-07 15:54:44 +05:30
|
|
|
}
|
2020-10-08 17:47:43 +05:30
|
|
|
children.push(t.div({className: vm => `focus-ring tile${vm.focusIndex}`}));
|
2020-10-19 18:22:18 +05:30
|
|
|
return t.div({className: "RoomGridView middle layout3x2"}, children);
|
2020-10-07 15:54:44 +05:30
|
|
|
}
|
|
|
|
}
|