Files
ember-panda/addon/controllers/action-list.js
T

83 lines
2.7 KiB
JavaScript

// Generated by CoffeeScript 1.12.5
var slice = [].slice;
import Ember from 'ember';
export default Ember.Controller.extend({
session: Ember.inject.service('session'),
filters: {},
scope_project: null,
scope_scenario: null,
scope_organization: null,
filter_query: Ember.computed('filters.filter_calls', function() {
var ref;
return ((ref = this.get('filters')) != null ? ref.toProperties() : void 0) || {};
}),
export_human_url: Ember.computed('filter_query', function() {
var base_url, filter_addition, model_name;
model_name = 'panda/project-instance-action';
base_url = this.store.adapterFor(model_name).buildURL(model_name);
filter_addition = Ember.$.param({
q: this.get('filter_query'),
include_pointing: true
});
return base_url + "/export_human.csv?" + filter_addition;
}),
export_technical_url: Ember.computed('filter_query', function() {
var base_url, filter_addition, model_name;
model_name = 'panda/project-instance-action';
base_url = this.store.adapterFor(model_name).buildURL(model_name);
filter_addition = Ember.$.param({
q: this.get('filter_query'),
include_pointing: true
});
return base_url + "/export_technical.csv?" + filter_addition;
}),
apply_filters: function() {
this.incrementProperty('filters.filter_calls');
this.set('model.project_instance_actions.page', 1);
this.set('model.project_instance_actions.lastPage', null);
this.get('model.project_instance_actions').setOtherParam('q', this.get('filter_query'));
return false;
},
actions: {
refresh_list: function() {
return this.apply_filters();
},
edit_project_instance_action: function(project_instance_action) {
return this.modal('project/edit-instance-action', {
model: project_instance_action
});
},
toggle_filter: function(key, value, checked) {
var new_value;
new_value = [];
if (checked) {
new_value = new_value.concat(this.get("filters." + key)).concat(value);
} else {
this.get("filters." + key).forEach(function(present_in_filter) {
if (present_in_filter !== value) {
return new_value.push(present_in_filter);
}
});
}
this.set("filters." + key, new_value);
return this.apply_filters();
},
clear_filter: function() {
var keys;
keys = 1 <= arguments.length ? slice.call(arguments, 0) : [];
keys.forEach((function(_this) {
return function(key) {
if (Ember.isArray(_this.get("filters." + key))) {
return _this.set("filters." + key, []);
} else {
return _this.set("filters." + key, null);
}
};
})(this));
return this.apply_filters();
}
}
});