aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/components/issue/views/plan-form-view.js
blob: ad924a6302e01695e535adc4e72a86cea4ff7beb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import $ from 'jquery';
import _ from 'underscore';
import ActionOptionsView from '../../common/action-options-view';
import Template from '../templates/issue-plan-form.hbs';

export default ActionOptionsView.extend({
  template: Template,

  getActionPlan: function () {
    return this.model.get('actionPlan') || '';
  },

  selectInitialOption: function () {
    this.makeActive(this.getOptions().filter('[data-value="' + this.getActionPlan() + '"]'));
  },

  selectOption: function (e) {
    var actionPlan = $(e.currentTarget).data('value'),
        actionPlanName = $(e.currentTarget).data('text');
    this.submit(actionPlan, actionPlanName);
    return ActionOptionsView.prototype.selectOption.apply(this, arguments);
  },

  submit: function (actionPlan) {
    return this.model.plan(actionPlan);
  },

  getActionPlans: function () {
    return [{ key: '', name: window.t('issue.unplanned') }].concat(this.collection.toJSON());
  },

  serializeData: function () {
    return _.extend(ActionOptionsView.prototype.serializeData.apply(this, arguments), {
      items: this.getActionPlans()
    });
  }
});