]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4759 Use modal windows in groups pages
authorstephenbroyer <stephen.broyer@sonarsource.com>
Wed, 16 Oct 2013 10:14:22 +0000 (12:14 +0200)
committerstephenbroyer <stephen.broyer@sonarsource.com>
Fri, 18 Oct 2013 07:57:35 +0000 (09:57 +0200)
(delete user)

sonar-server/src/main/webapp/WEB-INF/app/controllers/groups_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/views/groups/_delete_form.html.erb [new file with mode: 0644]
sonar-server/src/main/webapp/WEB-INF/app/views/groups/index.html.erb

index 2d3d5f8f4c0804b99676bc3a00444dfb79825872..62be6373df312bab0c9dd942444129055380a677 100644 (file)
@@ -76,14 +76,27 @@ class GroupsController < ApplicationController
     end
   end
 
+  def delete_form
+    group = Group.find(params[:id])
+    if group
+      @group = group
+      render :partial => 'groups/delete_form'
+    else
+      redirect_to(:action => 'index', :id => nil)
+    end
+  end
+
   def destroy
     group = Group.find(params[:id])
     if group.destroy
       flash[:notice] = 'Group is deleted.'
+      render :text => 'deleted', :status => 200
+    else
+      @errors == []
+      @errors << 'Error when deleting this group.'
+      render :partial => 'groups/delete_form', :status => 400
     end
-       
-    to_index(group.errors, nil)
-  end
+end
   
   def select_user
     @group = Group.find(params[:id])
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/groups/_delete_form.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/groups/_delete_form.html.erb
new file mode 100644 (file)
index 0000000..ccd1592
--- /dev/null
@@ -0,0 +1,30 @@
+<form action="<%= ApplicationController.root_context -%>/groups/destroy/<%= @group.id -%>" method="POST" id="group_form">
+    <fieldset>
+        <div class="modal-head">
+            <h2>Delete Group &nbsp;<%= @group.name %></h2>
+        </div>
+        <div class="modal-body">
+            <% if @errors
+                 @errors.each do |error|
+            %>
+                <p class="error"><%= h error -%></p>
+              <% end
+                 end
+              %>
+            <div class="modal-field">
+                <input type="hidden" name="id" value="<%= @group.id -%>"/>
+            </div>
+            <div class="modal-field">
+                Are you sure that you want to delete this group? <br/>
+                Members will not be deleted.
+            </div>
+        </div>
+        <div class="modal-foot">
+            <%= submit_tag 'Delete' %>
+            <%= link_to 'Cancel', { :controller => 'groups', :action => 'index'}, { :class => 'action' } %><br/>
+        </div>
+    </fieldset>
+</form>
+<script>
+  $j("#group_form").modalForm();
+</script>
\ No newline at end of file
index f797b77db482415a3e914f9f92c3f297fed42219..5273ddc663b2f77bdcbc14d746a75217c721e231 100644 (file)
@@ -34,8 +34,7 @@
             <td class="operations" style="text-align: right">
               <a id='edit-<%= h group.name %>' method='get' class='open-modal link-action' href="<%=ApplicationController.root_context-%>/groups/edit_form/<%= h group.id %>">Edit</a>
               &nbsp;
-              <%= link_to "Delete", { :action => 'destroy', :id => group.id},
-                                    {:confirm => "Are you sure that you want to delete this group? Members will not be deleted.", :class => 'link-action link-red', :method => 'get', :id => "delete-#{u group.name}"} %>
+              <a id="delete-<%= u group.name -%>" class="open-modal  link-action link-red" href="<%=ApplicationController.root_context-%>/groups/delete_form/<%= group.id -%>">Delete</a>
             </td>
           </tr>
         <% end %>