check confirmation string

This commit is contained in:
sua yoo 2024-05-07 15:14:27 -07:00
parent 13b6a5b15f
commit e7df805b51
No known key found for this signature in database
GPG Key ID: 5AD1B4C02D4F0567

View File

@ -1,7 +1,7 @@
import { localized, msg, str } from "@lit/localize"; import { localized, msg, str } from "@lit/localize";
import type { SlInput } from "@shoelace-style/shoelace"; import type { SlChangeEvent, SlInput } from "@shoelace-style/shoelace";
import { html, type TemplateResult } from "lit"; import { html, type TemplateResult } from "lit";
import { customElement, property, query } from "lit/decorators.js"; import { customElement, property, query, state } from "lit/decorators.js";
import { when } from "lit/directives/when.js"; import { when } from "lit/directives/when.js";
import { TailwindElement } from "@/classes/TailwindElement"; import { TailwindElement } from "@/classes/TailwindElement";
@ -26,6 +26,9 @@ export class OrgsList extends TailwindElement {
@property({ type: Object }) @property({ type: Object })
currOrg?: OrgData | null = null; currOrg?: OrgData | null = null;
@state()
enableDeleteButton = false;
@query("#orgDeleteDialog") @query("#orgDeleteDialog")
orgDeleteDialog?: Dialog | null; orgDeleteDialog?: Dialog | null;
@ -122,7 +125,13 @@ export class OrgsList extends TailwindElement {
</li> </li>
</ul> </ul>
<sl-divider></sl-divider> <sl-divider></sl-divider>
<sl-input placeholder=${confirmationStr}> <sl-input
placeholder=${confirmationStr}
@sl-input=${(e: SlChangeEvent) => {
const { value } = e.target as SlInput;
this.enableDeleteButton = value === confirmationStr;
}}
>
<strong slot="label" class="font-semibold"> <strong slot="label" class="font-semibold">
${msg(str`Type "${confirmationStr}" to confirm`)} ${msg(str`Type "${confirmationStr}" to confirm`)}
</strong> </strong>
@ -132,9 +141,13 @@ export class OrgsList extends TailwindElement {
<div slot="footer" class="flex justify-end"> <div slot="footer" class="flex justify-end">
<sl-button <sl-button
size="small" size="small"
@click="${this.onSubmitQuotas}" @click=${() => {
console.log("TODO");
}}
variant="danger" variant="danger"
>${msg("Delete Org")} ?disabled=${!this.enableDeleteButton}
>
${msg("Delete Org")}
</sl-button> </sl-button>
</div> </div>
</btrix-dialog> </btrix-dialog>