Sortable table component

This commit is contained in:
Matthew Dillon 2015-06-04 20:32:39 -08:00
parent e623d52f34
commit 6ba5cf2322
23 changed files with 225 additions and 74 deletions

View file

@ -0,0 +1,5 @@
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'tr',
});

View file

@ -0,0 +1,6 @@
<td>
{{data.characteristicName}}
</td>
<td>
{{data.characteristicType}}
</td>

View file

@ -0,0 +1,13 @@
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'th',
upArrow: '&#9650',
downArrow: '&#9660',
actions: {
sortBy: function(sortProperty, ascending) {
this.sendAction('action', sortProperty, ascending);
}
},
});

View file

@ -0,0 +1,3 @@
{{title}}
<span {{action 'sortBy' sortProperty true}}>{{{upArrow}}}</span>
<span {{action 'sortBy' sortProperty false}}>{{{downArrow}}}</span>

View file

@ -0,0 +1,13 @@
import Ember from 'ember';
export default Ember.Component.extend(Ember.SortableMixin, {
tagName: 'table',
classNames: ['flakes-table'],
actions: {
sortBy: function(property, ascending) {
this.set('sortAscending', ascending);
this.set('sortProperties', [property]);
}
},
});

View file

@ -0,0 +1,13 @@
<thead>
<tr>
{{#each a in tableAttrs}}
{{sortable-table-header title=a.name sortProperty=a.attr action="sortBy"}}
{{/each}}
</tr>
</thead>
<tbody>
{{#each item in arrangedContent}}
{{component row data=item}}
{{/each}}
</tbody>

View file

@ -0,0 +1,5 @@
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'tr',
});

View file

@ -0,0 +1,13 @@
<td>
{{#link-to 'species.show' data}}
{{data.speciesName}}
{{/link-to}}
</td>
<td>
{{#each data.strains as |strain index|}}
{{if index ","}}
{{#link-to 'strains.show' strain.id}}
{{strain.strainName}}
{{/link-to}}
{{/each}}
</td>

View file

@ -0,0 +1,5 @@
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'tr',
});

View file

@ -0,0 +1,8 @@
<td>
{{#link-to 'strains.show' data.id}}
{{scientific-name strain=data}}
{{/link-to}}
</td>
<td>
{{data.totalMeasurements}}
</td>