diff options
Diffstat (limited to 'server/sonar-web/src/main/js/apps/custom-measures/custom-measure.js')
-rw-r--r-- | server/sonar-web/src/main/js/apps/custom-measures/custom-measure.js | 65 |
1 files changed, 33 insertions, 32 deletions
diff --git a/server/sonar-web/src/main/js/apps/custom-measures/custom-measure.js b/server/sonar-web/src/main/js/apps/custom-measures/custom-measure.js index fce8bf4fbdf..17565de6cfe 100644 --- a/server/sonar-web/src/main/js/apps/custom-measures/custom-measure.js +++ b/server/sonar-web/src/main/js/apps/custom-measures/custom-measure.js @@ -1,37 +1,38 @@ -define(function () { +import _ from 'underscore'; +import Backbone from 'backbone'; - return Backbone.Model.extend({ - idAttribute: 'id', +export default Backbone.Model.extend({ + idAttribute: 'id', - urlRoot: function () { - return baseUrl + '/api/custom_measures'; - }, + urlRoot: function () { + return baseUrl + '/api/custom_measures'; + }, - sync: function (method, model, options) { - var opts = options || {}; - if (method === 'create') { - _.defaults(opts, { - url: this.urlRoot() + '/create', - type: 'POST', - data: _.pick(model.toJSON(), 'metricId', 'value', 'description', 'projectId') - }); - } - if (method === 'update') { - _.defaults(opts, { - url: this.urlRoot() + '/update', - type: 'POST', - data: _.pick(model.toJSON(), 'id', 'value', 'description') - }); - } - if (method === 'delete') { - _.defaults(opts, { - url: this.urlRoot() + '/delete', - type: 'POST', - data: { id: this.id } - }); - } - return Backbone.ajax(opts); + sync: function (method, model, options) { + var opts = options || {}; + if (method === 'create') { + _.defaults(opts, { + url: this.urlRoot() + '/create', + type: 'POST', + data: _.pick(model.toJSON(), 'metricId', 'value', 'description', 'projectId') + }); } - }); - + if (method === 'update') { + _.defaults(opts, { + url: this.urlRoot() + '/update', + type: 'POST', + data: _.pick(model.toJSON(), 'id', 'value', 'description') + }); + } + if (method === 'delete') { + _.defaults(opts, { + url: this.urlRoot() + '/delete', + type: 'POST', + data: { id: this.id } + }); + } + return Backbone.ajax(opts); + } }); + + |