import { gettext } from "django"; import { customElement, html, property, TemplateResult } from "lit-element"; import { EVENT_REFRESH } from "../../constants"; import { ModalButton } from "../buttons/ModalButton"; import { Form } from "./Form"; import "../buttons/SpinnerButton"; @customElement("ak-forms-modal") export class ModalForm extends ModalButton { @property({ type: Boolean }) closeAfterSuccessfulSubmit = true; confirm(): void { this.querySelectorAll>("[slot=form]").forEach(form => { const formPromise = form.submit(new Event("submit")); if (!formPromise) { return; } formPromise.then(() => { if (this.closeAfterSuccessfulSubmit) { this.open = false; form.reset(); } this.dispatchEvent( new CustomEvent(EVENT_REFRESH, { bubbles: true, composed: true, }) ); }).catch((e) => { console.log(e); }); }); } renderModalInner(): TemplateResult { return html`

`; } }