From 33e7b92a8c79f40da6ca531c7ebad324e6ab169b Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Mon, 29 Jun 2015 07:19:20 -0800 Subject: [PATCH] Component cleanup (dropping sortable table) + remove `sortable-table` + remove `sortable-table-header` + remove `characteristic-index-row` + remove `species-index-row` + remove `strain-index-row` --- app/pods/characteristics/controller.js | 6 +++ app/pods/characteristics/route.js | 10 +---- app/pods/characteristics/template.hbs | 25 ++++++++---- .../characteristic-index-row/component.js | 5 --- .../characteristic-index-row/template.hbs | 6 --- .../sortable-table-header/component.js | 13 ------- .../sortable-table-header/template.hbs | 3 -- .../components/sortable-table/component.js | 14 ------- .../components/sortable-table/template.hbs | 13 ------- .../components/species-index-row/component.js | 5 --- .../components/species-index-row/template.hbs | 15 -------- .../components/strain-index-row/component.js | 5 --- .../components/strain-index-row/template.hbs | 8 ---- app/pods/species/index/controller.js | 6 +++ app/pods/species/index/route.js | 14 +++---- app/pods/species/index/template.hbs | 38 +++++++++++++++---- app/pods/strains/index/controller.js | 6 +++ app/pods/strains/index/route.js | 14 +++---- app/pods/strains/index/template.hbs | 31 +++++++++++---- 19 files changed, 100 insertions(+), 137 deletions(-) create mode 100644 app/pods/characteristics/controller.js delete mode 100644 app/pods/components/characteristic-index-row/component.js delete mode 100644 app/pods/components/characteristic-index-row/template.hbs delete mode 100644 app/pods/components/sortable-table-header/component.js delete mode 100644 app/pods/components/sortable-table-header/template.hbs delete mode 100644 app/pods/components/sortable-table/component.js delete mode 100644 app/pods/components/sortable-table/template.hbs delete mode 100644 app/pods/components/species-index-row/component.js delete mode 100644 app/pods/components/species-index-row/template.hbs delete mode 100644 app/pods/components/strain-index-row/component.js delete mode 100644 app/pods/components/strain-index-row/template.hbs create mode 100644 app/pods/species/index/controller.js create mode 100644 app/pods/strains/index/controller.js diff --git a/app/pods/characteristics/controller.js b/app/pods/characteristics/controller.js new file mode 100644 index 0000000..ae686a9 --- /dev/null +++ b/app/pods/characteristics/controller.js @@ -0,0 +1,6 @@ +import Ember from 'ember'; + +export default Ember.Controller.extend({ + sortParams: ['characteristicType.characteristicTypeName', 'characteristicName'], + sortedCharacteristics: Ember.computed.sort('characteristics', 'sortParams'), +}); diff --git a/app/pods/characteristics/route.js b/app/pods/characteristics/route.js index 5ac902c..6fc0c60 100644 --- a/app/pods/characteristics/route.js +++ b/app/pods/characteristics/route.js @@ -8,14 +8,8 @@ export default Ember.Route.extend(AuthenticatedRouteMixin, { characteristics: this.store.findAll('characteristic'), }); }, + setupController: function(controller, models) { - var tableAttrs = [ - { name: 'Name', attr: 'characteristicName' }, - { name: 'Type', attr: 'characteristicType.characteristicTypeName' } - ]; - controller.set('model', models.characteristics); - controller.set('tableAttrs', tableAttrs); - controller.set('row', 'characteristic-index-row'); - controller.set('sort', ['characteristicType.characteristicTypeName', 'sortOrder']); + controller.setProperties(models); }, }); diff --git a/app/pods/characteristics/template.hbs b/app/pods/characteristics/template.hbs index d9e559a..63f40a4 100644 --- a/app/pods/characteristics/template.hbs +++ b/app/pods/characteristics/template.hbs @@ -1,10 +1,19 @@

{{genus-name}} Characteristics

-

Total characteristics: {{model.length}}

+

Total characteristics: {{characteristics.length}}

-{{ - sortable-table - content=model - tableAttrs=tableAttrs - row=row - sortProperties=sort -}} + + + + + + + + + {{#each sortedCharacteristics as |row|}} + + + + + {{/each}} + +
NameType
{{row.characteristicName}}{{row.characteristicType.characteristicTypeName}}
diff --git a/app/pods/components/characteristic-index-row/component.js b/app/pods/components/characteristic-index-row/component.js deleted file mode 100644 index f48ea57..0000000 --- a/app/pods/components/characteristic-index-row/component.js +++ /dev/null @@ -1,5 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Component.extend({ - tagName: 'tr', -}); diff --git a/app/pods/components/characteristic-index-row/template.hbs b/app/pods/components/characteristic-index-row/template.hbs deleted file mode 100644 index c829365..0000000 --- a/app/pods/components/characteristic-index-row/template.hbs +++ /dev/null @@ -1,6 +0,0 @@ - - {{data.characteristicName}} - - - {{data.characteristicType.characteristicTypeName}} - diff --git a/app/pods/components/sortable-table-header/component.js b/app/pods/components/sortable-table-header/component.js deleted file mode 100644 index 638b078..0000000 --- a/app/pods/components/sortable-table-header/component.js +++ /dev/null @@ -1,13 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Component.extend({ - tagName: 'th', - upArrow: '▲', - downArrow: '▼', - - actions: { - sortBy: function(sortProperty, ascending) { - this.sendAction('action', sortProperty, ascending); - } - }, -}); diff --git a/app/pods/components/sortable-table-header/template.hbs b/app/pods/components/sortable-table-header/template.hbs deleted file mode 100644 index 7710080..0000000 --- a/app/pods/components/sortable-table-header/template.hbs +++ /dev/null @@ -1,3 +0,0 @@ -{{title}} -{{{upArrow}}} -{{{downArrow}}} diff --git a/app/pods/components/sortable-table/component.js b/app/pods/components/sortable-table/component.js deleted file mode 100644 index acef098..0000000 --- a/app/pods/components/sortable-table/component.js +++ /dev/null @@ -1,14 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Component.extend(Ember.SortableMixin, { - tagName: 'table', - classNames: ['flakes-table'], - sortProperties: [], - - actions: { - sortBy: function(property, ascending) { - this.set('sortAscending', ascending); - this.set('sortProperties', [property]); - } - }, -}); diff --git a/app/pods/components/sortable-table/template.hbs b/app/pods/components/sortable-table/template.hbs deleted file mode 100644 index 1e48be3..0000000 --- a/app/pods/components/sortable-table/template.hbs +++ /dev/null @@ -1,13 +0,0 @@ - - - {{#each tableAttrs as |a|}} - {{sortable-table-header title=a.name sortProperty=a.attr action="sortBy"}} - {{/each}} - - - - - {{#each arrangedContent as |item|}} - {{component row data=item}} - {{/each}} - diff --git a/app/pods/components/species-index-row/component.js b/app/pods/components/species-index-row/component.js deleted file mode 100644 index f48ea57..0000000 --- a/app/pods/components/species-index-row/component.js +++ /dev/null @@ -1,5 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Component.extend({ - tagName: 'tr', -}); diff --git a/app/pods/components/species-index-row/template.hbs b/app/pods/components/species-index-row/template.hbs deleted file mode 100644 index e86113a..0000000 --- a/app/pods/components/species-index-row/template.hbs +++ /dev/null @@ -1,15 +0,0 @@ - - - {{#link-to 'species.show' data}} - {{data.speciesName}} - {{/link-to}} - - - - {{#each data.strains as |strain index|}} - {{if index ","}} - {{#link-to 'strains.show' strain.id}} - {{{strain.strainNameMU}}} - {{/link-to}} - {{/each}} - diff --git a/app/pods/components/strain-index-row/component.js b/app/pods/components/strain-index-row/component.js deleted file mode 100644 index f48ea57..0000000 --- a/app/pods/components/strain-index-row/component.js +++ /dev/null @@ -1,5 +0,0 @@ -import Ember from 'ember'; - -export default Ember.Component.extend({ - tagName: 'tr', -}); diff --git a/app/pods/components/strain-index-row/template.hbs b/app/pods/components/strain-index-row/template.hbs deleted file mode 100644 index 0cebc7a..0000000 --- a/app/pods/components/strain-index-row/template.hbs +++ /dev/null @@ -1,8 +0,0 @@ - - {{#link-to 'strains.show' data.id classBinding="data.typeStrain:type-strain"}} - {{data.fullNameMU}} - {{/link-to}} - - - {{data.totalMeasurements}} - diff --git a/app/pods/species/index/controller.js b/app/pods/species/index/controller.js new file mode 100644 index 0000000..a28a11f --- /dev/null +++ b/app/pods/species/index/controller.js @@ -0,0 +1,6 @@ +import Ember from 'ember'; + +export default Ember.Controller.extend({ + sortParams: ['speciesName', 'strainCount'], + sortedSpecies: Ember.computed.sort('species', 'sortParams'), +}); diff --git a/app/pods/species/index/route.js b/app/pods/species/index/route.js index 9d02d32..d2ab490 100644 --- a/app/pods/species/index/route.js +++ b/app/pods/species/index/route.js @@ -3,16 +3,12 @@ import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixi export default Ember.Route.extend(AuthenticatedRouteMixin, { model: function() { - return this.store.findAll('species'); + return Ember.RSVP.hash({ + species: this.store.findAll('species'), + }); }, + setupController: function(controller, model) { - var tableAttrs = [ - { name: 'Name', attr: 'speciesName' }, - { name: 'Strains', attr: 'totalStrains' } - ]; - controller.set('model', model); - controller.set('tableAttrs', tableAttrs); - controller.set('row', 'species-index-row'); - controller.set('sort', ['sortOrder']); + controller.setProperties(model); }, }); diff --git a/app/pods/species/index/template.hbs b/app/pods/species/index/template.hbs index 13fa4b7..00454fb 100644 --- a/app/pods/species/index/template.hbs +++ b/app/pods/species/index/template.hbs @@ -1,12 +1,34 @@

{{genus-name}} Species

-

Total species: {{model.length}}

+

Total species: {{species.length}}

{{add-button label="Add Species" link="species.new"}} -{{ - sortable-table - content=model - tableAttrs=tableAttrs - row=row - sortProperties=sort -}} + + + + + + + + + {{#each sortedSpecies as |row|}} + + + + + {{/each}} + +
NameStrains
+ + {{#link-to 'species.show' row}} + {{row.speciesName}} + {{/link-to}} + + + {{#each row.strains as |strain index|}} + {{if index ","}} + {{#link-to 'strains.show' strain.id}} + {{{strain.strainNameMU}}} + {{/link-to}} + {{/each}} +
diff --git a/app/pods/strains/index/controller.js b/app/pods/strains/index/controller.js new file mode 100644 index 0000000..25e4db1 --- /dev/null +++ b/app/pods/strains/index/controller.js @@ -0,0 +1,6 @@ +import Ember from 'ember'; + +export default Ember.Controller.extend({ + sortParams: ['fullNameMU', 'totalMeasurements'], + sortedStrains: Ember.computed.sort('strains', 'sortParams'), +}); diff --git a/app/pods/strains/index/route.js b/app/pods/strains/index/route.js index 7185ff2..034c403 100644 --- a/app/pods/strains/index/route.js +++ b/app/pods/strains/index/route.js @@ -3,16 +3,12 @@ import AuthenticatedRouteMixin from 'simple-auth/mixins/authenticated-route-mixi export default Ember.Route.extend(AuthenticatedRouteMixin, { model: function() { - return this.store.findAll('strain'); + return Ember.RSVP.hash({ + strains: this.store.findAll('strain'), + }); }, + setupController: function(controller, model) { - var tableAttrs = [ - { name: 'Name', attr: 'fullNameMU' }, - { name: 'Total Measurements', attr: 'totalMeasurements' } - ]; - controller.set('model', model); - controller.set('tableAttrs', tableAttrs); - controller.set('row', 'strain-index-row'); - controller.set('sort', ['sortOrder']); + controller.setProperties(model); }, }); diff --git a/app/pods/strains/index/template.hbs b/app/pods/strains/index/template.hbs index 3d91f2a..9ac0600 100644 --- a/app/pods/strains/index/template.hbs +++ b/app/pods/strains/index/template.hbs @@ -1,12 +1,27 @@

{{genus-name}} Strains

-

Total strains: {{model.length}}

+

Total strains: {{strains.length}}

{{add-button label="Add Strain" link="strains.new"}} -{{ - sortable-table - content=model - tableAttrs=tableAttrs - row=row - sortProperties=sort -}} + + + + + + + + + {{#each sortedStrains as |row|}} + + + + + {{/each}} + +
SpeciesTotal Measurements
+ {{#link-to 'strains.show' row.id classBinding="data.typeStrain:type-strain"}} + {{row.fullNameMU}} + {{/link-to}} + + {{row.totalMeasurements}} +