Pods, pods, everywhere

This commit is contained in:
Matthew Dillon 2015-06-04 12:18:59 -08:00
parent 33f783bc42
commit e623d52f34
66 changed files with 53 additions and 113 deletions

View file

@ -0,0 +1,5 @@
import SortableController from '../../../controllers/sortable';
export default SortableController.extend({
sortBy: 'speciesName',
});

View file

@ -0,0 +1,8 @@
import Ember from 'ember';
import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixin';
export default Ember.Route.extend(AuthenticatedRouteMixin, {
model: function() {
return this.store.findAll('species');
}
});

View file

@ -0,0 +1,37 @@
<h2>{{genus-name}} Species</h2>
<h3>Total species: {{controller.length}}</h3>
{{#if (can "add species")}}
{{! Does nothing ATM }}
{{#link-to 'species.new' class="button-gray smaller"}}
Add Species
{{/link-to}}
{{/if}}
<table class="flakes-table">
<thead>
<tr>
<th {{action "setSortBy" "speciesName"}}>Name</th>
<th {{action "setSortBy" "totalStrains"}}>Strains</th>
</tr>
</thead>
<tbody>
{{#each species in controller}}
<tr>
<td>
{{#link-to 'species.show' species}}
{{species.speciesName}}
{{/link-to}}
</td>
<td>
{{#each species.strains as |strain index|}}
{{if index ","}}
{{#link-to 'strains.show' strain.id}}
{{strain.strainName}}
{{/link-to}}
{{/each}}
</td>
</tr>
{{/each}}
</tbody>
</table>

View file

@ -0,0 +1,21 @@
import Ember from 'ember';
export default Ember.Controller.extend({
isEditing: true,
actions: {
save: function() {
var species = this.get('model');
if (species.get('isDirty')) {
species.save();
}
this.transitionToRoute('species.index');
},
cancel: function() {
var species = this.get('model');
if (species.get('isNew')) {
species.deleteRecord();
}
this.transitionToRoute('species.index');
}
}
});

View file

@ -0,0 +1,12 @@
import Ember from 'ember';
export default Ember.Route.extend({
model: function() {
return this.store.createRecord('species');
},
actions: {
cancelSpecies: function() {
this.transitionTo('species.index');
}
}
});

View file

@ -0,0 +1,7 @@
{{
species-details
species=model
isEditing=true
save="save"
cancel="cancel"
}}

View file

@ -0,0 +1,22 @@
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

@ -0,0 +1,4 @@
import Ember from 'ember';
export default Ember.Route.extend({
});

View file

@ -0,0 +1,7 @@
{{
species-details
species=model
isEditing=isEditing
save="save"
cancel="cancel"
}}