2020-01-15 21:36:01 +01:00
|
|
|
import Component from "./component.js";
|
|
|
|
|
|
|
|
class BasicWidget extends Component {
|
2020-01-11 21:19:56 +01:00
|
|
|
constructor(appContext) {
|
2020-01-15 21:36:01 +01:00
|
|
|
super(appContext);
|
2020-01-11 21:19:56 +01:00
|
|
|
this.widgetId = `widget-${this.constructor.name}`;
|
|
|
|
}
|
|
|
|
|
2020-01-14 20:27:40 +01:00
|
|
|
renderTo($parent) {
|
|
|
|
$parent.append(this.render());
|
|
|
|
}
|
|
|
|
|
2020-01-11 21:19:56 +01:00
|
|
|
render() {
|
|
|
|
// actual rendering is async
|
2020-01-14 20:27:40 +01:00
|
|
|
this.$widget = this.doRender();
|
2020-01-12 20:15:05 +01:00
|
|
|
|
|
|
|
// $widget.attr('id', this.widgetId);
|
2020-01-11 21:19:56 +01:00
|
|
|
|
2020-01-14 20:27:40 +01:00
|
|
|
return this.$widget;
|
2020-01-11 21:19:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* for overriding
|
|
|
|
*/
|
2020-01-12 20:15:05 +01:00
|
|
|
doRender() {}
|
2020-01-11 21:19:56 +01:00
|
|
|
|
2020-01-14 20:27:40 +01:00
|
|
|
toggle(show) {
|
|
|
|
this.$widget.toggle(show);
|
|
|
|
}
|
|
|
|
|
2020-01-11 21:19:56 +01:00
|
|
|
cleanup() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default BasicWidget;
|