// Generated by CoffeeScript 1.12.5
var get;

import Ember from 'ember';

get = Ember.get;

export default Ember.Component.extend({
  tagName: 'span',
  scope_project: null,
  scope_scenario: null,
  projects: [],
  actions: {
    apply_filters: function() {
      var base;
      return typeof (base = this.get('apply_filters')) === "function" ? base() : void 0;
    },
    edit_project_instance_action: function(project_instance_action) {
      return this.modal('project/edit-instance-action', {
        model: project_instance_action
      });
    },
    set_scope_project: function(project) {
      if (project != null) {
        return project.reload().then((function(_this) {
          return function() {
            var project_id;
            project_id = (project != null ? project.get('id') : void 0) || '';
            _this.set('scope_project', project);
            _this.set('filters.workflow_action_definition_title_cont', '');
            _this.set('filters.project_id', project_id);
            _this.$('.select-project .dropdown.button').addClass('orange');
            return _this.send('apply_filters');
          };
        })(this));
      } else {
        this.setProperties({
          scope_project: null,
          scope_scenario: null,
          'filters.project_id': '',
          'filters.project_instance_project_scenario_id': ''
        }, this.$('.select-project .dropdown.button').removeClass('orange'));
        return this.send('apply_filters');
      }
    },
    set_scope_scenario: function(project_scenario) {
      var scenario_id;
      if (project_scenario) {
        scenario_id = get(project_scenario, 'id');
        this.$('.select-project-scenario .dropdown.button').addClass('orange');
      } else {
        this.$('.select-project-scenario .dropdown.button').removeClass('orange');
        scenario_id = '';
      }
      this.set('filters.project_instance_project_scenario_id', scenario_id);
      this.set('scope_scenario', project_scenario);
      return this.send('apply_filters');
    }
  }
});
