Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(check-question): add reset button for optional question #2549

Merged
merged 8 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from 6 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
9 changes: 8 additions & 1 deletion packages/form/addon/components/cf-field/input/radio.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,11 @@
{{option.label}}
{{/if}}
</label>
{{/each}}
{{/each}}
anehx marked this conversation as resolved.
Show resolved Hide resolved
{{#if (and (eq @field.question.raw.isRequired "false") @field.answer.value)}}
anehx marked this conversation as resolved.
Show resolved Hide resolved
<br />
anehx marked this conversation as resolved.
Show resolved Hide resolved
<a data-test-radio-reset href="#" {{on "click" (fn @onSave null)}}>{{t
"caluma.form.power-select.reset"
anehx marked this conversation as resolved.
Show resolved Hide resolved
}}</a>

{{/if}}
1 change: 1 addition & 0 deletions packages/form/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"ember-math-helpers": "^4.0.0",
"ember-power-select": "^7.2.0",
"ember-resources": "^6.4.2",
"ember-truth-helpers": "^4.0.3",
anehx marked this conversation as resolved.
Show resolved Hide resolved
"ember-uikit": "^9.0.0",
"ember-validators": "^4.1.2",
"graphql": "^15.8.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,19 +86,32 @@ module("Integration | Component | cf-field/input/radio", function (hooks) {
});

test("it triggers save on click", async function (assert) {
assert.expect(1);

this.set("save", (value) => assert.strictEqual(value, "option-1"));
this.set("value", false);
this.set("raw", { isRequired: "false" });
this.set("onSave", (value) => {
this.set("value", value);
assert.step("save");
});

await render(hbs`<CfField::Input::Radio
@onSave={{this.save}}
@onSave={{this.onSave}}
@field={{hash
options=(array (hash slug="option-1" label="Option 1"))
question=(hash __typename="ChoiceQuestion")
answer=(hash value=this.value)
question=(hash __typename="ChoiceQuestion" slug="test" raw=this.raw)
}}
/>`);

await click("label:nth-of-type(1) input");
await click("[data-test-radio-reset]");

assert.verifySteps(["save", "save"]);

this.set("raw", { isRequired: "true" });
await click("label:nth-of-type(1) input");

assert.verifySteps(["save"]);
assert.dom("[data-test-radio-reset]").isNotVisible();
});

test("it renders disabled options", async function (assert) {
Expand Down
1 change: 1 addition & 0 deletions packages/form/translations/de.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ caluma:
options-empty: "Keine Optionen vorhanden"
search-placeholder: "Hier tippen um zu suchen"
search-empty: "Keine Optionen gefunden"
reset: "Zurücksetzen"

validation:
blank: "Dieses Feld darf nicht leer gelassen werden"
Expand Down
1 change: 1 addition & 0 deletions packages/form/translations/en.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ caluma:
options-empty: "No options available"
search-placeholder: "Type here to search options"
search-empty: "Search didn't match any options"
reset: "Reset"

validation:
blank: "This field can't be blank"
Expand Down
1 change: 1 addition & 0 deletions packages/form/translations/fr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ caluma:
options-empty: "Pas d'options disponibles"
search-placeholder: "Tapez ici pour rechercher"
search-empty: "Pas d'options trouvées"
reset: "Réinitialiser"

validation:
blank: "Ce champ ne doit pas être laissé vide"
Expand Down
4 changes: 4 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading