diff --git a/app/pods/protected/about/route.js b/app/pods/protected/about/route.js index 096e3c5..5f46de6 100644 --- a/app/pods/protected/about/route.js +++ b/app/pods/protected/about/route.js @@ -1,3 +1,5 @@ import Ember from 'ember'; -export default Ember.Route.extend({}); +const { Route } = Ember; + +export default Route.extend({}); diff --git a/app/pods/protected/compare/controller.js b/app/pods/protected/compare/controller.js index 00ef991..bc04ca2 100644 --- a/app/pods/protected/compare/controller.js +++ b/app/pods/protected/compare/controller.js @@ -1,41 +1,11 @@ import Ember from 'ember'; -export default Ember.Controller.extend({ +const { Controller } = Ember; + +export default Controller.extend({ actions: { - search: function() { - let query = { - strain_ids: this.get('selectedStrains'), - characteristic_ids: this.get('selectedCharacteristics'), - }; - - this.transitionToRoute('protected.compare.results', {queryParams: query}); + search: function(query) { + this.transitionToRoute('protected.compare.results', { queryParams: query }); }, - - selectAllStrains: function() { - let strains = this.get('strains'); - let strain_ids = []; - strains.forEach((strain) => { - strain_ids.push(strain.id); - }); - this.set('selectedStrains', strain_ids.join(",")); - }, - - deselectAllStrains: function() { - this.set('selectedStrains', ''); - }, - - selectAllCharacteristics: function() { - let chars = this.get('characteristics'); - let char_ids = []; - chars.forEach((char) => { - char_ids.push(char.id); - }); - this.set('selectedCharacteristics', char_ids.join(",")); - }, - - deselectAllCharacteristics: function() { - this.set('selectedCharacteristics', ''); - }, - } }); diff --git a/app/pods/protected/compare/route.js b/app/pods/protected/compare/route.js index 19c8e94..199ade7 100644 --- a/app/pods/protected/compare/route.js +++ b/app/pods/protected/compare/route.js @@ -1,6 +1,8 @@ import Ember from 'ember'; -export default Ember.Route.extend({ +const { Route } = Ember; + +export default Route.extend({ model: function() { return this.store.findAll('characteristic'); }, diff --git a/app/pods/protected/compare/select-form/component.js b/app/pods/protected/compare/select-form/component.js new file mode 100644 index 0000000..34f5bff --- /dev/null +++ b/app/pods/protected/compare/select-form/component.js @@ -0,0 +1,49 @@ +import Ember from 'ember'; + +const { Component } = Ember; + +export default Component.extend({ + characteristics: null, + strains: null, + + "on-search": null, + + selectedStrains: null, + selectedCharacteristics: null, + + actions: { + search: function() { + const query = { + strain_ids: this.get('selectedStrains'), + characteristic_ids: this.get('selectedCharacteristics'), + }; + this.attrs['on-search'](query); + }, + + selectAllStrains: function() { + const strains = this.get('strains'); + const strain_ids = []; + strains.forEach((strain) => { + strain_ids.push(strain.get('id')); + }); + this.set('selectedStrains', strain_ids.join(",")); + }, + + deselectAllStrains: function() { + this.set('selectedStrains', ''); + }, + + selectAllCharacteristics: function() { + const chars = this.get('characteristics'); + const char_ids = []; + chars.forEach((char) => { + char_ids.push(char.get('id')); + }); + this.set('selectedCharacteristics', char_ids.join(",")); + }, + + deselectAllCharacteristics: function() { + this.set('selectedCharacteristics', ''); + }, + }, +}); diff --git a/app/pods/protected/compare/select-form/template.hbs b/app/pods/protected/compare/select-form/template.hbs new file mode 100644 index 0000000..61a07a5 --- /dev/null +++ b/app/pods/protected/compare/select-form/template.hbs @@ -0,0 +1,53 @@ +
+
+
+
    +
  • + + {{ + select-2 + multiple=true + content=strains + value=selectedStrains + optionValuePath="id" + optionLabelPath="fullNameMU" + placeholder="Select one or more strains" + }} +
  • +
  • + + +
  • +
  • + + {{ + select-2 + multiple=true + content=characteristics + value=selectedCharacteristics + optionValuePath="id" + optionLabelPath="characteristicName" + placeholder="Select one or more characteristics" + }} +
  • +
  • + + +
  • +
  • + +
  • +
+
+
+
diff --git a/app/pods/protected/compare/template.hbs b/app/pods/protected/compare/template.hbs index fefe9a6..6dc89e8 100644 --- a/app/pods/protected/compare/template.hbs +++ b/app/pods/protected/compare/template.hbs @@ -1,57 +1,10 @@

{{genus-name}} - Compare Strains

-
-
-
-
    -
  • - - {{ - select-2 - multiple=true - content=strains - value=selectedStrains - optionValuePath="id" - optionLabelPath="fullNameMU" - placeholder="Select one or more strains" - }} -
  • -
  • - - -
  • -
  • - - {{ - select-2 - multiple=true - content=characteristics - value=selectedCharacteristics - optionValuePath="id" - optionLabelPath="characteristicName" - placeholder="Select one or more characteristics" - }} -
  • -
  • - - -
  • -
  • - -
  • -
-
-
-
+{{ + protected/compare/select-form + characteristics=characteristics + strains=strains + on-search=(action "search") +}} {{outlet}} diff --git a/app/pods/protected/index/route.js b/app/pods/protected/index/route.js index bfdf329..fdf337b 100644 --- a/app/pods/protected/index/route.js +++ b/app/pods/protected/index/route.js @@ -1,6 +1,8 @@ import Ember from 'ember'; -export default Ember.Route.extend({ +const { Route } = Ember; + +export default Route.extend({ beforeModel: function(transition) { this._super(transition); this.transitionTo('protected.compare'); diff --git a/app/pods/protected/index/template.hbs b/app/pods/protected/index/template.hbs deleted file mode 100644 index ba4c514..0000000 --- a/app/pods/protected/index/template.hbs +++ /dev/null @@ -1 +0,0 @@ -Welcome