From 116d5b9b007c8b21c210a5559ee19c31e4299606 Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Mon, 26 Aug 2019 16:12:15 +0200 Subject: [PATCH] Fix dialogs --- uikit/lib/modal.ts | 13 ++++++------- windows/prefs.ts | 2 +- windows/select.ts | 3 +-- windows/single.ts | 3 +-- 4 files changed, 9 insertions(+), 12 deletions(-) diff --git a/uikit/lib/modal.ts b/uikit/lib/modal.ts index 52f612d..bee054a 100644 --- a/uikit/lib/modal.ts +++ b/uikit/lib/modal.ts @@ -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 { - throw new Error("Not implemented"); - } + abstract getContent(): + Promise | 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"; diff --git a/windows/prefs.ts b/windows/prefs.ts index bb17d26..3c18a3c 100644 --- a/windows/prefs.ts +++ b/windows/prefs.ts @@ -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() { diff --git a/windows/select.ts b/windows/select.ts index 8f0fda6..c73db0a 100644 --- a/windows/select.ts +++ b/windows/select.ts @@ -51,10 +51,9 @@ function matched(item: any) { } class PausedModalDialog extends ModalDialog { - get content() { + getContent() { const tmpl = $("#paused-template"); const content = tmpl.content.cloneNode(true) as DocumentFragment; - localize(content); return content; } diff --git a/windows/single.ts b/windows/single.ts index 716f196..f5cbf51 100644 --- a/windows/single.ts +++ b/windows/single.ts @@ -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;