Skip to content

Commit

Permalink
fix(form builder): fix float inputs
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Metzener authored and czosel committed Jun 14, 2019
1 parent c46b7ad commit 6c111e5
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 2 deletions.
5 changes: 5 additions & 0 deletions addon/components/cfb-float-input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import RenderComponent from "ember-validated-form/components/validated-input/-themes/uikit/render";

export default RenderComponent.extend({
inputComponent: "cfb-float-input/input"
});
12 changes: 12 additions & 0 deletions addon/components/cfb-float-input/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import InputComponent from "ember-validated-form/components/validated-input/types/-themes/uikit/input";

export default InputComponent.extend({
init() {
this._super(...arguments);

this.set("type", "number");
},

attributeBindings: ["step"],
step: "any"
});
4 changes: 2 additions & 2 deletions addon/templates/components/cfb-form-editor/question.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -132,17 +132,17 @@
<div uk-grid class="uk-grid-small uk-child-width-1-2 uk-margin">
<div>
{{f.input
type="number"
name="floatMinValue"
label=(t "caluma.form-builder.question.min-value")
renderComponent=(component "cfb-float-input")
}}
</div>

<div>
{{f.input
type="number"
name="floatMaxValue"
label=(t "caluma.form-builder.question.max-value")
renderComponent=(component "cfb-float-input")
}}
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions app/components/cfb-float-input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "ember-caluma/components/cfb-float-input";
1 change: 1 addition & 0 deletions app/components/cfb-float-input/input.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from "ember-caluma/components/cfb-float-input/input";
18 changes: 18 additions & 0 deletions tests/integration/components/cfb-float-input-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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 | cfb-float-input", function(hooks) {
setupRenderingTest(hooks);

test("it renders", async function(assert) {
assert.expect(1);

await render(
hbs`{{cfb-float-input name="test" update=(action (mut value))}}`
);

assert.dom("input[name=test]").exists();
});
});
18 changes: 18 additions & 0 deletions tests/integration/components/cfb-float-input/input-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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 | cfb-float-input/input", function(hooks) {
setupRenderingTest(hooks);

test("it renders", async function(assert) {
assert.expect(3);

await render(hbs`{{cfb-float-input/input name="test"}}`);

assert.dom("input[name=test]").exists();
assert.dom("input[name=test]").hasAttribute("type", "number");
assert.dom("input[name=test]").hasAttribute("step", "any");
});
});

0 comments on commit 6c111e5

Please sign in to comment.