4a91a7d2e2
* fix repo in api client Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * web: re-organise files to match their interface Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * core: include version in script tags Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * cleanup maybe broken Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * revert rename Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * web: get rid of Client.ts Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * move more to common Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * more moving Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * format Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * unfuck files that vscode fucked, thanks Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * move more Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * finish moving (maybe) Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * ok more moving Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * fix more stuff that vs code destroyed Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * get rid "web" prefix for virtual package Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * fix locales Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * use custom base element Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * fix css file Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * don't run autoDetectLanguage when importing locale Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * fix circular dependencies Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> * web: fix build Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org> Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
92 lines
2.9 KiB
TypeScript
92 lines
2.9 KiB
TypeScript
import { AKElement } from "@goauthentik/elements/Base";
|
|
import { PFSize } from "@goauthentik/elements/Spinner";
|
|
import { MODAL_BUTTON_STYLES } from "@goauthentik/elements/buttons/ModalButton";
|
|
import { Table } from "@goauthentik/elements/table/Table";
|
|
|
|
import { CSSResult } from "lit";
|
|
import { TemplateResult, html } from "lit";
|
|
import { property } from "lit/decorators.js";
|
|
|
|
import AKGlobal from "@goauthentik/common/styles/authentik.css";
|
|
import PFBackdrop from "@patternfly/patternfly/components/Backdrop/backdrop.css";
|
|
import PFContent from "@patternfly/patternfly/components/Content/content.css";
|
|
import PFModalBox from "@patternfly/patternfly/components/ModalBox/modal-box.css";
|
|
import PFPage from "@patternfly/patternfly/components/Page/page.css";
|
|
import PFBullseye from "@patternfly/patternfly/layouts/Bullseye/bullseye.css";
|
|
import PFStack from "@patternfly/patternfly/layouts/Stack/stack.css";
|
|
|
|
export abstract class TableModal<T> extends Table<T> {
|
|
@property()
|
|
size: PFSize = PFSize.Large;
|
|
|
|
@property({ type: Boolean })
|
|
open = false;
|
|
|
|
static get styles(): CSSResult[] {
|
|
return super.styles.concat(
|
|
PFModalBox,
|
|
PFBullseye,
|
|
PFContent,
|
|
PFBackdrop,
|
|
PFPage,
|
|
PFStack,
|
|
AKGlobal,
|
|
MODAL_BUTTON_STYLES,
|
|
);
|
|
}
|
|
|
|
constructor() {
|
|
super();
|
|
window.addEventListener("keyup", (e) => {
|
|
if (e.code === "Escape") {
|
|
this.resetForms();
|
|
this.open = false;
|
|
}
|
|
});
|
|
}
|
|
|
|
resetForms(): void {
|
|
this.querySelectorAll<HTMLFormElement>("[slot=form]").forEach((form) => {
|
|
if ("resetForm" in form) {
|
|
form?.resetForm();
|
|
}
|
|
});
|
|
}
|
|
|
|
onClick(): void {
|
|
this.open = true;
|
|
this.querySelectorAll("*").forEach((child) => {
|
|
if ("requestUpdate" in child) {
|
|
(child as AKElement).requestUpdate();
|
|
}
|
|
});
|
|
}
|
|
|
|
renderModalInner(): TemplateResult {
|
|
return this.renderTable();
|
|
}
|
|
|
|
renderModal(): TemplateResult {
|
|
return html`<div class="pf-c-backdrop">
|
|
<div class="pf-l-bullseye">
|
|
<div class="pf-c-modal-box ${this.size}" role="dialog" aria-modal="true">
|
|
<button
|
|
@click=${() => (this.open = false)}
|
|
class="pf-c-button pf-m-plain"
|
|
type="button"
|
|
aria-label="Close dialog"
|
|
>
|
|
<i class="fas fa-times" aria-hidden="true"></i>
|
|
</button>
|
|
${this.renderModalInner()}
|
|
</div>
|
|
</div>
|
|
</div>`;
|
|
}
|
|
|
|
render(): TemplateResult {
|
|
return html` <slot name="trigger" @click=${() => this.onClick()}></slot>
|
|
${this.open ? this.renderModal() : ""}`;
|
|
}
|
|
}
|