Skip to content

Commit ce97d67

Browse files
committed
fixes user points page
1 parent 67e7b7d commit ce97d67

File tree

3 files changed

+52
-9
lines changed

3 files changed

+52
-9
lines changed

app/controllers/points_controller.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ def index
1919
@points = @q.result(distinct: true).page(params[:page] || 1)
2020
end
2121

22+
def user_points
23+
authorize Point
24+
@q = Point.eager_loaded.current_user_points(current_user).ransack(params[:q])
25+
@points = @q.result(distinct: true).page(params[:page] || 1)
26+
end
27+
2228
def list_docbot
2329
@docbot_points = Point.docbot
2430
@q = @docbot_points.ransack(params[:q])

app/views/points/user_points.html.erb

Lines changed: 45 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,26 +8,63 @@
88
<div class="row">
99
<div class="col-lg-6">
1010
<h1>My Contributions</h1>
11-
<% if @points.length == 100 %>
12-
(showing only 100 items)
13-
<% else %>
14-
(showing all <%= @points.length %> items)
15-
<% end %>
1611
</div>
1712
</div>
1813
<br>
1914
<br>
2015
<div class="row">
21-
<div class="col-lg-6">
22-
<%= render "shared/search" %>
16+
<div class="col-lg-4 text-left">
17+
<div class="">
18+
<%= search_form_for @q do |f| %>
19+
<%= f.label :service_name_cont %>
20+
<%= f.search_field :service_name_cont %>
21+
22+
<%= f.submit %>
23+
<% end %>
24+
</div>
2325
</div>
2426
</div>
2527
<br>
2628
<% if @points.empty? %>
2729
<p>There are no points to display at this time!</p>
2830
<% else %>
29-
<%= render "shared/table_points", points: @points %>
31+
<div class="">
32+
<div class="table-responsive">
33+
<table class="table table-striped">
34+
<thead>
35+
<tr>
36+
<th scope="col">Service</th>
37+
<th scope="col">Title</th>
38+
<th scope="col">Rating</th>
39+
<th scope="col">Status</th>
40+
<th scope="col">Author</th>
41+
</tr>
42+
</thead>
43+
<tbody id="myTableBody">
44+
<% @points.each do |point| %>
45+
<% if point.case&.classification == 'good' %>
46+
<% pointbox = "point-good" %>
47+
<% elsif point.case&.classification == 'neutral' %>
48+
<% pointbox = "point-neutral" %>
49+
<% elsif point.case&.classification == 'bad' %>
50+
<% pointbox = "point-bad" %>
51+
<% elsif point.case&.classification == 'blocker' %>
52+
<% pointbox = "point-blocker" %>
53+
<% end %>
54+
<tr class="toSort">
55+
<td><%= point.service.name %></td>
56+
<td><%= link_to point.quote_text ? "\"" + point.quote_text + "\"" : point.title, point_path(point), title: "View more details" %></td>
57+
<td class="<%= pointbox %>"></td>
58+
<td> <%= status_badge point.status %> </td>
59+
<td><%= username point.user %> <%= rank_badge point.user %></td>
60+
</tr>
61+
<% end %>
62+
</tbody>
63+
</table>
64+
</div>
65+
</div>
3066
<% end %>
3167
</div>
3268
</div>
69+
<%= paginate @points %>
3370
<% end %>

config/routes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
get 'about', to: 'pages#about'
1717
get 'flag_spam', to: 'spam#flag_as_spam', as: 'flag_as_spam'
1818

19-
get 'my_points', to: 'points#user_points', as: :my_points
19+
get 'my_points', to: 'points#user_points', as: 'my_points'
2020
get 'points/:id/review', to: 'points#review', as: 'review'
2121
post 'points/:id/review', to: 'points#post_review', as: 'post_review'
2222
get 'points/:id/approve', to: 'points#approve', as: 'approve'

0 commit comments

Comments
 (0)