]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5851 improve forms
authorStas Vilchik <vilchiks@gmail.com>
Wed, 15 Apr 2015 13:29:49 +0000 (15:29 +0200)
committerStas Vilchik <vilchiks@gmail.com>
Wed, 15 Apr 2015 13:29:56 +0000 (15:29 +0200)
server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-copy-profile.hbs
server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-rename-profile.hbs
server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-restore-profile.hbs
server/sonar-web/src/main/js/common/modal-form.js
server/sonar-web/src/main/js/quality-profiles/change-profile-parent-view.js
server/sonar-web/src/main/js/quality-profiles/copy-profile-view.js
server/sonar-web/src/main/js/quality-profiles/create-profile-view.js
server/sonar-web/src/main/js/quality-profiles/delete-profile-view.js
server/sonar-web/src/main/js/quality-profiles/rename-profile-view.js
server/sonar-web/src/main/js/quality-profiles/restore-built-in-profiles-view.js
server/sonar-web/src/main/js/quality-profiles/restore-profile-view.js

index 04c5a10c516b0f62c3b15e2362a2f984863edd60..6cc034f1209660eb52c2ea741f68b4e107745620 100644 (file)
@@ -6,7 +6,7 @@
     <div class="js-modal-messages"></div>
     <div class="modal-field">
       <label for="copy-profile-name">{{t 'quality_profiles.copy_new_name'}}<em class="mandatory">*</em></label>
-      <input id="copy-profile-name" name="name" type="text" size="50" maxlength="100">
+      <input id="copy-profile-name" name="name" type="text" size="50" maxlength="100" required>
     </div>
   </div>
   <div class="modal-foot">
index fc57dcaa03f6b98be5e1abce24e7c7a9c45d1e8b..3da132f8f4f878d47a421c9a91c5841f5a2e3f0f 100644 (file)
@@ -6,7 +6,7 @@
     <div class="js-modal-messages"></div>
     <div class="modal-field">
       <label for="rename-profile-name">{{t 'quality_profiles.new_name'}} <em class="mandatory">*</em></label>
-      <input id="rename-profile-name" name="name" type="text" size="50" maxlength="100" value="{{name}}">
+      <input id="rename-profile-name" name="name" type="text" size="50" maxlength="100" value="{{name}}" required>
     </div>
   </div>
   <div class="modal-foot">
index 4f27e912d488ba28b106aa7403c6dfb0b5565dcf..faffd5950aede16114d18fe29a8835c60604c967 100644 (file)
@@ -7,7 +7,7 @@
     <div class="js-modal-messages"></div>
     <div class="modal-field">
       <label for="restore-profile-backup">{{t 'backup'}}<em class="mandatory">*</em></label>
-      <input type="file" id="restore-profile-backup" name="backup">
+      <input type="file" id="restore-profile-backup" name="backup" required>
     </div>
   </div>
   <div class="modal-foot">
index c369bdf0ef6e042bbe04e40286f902f89af0c62e..322610e28b456abb9e7c9b5f477b401c0af1fbfc 100644 (file)
@@ -60,6 +60,18 @@ define(['common/modals'], function (ModalView) {
         });
       }
       this.ui.messagesContainer.scrollParent().scrollTop(0);
+    },
+
+    disableForm: function () {
+      var form = this.$('form');
+      this.disabledFields = form.find(':input:not(:disabled)');
+      this.disabledFields.prop('disabled', true);
+    },
+
+    enableForm: function () {
+      if (this.disabledFields != null) {
+        this.disabledFields.prop('disabled', false);
+      }
     }
   });
 
index 27a0611248a538a8ddf9e0106abd272b24a8e109..ef087af1a1866c7717bce2fc84b777e916807812 100644 (file)
@@ -37,6 +37,7 @@ define([
 
     onFormSubmit: function () {
       ModalFormView.prototype.onFormSubmit.apply(this, arguments);
+      this.disableForm();
       this.sendRequest();
     },
 
@@ -62,6 +63,7 @@ define([
         that.close();
       }).fail(function (jqXHR) {
         that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+        that.enableForm();
       });
     },
 
index 7d686a86bb9c7f6b17e0a9f156c5931887b720c3..5c5eb9879572ede4bebe5771083ae923ce00f3fb 100644 (file)
@@ -30,6 +30,7 @@ define([
 
     onFormSubmit: function () {
       ModalFormView.prototype.onFormSubmit.apply(this, arguments);
+      this.disableForm();
       this.sendRequest();
     },
 
@@ -53,6 +54,7 @@ define([
         that.addProfile(r);
         that.close();
       }).fail(function (jqXHR) {
+        that.enableForm();
         that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
       });
     },
index e6045f31716008eb704396de9c18230b8ef241b2..00d54e2b38d09cbe29d278338f8fb438ec93d90f 100644 (file)
@@ -37,6 +37,7 @@ define([
 
     onFormSubmit: function (e) {
       ModalFormView.prototype.onFormSubmit.apply(this, arguments);
+      this.disableForm();
       this.sendRequest(e);
     },
 
@@ -72,6 +73,7 @@ define([
       uploader({ form: $(e.currentTarget) }).done(function (r) {
         if (_.isArray(r.errors) || _.isArray(r.warnings)) {
           that.showErrors(r.errors, r.warnings);
+          that.enableForm();
         } else {
           that.addProfile(r.profile);
           that.close();
index 570b60f00d8e15db33ecfba186a04738fb4f9880..e1026727f79b915437127a0e33b4750e80f836bb 100644 (file)
@@ -33,6 +33,7 @@ define([
 
     onFormSubmit: function () {
       ModalFormView.prototype.onFormSubmit.apply(this, arguments);
+      this.disableForm();
       this.sendRequest();
     },
 
@@ -53,6 +54,7 @@ define([
         that.model.trigger('destroy', that.model, that.model.collection);
       }).fail(function (jqXHR) {
         that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+        that.enableForm();
       });
     }
   });
index 023f3a94f780d08c9381e88f8e6f6026f78d1e17..7ca92f76d241e1b60ddf0268f634d43a2a03c241 100644 (file)
@@ -29,6 +29,7 @@ define([
 
     onFormSubmit: function () {
       ModalFormView.prototype.onFormSubmit.apply(this, arguments);
+      this.disableForm();
       this.sendRequest();
     },
 
@@ -53,6 +54,7 @@ define([
         that.close();
       }).fail(function (jqXHR) {
         that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+        that.enableForm();
       });
     }
   });
index 83dfc2a0c5d039dd50dc6c7b58ba36d0f79fc0ab..4285a6bf8d318af27cda4c82e44975a384c022d4 100644 (file)
@@ -29,6 +29,7 @@ define([
 
     onFormSubmit: function (e) {
       ModalFormView.prototype.onFormSubmit.apply(this, arguments);
+      this.disableForm();
       this.sendRequest();
     },
 
@@ -59,6 +60,7 @@ define([
         that.close();
       }).fail(function (jqXHR) {
         that.showErrors(jqXHR.responseJSON.errors, jqXHR.responseJSON.warnings);
+        that.enableForm();
       });
     },
 
index dea4bfeeab0b440235a664a42a7dbe5397178c70..75b7a735cddb2dd91430d1c3b537312fb7ed7e5f 100644 (file)
@@ -31,9 +31,11 @@ define([
     onFormSubmit: function (e) {
       var that = this;
       ModalFormView.prototype.onFormSubmit.apply(this, arguments);
+      this.disableForm();
       uploader({ form: $(e.currentTarget) }).done(function (r) {
         if (_.isArray(r.errors) || _.isArray(r.warnings)) {
           that.showErrors(r.errors, r.warnings);
+          that.enableForm();
         } else {
           that.collection.fetch().done(function () {
             var profile = that.collection.findWhere({ key: r.profile.key });