New index
This commit is contained in:
parent
6dbdd70d31
commit
a52710f090
5 changed files with 54 additions and 47 deletions
|
@ -1,6 +0,0 @@
|
||||||
import Ember from 'ember';
|
|
||||||
|
|
||||||
export default Ember.Controller.extend({
|
|
||||||
sortParams: ['speciesName', 'strainCount'],
|
|
||||||
sortedSpecies: Ember.computed.sort('model', 'sortParams'),
|
|
||||||
});
|
|
|
@ -1,17 +1,8 @@
|
||||||
import Ember from 'ember';
|
import Ember from 'ember';
|
||||||
|
|
||||||
export default Ember.Route.extend({
|
export default Ember.Route.extend({
|
||||||
currentUser: Ember.inject.service('session-account'),
|
|
||||||
|
|
||||||
model: function() {
|
model: function() {
|
||||||
return this.store.findAll('species');
|
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'));
|
|
||||||
});
|
|
||||||
},
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
17
app/pods/protected/species/index/species-table/component.js
Normal file
17
app/pods/protected/species/index/species-table/component.js
Normal 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'),
|
||||||
|
|
||||||
|
});
|
33
app/pods/protected/species/index/species-table/template.hbs
Normal file
33
app/pods/protected/species/index/species-table/template.hbs
Normal 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>
|
|
@ -1,34 +1,6 @@
|
||||||
<h2>{{genus-name}} Species</h2>
|
<h2>{{genus-name}} Species</h2>
|
||||||
<h3>Total species: {{model.length}}</h3>
|
|
||||||
|
|
||||||
{{add-button label="Add Species" link="protected.species.new" canAdd=metaData.canAdd}}
|
{{
|
||||||
|
protected/species/index/species-table
|
||||||
<table class="flakes-table">
|
species=model
|
||||||
<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>
|
|
||||||
|
|
Reference in a new issue