Skip to content

Commit

Permalink
Add a model to the route and create the component to iterate on
Browse files Browse the repository at this point in the history
Also display two instances in the application
  • Loading branch information
corrspt committed Nov 19, 2016
1 parent b558090 commit aa38977
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/components/attribute-text.js
@@ -0,0 +1,4 @@
import Ember from 'ember';

export default Ember.Component.extend({
});
3 changes: 3 additions & 0 deletions app/routes/application.js
@@ -1,4 +1,7 @@
import Ember from 'ember'; import Ember from 'ember';


export default Ember.Route.extend({ export default Ember.Route.extend({
model() {
return this.store.createRecord('person');
}
}); });
29 changes: 28 additions & 1 deletion app/templates/application.hbs
@@ -1 +1,28 @@
{{outlet}} <div class="container">
<h2 id="title">Conventions, Conventions</h2>

<div class="row">
<div class="col-sm-6">
{{
attribute-text
model=model
attribute='name'
label='Name'
placeholder='Insert your name'
}}
</div>
<div class="col-sm-6">
{{
attribute-text
model=model
attribute='age'
label='Age'
placeholder='Insert your age'
}}
</div>
</div>

{{outlet}}
</div>


13 changes: 13 additions & 0 deletions app/templates/components/attribute-text.hbs
@@ -0,0 +1,13 @@
<div class="form-group">
<label title="{{placeholder}}" class='control-label' for='{{attribute}}'>
{{label}}
</label>
<input
value={{get model attribute}}
class='form-control'
placeholder={{placeholder}}
type='text'
id={{attribute}}
>
</div>

24 changes: 24 additions & 0 deletions tests/integration/components/attribute-text-test.js
@@ -0,0 +1,24 @@
import { moduleForComponent, test } from 'ember-qunit';
import hbs from 'htmlbars-inline-precompile';

moduleForComponent('attribute-text', 'Integration | Component | attribute text', {
integration: true
});

test('it renders', function(assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.on('myAction', function(val) { ... });

this.render(hbs`{{attribute-text}}`);

assert.equal(this.$().text().trim(), '');

// Template block usage:
this.render(hbs`
{{#attribute-text}}
template block text
{{/attribute-text}}
`);

assert.equal(this.$().text().trim(), 'template block text');
});

0 comments on commit aa38977

Please sign in to comment.