aboutsummaryrefslogtreecommitdiffstats
path: root/server/sonar-web/src/main/js/apps/quality-gates/form-view.js
diff options
context:
space:
mode:
Diffstat (limited to 'server/sonar-web/src/main/js/apps/quality-gates/form-view.js')
-rw-r--r--server/sonar-web/src/main/js/apps/quality-gates/form-view.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/server/sonar-web/src/main/js/apps/quality-gates/form-view.js b/server/sonar-web/src/main/js/apps/quality-gates/form-view.js
new file mode 100644
index 00000000000..5da9dfd05a2
--- /dev/null
+++ b/server/sonar-web/src/main/js/apps/quality-gates/form-view.js
@@ -0,0 +1,47 @@
+define([
+ 'components/common/modal-form',
+ './gate',
+ './templates'
+], function (ModalForm, Gate) {
+
+ return ModalForm.extend({
+ template: Templates['quality-gate-form'],
+
+ onFormSubmit: function () {
+ ModalForm.prototype.onFormSubmit.apply(this, arguments);
+ this.disableForm();
+ this.prepareRequest();
+ },
+
+ sendRequest: function (options) {
+ var that = this,
+ opts = _.defaults(options || {}, {
+ type: 'POST',
+ statusCode: {
+ // do not show global error
+ 400: null
+ }
+ });
+ return Backbone.ajax(opts)
+ .done(function () {
+ that.close();
+ }).fail(function (jqXHR) {
+ that.enableForm();
+ that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+ });
+ },
+
+ addGate: function (attrs) {
+ var gate = new Gate(attrs);
+ this.collection.add(gate, { merge: true });
+ return gate;
+ },
+
+ serializeData: function () {
+ return _.extend(ModalForm.prototype.serializeData.apply(this, arguments), {
+ method: this.method
+ });
+ }
+ });
+
+});