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 }) @property({ type: Boolean })
open = false; open = false;
handlerBound = false;
static get styles(): CSSResult[] { static get styles(): CSSResult[] {
return [ return [
PFBase, PFBase,
@ -64,20 +66,22 @@ export class ModalButton extends LitElement {
]; ];
} }
firstUpdated(): void { connectedCallback(): void {
if (this.handlerBound) return;
window.addEventListener("keyup", this.keyUpHandler); window.addEventListener("keyup", this.keyUpHandler);
this.handlerBound = true;
} }
keyUpHandler = (e: KeyboardEvent) => { keyUpHandler = (e: KeyboardEvent): void => {
if (e.code === "Escape") { if (e.code === "Escape") {
this.resetForms(); this.resetForms();
this.open = false; this.open = false;
} }
} };
disconnectedCallback(): void { disconnectedCallback(): void {
super.disconnectedCallback() super.disconnectedCallback();
window.removeEventListener("keyup", this.keyUpHandler) window.removeEventListener("keyup", this.keyUpHandler);
} }
resetForms(): void { 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.`} ${t`Scope which the client can specify to access these properties.`}
</p> </p>
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal <ak-form-element-horizontal label=${t`Description`} name="description">
label=${t`Description`}
?required=${true}
name="description"
>
<input <input
type="text" type="text"
value="${ifDefined(this.instance?.description)}" value="${ifDefined(this.instance?.description)}"
class="pf-c-form-control" class="pf-c-form-control"
required
/> />
<p class="pf-c-form__helper-text"> <p class="pf-c-form__helper-text">
${t`Description shown to the user when consenting. If left empty, the user won't be informed.`} ${t`Description shown to the user when consenting. If left empty, the user won't be informed.`}