Refactor strains/index
This commit is contained in:
parent
35475c2b92
commit
85d861da27
6 changed files with 46 additions and 42 deletions
|
@ -1,12 +1,12 @@
|
|||
import Ember from 'ember';
|
||||
import SetupMetaData from '../../../../../mixins/setup-metadata';
|
||||
|
||||
const { Component } = Ember;
|
||||
const { Component, computed: { sort } } = Ember;
|
||||
|
||||
export default Component.extend(SetupMetaData, {
|
||||
species: null,
|
||||
|
||||
sortParams: ['speciesName', 'strainCount'],
|
||||
sortedSpecies: Ember.computed.sort('species', 'sortParams'),
|
||||
sortedSpecies: sort('species', 'sortParams'),
|
||||
|
||||
});
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Controller.extend({
|
||||
sortParams: ['sortOrder'],
|
||||
sortedStrains: Ember.computed.sort('model', 'sortParams'),
|
||||
});
|
|
@ -1,17 +1,10 @@
|
|||
import Ember from 'ember';
|
||||
|
||||
export default Ember.Route.extend({
|
||||
currentUser: Ember.inject.service('session-account'),
|
||||
const { Route } = Ember;
|
||||
|
||||
export default Route.extend({
|
||||
model: function() {
|
||||
return this.store.findAll('strain');
|
||||
},
|
||||
|
||||
setupController: function(controller, model) {
|
||||
controller.set('model', model);
|
||||
this.get('currentUser.account').then((user) => {
|
||||
controller.set('metaData', user.get('metaData'));
|
||||
});
|
||||
},
|
||||
|
||||
});
|
||||
|
|
12
app/pods/protected/strains/index/strain-table/component.js
Normal file
12
app/pods/protected/strains/index/strain-table/component.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
import Ember from 'ember';
|
||||
import SetupMetaData from '../../../../../mixins/setup-metadata';
|
||||
|
||||
const { Component, computed: { sort } } = Ember;
|
||||
|
||||
export default Component.extend(SetupMetaData, {
|
||||
strains: null,
|
||||
|
||||
sortParams: ['fullNameMU'],
|
||||
sortedStrains: sort('strains', 'sortParams'),
|
||||
|
||||
});
|
26
app/pods/protected/strains/index/strain-table/template.hbs
Normal file
26
app/pods/protected/strains/index/strain-table/template.hbs
Normal file
|
@ -0,0 +1,26 @@
|
|||
<h3 id="total-strains">Total strains: {{strains.length}}</h3>
|
||||
|
||||
{{add-button label="Add Strain" link="protected.strains.new" canAdd=metaData.canAdd}}
|
||||
|
||||
<table class="flakes-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Species</th>
|
||||
<th>Total Measurements</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each sortedStrains as |strain|}}
|
||||
<tr>
|
||||
<td>
|
||||
{{#link-to 'protected.strains.show' strain classBinding="data.typeStrain:type-strain"}}
|
||||
{{strain.fullNameMU}}
|
||||
{{/link-to}}
|
||||
</td>
|
||||
<td>
|
||||
{{strain.totalMeasurements}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
|
@ -1,27 +1,6 @@
|
|||
<h2>{{genus-name}} Strains</h2>
|
||||
<h3 id="total-strains">Total strains: {{model.length}}</h3>
|
||||
|
||||
{{add-button label="Add Strain" link="protected.strains.new" canAdd=metaData.canAdd}}
|
||||
|
||||
<table class="flakes-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Species</th>
|
||||
<th>Total Measurements</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{#each sortedStrains as |row|}}
|
||||
<tr>
|
||||
<td>
|
||||
{{#link-to 'protected.strains.show' row classBinding="data.typeStrain:type-strain"}}
|
||||
{{row.fullNameMU}}
|
||||
{{/link-to}}
|
||||
</td>
|
||||
<td>
|
||||
{{row.totalMeasurements}}
|
||||
</td>
|
||||
</tr>
|
||||
{{/each}}
|
||||
</tbody>
|
||||
</table>
|
||||
{{
|
||||
protected/strains/index/strain-table
|
||||
strains=model
|
||||
}}
|
||||
|
|
Reference in a new issue