dedicated template view for gaps

This commit is contained in:
Bruno Windels 2019-06-14 22:55:07 +02:00
parent 69be5012e8
commit f9038e2af9
2 changed files with 19 additions and 1 deletions

View file

@ -1,6 +1,7 @@
import TimelineTile from "./TimelineTile.js"; import TimelineTile from "./TimelineTile.js";
import ListView from "./ListView.js"; import ListView from "./ListView.js";
import * as html from "./html.js"; import * as html from "./html.js";
import GapView from "./timeline/GapView.js";
export default class RoomView { export default class RoomView {
constructor(viewModel) { constructor(viewModel) {
@ -16,7 +17,9 @@ export default class RoomView {
this._nameLabel = html.h2(null, this._viewModel.name); this._nameLabel = html.h2(null, this._viewModel.name);
this._errorLabel = html.div({className: "RoomView_error"}); this._errorLabel = html.div({className: "RoomView_error"});
this._timelineList = new ListView({}, entry => new TimelineTile(entry)); this._timelineList = new ListView({}, entry => {
return entry.shape === "gap" ? new GapView(entry) : new TimelineTile(entry);
});
this._timelineList.mount(); this._timelineList.mount();
this._root = html.div({className: "RoomView"}, [ this._root = html.div({className: "RoomView"}, [

View file

@ -0,0 +1,15 @@
import TemplateView from "../TemplateView.js";
export default class GapView extends TemplateView {
render(t, vm) {
const className = {
gap: true,
loading: vm => vm.isLoading
};
const label = (vm.isUp ? "🠝" : "🠟") + " fill gap"; //no binding
return t.li({className}, [
t.button({onClick: () => this.viewModel.fill(), disabled: vm => vm.isLoading}, label),
t.if(vm => vm.error, t => t.strong(vm => vm.error))
]);
}
}