]> source.dussan.org Git - sonarqube.git/commitdiff
Improve error handling in modal form in order to let the possibility to display error...
authorJulien Lancelot <julien.lancelot@gmail.com>
Fri, 19 Jul 2013 09:56:22 +0000 (11:56 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Fri, 19 Jul 2013 09:56:34 +0000 (11:56 +0200)
13 files changed:
sonar-server/src/main/webapp/WEB-INF/app/views/issues/_bulk_change_form.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/issues/_filter_copy_form.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/issues/_filter_edit_form.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/issues/_filter_save_as_form.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/issues/_filter_shared_form.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/_default_templates_form.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/_edit_groups.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/_edit_users.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/permission_templates/_permission_template_form.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/roles/_apply_template_form.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/roles/_edit_groups.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/roles/_edit_users.html.erb
sonar-server/src/main/webapp/javascripts/application.js

index 8063e1d6464acff726c0b7f757c2c2605204eb0d..28dbe20342c79015214e2b80a667cff84ce35a26 100644 (file)
@@ -30,7 +30,7 @@
         <p class="notes"><%= message('issue_bulk_change.max_issues_reached', :params => issues.size) -%></p>
       <% end %>
       </div>
-      <div class="bulk-change errors error" style="display:none;"/>
+      <div class="modal-error"/>
 
       <% if unresolved_issues > 0 %>
       <div class="modal-field">
       </div>
     </div>
     <div class="modal-foot">
-      <span id="bulk-change-loading-image" class="hidden"><%= image_tag 'loading.gif' %></span>
+      <span id="bulk-change-loading-image" class="loading-image hidden"><%= image_tag 'loading.gif' %></span>
       <input type="submit" value="<%= message('apply') -%>" id="bulk-change-submit" class="bulk-change" onclick="return displayLoadingImage()" />
       <a href="#" onclick="return closeModalWindow()" id="bulk-change-cancel"><%= message('cancel') -%></a>
     </div>
   $j("#bulk-change-form").modalForm({
     success: function () {
       onBulkIssues(<%= params.to_json -%>);
-    },
-    error: function (xhr, textStatus, errorThrown) {
-      $j('#bulk-change-loading-image').addClass("hidden");
-      var htmlClass = 'bulk-change';
-      $j('input[type=submit].' + htmlClass).removeAttr('disabled');
-      $j('.' + htmlClass + '.errors').show();
-      $j('.' + htmlClass + '.errors').html(xhr.responseText);
     }
   });
 
index 44fd2281a74043dc76bc0e22a8b7ac5bebb31b9d..8f4d1a26f6dfbdebbbcb166ee4ff2c8e53b34bf7 100644 (file)
   $j("#copy-filter-form").modalForm({
     success: function (data) {
       window.location = baseUrl + '/issues/filter/' + data;
-    },
-    error: function (xhr, textStatus, errorThrown) {
-      var htmlClass = 'issue-filter';
-      $j('input[type=submit].' + htmlClass).removeAttr('disabled');
-      $j('.' + htmlClass + '.errors').show();
-      $j('.' + htmlClass + '.errors').html(xhr.responseText);
     }
   });
 </script>
\ No newline at end of file
index 4333ed8cdd4760bff2bb042008538465537ca8c5..f12ef26050bbfd7adabd84000d72abd427236034 100644 (file)
   $j("#edit-filter-form").modalForm({
     success: function (data) {
       window.location = baseUrl + '/issues/filter/' + data;
-    },
-    error: function (xhr, textStatus, errorThrown) {
-      var htmlClass = 'issue-filter';
-      $j('input[type=submit].' + htmlClass).removeAttr('disabled');
-      $j('.' + htmlClass + '.errors').show();
-      $j('.' + htmlClass + '.errors').html(xhr.responseText);
     }
   });
 </script>
\ No newline at end of file
index ccc964245837eac4f754f2e8cdccf22e9ad41f24..40dcc6cd48454b861741a3acc493500a33534651 100644 (file)
   $j("#save-as-filter-form").modalForm({
     success: function (data) {
       window.location = baseUrl + '/issues/filter/' + data;
-    },
-    error: function (xhr, textStatus, errorThrown) {
-      var htmlClass = 'issue-filter';
-      $j('input[type=submit].' + htmlClass).removeAttr('disabled');
-      $j('.' + htmlClass + '.errors').show();
-      $j('.' + htmlClass + '.errors').html(xhr.responseText);
     }
   });
 </script>
\ No newline at end of file
index 5945781f885e3c8fd19ccfd4355770e401bd7cae..d90b9660b73ed94cc3b56384c66538e80790d9cb 100644 (file)
@@ -2,7 +2,7 @@
      display_owner = false
    end %>
 <div class="modal-body">
-  <div id="issue-filter-error" class="issue-filter errors error" style="display:none;" />
+  <div class="modal-error"/>
   <div class="modal-field">
     <label for="name"><%= message('issue_filter.form.name') -%> <em class="mandatory">*</em></label>
     <input id="name" name="name" type="text" size="50" maxlength="100" value="<%= h(@filter.name) if @filter -%>" autofocus="autofocus"/>
index 825e2468e5e0c3d0a0eb66654dca476001d74d4a..950a07da449a19ebc3e87e426ef34c60d007f53c 100644 (file)
@@ -4,7 +4,7 @@
       <h2><%= message('permission_template.set_default_templates') -%></h2>
     </div>
     <div class="modal-body">
-      <div id="permission-template-error" class="permission-template error errors" style="display:none;" />
+      <div class="modal-error"/>
       <% @root_qualifiers.each do |qualifier| %>
         <div class="modal-field">
           <%= label_tag("default_template_#{qualifier}", " For #{message('qualifier.' + qualifier).downcase}s:") %>
   $j("#default-templates-form").modalForm({
     success: function (data) {
       window.location.reload();
-    },
-    error: function (xhr, textStatus, errorThrown) {
-      var htmlClass = 'permission-template';
-      $j('input[id^="submit-default-templates"]').removeAttr('disabled');
-      $j('.' + htmlClass + '.errors').show();
-      $j('.' + htmlClass + '.errors').html(xhr.responseText);
     }
   });
 </script>
index 98d081b349293174122f31d93d8cf9952ee4af33..adc6dd84b3b69a20222fb5ce1f6bd0d2be598d55 100644 (file)
@@ -7,7 +7,7 @@
       <h2><%= message('permission_template.edit_permissions', :params => @permission_template.name) -%></h2>
     </div>
     <div class="modal-body">
-      <div id="permission-template-error" class="permission-template error" style="display:none;" />
+      <div class="modal-error"/>
       <table>
         <tbody>
         <tr>
   $j("#permission-template-form").modalForm({
     success: function (data) {
       window.location.reload();
-    },
-    error: function (xhr, textStatus, errorThrown) {
-      var htmlClass = 'permission-template';
-      $j('input[id="submit-permission-template-update"]').removeAttr('disabled');
-      $j('.' + htmlClass + '.error').show();
-      $j('.' + htmlClass + '.error').html(xhr.responseText);
     }
   });
 </script>
index 38dc4fdbb677a5ff9e14fc05c265bae063b70a00..be35ff88538f3e08eca73047bd05cdddcf292993 100644 (file)
@@ -7,7 +7,7 @@
       <h2><%= message('permission_template.edit_permissions', :params => @permission_template.name) -%></h2>
     </div>
     <div class="modal-body">
-      <div id="permission-template-error" class="permission-template error" style="display:none;" />
+      <div class="modal-error"/>
       <table>
         <tbody>
         <tr>
   $j("#permission-template-form").modalForm({
     success: function (data) {
       window.location.reload();
-    },
-    error: function (xhr, textStatus, errorThrown) {
-      var htmlClass = 'permission-template';
-      $j('input[id="submit-permission-template-update"]').removeAttr('disabled');
-      $j('.' + htmlClass + '.error').show();
-      $j('.' + htmlClass + '.error').html(xhr.responseText);
     }
   });
 </script>
index ede87920cb32858f6d323dca9be20ee629e9a72c..3679f47f8d4fd979328ebd4eec3b10e49c525829 100644 (file)
@@ -7,7 +7,7 @@
       <h2><%= message("permission_template.#{message_title}") -%></h2>
     </div>
     <div class="modal-body">
-      <div id="permission-template-error" class="permission-template error errors" style="display:none;" />
+      <div class="modal-error"/>
       <div class="modal-field">
         <label for="name"><%= h message('name') -%> <em class="mandatory">*</em></label>
         <input id="name" name="name" type="text" size="50" maxlength="256" value="<%= @permission_template ? @permission_template.name : '' -%>" autofocus="autofocus"/>
   $j("#permission-template-form").modalForm({
     success: function (data) {
       window.location.reload();
-    },
-    error: function (xhr, textStatus, errorThrown) {
-      var htmlClass = 'permission-template';
-      $j('input[id^="submit-permission-template"]').removeAttr('disabled');
-      $j('.' + htmlClass + '.errors').show();
-      $j('.' + htmlClass + '.errors').html(xhr.responseText);
     }
   });
 </script>
index 2889a02842f6a7e17f14c4cdf9f9a952968a053e..28db709d40d820aac74b323e9d79ece3254cb44e 100644 (file)
@@ -11,7 +11,7 @@
     <% end %>
     </div>
     <div class="modal-body">
-      <div class="apply-template errors error" style="display:none;"/>
+      <div class="modal-error"/>
       <% if components.nil? %>
         <div class="info">
           <img src="<%= ApplicationController.root_context -%>/images/information.png" style="vertical-align: text-bottom"/>
@@ -29,7 +29,7 @@
     </div>
     <div class="modal-foot">
       <% unless components.nil? %>
-        <span id="apply-template-loading-image" class="hidden"><%= image_tag 'loading.gif' %></span>
+        <span id="apply-template-loading-image" class="loading-image hidden"><%= image_tag 'loading.gif' %></span>
         <input type="submit" value="<%= message('apply') -%>" id="apply-template-submit" class="apply-template" onclick="return displayLoadingImage()" />
       <% end %>
       <a href="#" onclick="return closeModalWindow()" id="apply-template-cancel"><%= message('cancel') -%></a>
   </fieldset>
 </form>
 <script>
-  $j("#apply-template-form").modalForm({
-    error: function (xhr, textStatus, errorThrown) {
-      $j('#apply-template-loading-image').addClass("hidden");
-      var htmlClass = 'apply-template';
-      $j('input[type=submit].' + htmlClass).removeAttr('disabled');
-      $j('.' + htmlClass + '.errors').show();
-      $j('.' + htmlClass + '.errors').html(xhr.responseText);
-    }
-  });
+  $j("#apply-template-form").modalForm();
 
   function displayLoadingImage() {
     $j('#apply-template-loading-image').removeClass("hidden");
   }
-
 </script>
index 44dc3efb3ee669e7881c384c72be82b61d21f06a..d69c032ff0c3567964dc67ffd5906e7c92c36968 100644 (file)
       <h2><%= @project ? 'Edit permissions for: ' + h(@project.name) : "Edit system permissions: #{message("global_permissions.#{@role}")}" -%></h2>
     </div>
     <div class="modal-body">
-      <div id="permission-groups-error" class="permission-groups error" style="display:none;" />
-        <table>
-          <tbody>
-            <tr>
-              <td style="padding: 5px 0;" valign="top">
-                <h2>Add Groups</h2>
-                <select name="from" id="from" size="30" style="margin: 5px 0; width: 300px;" multiple="multiple">
-                  <% ungranted_groups.each do |group| %>
-                    <option value="<%= group ? group.id : '' -%>"><%= group_name(group) -%></option>
-                  <% end %>
-                </select>
-              </td>
-              <td style="padding: 0 10px;" align="center" nowrap="nowrap">
-                <button id="select_right" onclick="SelectBox.move('from', 'to');SelectBox.sort('to');SelectBox.redisplay('to');return false;">select >></button><br>
-                <button id="select_right_all" onclick="SelectBox.move_all('from', 'to');return false;">select all >></button><br><br>
-                <button id="select_left" onclick="SelectBox.move('to', 'from');return false;"><< unselect</button><br>
-                <button id="select_left_all" onclick="SelectBox.move_all('to', 'from');return false;"><< unselect all</button>
-              </td>
-              <td class="box" style="padding: 5px 10px;" valign="top">
-                <h2>Permission: <%= @project ? role_name(@role) : global_role_name(@role) -%></h2>
+      <div class="modal-error"/>
+      <table>
+        <tbody>
+          <tr>
+            <td style="padding: 5px 0;" valign="top">
+              <h2>Add Groups</h2>
+              <select name="from" id="from" size="30" style="margin: 5px 0; width: 300px;" multiple="multiple">
+                <% ungranted_groups.each do |group| %>
+                  <option value="<%= group ? group.id : '' -%>"><%= group_name(group) -%></option>
+                <% end %>
+              </select>
+            </td>
+            <td style="padding: 0 10px;" align="center" nowrap="nowrap">
+              <button id="select_right" onclick="SelectBox.move('from', 'to');SelectBox.sort('to');SelectBox.redisplay('to');return false;">select >></button><br>
+              <button id="select_right_all" onclick="SelectBox.move_all('from', 'to');return false;">select all >></button><br><br>
+              <button id="select_left" onclick="SelectBox.move('to', 'from');return false;"><< unselect</button><br>
+              <button id="select_left_all" onclick="SelectBox.move_all('to', 'from');return false;"><< unselect all</button>
+            </td>
+            <td class="box" style="padding: 5px 10px;" valign="top">
+              <h2>Permission: <%= @project ? role_name(@role) : global_role_name(@role) -%></h2>
 
-                <select name="groups[]" id="to" size="30" multiple="multiple" style="margin: 5px 0pt; width: 300px;">
-                  <% granted_groups.each do |group| %>
-                    <option value="<%= group ? group.id : '' -%>"><%= group_name(group) -%></option>
-                  <% end %>
-                </select><br>
-              </td>
-            </tr>
-          </tbody>
-        </table>
+              <select name="groups[]" id="to" size="30" multiple="multiple" style="margin: 5px 0pt; width: 300px;">
+                <% granted_groups.each do |group| %>
+                  <option value="<%= group ? group.id : '' -%>"><%= group_name(group) -%></option>
+                <% end %>
+              </select><br>
+            </td>
+          </tr>
+        </tbody>
+      </table>
     </div>
     <div class="modal-foot">
       <input type="submit" onclick="SelectBox.select_all('to');" value="<%= h message('save') -%>" id="submit-permission-groups-update"/>
   $j("#permission-groups-form").modalForm({
     success: function (data) {
       window.location.reload();
-    },
-    error: function (xhr, textStatus, errorThrown) {
-      var htmlClass = 'permission-groups';
-      $j('input[id="submit-permission-groups-update"]').removeAttr('disabled');
-      $j('.' + htmlClass + '.error').show();
-      $j('.' + htmlClass + '.error').html(xhr.responseText);
     }
   });
 </script>
index 9c3cd32364ee1d80859b0e5c8fbf420fdc3f9856..8f55c9e749436fe4ccf802a895286da3335e2dce 100644 (file)
@@ -11,7 +11,7 @@
       <h2><%= @project ? 'Edit permissions for: ' + h(@project.name) : "Edit system permissions: #{message("global_permissions.#{@role}")}" -%></h2>
     </div>
     <div class="modal-body">
-      <div id="permission-users-error" class="permission-users error" style="display:none;" />
+      <div class="modal-error"/>
       <table>
         <tbody>
           <tr>
   $j("#permission-users-form").modalForm({
     success: function (data) {
       window.location.reload();
-    },
-    error: function (xhr, textStatus, errorThrown) {
-      var htmlClass = 'permission-users';
-      $j('input[id="submit-permission-users-update"]').removeAttr('disabled');
-      $j('.' + htmlClass + '.error').show();
-      $j('.' + htmlClass + '.error').html(xhr.responseText);
     }
   });
 </script>
index 5e8d4764b1ee3f8542b91fe1f16ab81cc4334567..857298a34daef888aeac828c7234ab0163a54516 100644 (file)
@@ -314,6 +314,9 @@ function openModalWindow(url, options) {
               // If the modal window has defined a modal-error element, then returned text must be displayed in it
               var errorElt = obj.find(".modal-error");
               if (errorElt.length) {
+                // Hide all loading images
+                $j('.loading-image').addClass("hidden");
+                // Re activate submit button
                 $j('input[type=submit]', obj).removeAttr('disabled');
                 errorElt.show();
                 errorElt.html(xhr.responseText);