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

View File

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

View File

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

View File

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