Permalink
Browse files

add delete visible option

git-svn-id: http://svn.techno-weenie.net/projects/plugins/exception_logger@1277 567b1171-46fb-0310-a4c9-b4bef9110e78
  • Loading branch information...
1 parent 186d9b1 commit 82dd3b1ca72abd40888087ded14f338ac434d407 technoweenie committed Jun 26, 2006
View
@@ -18,6 +18,10 @@ ExceptionLogger = {
var value = $(filterName) ? $F(filterName) : null;
a.className = (value && (a.getAttribute('title') == value || a.innerHTML == value)) ? 'selected' : '';
});
+ },
+
+ deleteAll: function() {
+ return $$('tr.exception').collect(function(tr) { return tr.getAttribute('id').gsub(/^\w+-/, ''); }).toQueryString('ids');
}
}
@@ -27,6 +31,12 @@ Event.observe(window, 'load', function() {
});
});
+Object.extend(Array.prototype, {
+ toQueryString: function(name) {
+ return this.collect(function(item) { return name + "[]=" + encodeURIComponent(item) }).join('&');
+ }
+});
+
Ajax.Responders.register({
onCreate: function() {
if($('activity') && Ajax.activeRequestCount > 0) $('activity').visualEffect('appear', {duration:0.25});
@@ -38,4 +38,9 @@ def show
def destroy
LoggedException.destroy params[:id]
end
+
+ def destroy_all
+ LoggedException.delete_all ['id in (?)', params[:ids]] unless params[:ids].blank?
+ query
+ end
end
@@ -1,10 +1,11 @@
<div id="exceptions">
-<% if @exception_pages.page_count>1 %>
<div class="pages">
-Pages: <strong><%= pagination_remote_links @exception_pages, :params => { :action => :index } %></strong>
-</div>
+ <%= link_to_remote 'Delete Visible', :url => { :action => 'destroy_all' }, :with => "ExceptionLogger.deleteAll()" %>
+<% if @exception_pages.page_count > 1 %>
+:: Pages: <strong><%= pagination_remote_links @exception_pages, :params => { :action => :index } %></strong>
<% end %>
+</div>
<h1>Exceptions <%= "<span>(filtered)</span>" if filtered? %> </h1>
@@ -24,7 +25,7 @@ Pages: <strong><%= pagination_remote_links @exception_pages, :params => { :actio
<tbody>
<% exceptions.each do |exc| -%>
- <tr id="exception-<%= exc.id %>" class="<%= cycle("eor", "") %>">
+ <tr id="exception-<%= exc.id %>" class="<%= cycle("eor", "") %> exception">
<td>
<div class="expclass">
@@ -37,7 +38,7 @@ Pages: <strong><%= pagination_remote_links @exception_pages, :params => { :actio
-->
<%
-if Date.today==exc.created_at.to_date
+if Date.today == exc.created_at.to_date
if exc.created_at > Time.now - 4.hours
%>
<%= time_ago_in_words(exc.created_at).gsub(/about /,"~ ") %> ago
@@ -0,0 +1,2 @@
+page[:exceptions].replace :partial => "exceptions"
+page[:showpage].hide

0 comments on commit 82dd3b1

Please sign in to comment.