Species edit refactor (wip)

This commit is contained in:
Matthew Dillon 2015-07-06 11:02:41 -08:00
parent cdc825cc6a
commit 622cd0faaf
11 changed files with 155 additions and 124 deletions

View file

@ -0,0 +1,18 @@
import Ember from 'ember';
export default Ember.Controller.extend({
actions: {
save: function() {
let species = this.get('species');
if (species.get('isDirty')) {
species.save().then((species) => {
this.transitionToRoute('species.show', species.get('id'));
}, (err) => {
this.get('flashMessages').error(err.message);
});
} else {
this.transitionToRoute('species.show', species.get('id'));
}
},
}
});

View file

@ -0,0 +1,14 @@
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);
},
});

View file

@ -0,0 +1,37 @@
<form class="grid-form">
<fieldset>
<legend><em>{{species.speciesName}}</em></legend>
<div data-row-span="2">
<div data-field-span="1">
<label>Species Name</label>
{{input value=species.speciesName}}
</div>
<div data-field-span="1">
<label>Type Species?</label>
{{input type="checkbox" checked=species.typeSpecies}} {{if species.typeSpecies 'Yes' 'No'}}
</div>
</div>
<div data-row-span="2">
<div data-field-span="2">
<label>Strains</label>
{{#each species.strains as |strain index|}}
{{if index ","}}
{{#link-to 'strains.show' strain.id}}
{{{strain.strainNameMU}}}
{{/link-to}}
{{/each}}
{{add-button label="Add Strain" link="strains.new"}}
</div>
</div>
<div data-row-span="2">
<div data-field-span="2">
<label>Etymology</label>
{{textarea value=species.etymology cols="70" rows="5"}}
</div>
</div>
</fieldset>
</form>
<br>
<a class="button-green smaller" {{action 'save'}}>
Save
</a>