aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/provisioning/projects.js
blob: 05a59f822affb48687cc07ed0c8882e553ee829f (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
38
39
40
41
42
43
44
45
46
47
48
49
define([
  './project'
], function (Project) {

  return Backbone.Collection.extend({
    model: Project,

    url: function () {
      return baseUrl + '/api/projects/provisioned';
    },

    parse: function (r) {
      this.total = r.total;
      this.p = r.p;
      this.ps = r.ps;
      return r.projects;
    },

    fetch: function (options) {
      var d = (options && options.data) || {};
      this.q = d.q;
      return this._super(options);
    },

    fetchMore: function () {
      var p = this.p + 1;
      return this.fetch({ add: true, remove: false, data: { p: p, ps: this.ps, q: this.q } });
    },

    refresh: function () {
      return this.fetch({ reset: true, data: { q: this.q } });
    },

    hasMore: function () {
      return this.total > this.p * this.ps;
    },

    bulkDelete: function (ids, options) {
      var opts = _.extend({}, options, {
        type: 'POST',
        url: baseUrl + '/api/projects/bulk_delete',
        data: { ids: ids.join() }
      });
      return Backbone.ajax(opts);
    }

  });

});