added ability to delete items

This commit is contained in:
Connor Turland 2012-10-18 14:24:07 -04:00
parent 26c4e9cffc
commit 7d45a83776
6 changed files with 122 additions and 97 deletions

View file

@ -28,7 +28,7 @@ h2 {display:block; text-align:center; background: #333; font-size:24px;}
a {color:#2d6a5d; text-decoration:none;}
.clearfloat {clear:both;}
form { display: block; width: 350px; margin: 0 auto; background: #D1D1D1; padding: 20px; border-radius: 15px; color: #000; }
.new_session, .new_item, .new_synapse, .edit_item, .edit_synapse { display: block; width: 350px; margin: 0 auto; background: #D1D1D1; padding: 20px; border-radius: 15px; color: #000; }
label, select, input, textarea { display:block; }

View file

@ -4,6 +4,19 @@
.item { display:block; float:left; position:relative; width:170px; height:300px; padding:10px 10px 10px 35px; background:#d1d1d1; border-radius:15px; margin:30px 0 30px 50px; color:#000; }
.item .delete {position: absolute;
top: -14px;
left: 0px;
background: none;
border: 0;
color: white;
border: none;
font-size: 14px;
margin: 0;
padding: 0;
cursor:pointer;
}
.item .type {position: absolute;
color: white;
top: -22px;

View file

@ -81,7 +81,17 @@ class ItemsController < ApplicationController
def destroy
@item = Item.find_by_id(params[:id])
@synapses = @item.synapses
@synapses.each do |synapse|
synapse.delete
end
@item.delete
respond_to do |format|
format.js
end
end
end

View file

@ -1,4 +1,5 @@
<%= div_for item do %>
<%= link_to 'Delete', item, :class => 'delete', :confirm => 'Delete this topic and all synapses linking to it?', :method => :delete, :remote => true%>
<p class="type"><%= item.item_category.name %></p>
<%= image_tag item.item_category.icon, :class => 'icon', :size => '50x50' %>
<%= link_to item.name, item_url(item), :class => 'title' %>

View file

@ -0,0 +1 @@
$('#<%= dom_id(@item) %>').fadeOut('slow');