This repository has been archived by the owner on Feb 27, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jonas Metzener
committed
Oct 25, 2018
1 parent
6a968a4
commit 55b08e1
Showing
8 changed files
with
119 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Component from "@ember/component"; | ||
import layout from "../../../templates/components/cf-field/input/radio"; | ||
|
||
/** | ||
* Input component for the radio question type | ||
* | ||
* @class CfFieldInputRadioComponent | ||
*/ | ||
export default Component.extend({ | ||
layout, | ||
tagName: "" | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{{#each field.question.radioOptions.edges as |optionEdge i|}} | ||
{{#let optionEdge.node as |option|}} | ||
{{#if (gt i 0)}}<br>{{/if}} | ||
<label> | ||
<input | ||
class="uk-radio uk-margin-small-right" | ||
type="radio" | ||
name={{field.id}} | ||
value={{option.slug}} | ||
checked={{eq option.slug field.answer.stringValue}} | ||
> | ||
{{option.label}} | ||
</label> | ||
{{/let}} | ||
{{/each}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "ember-caluma-form/components/cf-field/input/radio"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { module, test } from "qunit"; | ||
import { setupRenderingTest } from "ember-qunit"; | ||
import { render } from "@ember/test-helpers"; | ||
import hbs from "htmlbars-inline-precompile"; | ||
|
||
module("Integration | Component | cf-field/input/radio", function(hooks) { | ||
setupRenderingTest(hooks); | ||
|
||
test("it renders", async function(assert) { | ||
assert.expect(11); | ||
|
||
await render(hbs` | ||
{{cf-field/input/radio | ||
field=(hash | ||
id="test" | ||
answer=(hash | ||
stringValue="option-1" | ||
) | ||
question=(hash | ||
radioOptions=(hash | ||
edges=(array | ||
(hash node=(hash slug="option-1" label="Option 1")) | ||
(hash node=(hash slug="option-2" label="Option 2")) | ||
(hash node=(hash slug="option-3" label="Option 3")) | ||
) | ||
) | ||
) | ||
) | ||
}} | ||
`); | ||
|
||
assert.dom("input[type=radio]").exists({ count: 3 }); | ||
assert.dom("label").exists({ count: 3 }); | ||
assert.dom("br").exists({ count: 2 }); | ||
assert.dom("label:nth-of-type(3) + br").doesNotExist(); | ||
|
||
assert.dom("label:nth-of-type(1)").hasText("Option 1"); | ||
assert.dom("label:nth-of-type(2)").hasText("Option 2"); | ||
assert.dom("label:nth-of-type(3)").hasText("Option 3"); | ||
|
||
assert.dom("label:nth-of-type(1) input[type=radio]").hasValue("option-1"); | ||
assert.dom("label:nth-of-type(2) input[type=radio]").hasValue("option-2"); | ||
assert.dom("label:nth-of-type(3) input[type=radio]").hasValue("option-3"); | ||
|
||
assert.dom("label:nth-of-type(1) input[type=radio]").isChecked(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters