diff options
author | Stas Vilchik <vilchiks@gmail.com> | 2015-04-15 15:29:49 +0200 |
---|---|---|
committer | Stas Vilchik <vilchiks@gmail.com> | 2015-04-15 15:29:56 +0200 |
commit | 2a7b8ef70bf6d60f3c30be80402b8d937aeb46c6 (patch) | |
tree | eadf8213b64926044079c1152a4540b125b42e0a | |
parent | a1b10d22ff9b0785bff99daac17ac499d010ea74 (diff) | |
download | sonarqube-2a7b8ef70bf6d60f3c30be80402b8d937aeb46c6.tar.gz sonarqube-2a7b8ef70bf6d60f3c30be80402b8d937aeb46c6.zip |
SONAR-5851 improve forms
11 files changed, 29 insertions, 3 deletions
diff --git a/server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-copy-profile.hbs b/server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-copy-profile.hbs index 04c5a10c516..6cc034f1209 100644 --- a/server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-copy-profile.hbs +++ b/server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-copy-profile.hbs @@ -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"> diff --git a/server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-rename-profile.hbs b/server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-rename-profile.hbs index fc57dcaa03f..3da132f8f4f 100644 --- a/server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-rename-profile.hbs +++ b/server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-rename-profile.hbs @@ -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"> diff --git a/server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-restore-profile.hbs b/server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-restore-profile.hbs index 4f27e912d48..faffd5950ae 100644 --- a/server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-restore-profile.hbs +++ b/server/sonar-web/src/main/hbs/quality-profiles/quality-profiles-restore-profile.hbs @@ -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"> diff --git a/server/sonar-web/src/main/js/common/modal-form.js b/server/sonar-web/src/main/js/common/modal-form.js index c369bdf0ef6..322610e28b4 100644 --- a/server/sonar-web/src/main/js/common/modal-form.js +++ b/server/sonar-web/src/main/js/common/modal-form.js @@ -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); + } } }); diff --git a/server/sonar-web/src/main/js/quality-profiles/change-profile-parent-view.js b/server/sonar-web/src/main/js/quality-profiles/change-profile-parent-view.js index 27a0611248a..ef087af1a18 100644 --- a/server/sonar-web/src/main/js/quality-profiles/change-profile-parent-view.js +++ b/server/sonar-web/src/main/js/quality-profiles/change-profile-parent-view.js @@ -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(); }); }, diff --git a/server/sonar-web/src/main/js/quality-profiles/copy-profile-view.js b/server/sonar-web/src/main/js/quality-profiles/copy-profile-view.js index 7d686a86bb9..5c5eb987957 100644 --- a/server/sonar-web/src/main/js/quality-profiles/copy-profile-view.js +++ b/server/sonar-web/src/main/js/quality-profiles/copy-profile-view.js @@ -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); }); }, diff --git a/server/sonar-web/src/main/js/quality-profiles/create-profile-view.js b/server/sonar-web/src/main/js/quality-profiles/create-profile-view.js index e6045f31716..00d54e2b38d 100644 --- a/server/sonar-web/src/main/js/quality-profiles/create-profile-view.js +++ b/server/sonar-web/src/main/js/quality-profiles/create-profile-view.js @@ -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(); diff --git a/server/sonar-web/src/main/js/quality-profiles/delete-profile-view.js b/server/sonar-web/src/main/js/quality-profiles/delete-profile-view.js index 570b60f00d8..e1026727f79 100644 --- a/server/sonar-web/src/main/js/quality-profiles/delete-profile-view.js +++ b/server/sonar-web/src/main/js/quality-profiles/delete-profile-view.js @@ -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(); }); } }); diff --git a/server/sonar-web/src/main/js/quality-profiles/rename-profile-view.js b/server/sonar-web/src/main/js/quality-profiles/rename-profile-view.js index 023f3a94f78..7ca92f76d24 100644 --- a/server/sonar-web/src/main/js/quality-profiles/rename-profile-view.js +++ b/server/sonar-web/src/main/js/quality-profiles/rename-profile-view.js @@ -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(); }); } }); diff --git a/server/sonar-web/src/main/js/quality-profiles/restore-built-in-profiles-view.js b/server/sonar-web/src/main/js/quality-profiles/restore-built-in-profiles-view.js index 83dfc2a0c5d..4285a6bf8d3 100644 --- a/server/sonar-web/src/main/js/quality-profiles/restore-built-in-profiles-view.js +++ b/server/sonar-web/src/main/js/quality-profiles/restore-built-in-profiles-view.js @@ -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(); }); }, diff --git a/server/sonar-web/src/main/js/quality-profiles/restore-profile-view.js b/server/sonar-web/src/main/js/quality-profiles/restore-profile-view.js index dea4bfeeab0..75b7a735cdd 100644 --- a/server/sonar-web/src/main/js/quality-profiles/restore-profile-view.js +++ b/server/sonar-web/src/main/js/quality-profiles/restore-profile-view.js @@ -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 }); |