Going back to model reference
This commit is contained in:
parent
9aed858982
commit
4bbf931853
10 changed files with 17 additions and 66 deletions
|
@ -3,7 +3,7 @@ import Ember from 'ember';
|
||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
actions: {
|
actions: {
|
||||||
save: function() {
|
save: function() {
|
||||||
let species = this.get('species');
|
let species = this.get('model');
|
||||||
|
|
||||||
if (species.get('isDirty')) {
|
if (species.get('isDirty')) {
|
||||||
species.save().then((species) => {
|
species.save().then((species) => {
|
||||||
|
@ -17,7 +17,7 @@ export default Ember.Controller.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
cancel: function() {
|
cancel: function() {
|
||||||
let species = this.get('species');
|
let species = this.get('model');
|
||||||
|
|
||||||
species.get('errors').clear();
|
species.get('errors').clear();
|
||||||
species.rollback();
|
species.rollback();
|
||||||
|
|
|
@ -1,14 +1,4 @@
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||||
|
|
||||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
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);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{
|
{{
|
||||||
forms/species-form
|
forms/species-form
|
||||||
species=species
|
species=model
|
||||||
save="save"
|
save="save"
|
||||||
cancel="cancel"
|
cancel="cancel"
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -15,8 +15,7 @@
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<em>
|
<em>
|
||||||
{{!-- use species.id to call show model hook --}}
|
{{#link-to 'species.show' species}}
|
||||||
{{#link-to 'species.show' species.id}}
|
|
||||||
{{species.speciesName}}
|
{{species.speciesName}}
|
||||||
{{/link-to}}
|
{{/link-to}}
|
||||||
</em>
|
</em>
|
||||||
|
|
|
@ -3,7 +3,7 @@ import Ember from 'ember';
|
||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
actions: {
|
actions: {
|
||||||
save: function() {
|
save: function() {
|
||||||
let species = this.get('species');
|
let species = this.get('model');
|
||||||
|
|
||||||
if (species.get('isDirty')) {
|
if (species.get('isDirty')) {
|
||||||
species.save().then((species) => {
|
species.save().then((species) => {
|
||||||
|
@ -17,7 +17,7 @@ export default Ember.Controller.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
cancel: function() {
|
cancel: function() {
|
||||||
let species = this.get('species');
|
let species = this.get('model');
|
||||||
|
|
||||||
if (species.get('isNew')) {
|
if (species.get('isNew')) {
|
||||||
species.deleteRecord();
|
species.deleteRecord();
|
||||||
|
|
|
@ -3,13 +3,7 @@ import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixi
|
||||||
|
|
||||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
||||||
model: function() {
|
model: function() {
|
||||||
return Ember.RSVP.hash({
|
return this.store.createRecord('species');
|
||||||
species: this.store.createRecord('species'),
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
setupController: function(controller, model) {
|
|
||||||
controller.setProperties(model);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{
|
{{
|
||||||
forms/species-form
|
forms/species-form
|
||||||
species=species
|
species=model
|
||||||
save="save"
|
save="save"
|
||||||
cancel="cancel"
|
cancel="cancel"
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -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');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
|
@ -1,14 +1,4 @@
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
|
||||||
|
|
||||||
export default Ember.Route.extend(AuthenticatedRouteMixin, {
|
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);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div class="span-1">
|
<div class="span-1">
|
||||||
<fieldset class="flakes-information-box {{if isEditing 'is-editing'}}">
|
<fieldset class="flakes-information-box {{if isEditing 'is-editing'}}">
|
||||||
<legend>
|
<legend>
|
||||||
Species <em>{{species.speciesName}}</em>
|
Species <em>{{model.speciesName}}</em>
|
||||||
</legend>
|
</legend>
|
||||||
|
|
||||||
{{! ROW 1 }}
|
{{! ROW 1 }}
|
||||||
|
@ -10,7 +10,7 @@
|
||||||
<dl class="span-2">
|
<dl class="span-2">
|
||||||
<dt>Strains</dt>
|
<dt>Strains</dt>
|
||||||
<dd>
|
<dd>
|
||||||
{{#each species.strains as |strain index|}}
|
{{#each model.strains as |strain index|}}
|
||||||
{{if index ","}}
|
{{if index ","}}
|
||||||
{{#link-to 'strains.show' strain.id}}
|
{{#link-to 'strains.show' strain.id}}
|
||||||
{{{strain.strainNameMU}}}
|
{{{strain.strainNameMU}}}
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
<dl class="span-2">
|
<dl class="span-2">
|
||||||
<dt>Type Species?</dt>
|
<dt>Type Species?</dt>
|
||||||
<dd>
|
<dd>
|
||||||
{{if species.typeSpecies 'Yes' 'No'}}
|
{{if model.typeSpecies 'Yes' 'No'}}
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
@ -31,7 +31,7 @@
|
||||||
<dl class="span-4">
|
<dl class="span-4">
|
||||||
<dt>Etymology</dt>
|
<dt>Etymology</dt>
|
||||||
<dd>
|
<dd>
|
||||||
{{species.etymology}}
|
{{model.etymology}}
|
||||||
</dd>
|
</dd>
|
||||||
</dl>
|
</dl>
|
||||||
</div>
|
</div>
|
||||||
|
@ -40,15 +40,15 @@
|
||||||
<div class="grid-4">
|
<div class="grid-4">
|
||||||
<dl class="span-1">
|
<dl class="span-1">
|
||||||
<dt>Record Created</dt>
|
<dt>Record Created</dt>
|
||||||
<dd>{{null-time species.createdAt 'LL'}}</dd>
|
<dd>{{null-time model.createdAt 'LL'}}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dl class="span-1">
|
<dl class="span-1">
|
||||||
<dt>Record Updated</dt>
|
<dt>Record Updated</dt>
|
||||||
<dd>{{null-time species.updatedAt 'LL'}}</dd>
|
<dd>{{null-time model.updatedAt 'LL'}}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dl class="span-1">
|
<dl class="span-1">
|
||||||
<dt>Record Deleted</dt>
|
<dt>Record Deleted</dt>
|
||||||
<dd>{{null-time species.deletedAt 'LL'}}</dd>
|
<dd>{{null-time model.deletedAt 'LL'}}</dd>
|
||||||
</dl>
|
</dl>
|
||||||
<dl class="span-1"></dl>
|
<dl class="span-1"></dl>
|
||||||
</div>
|
</div>
|
||||||
|
|
Reference in a new issue