Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion web/src/flow/stages/prompt/PromptStage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ ${prompt.initialValue}</textarea
return html`<input
type="email"
id=${fieldId}
autocomplete="email"
name="${prompt.fieldKey}"
placeholder="${prompt.placeholder}"
class="pf-c-form-control"
Expand Down Expand Up @@ -243,9 +244,10 @@ ${prompt.initialValue}</textarea
}

renderPromptHelpText(prompt: StagePrompt) {
if (prompt.subText === "") {
if (!prompt.subText) {
return nothing;
}

return html`<p class="pf-c-form__helper-text">${unsafeHTML(prompt.subText)}</p>`;
}

Expand Down
37 changes: 25 additions & 12 deletions web/src/user/user-settings/details/stages/prompt/PromptStage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,31 @@ import "#flow/components/ak-flow-card";

import { globalAK } from "#common/global";

import { AKLabel } from "#components/ak-label";

import { PromptStage } from "#flow/stages/prompt/PromptStage";

import { PromptTypeEnum, StagePrompt } from "@goauthentik/api";

import { msg, str } from "@lit/localize";
import { msg } from "@lit/localize";
import { html, nothing, TemplateResult } from "lit";
import { customElement } from "lit/decorators.js";

@customElement("ak-user-stage-prompt")
export class UserSettingsPromptStage extends PromptStage {
renderPromptInner(prompt: StagePrompt): TemplateResult {
return prompt.type === PromptTypeEnum.Checkbox
? html`<input
type="checkbox"
class="pf-c-check__input"
name="${prompt.fieldKey}"
?checked=${prompt.initialValue !== ""}
?required=${prompt.required}
style="vertical-align: bottom"
/>`
: super.renderPromptInner(prompt);
if (prompt.type === PromptTypeEnum.Checkbox) {
return html`<input
type="checkbox"
class="pf-c-check__input"
name=${prompt.fieldKey}
?checked=${prompt.initialValue !== ""}
?required=${prompt.required}
style="vertical-align: bottom"
/>`;
}

return super.renderPromptInner(prompt);
}

renderField(prompt: StagePrompt): TemplateResult {
Expand All @@ -32,11 +36,20 @@ export class UserSettingsPromptStage extends PromptStage {
if (this.shouldRenderInWrapper(prompt)) {
return html`
<ak-form-element-horizontal
label=${msg(str`${prompt.label}`)}
?required=${prompt.required}
name=${prompt.fieldKey}
.errorMessages=${errors}
>
<div slot="label" class="pf-c-form__group-label">
${AKLabel(
{
htmlFor: `field-${prompt.fieldKey}`,
required: prompt.required,
},
prompt.label,
)}
</div>

${this.renderPromptInner(prompt)} ${this.renderPromptHelpText(prompt)}
</ak-form-element-horizontal>
`;
Expand Down
Loading