parent
024836cab0
commit
d05c31cc94
8 changed files with 75 additions and 28 deletions
|
@ -3,8 +3,8 @@ import Ember from 'ember';
|
|||
const { Controller } = Ember;
|
||||
|
||||
export default Controller.extend({
|
||||
selectedStrains: null,
|
||||
selectedCharacteristics: null,
|
||||
selectedStrains: [],
|
||||
selectedCharacteristics: [],
|
||||
|
||||
actions: {
|
||||
search: function(query) {
|
||||
|
|
|
@ -30,8 +30,8 @@ export default Route.extend({
|
|||
}
|
||||
|
||||
const compare = this.controllerFor('protected.compare');
|
||||
compare.set('selectedStrains', params.strain_ids);
|
||||
compare.set('selectedCharacteristics', params.characteristic_ids);
|
||||
compare.set('selectedStrains', params.strain_ids.split(","));
|
||||
compare.set('selectedCharacteristics', params.characteristic_ids.split(","));
|
||||
|
||||
return this.get('ajax').request('/compare', { data: params });
|
||||
},
|
||||
|
@ -45,14 +45,14 @@ export default Route.extend({
|
|||
const compare = this.controllerFor('protected.compare');
|
||||
|
||||
const strains = [];
|
||||
const strain_ids = compare.get('selectedStrains').split(',');
|
||||
const strain_ids = compare.get('selectedStrains');
|
||||
strain_ids.forEach((id) => {
|
||||
strains.push(this.store.peekRecord('strain', id));
|
||||
});
|
||||
controller.set('strains', strains);
|
||||
|
||||
const characteristics = [];
|
||||
const characteristic_ids = compare.get('selectedCharacteristics').split(',');
|
||||
const characteristic_ids = compare.get('selectedCharacteristics');
|
||||
characteristic_ids.forEach((id) => {
|
||||
characteristics.push(this.store.peekRecord('characteristic', id));
|
||||
});
|
||||
|
|
|
@ -10,8 +10,8 @@ export default Component.extend({
|
|||
"update-strains": null,
|
||||
"update-characteristics": null,
|
||||
|
||||
selectedStrains: null,
|
||||
selectedCharacteristics: null,
|
||||
selectedStrains: [],
|
||||
selectedCharacteristics: [],
|
||||
|
||||
updateStrains: function(selection) {
|
||||
this.set('selectedStrains', selection);
|
||||
|
@ -38,11 +38,11 @@ export default Component.extend({
|
|||
strains.forEach((strain) => {
|
||||
strain_ids.push(strain.get('id'));
|
||||
});
|
||||
this.updateStrains(strain_ids.join(","));
|
||||
this.updateStrains(strain_ids);
|
||||
},
|
||||
|
||||
deselectAllStrains: function() {
|
||||
this.updateStrains("");
|
||||
this.updateStrains([]);
|
||||
},
|
||||
|
||||
selectAllCharacteristics: function() {
|
||||
|
@ -51,11 +51,19 @@ export default Component.extend({
|
|||
chars.forEach((char) => {
|
||||
char_ids.push(char.get('id'));
|
||||
});
|
||||
this.updateCharacteristics(char_ids.join(","));
|
||||
this.updateCharacteristics(char_ids);
|
||||
},
|
||||
|
||||
deselectAllCharacteristics: function() {
|
||||
this.updateCharacteristics("");
|
||||
this.updateCharacteristics([]);
|
||||
},
|
||||
|
||||
updateStrainSelection: function(selection) {
|
||||
this.updateStrains(selection);
|
||||
},
|
||||
|
||||
updateCharacteristicsSelection: function(selection) {
|
||||
this.updateCharacteristics(selection);
|
||||
},
|
||||
},
|
||||
});
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
<li>
|
||||
<label>Strains</label>
|
||||
{{
|
||||
select-2
|
||||
x-select
|
||||
options=strains
|
||||
nameAttr='fullNameMU'
|
||||
multiple=true
|
||||
content=strains
|
||||
value=selectedStrains
|
||||
optionValuePath="id"
|
||||
optionLabelPath="fullNameMU"
|
||||
selected=selectedStrains
|
||||
update=(action "updateStrainSelection")
|
||||
placeholder="Select one or more strains"
|
||||
}}
|
||||
</li>
|
||||
|
@ -25,12 +25,12 @@
|
|||
<li>
|
||||
<label>Characteristics</label>
|
||||
{{
|
||||
select-2
|
||||
x-select
|
||||
options=characteristics
|
||||
nameAttr='characteristicName'
|
||||
multiple=true
|
||||
content=characteristics
|
||||
value=selectedCharacteristics
|
||||
optionValuePath="id"
|
||||
optionLabelPath="characteristicName"
|
||||
selected=selectedCharacteristics
|
||||
update=(action "updateCharacteristicsSelection")
|
||||
placeholder="Select one or more characteristics"
|
||||
}}
|
||||
</li>
|
||||
|
|
|
@ -15,11 +15,13 @@
|
|||
<div data-row-span="2">
|
||||
<div data-field-span="2">
|
||||
<label>Species</label>
|
||||
<select onchange={{action "speciesDidChange" value="target.value"}}>
|
||||
{{#each speciesList as |speciesChoice|}}
|
||||
<option value={{speciesChoice.id}} selected={{equal species.id speciesChoice.id}}>{{speciesChoice.speciesName}}</option>
|
||||
{{/each}}
|
||||
</select>
|
||||
{{
|
||||
x-select
|
||||
options=speciesList
|
||||
nameAttr='speciesName'
|
||||
selected=species.id
|
||||
update=(action "speciesDidChange")
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
<div data-row-span="2">
|
||||
|
|
Reference in a new issue