Files
owl/web/static/src/ts/widgets/Discuss.ts
T

44 lines
1.2 KiB
TypeScript
Raw Normal View History

2019-01-24 10:33:11 +01:00
import { Widget } from "../core/widget";
2019-01-23 14:28:41 +01:00
import { Env } from "../env";
import { Clock } from "./clock";
import { Counter } from "./counter";
2019-01-28 21:32:21 +01:00
export class Discuss extends Widget<Env, {}> {
template = "discuss";
widgets = { Clock, Counter, ColorWidget };
state = { validcounter: true, color: "red" };
resetCounter(ev: MouseEvent) {
2019-01-25 10:25:42 +01:00
if (this.refs.counter instanceof Counter) {
this.refs.counter.updateState({ counter: 3 });
}
}
resetCounterAsync(ev: MouseEvent) {
setTimeout(() => {
if (this.refs.counter2 instanceof Counter) {
this.refs.counter2.updateState({ counter: 300 });
2019-01-25 10:25:42 +01:00
}
}, 3000);
}
toggle() {
this.updateState({ validcounter: !this.state.validcounter });
}
2019-01-28 12:13:03 +01:00
toggleColor() {
const newColor = this.state.color === "red" ? "blue" : "red";
this.updateState({ color: newColor });
}
2019-01-29 15:19:02 +01:00
2019-01-29 16:13:05 +01:00
addNotif(sticky: boolean) {
2019-01-29 15:19:02 +01:00
const text = (<any>this.refs.textinput).value;
const message = `It is now ${new Date().toLocaleTimeString()}.<br/> Msg: ${text}`;
2019-01-29 16:13:05 +01:00
this.env.notifications.add({ title: "hey", message: message, sticky });
2019-01-29 15:19:02 +01:00
}
2019-01-28 12:13:03 +01:00
}
2019-01-28 21:32:21 +01:00
class ColorWidget extends Widget<Env, { color: "red" | "blue" }> {
template = "colorwidget";
}