New index

This commit is contained in:
Matthew Dillon 2015-10-29 16:52:20 -07:00
parent 6dbdd70d31
commit a52710f090
5 changed files with 54 additions and 47 deletions

View file

@ -1,6 +0,0 @@
import Ember from 'ember';
export default Ember.Controller.extend({
sortParams: ['speciesName', 'strainCount'],
sortedSpecies: Ember.computed.sort('model', 'sortParams'),
});

View file

@ -1,17 +1,8 @@
import Ember from 'ember';
export default Ember.Route.extend({
currentUser: Ember.inject.service('session-account'),
model: function() {
return this.store.findAll('species');
},
setupController: function(controller, model) {
controller.set('model', model);
this.get('currentUser.account').then((user) => {
controller.set('metaData', user.get('metaData'));
});
},
});

View file

@ -0,0 +1,17 @@
import Ember from 'ember';
export default Ember.Component.extend({
currentUser: Ember.inject.service('session-account'),
metaData: null,
setupMetaDataOnInit: Ember.on('init', function() {
this.get('currentUser.account').then((user) => {
this.set('metaData', user.get('metaData'));
});
}),
sortParams: ['speciesName', 'strainCount'],
sortedSpecies: Ember.computed.sort('species', 'sortParams'),
});

View file

@ -0,0 +1,33 @@
<h3>Total species: {{species.length}}</h3>
{{add-button label="Add Species" link="protected.species.new" canAdd=metaData.canAdd}}
<table class="flakes-table">
<thead>
<tr>
<th>Name</th>
<th>Strains</th>
</tr>
</thead>
<tbody>
{{#each sortedSpecies as |species|}}
<tr>
<td>
<em>
{{#link-to 'protected.species.show' species}}
{{species.speciesName}}
{{/link-to}}
</em>
</td>
<td>
{{#each species.strains as |strain index|}}
{{if index ","}}
{{#link-to 'protected.strains.show' strain.id}}
{{{strain.strainNameMU}}}
{{/link-to}}
{{/each}}
</td>
</tr>
{{/each}}
</tbody>
</table>

View file

@ -1,34 +1,6 @@
<h2>{{genus-name}} Species</h2>
<h3>Total species: {{model.length}}</h3>
{{add-button label="Add Species" link="protected.species.new" canAdd=metaData.canAdd}}
<table class="flakes-table">
<thead>
<tr>
<th>Name</th>
<th>Strains</th>
</tr>
</thead>
<tbody>
{{#each sortedSpecies as |species|}}
<tr>
<td>
<em>
{{#link-to 'protected.species.show' species}}
{{species.speciesName}}
{{/link-to}}
</em>
</td>
<td>
{{#each species.strains as |strain index|}}
{{if index ","}}
{{#link-to 'protected.strains.show' strain.id}}
{{{strain.strainNameMU}}}
{{/link-to}}
{{/each}}
</td>
</tr>
{{/each}}
</tbody>
</table>
{{
protected/species/index/species-table
species=model
}}