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:
parent
335131affc
commit
4ed8171130
|
@ -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,26 +163,19 @@ 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`
|
||||
if (this.shouldRenderInWrapper(prompt)) {
|
||||
return html`<ak-form-element
|
||||
label="${prompt.label}"
|
||||
?required="${prompt.required}"
|
||||
class="pf-c-form__group"
|
||||
.errors=${(this.challenge?.responseErrors || {})[prompt.fieldKey]}
|
||||
>
|
||||
${unsafeHTML(this.renderPromptInner(prompt, false))}
|
||||
${this.renderPromptHelpText(prompt)}
|
||||
`;
|
||||
</ak-form-element>`;
|
||||
}
|
||||
return html`<ak-form-element
|
||||
label="${prompt.label}"
|
||||
?required="${prompt.required}"
|
||||
class="pf-c-form__group"
|
||||
.errors=${(this.challenge?.responseErrors || {})[prompt.fieldKey]}
|
||||
>
|
||||
${unsafeHTML(this.renderPromptInner(prompt, false))}
|
||||
${this.renderPromptHelpText(prompt)}
|
||||
</ak-form-element>`;
|
||||
return html` ${unsafeHTML(this.renderPromptInner(prompt, false))}
|
||||
${this.renderPromptHelpText(prompt)}`;
|
||||
}
|
||||
|
||||
renderContinue(): TemplateResult {
|
||||
|
|
|
@ -36,19 +36,24 @@ 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}`}
|
||||
?required=${prompt.required}
|
||||
name=${prompt.fieldKey}
|
||||
?invalid=${errors !== undefined}
|
||||
.errorMessages=${(errors || []).map((error) => {
|
||||
return error.string;
|
||||
})}
|
||||
>
|
||||
${unsafeHTML(this.renderPromptInner(prompt, true))}
|
||||
${this.renderPromptHelpText(prompt)}
|
||||
</ak-form-element-horizontal>
|
||||
`;
|
||||
}
|
||||
return html`
|
||||
<ak-form-element-horizontal
|
||||
label=${t`${prompt.label}`}
|
||||
?required=${prompt.required}
|
||||
name=${prompt.fieldKey}
|
||||
?invalid=${errors !== undefined}
|
||||
.errorMessages=${(errors || []).map((error) => {
|
||||
return error.string;
|
||||
})}
|
||||
>
|
||||
${unsafeHTML(this.renderPromptInner(prompt, true))}
|
||||
${this.renderPromptHelpText(prompt)}
|
||||
</ak-form-element-horizontal>
|
||||
${unsafeHTML(this.renderPromptInner(prompt, true))} ${this.renderPromptHelpText(prompt)}
|
||||
`;
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue