added ability to delete items
This commit is contained in:
parent
26c4e9cffc
commit
7d45a83776
6 changed files with 122 additions and 97 deletions
|
@ -28,7 +28,7 @@ h2 {display:block; text-align:center; background: #333; font-size:24px;}
|
||||||
a {color:#2d6a5d; text-decoration:none;}
|
a {color:#2d6a5d; text-decoration:none;}
|
||||||
.clearfloat {clear:both;}
|
.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; }
|
label, select, input, textarea { display:block; }
|
||||||
|
|
||||||
|
|
|
@ -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 { 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;
|
.item .type {position: absolute;
|
||||||
color: white;
|
color: white;
|
||||||
top: -22px;
|
top: -22px;
|
||||||
|
|
|
@ -81,7 +81,17 @@ class ItemsController < ApplicationController
|
||||||
def destroy
|
def destroy
|
||||||
@item = Item.find_by_id(params[:id])
|
@item = Item.find_by_id(params[:id])
|
||||||
|
|
||||||
|
@synapses = @item.synapses
|
||||||
|
|
||||||
|
@synapses.each do |synapse|
|
||||||
|
synapse.delete
|
||||||
|
end
|
||||||
|
|
||||||
@item.delete
|
@item.delete
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.js
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<%= div_for item do %>
|
<%= 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>
|
<p class="type"><%= item.item_category.name %></p>
|
||||||
<%= image_tag item.item_category.icon, :class => 'icon', :size => '50x50' %>
|
<%= image_tag item.item_category.icon, :class => 'icon', :size => '50x50' %>
|
||||||
<%= link_to item.name, item_url(item), :class => 'title' %>
|
<%= link_to item.name, item_url(item), :class => 'title' %>
|
||||||
|
|
1
app/views/items/destroy.js.erb
Normal file
1
app/views/items/destroy.js.erb
Normal file
|
@ -0,0 +1 @@
|
||||||
|
$('#<%= dom_id(@item) %>').fadeOut('slow');
|
Loading…
Reference in a new issue