Fix dialogs

This commit is contained in:
Nils Maier 2019-08-26 16:12:15 +02:00
parent 976c57c043
commit 116d5b9b00
4 changed files with 9 additions and 12 deletions

View File

@ -8,7 +8,7 @@ interface ModalButton {
dismiss?: boolean;
}
export default class ModalDialog {
export default abstract class ModalDialog {
private _showing: any;
private _dismiss: HTMLButtonElement | null;
@ -87,9 +87,8 @@ export default class ModalDialog {
return el;
}
getContent(): Promise<DocumentFragment | HTMLElement> {
throw new Error("Not implemented");
}
abstract getContent():
Promise<DocumentFragment | HTMLElement> | HTMLElement | DocumentFragment;
get buttons(): ModalButton[] {
return [
@ -205,7 +204,7 @@ export default class ModalDialog {
*/
static async inform(title: string, text: string, oktext: string) {
const dialog = new class extends ModalDialog {
get content() {
getContent() {
const rv = document.createDocumentFragment();
const h = document.createElement("h1");
h.textContent = title || "Information";
@ -241,7 +240,7 @@ export default class ModalDialog {
static async confirm(title: string, text: string) {
const dialog = new class extends ModalDialog {
get content() {
getContent() {
const rv = document.createDocumentFragment();
const h = document.createElement("h1");
h.textContent = title || "Confirm";
@ -280,7 +279,7 @@ export default class ModalDialog {
const dialog = new class extends ModalDialog {
_input: HTMLInputElement;
get content() {
getContent() {
const rv = document.createDocumentFragment();
const h = document.createElement("h1");
h.textContent = title || "Confirm";

View File

@ -116,7 +116,7 @@ class CreateFilterDialog extends ModalDialog {
this.expr = $("#filter-create-expr", rv);
this.link = $("#filter-create-type-link", rv);
this.media = $("#filter-create-type-media", rv);
return Promise.resolve(rv);
return rv;
}
get buttons() {

View File

@ -51,10 +51,9 @@ function matched(item: any) {
}
class PausedModalDialog extends ModalDialog {
get content() {
getContent() {
const tmpl = $<HTMLTemplateElement>("#paused-template");
const content = tmpl.content.cloneNode(true) as DocumentFragment;
localize(content);
return content;
}

View File

@ -27,10 +27,9 @@ class BatchModalDialog extends ModalDialog {
this.gen = gen;
}
get content() {
getContent() {
const tmpl = $("#batch-template") as HTMLTemplateElement;
const content = tmpl.content.cloneNode(true) as DocumentFragment;
localize(content);
$(".batch-items", content).textContent = this.gen.length.toLocaleString();
$(".batch-preview", content).textContent = this.gen.preview;
return content;