recycle_bin 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,10 @@
1
+ <% if defined?(resource) && resource.errors.any? %>
2
+ <div class="alert alert-danger">
3
+ <h4><%= pluralize(resource.errors.count, "error") %> prohibited this action:</h4>
4
+ <ul>
5
+ <% resource.errors.full_messages.each do |message| %>
6
+ <li><%= message %></li>
7
+ <% end %>
8
+ </ul>
9
+ </div>
10
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <% if notice %>
2
+ <div class="alert alert-success"><%= notice %></div>
3
+ <% end %>
4
+ <% if alert %>
5
+ <div class="alert alert-danger"><%= alert %></div>
6
+ <% end %>
@@ -0,0 +1,71 @@
1
+ <div class="main-card">
2
+ <div class="card-header">
3
+ <h3 class="card-title">Action History</h3>
4
+ </div>
5
+ <div class="card-body">
6
+ <% if item.respond_to?(:versions) && item.versions.any? %>
7
+ <div class="table-container">
8
+ <table class="table">
9
+ <thead>
10
+ <tr>
11
+ <th>Event</th>
12
+ <th>User</th>
13
+ <th>Timestamp</th>
14
+ <th>Details</th>
15
+ </tr>
16
+ </thead>
17
+ <tbody>
18
+ <% item.versions.each do |version| %>
19
+ <tr>
20
+ <td><span class="event-type"><%= version.event.humanize %></span></td>
21
+ <td>
22
+ <% if version.whodunnit %>
23
+ <%= version.whodunnit %>
24
+ <% else %>
25
+ <span class="timestamp">System</span>
26
+ <% end %>
27
+ </td>
28
+ <td>
29
+ <span class="timestamp">
30
+ <%= time_ago_in_words(version.created_at) %> ago •
31
+ <%= version.created_at.strftime('%B %d, %Y at %l:%M %p') %>
32
+ </span>
33
+ </td>
34
+ <td>
35
+ <% if version.changeset.any? %>
36
+ <details>
37
+ <summary class="btn btn-outline btn-sm">View Changes</summary>
38
+ <div class="changeset-details">
39
+ <% version.changeset.each do |key, changes| %>
40
+ <div class="change-item">
41
+ <strong><%= key.humanize %>:</strong>
42
+ <span class="change-from"><%= changes[0].nil? ? 'nil' : changes[0] %></span>
43
+
44
+ <span class="change-to"><%= changes[1].nil? ? 'nil' : changes[1] %></span>
45
+ </div>
46
+ <% end %>
47
+ </div>
48
+ </details>
49
+ <% else %>
50
+ <span class="timestamp">No changes recorded</span>
51
+ <% end %>
52
+ </td>
53
+ </tr>
54
+ <% end %>
55
+ </tbody>
56
+ </table>
57
+ </div>
58
+ <% else %>
59
+ <div class="empty-state">
60
+ <div class="empty-icon">📜</div>
61
+ <h4 class="empty-title">No history available</h4>
62
+ <p class="empty-subtitle">
63
+ This item has no recorded actions.
64
+ <% if Rails.env.development? %>
65
+ <br>Debug: <%= item.class.name %> ID: <%= item.id %> has <%= item.respond_to?(:versions) ? item.versions.count : 'no versions method' %> versions.
66
+ <% end %>
67
+ </p>
68
+ </div>
69
+ <% end %>
70
+ </div>
71
+ </div>
@@ -0,0 +1,46 @@
1
+ <div class="main-card">
2
+ <div class="card-header">
3
+ <h3 class="card-title">Related Items</h3>
4
+ <div class="card-actions">
5
+ <span class="timestamp"><%= associations.values.flatten.count %> related items</span>
6
+ </div>
7
+ </div>
8
+ <div class="card-body">
9
+ <% associations.each do |association_name, items| %>
10
+ <div class="association-section">
11
+ <h4 class="card-title"><%= association_name.humanize %> <span class="timestamp">(<%= items.count %> items)</span></h4>
12
+ <% if items.any? %>
13
+ <div class="association-grid">
14
+ <% items.each do |item| %>
15
+ <div class="association-item">
16
+ <div class="association-content">
17
+ <div class="card-title">
18
+ <%= item.class.name %> -
19
+ <%= item.respond_to?(:title) ? item.title :
20
+ item.respond_to?(:name) ? item.name :
21
+ "ID: #{item.id}" %>
22
+ </div>
23
+ <div class="timestamp">
24
+ Created <%= time_ago_in_words(item.created_at) %> ago
25
+ <% if item.respond_to?(:deleted_at) && item.deleted_at %>
26
+ • <span class="deleted-status">Also deleted</span>
27
+ <% end %>
28
+ </div>
29
+ </div>
30
+ <% if item.respond_to?(:deleted_at) && item.deleted_at %>
31
+ <span class="model-badge deleted-badge">Deleted</span>
32
+ <% else %>
33
+ <span class="model-badge active-badge">Active</span>
34
+ <% end %>
35
+ </div>
36
+ <% end %>
37
+ </div>
38
+ <% else %>
39
+ <div class="empty-state">
40
+ <p class="timestamp">No related items found.</p>
41
+ </div>
42
+ <% end %>
43
+ </div>
44
+ <% end %>
45
+ </div>
46
+ </div>
@@ -0,0 +1,17 @@
1
+ <% if model_types.any? %>
2
+ <div class="filters">
3
+ <div class="filter-group">
4
+ <span class="filter-label">Filter by type:</span>
5
+ <%= link_to "All", recycle_bin.root_path(page: 1), class: "btn btn-sm #{params[:type].blank? ? 'btn-primary' : 'btn-outline'}" %>
6
+ <% model_types.each do |model_type| %>
7
+ <%= link_to model_type, recycle_bin.root_path(type: model_type, page: 1), class: "btn btn-sm #{params[:type] == model_type ? 'btn-primary' : 'btn-outline'}" %>
8
+ <% end %>
9
+ </div>
10
+ <div class="filter-group">
11
+ <span class="filter-label">Time:</span>
12
+ <%= link_to "Today", recycle_bin.root_path(time: 'today', page: 1), class: "btn btn-sm #{params[:time] == 'today' ? 'btn-primary' : 'btn-outline'}" %>
13
+ <%= link_to "This Week", recycle_bin.root_path(time: 'week', page: 1), class: "btn btn-sm #{params[:time] == 'week' ? 'btn-primary' : 'btn-outline'}" %>
14
+ <%= link_to "This Month", recycle_bin.root_path(time: 'month', page: 1), class: "btn btn-sm #{params[:time] == 'month' ? 'btn-primary' : 'btn-outline'}" %>
15
+ </div>
16
+ </div>
17
+ <% end %>
@@ -0,0 +1,24 @@
1
+ <tr>
2
+ <td><input type="checkbox" class="item-checkbox" value="<%= item.class.name %>:<%= item.id %>" onchange="updateBulkActions()"></td>
3
+ <td><span class="model-badge"><%= item.class.name %></span></td>
4
+ <td>
5
+ <div class="card-title">
6
+ <%= link_to truncate(item.recyclable_title, length: 60), recycle_bin.trash_path(item.class.name, item.id) %>
7
+ </div>
8
+ <div class="timestamp">ID: <%= item.id %></div>
9
+ </td>
10
+ <td>
11
+ <div class="card-title"><%= time_ago_in_words(item.deleted_at) %> ago</div>
12
+ <div class="timestamp"><%= item.deleted_at.strftime('%B %d, %Y at %l:%M %p') %></div>
13
+ </td>
14
+ <td>
15
+ <div class="card-actions">
16
+ <%= form_with url: recycle_bin.restore_trash_path(item.class.name, item.id), method: :patch, local: true do |form| %>
17
+ <%= form.submit "↶ Restore", class: "btn btn-success btn-sm", onclick: "return confirm('Restore this #{item.class.name.downcase}?')" %>
18
+ <% end %>
19
+ <%= form_with url: recycle_bin.destroy_trash_path(item.class.name, item.id), method: :delete, local: true do |form| %>
20
+ <%= form.submit "🗑️ Delete", class: "btn btn-danger btn-sm", onclick: "return confirm('Permanently delete this #{item.class.name.downcase}? This cannot be undone!')" %>
21
+ <% end %>
22
+ </div>
23
+ </td>
24
+ </tr>
@@ -0,0 +1,75 @@
1
+ <div class="pagination-wrapper">
2
+ <div class="pagination">
3
+ <% if total_pages > 1 %>
4
+ <!-- First/Previous links -->
5
+ <% if current_page > 1 %>
6
+ <%= link_to "« First", request.params.merge(page: 1) %>
7
+ <%= link_to "‹ Prev", request.params.merge(page: current_page - 1) %>
8
+ <% else %>
9
+ <span class="disabled">« First</span>
10
+ <span class="disabled">‹ Prev</span>
11
+ <% end %>
12
+
13
+ <%
14
+ # Smart pagination logic
15
+ window_size = 2 # Number of pages to show on each side of current page
16
+ start_page = [current_page - window_size, 1].max
17
+ end_page = [current_page + window_size, total_pages].min
18
+ %>
19
+
20
+ <!-- First page if not in window -->
21
+ <% if start_page > 1 %>
22
+ <%= link_to 1, request.params.merge(page: 1) %>
23
+ <% if start_page > 2 %>
24
+ <span class="disabled">…</span>
25
+ <% end %>
26
+ <% end %>
27
+
28
+ <!-- Page window around current page -->
29
+ <% (start_page..end_page).each do |page| %>
30
+ <% if page == current_page %>
31
+ <span class="current"><%= page %></span>
32
+ <% else %>
33
+ <%= link_to page, request.params.merge(page: page) %>
34
+ <% end %>
35
+ <% end %>
36
+
37
+ <!-- Last page if not in window -->
38
+ <% if end_page < total_pages %>
39
+ <% if end_page < total_pages - 1 %>
40
+ <span class="disabled">…</span>
41
+ <% end %>
42
+ <%= link_to total_pages, request.params.merge(page: total_pages) %>
43
+ <% end %>
44
+
45
+ <!-- Next/Last links -->
46
+ <% if current_page < total_pages %>
47
+ <%= link_to "Next ›", request.params.merge(page: current_page + 1) %>
48
+ <%= link_to "Last »", request.params.merge(page: total_pages) %>
49
+ <% else %>
50
+ <span class="disabled">Next ›</span>
51
+ <span class="disabled">Last »</span>
52
+ <% end %>
53
+ <% end %>
54
+ </div>
55
+
56
+ <!-- Page info -->
57
+ <div class="pagination-info">
58
+ <span>
59
+ Showing page <%= current_page %> of <%= total_pages %>
60
+ (<%= pluralize(total_count, 'item') %> total)
61
+ </span>
62
+ </div>
63
+
64
+ <!-- Per page selector -->
65
+ <div class="per-page">
66
+ <span>Items per page:</span>
67
+ <% [25, 50, 100].each do |num| %>
68
+ <% if num == per_page %>
69
+ <span class="current"><%= num %></span>
70
+ <% else %>
71
+ <%= link_to num, request.params.merge(per_page: num, page: 1), class: "per-page-link" %>
72
+ <% end %>
73
+ <% end %>
74
+ </div>
75
+ </div>
@@ -0,0 +1,32 @@
1
+ <div class="stats-grid">
2
+ <div class="stat-card">
3
+ <div class="stat-number"><%= number_with_delimiter(total_count) %></div>
4
+ <div class="stat-label">Total Items in Trash</div>
5
+ <div class="stat-change positive">
6
+ <%= filtered_items.items.select { |item| item.deleted_at > 1.day.ago }.count %> deleted today
7
+ </div>
8
+ </div>
9
+ <div class="stat-card">
10
+ <div class="stat-number"><%= model_types.count %></div>
11
+ <div class="stat-label">Model Types</div>
12
+ <div class="stat-change">
13
+ <% if model_types.any? %>
14
+ <%= model_types.join(', ') %>
15
+ <% else %>
16
+ No types
17
+ <% end %>
18
+ </div>
19
+ </div>
20
+ <div class="stat-card">
21
+ <div class="stat-number"><%= filtered_items.items.select { |item| item.deleted_at > 7.days.ago }.count %></div>
22
+ <div class="stat-label">This Week</div>
23
+ <div class="stat-change">Recent activity</div>
24
+ </div>
25
+ <div class="stat-card">
26
+ <div class="stat-number"><%= current_page %> / <%= defined?(total_pages) ? total_pages : 1 %></div>
27
+ <div class="stat-label">Current Page</div>
28
+ <div class="stat-change">
29
+ Showing <%= (current_page - 1) * per_page + 1 %>-<%= [(current_page * per_page), total_count].min %> of <%= number_with_delimiter(total_count) %>
30
+ </div>
31
+ </div>
32
+ </div>