This repository has been archived on 2025-03-30. You can view files and clone it, but cannot push or open issues or pull requests.
hymenobacterdotinfo/app/pods/protected/compare/results/route.js

47 lines
1.3 KiB
JavaScript

import Ember from 'ember';
import ajaxRequest from '../../../../utils/ajax-request';
export default Ember.Route.extend({
queryParams: {
strain_ids: {
refreshModel: true,
},
characteristic_ids: {
refreshModel: true,
},
},
beforeModel: function(transition) {
this._super(transition);
if (Ember.$.isEmptyObject(transition.queryParams.strain_ids) ||
Ember.$.isEmptyObject(transition.queryParams.characteristic_ids)) {
this.transitionTo('protected.compare');
}
},
model: function(params) {
if (params.strain_ids === '' || params.characteristic_ids === '') {
this.transitionTo('protected.compare');
}
let compare = this.controllerFor('protected.compare');
compare.set('selectedStrains', params.strain_ids);
compare.set('selectedCharacteristics', params.characteristic_ids);
let url = `${this.get('globals.apiURL')}/api/${this.get('globals.genus')}/compare`;
let options = {
method: 'GET',
data: params,
};
return ajaxRequest(url, options);
},
setupController: function(controller, model) {
model.forEach((m, i) => {
let c = this.store.peekRecord('characteristic', m[0]);
model[i][0] = c.get('characteristicName');
});
controller.set('model', model);
},
});