-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move contact create form in a component
- Loading branch information
Showing
7 changed files
with
96 additions
and
59 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
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,28 @@ | ||
import Ember from 'ember'; | ||
|
||
export default Ember.Component.extend({ | ||
|
||
classNames: ['container-fluid'], | ||
|
||
isNameEmpty: Ember.computed('name', function() {return Ember.isBlank(this.get('name'));}), | ||
isPhoneEmpty: Ember.computed('phone', function() {return Ember.isBlank(this.get('phone'));}), | ||
|
||
nothingThere: Ember.computed.or('isNameEmpty', 'isPhoneEmpty'), | ||
|
||
actions: { | ||
buttonClicked() { | ||
if (this.get('nothingThere')) {return;} | ||
|
||
const name = this.get('name'); | ||
const phone = this.get('phone'); | ||
const email = this.get('email'); | ||
|
||
this.sendAction('action', name, phone, email); | ||
|
||
this.set('name', ''); | ||
this.set('phone', ''); | ||
this.set('email', ''); | ||
} | ||
} | ||
|
||
}); |
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,15 @@ | ||
<div class="row well"> | ||
<div class="col-xs-3"> | ||
{{input type="text" value=name size="100" placeholder="Enter a new name" class="form-control"}} | ||
</div> | ||
|
||
<div class="col-xs-3"> | ||
{{input type="text" value=phone size="20" placeholder="Phone" class="form-control"}} | ||
</div> | ||
|
||
<div class="col-xs-3"> | ||
{{input type="text" value=email size="100" placeholder="Email" class="form-control"}} | ||
</div> | ||
|
||
<button type="submit" class="btn btn-warning" {{action 'buttonClicked'}} disabled={{nothingThere}}>Add New Contact</button> | ||
</div> |
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,19 @@ | ||
import { moduleForComponent, test } from 'ember-qunit'; | ||
|
||
moduleForComponent('contacts/add-contact-form', 'Unit | Component | contacts/add contact form', { | ||
// Specify the other units that are required for this test | ||
// needs: ['component:foo', 'helper:bar'], | ||
unit: true | ||
}); | ||
|
||
test('it renders', function(assert) { | ||
assert.expect(2); | ||
|
||
// Creates the component instance | ||
var component = this.subject(); | ||
assert.equal(component._state, 'preRender'); | ||
|
||
// Renders the component to the page | ||
this.render(); | ||
assert.equal(component._state, 'inDOM'); | ||
}); |