web/admin: fix ScopeMapping requiring description

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-08-10 23:26:17 +02:00
parent 34fe250fb0
commit 0f5e0a774a
2 changed files with 10 additions and 11 deletions

View File

@ -46,6 +46,8 @@ export class ModalButton extends LitElement {
@property({ type: Boolean })
open = false;
handlerBound = false;
static get styles(): CSSResult[] {
return [
PFBase,
@ -64,20 +66,22 @@ export class ModalButton extends LitElement {
];
}
firstUpdated(): void {
connectedCallback(): void {
if (this.handlerBound) return;
window.addEventListener("keyup", this.keyUpHandler);
this.handlerBound = true;
}
keyUpHandler = (e: KeyboardEvent) => {
keyUpHandler = (e: KeyboardEvent): void => {
if (e.code === "Escape") {
this.resetForms();
this.open = false;
}
}
};
disconnectedCallback(): void {
super.disconnectedCallback()
window.removeEventListener("keyup", this.keyUpHandler)
super.disconnectedCallback();
window.removeEventListener("keyup", this.keyUpHandler);
}
resetForms(): void {

View File

@ -58,16 +58,11 @@ export class PropertyMappingScopeForm extends ModelForm<ScopeMapping, string> {
${t`Scope which the client can specify to access these properties.`}
</p>
</ak-form-element-horizontal>
<ak-form-element-horizontal
label=${t`Description`}
?required=${true}
name="description"
>
<ak-form-element-horizontal label=${t`Description`} name="description">
<input
type="text"
value="${ifDefined(this.instance?.description)}"
class="pf-c-form-control"
required
/>
<p class="pf-c-form__helper-text">
${t`Description shown to the user when consenting. If left empty, the user won't be informed.`}