Skip to content

Commit

Permalink
web/user: add missing checkbox element in user settings (#2762)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomtom5152 committed May 7, 2022
1 parent 22026f0 commit 948d2cb
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions web/src/user/user-settings/details/stages/prompt/PromptStage.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,39 @@
import { t } from "@lingui/macro";

import { TemplateResult, html } from "lit";
import { CSSResult, TemplateResult, html } from "lit";
import { customElement } from "lit/decorators.js";
import { unsafeHTML } from "lit/directives/unsafe-html.js";

import { StagePrompt } from "@goauthentik/api";
import PFCheck from "@patternfly/patternfly/components/Check/check.css";

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

import "../../../../../elements/forms/HorizontalFormElement";
import { PromptStage } from "../../../../../flows/stages/prompt/PromptStage";

@customElement("ak-user-stage-prompt")
export class UserSettingsPromptStage extends PromptStage {
static get styles(): CSSResult[] {
return super.styles.concat([PFCheck]);
}

renderPromptInner(prompt: StagePrompt, placeholderAsValue: boolean): string {
switch (prompt.type) {
// Checkbox requires slightly different rendering here due to the use of horizontal form elements
case PromptTypeEnum.Checkbox:
return `<input
type="checkbox"
class="pf-c-check__input"
name="${prompt.fieldKey}"
?checked=${prompt.placeholder !== ""}
?required=${prompt.required}
style="vertical-align: bottom"
/>`;
default:
return super.renderPromptInner(prompt, placeholderAsValue);
}
}

renderField(prompt: StagePrompt): TemplateResult {
const errors = (this.challenge?.responseErrors || {})[prompt.fieldKey];
return html`
Expand Down

0 comments on commit 948d2cb

Please sign in to comment.