Going back to model reference

This commit is contained in:
Matthew Dillon 2015-07-07 08:38:05 -08:00
parent 9aed858982
commit 4bbf931853
10 changed files with 17 additions and 66 deletions

View file

@ -3,7 +3,7 @@ import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
save: function() {
let species = this.get('species');
let species = this.get('model');
if (species.get('isDirty')) {
species.save().then((species) => {
@ -17,7 +17,7 @@ export default Ember.Controller.extend({
},
cancel: function() {
let species = this.get('species');
let species = this.get('model');
species.get('errors').clear();
species.rollback();

View file

@ -1,14 +1,4 @@
import Ember from 'ember';
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
export default Ember.Route.extend(AuthenticatedRouteMixin, {
model: function(params) {
return Ember.RSVP.hash({
species: this.store.find('species', params.species_id),
});
},
setupController: function(controller, model) {
controller.setProperties(model);
},
});
export default Ember.Route.extend(AuthenticatedRouteMixin, {});

View file

@ -1,6 +1,6 @@
{{
forms/species-form
species=species
species=model
save="save"
cancel="cancel"
}}

View file

@ -15,8 +15,7 @@
<tr>
<td>
<em>
{{!-- use species.id to call show model hook --}}
{{#link-to 'species.show' species.id}}
{{#link-to 'species.show' species}}
{{species.speciesName}}
{{/link-to}}
</em>

View file

@ -3,7 +3,7 @@ import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
save: function() {
let species = this.get('species');
let species = this.get('model');
if (species.get('isDirty')) {
species.save().then((species) => {
@ -17,7 +17,7 @@ export default Ember.Controller.extend({
},
cancel: function() {
let species = this.get('species');
let species = this.get('model');
if (species.get('isNew')) {
species.deleteRecord();

View file

@ -3,13 +3,7 @@ import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixi
export default Ember.Route.extend(AuthenticatedRouteMixin, {
model: function() {
return Ember.RSVP.hash({
species: this.store.createRecord('species'),
});
},
setupController: function(controller, model) {
controller.setProperties(model);
return this.store.createRecord('species');
},
});

View file

@ -1,6 +1,6 @@
{{
forms/species-form
species=species
species=model
save="save"
cancel="cancel"
}}

View file

@ -1,22 +0,0 @@
import Ember from 'ember';
export default Ember.Controller.extend({
isEditing: false,
actions: {
save: function() {
var species = this.get('model');
if (species.get('isDirty')) {
species.save();
}
this.toggleProperty('isEditing');
},
cancel: function() {
if (this.get('isEditing')) {
var species = this.get('model');
species.get('errors').clear();
species.rollback();
}
this.toggleProperty('isEditing');
}
}
});

View file

@ -1,14 +1,4 @@
import Ember from 'ember';
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
export default Ember.Route.extend(AuthenticatedRouteMixin, {
model: function(params) {
return Ember.RSVP.hash({
species: this.store.find('species', params.species_id),
});
},
setupController: function(controller, model) {
controller.setProperties(model);
},
});
export default Ember.Route.extend(AuthenticatedRouteMixin, {});

View file

@ -2,7 +2,7 @@
<div class="span-1">
<fieldset class="flakes-information-box {{if isEditing 'is-editing'}}">
<legend>
Species <em>{{species.speciesName}}</em>
Species <em>{{model.speciesName}}</em>
</legend>
{{! ROW 1 }}
@ -10,7 +10,7 @@
<dl class="span-2">
<dt>Strains</dt>
<dd>
{{#each species.strains as |strain index|}}
{{#each model.strains as |strain index|}}
{{if index ","}}
{{#link-to 'strains.show' strain.id}}
{{{strain.strainNameMU}}}
@ -21,7 +21,7 @@
<dl class="span-2">
<dt>Type Species?</dt>
<dd>
{{if species.typeSpecies 'Yes' 'No'}}
{{if model.typeSpecies 'Yes' 'No'}}
</dd>
</dl>
</div>
@ -31,7 +31,7 @@
<dl class="span-4">
<dt>Etymology</dt>
<dd>
{{species.etymology}}
{{model.etymology}}
</dd>
</dl>
</div>
@ -40,15 +40,15 @@
<div class="grid-4">
<dl class="span-1">
<dt>Record Created</dt>
<dd>{{null-time species.createdAt 'LL'}}</dd>
<dd>{{null-time model.createdAt 'LL'}}</dd>
</dl>
<dl class="span-1">
<dt>Record Updated</dt>
<dd>{{null-time species.updatedAt 'LL'}}</dd>
<dd>{{null-time model.updatedAt 'LL'}}</dd>
</dl>
<dl class="span-1">
<dt>Record Deleted</dt>
<dd>{{null-time species.deletedAt 'LL'}}</dd>
<dd>{{null-time model.deletedAt 'LL'}}</dd>
</dl>
<dl class="span-1"></dl>
</div>