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])
--- /dev/null
+<form action="<%= ApplicationController.root_context -%>/groups/destroy/<%= @group.id -%>" method="POST" id="group_form">
+ <fieldset>
+ <div class="modal-head">
+ <h2>Delete Group <%= @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
<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>
- <%= 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 %>