aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/quality-gates/condition.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/apps/quality-gates/condition.js')
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/condition.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/condition.js b/server/sonar-web/src/main/js/apps/quality-gates/condition.js
new file mode 100644
index 00000000000..9ca451ee5a0
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/quality-gates/condition.js
@@ -0,0 +1,47 @@
+define(function () {
+
+ return Backbone.Model.extend({
+
+ defaults: {
+ period: 0
+ },
+
+ url: function () {
+ return baseUrl + '/api/qualitygates';
+ },
+
+ createUrl: function () {
+ return this.url() + '/create_condition';
+ },
+
+ updateUrl: function () {
+ return this.url() + '/update_condition';
+ },
+
+ deleteUrl: function () {
+ return this.url() + '/delete_condition';
+ },
+
+ sync: function (method, model, options) {
+ var opts = options || {};
+ opts.type = 'POST';
+ if (method === 'create') {
+ opts.url = this.createUrl();
+ opts.data = model.toJSON();
+ }
+ if (method === 'update') {
+ opts.url = this.updateUrl();
+ opts.data = model.toJSON();
+ }
+ if (method === 'delete') {
+ opts.url = this.deleteUrl();
+ opts.data = { id: model.id };
+ }
+ if (opts.data.period === '0') {
+ delete opts.data.period;
+ }
+ return Backbone.ajax(opts);
+ }
+ });
+
+});