web/admin: only set ?writeOnly when editing an object

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-04-04 20:11:57 +02:00
parent 93b362570d
commit 85121de9d7
5 changed files with 6 additions and 6 deletions

View file

@ -60,7 +60,7 @@ export class HorizontalFormElement extends LitElement {
if (this.writeOnly && !this.writeOnlyActivated) { if (this.writeOnly && !this.writeOnlyActivated) {
const i = (input as HTMLInputElement); const i = (input as HTMLInputElement);
i.setAttribute("hidden", "true"); i.setAttribute("hidden", "true");
const handler = (ev: Event) => { const handler = () => {
i.removeAttribute("hidden"); i.removeAttribute("hidden");
this.writeOnlyActivated = true; this.writeOnlyActivated = true;
i.parentElement?.removeEventListener("click", handler); i.parentElement?.removeEventListener("click", handler);

View file

@ -48,14 +48,14 @@ export class CertificateKeyPairForm extends Form<CertificateKeyPair> {
<ak-form-element-horizontal <ak-form-element-horizontal
label=${t`Certificate`} label=${t`Certificate`}
name="certificateData" name="certificateData"
?writeOnly=${true} ?writeOnly=${this.keyPair !== undefined}
?required=${true}> ?required=${true}>
<textarea class="pf-c-form-control" required>${ifDefined(this.keyPair?.certificateData)}</textarea> <textarea class="pf-c-form-control" required>${ifDefined(this.keyPair?.certificateData)}</textarea>
<p class="pf-c-form__helper-text">${t`PEM-encoded Certificate data.`}</p> <p class="pf-c-form__helper-text">${t`PEM-encoded Certificate data.`}</p>
</ak-form-element-horizontal> </ak-form-element-horizontal>
<ak-form-element-horizontal <ak-form-element-horizontal
name="keyData" name="keyData"
?writeOnly=${true} ?writeOnly=${this.keyPair !== undefined}
label=${t`Private Key`}> label=${t`Private Key`}>
<textarea class="pf-c-form-control" >${ifDefined(this.keyPair?.keyData)}</textarea> <textarea class="pf-c-form-control" >${ifDefined(this.keyPair?.keyData)}</textarea>
<p class="pf-c-form__helper-text">${t`Optional Private Key. If this is set, you can use this keypair for encryption.`}</p> <p class="pf-c-form__helper-text">${t`Optional Private Key. If this is set, you can use this keypair for encryption.`}</p>

View file

@ -119,7 +119,7 @@ export class LDAPSourceForm extends Form<LDAPSource> {
<ak-form-element-horizontal <ak-form-element-horizontal
label=${t`Bind Password`} label=${t`Bind Password`}
?required=${true} ?required=${true}
?writeOnly=${true} ?writeOnly=${this.source !== undefined}
name="bindPassword"> name="bindPassword">
<input type="text" value="${ifDefined(this.source?.bindPassword)}" class="pf-c-form-control" required> <input type="text" value="${ifDefined(this.source?.bindPassword)}" class="pf-c-form-control" required>
</ak-form-element-horizontal> </ak-form-element-horizontal>

View file

@ -66,7 +66,7 @@ export class CaptchaStageForm extends Form<CaptchaStage> {
<ak-form-element-horizontal <ak-form-element-horizontal
label=${t`Private Key`} label=${t`Private Key`}
?required=${true} ?required=${true}
?writeOnly=${true} ?writeOnly=${this.stage !== undefined}
name="privateKey"> name="privateKey">
<input type="text" value="${ifDefined(this.stage?.privateKey || "")}" class="pf-c-form-control" required> <input type="text" value="${ifDefined(this.stage?.privateKey || "")}" class="pf-c-form-control" required>
<p class="pf-c-form__helper-text">${t`Private key, acquired from https://www.google.com/recaptcha/intro/v3.html.`}</p> <p class="pf-c-form__helper-text">${t`Private key, acquired from https://www.google.com/recaptcha/intro/v3.html.`}</p>

View file

@ -78,7 +78,7 @@ export class EmailStageForm extends Form<EmailStage> {
<ak-form-element-horizontal <ak-form-element-horizontal
label=${t`SMTP Password`} label=${t`SMTP Password`}
?required=${true} ?required=${true}
?writeOnly=${true} ?writeOnly=${this.stage !== undefined}
name="password"> name="password">
<input type="text" value="${ifDefined(this.stage?.password || "")}" class="pf-c-form-control" required> <input type="text" value="${ifDefined(this.stage?.password || "")}" class="pf-c-form-control" required>
</ak-form-element-horizontal> </ak-form-element-horizontal>