/
category_index.html.erb
76 lines (70 loc) · 2.73 KB
/
category_index.html.erb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<h1>Suggested Edits</h1>
<p class="is-lead">Suggested edits for review.</p>
<% categories = Category.unscoped.where(community: @community).order(sequence: :asc, id: :asc) %>
<% current_cat = current_category %>
<div class="button-list is-gutterless">
<%= link_to 'Pending', query_url(show_decided: 0),
class: "button is-muted is-outlined #{params[:show_decided] != '1' ? 'is-active' : ''}" %>
<%= link_to 'Decided', query_url(show_decided: 1),
class: "button is-muted is-outlined #{params[:show_decided] == '1' ? 'is-active' : ''}" %>
</div>
<% if params[:show_decided] != '1' && !current_user&.privilege?('edit_posts') %>
<div class="notice is-info has-color-teal-800">
<i class="fas fa-info-circle"></i> You can't approve or reject suggested edits (except on your own posts)
because you haven't yet earned the <%= link_to 'Edit Posts', ability_path('edit_posts') %> ability.
</div>
<% end %>
<% if params[:show_decided] != '1' %>
<h3>All categories</h3>
<table>
<tr>
<th>category</th>
<th>pending edits</th>
</tr>
<% categories.each do |cat| %>
<% next if (cat.min_view_trust_level || -1) > (current_user&.trust_level || 0) %>
<% sug_edits = SuggestedEdit.where(post: Post.undeleted.where(category: cat), active: true).count %>
<tr>
<td>
<% if cat == current_cat %>
<%= cat.name %>
<% else %>
<%= link_to suggested_edits_queue_url(cat) do %>
<%= cat.name %>
<% end %>
<% end %>
</td>
<td>
<% if cat == current_cat %>
<%= sug_edits %>
<% else %>
<%= link_to suggested_edits_queue_url(cat) do %>
<%= sug_edits %>
<% end %>
<% end %>
</td>
</tr>
<% end %>
</table>
<% end %>
<% if @edits.any? %>
<div class="widget">
<% @edits.each do |edit| %>
<div class="widget--body h-p-b-0" data-ckb-list-item data-ckb-item-type="link">
<div>
<%= link_to suggested_edit_path(edit.id), class: 'has-font-size-larger', data: {'ckb-item-link' => ''} do %>
<%= edit.post.post_type.name %>: <strong><%= edit.post.post_type.is_top_level ? edit.post.title : edit.post.parent.title %></strong>
<% end %>
</div>
<div class="form-caption h-m-t-2">
<strong class="<%= edit.active ? '' : (edit.approved? ? 'h-c-green-700' : 'h-c-red-600' ) %>"
><%= edit.active ? 'Pending' : (edit.approved? ? 'Approved' : 'Rejected' ) %></strong> suggested edit
by <%= user_link edit.user %>,
<span title="<%= edit.created_at.iso8601 %>"><%= time_ago_in_words(edit.created_at) %> ago</span>
</div>
</div>
<% end %>
</div>
<% else %>
<p>There are no suggested edits in this category.</p>
<% end %>