web/user: fix static prompt fields being rendered with label

closes #2584

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2022-05-28 20:05:43 +02:00
parent 335131affc
commit 4ed8171130
2 changed files with 39 additions and 29 deletions

View File

@ -133,6 +133,18 @@ export class PromptStage extends BaseStage<PromptChallenge, PromptChallengeRespo
return html`<p class="pf-c-form__helper-text">${unsafeHTML(prompt.subText)}</p>`;
}
shouldRenderInWrapper(prompt: StagePrompt): bool {
// Special types that aren't rendered in a wrapper
if (
prompt.type === PromptTypeEnum.Static ||
prompt.type === PromptTypeEnum.Hidden ||
prompt.type === PromptTypeEnum.Separator
) {
return false;
}
return true;
}
renderField(prompt: StagePrompt): TemplateResult {
// Checkbox is rendered differently
if (prompt.type === PromptTypeEnum.Checkbox) {
@ -151,17 +163,7 @@ export class PromptStage extends BaseStage<PromptChallenge, PromptChallengeRespo
<p class="pf-c-form__helper-text">${unsafeHTML(prompt.subText)}</p>
</div>`;
}
// Special types that aren't rendered in a wrapper
if (
prompt.type === PromptTypeEnum.Static ||
prompt.type === PromptTypeEnum.Hidden ||
prompt.type === PromptTypeEnum.Separator
) {
return html`
${unsafeHTML(this.renderPromptInner(prompt, false))}
${this.renderPromptHelpText(prompt)}
`;
}
if (this.shouldRenderInWrapper(prompt)) {
return html`<ak-form-element
label="${prompt.label}"
?required="${prompt.required}"
@ -172,6 +174,9 @@ export class PromptStage extends BaseStage<PromptChallenge, PromptChallengeRespo
${this.renderPromptHelpText(prompt)}
</ak-form-element>`;
}
return html` ${unsafeHTML(this.renderPromptInner(prompt, false))}
${this.renderPromptHelpText(prompt)}`;
}
renderContinue(): TemplateResult {
return html` <div class="pf-c-form__group pf-m-action">

View File

@ -36,6 +36,7 @@ export class UserSettingsPromptStage extends PromptStage {
renderField(prompt: StagePrompt): TemplateResult {
const errors = (this.challenge?.responseErrors || {})[prompt.fieldKey];
if (this.shouldRenderInWrapper(prompt)) {
return html`
<ak-form-element-horizontal
label=${t`${prompt.label}`}
@ -51,6 +52,10 @@ export class UserSettingsPromptStage extends PromptStage {
</ak-form-element-horizontal>
`;
}
return html`
${unsafeHTML(this.renderPromptInner(prompt, true))} ${this.renderPromptHelpText(prompt)}
`;
}
renderContinue(): TemplateResult {
return html` <div class="pf-c-form__group pf-m-action">