Permalink
Browse files

Features:

* Add correct delete, edit and show buttons to database instance page
* Implement database instance delete view and change destroy action to allow cancel
* Change sort for database instances to sort by environment, alias
  • Loading branch information...
1 parent 3ef4854 commit ffb366e58cdc4267ffe619de68a45f44d9215e08 Joakim Bodin committed Mar 12, 2009
@@ -2,7 +2,7 @@ class DbInstancesController < ApplicationController
# GET /db_instances
# GET /db_instances.xml
def index
- @db_instances = DbInstance.all(:order => 'db_env ASC')
+ @db_instances = DbInstance.all(:order => 'db_env, db_alias ASC')
respond_to do |format|
format.html # index.html.erb
@@ -71,15 +71,32 @@ def update
end
end
+ # GET /db_instances/1/delete
+ def delete
+ @db_instance = DbInstance.find(params[:id])
+ end
+
# DELETE /db_instances/1
# DELETE /db_instances/1.xml
def destroy
@db_instance = DbInstance.find(params[:id])
- @db_instance.destroy
+
+ if params[:db_instance_delete_cancel]
+ redirect_to db_instances_path
+ return
+ end
respond_to do |format|
- format.html { redirect_to(db_instances_url) }
- format.xml { head :ok }
+ if @db_instance.destroy
+ format.html do
+ flash[:notice] = "Database Instance '#{@db_instance}' successfully deleted"
+ redirect_to db_instances_path
+ end
+ format.xml { head :ok }
+ else
+ format.html { render :action => 'delete' }
+ format.xml { render :xml => @db_instance.errors, :status => :unprocessable_entity }
+ end
end
end
@@ -0,0 +1,32 @@
+<fieldset>
+ <legend>Delete Database Instance</legend>
+
+ <h3>Are you sure you want to delete this Database Instance?</h3>
+ <hr class="space" />
+
+ <table>
+ <thead>
+ <tr>
+ <th>Alias</th>
+ <th>Host</th>
+ <th>Port</th>
+ <th>Environment</th>
+ <th>Type</th>
+ </tr>
+ </thead>
+
+ <tr class="db_instance <%=h @db_instance.db_env %>">
+ <td><%=h @db_instance.db_alias %></td>
+ <td><%=h @db_instance.host %></td>
+ <td><%=h @db_instance.port %></td>
+ <td><%=h @db_instance.db_env %></td>
+ <td><%=h @db_instance.db_type %></td>
+ </tr>
+ </table>
+
+ <% form_for(@db_instance, :url => db_instance_path(@db_instance), :html => {:method => :delete}) do |f| %>
+ <%= render :partial => 'shared/form_error', :locals => {:f => f} %>
+ <%= f.submit 'Delete Database Instance' %>
+ <%= f.submit 'Cancel', :id => 'db_instance_delete_cancel', :name => 'db_instance_delete_cancel' %>
+ <% end %>
+</fieldset>
@@ -6,7 +6,7 @@
<th>Port</th>
<th>Environment</th>
<th>Type</th>
- <th colspan="3">Actions</th>
+ <th>Actions</th>
</tr>
</thead>
@@ -17,9 +17,13 @@
<td><%=h db_instance.port %></td>
<td><%=h db_instance.db_env %></td>
<td><%=h db_instance.db_type %></td>
- <td><%= link_to 'Show', db_instance %></td>
- <td><%= link_to 'Edit', edit_db_instance_path(db_instance) %></td>
- <td><%= link_to 'Delete', db_instance, {:confirm => 'Are you sure?', :method => :delete} %></td>
+ <td>
+ <ul class="actions">
+ <li class="destroy"><%= link_to 'Delete', delete_db_instance_path(db_instance) %></li>
+ <li><%= link_to 'Show', db_instance_path(db_instance) %></li>
+ <li><%= link_to 'Edit', edit_db_instance_path(db_instance) %></li>
+ </ul>
+ </td>
</tr>
<% end %>
<tr>
View
@@ -1,5 +1,5 @@
common:
- release_version: 1.2.9.3
+ release_version: 1.2.9.4
release_name: 'Hot Shots'
vc_type: 'svn'
vc_uri: ''
View
@@ -1,5 +1,5 @@
ActionController::Routing::Routes.draw do |map|
- map.resources :db_instances
+ map.resources :db_instances, :member => {:delete => :get}
map.resources :apps, :except => [:destroy] do |apps|
apps.resources :activities, :except => [:destroy] do |activities|
@@ -0,0 +1,7 @@
+fieldset {
+ border: 1px solid #AB3E1D;
+}
+
+fieldset legend {
+ color: #AB3E1D;
+}

0 comments on commit ffb366e

Please sign in to comment.