import { gettext } from "django"; import { customElement, html, property, TemplateResult } from "lit-element"; import { BaseInheritanceModel } from "../../api/Client"; import { ModalButton } from "../buttons/ModalButton"; export interface DeletableObject extends BaseInheritanceModel { name: string | number; } @customElement("ak-forms-delete") export class DeleteForm extends ModalButton { @property() obj?: DeletableObject; @property() objectLabel?: string; @property({attribute: false}) delete!: () => Promise; confirm(): void { this.delete().then(() => { this.open = false; this.dispatchEvent( new CustomEvent("ak-refresh", { bubbles: true, composed: true, }) ); }); } renderModalInner(): TemplateResult { return html`

${gettext(`Delete ${(this.obj?.verboseName) || this.objectLabel}`)}

${gettext( `Are you sure you want to delete ${(this.obj?.verboseName) || this.objectLabel} '${this.obj?.name}'?` )}

`; } }