Skip to content

Commit a4866b8

Browse files
committed
refactors points views
1 parent 44fe4e1 commit a4866b8

File tree

5 files changed

+86
-63
lines changed

5 files changed

+86
-63
lines changed

app/models/point.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,12 @@ def migrate
100100
annotation.index_elasticsearch
101101
end
102102

103+
def display_title
104+
return self.case&.title if self.case
105+
106+
point.quote_text ? "\"" + point.quote_text + "\"" : point.title
107+
end
108+
103109
def annotation_uuid
104110
StringConverter.new(string: annotation_ref).to_uuid
105111
end

app/policies/point_policy.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# app/policies/point_policy.rb
44
class PointPolicy < ApplicationPolicy
55
def index?
6-
true
6+
!user.nil?
77
end
88

99
def show?
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<div>
2+
<div class="table-responsive">
3+
<table class="table table-hover table-condensed">
4+
<thead>
5+
<tr>
6+
<th scope="col" class="lighter">Service</th>
7+
<th scope="col" class="lighter">Title</th>
8+
<th scope="col" class="lighter text-left">Rating</th>
9+
<th scope="col" class="lighter text-right">Status</th>
10+
<th scope="col" class="lighter text-right">Author</th>
11+
<th scope="col"></th>
12+
</tr>
13+
</thead>
14+
<tbody>
15+
<% points.each do |point| %>
16+
<% if point.case&.classification == 'good' %>
17+
<% pointbox = "point-good" %>
18+
<% elsif point.case&.classification == 'neutral' %>
19+
<% pointbox = "point-neutral" %>
20+
<% elsif point.case&.classification == 'bad' %>
21+
<% pointbox = "point-bad" %>
22+
<% elsif point.case&.classification == 'blocker' %>
23+
<% pointbox = "point-blocker" %>
24+
<% end %>
25+
<tr>
26+
<td class="small lighter"><%= link_to point.service.name, service_path(point.service), title: "View service" %></td>
27+
<td class="small"><mark><%= link_to point.display_title, point_path(point), title: "View point" %></mark></td>
28+
<td class="small text-right <%= pointbox %>"></td>
29+
<td class="small text-right"><%= status_badge point.status %></td>
30+
<td class="small text-right"><%= username point.user %> <%= rank_badge point.user %></td>
31+
<td></td>
32+
</tr>
33+
<% end %>
34+
</tbody>
35+
</table>
36+
</div>
37+
</div>

app/views/points/index.html.erb

Lines changed: 41 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,50 @@
1-
<% if current_user %>
2-
<% content_for :title do %>
3-
<title>Points (ToS;DR Phoenix)</title>
4-
<% end %>
1+
<% content_for :title do %>
2+
<title>Points</title>
3+
<% end %>
54

6-
<div class="card-inline">
7-
<div class="card-inline-item card-inline-service">
8-
<div class="row">
9-
<div class="col-lg-6">
10-
<h1>Points</h1>
11-
</div>
5+
<% if current_user %>
6+
<div class="container">
7+
<div class="panel panel-default">
8+
<div class="panel-heading">
9+
<small><mark>Points</mark> are <mark>easy-to-understand</mark> mini-conclusions, annotated via the text of a service's <mark>documents</mark>.</small>
1210
</div>
13-
<br>
14-
<br>
15-
<div class="row">
16-
<div class="col-lg-4 text-left">
17-
<div class="">
11+
<div class="panel-body">
12+
<span class="lighter">
13+
<h3>Points
14+
<% if current_user&.admin || current_user&.curator %>
15+
<small>
16+
Can't find what you're looking for?
17+
<%= link_to 'Annotate', services_path %>
18+
a service
19+
</small>
20+
<% end %>
21+
</h3>
22+
</span>
23+
</div>
24+
</div>
25+
<div class="panel panel-default">
26+
<div class="panel-body">
27+
<br>
28+
<div class="row">
29+
<form class="navbar-form navbar-left" role="search">
1830
<%= search_form_for @q do |f| %>
19-
<%= f.label :service_name_cont %>
20-
<%= f.search_field :service_name_cont %>
21-
22-
<%= f.submit %>
31+
<div>
32+
<%= f.label :service_name_cont, class: "small lighter" %>
33+
</div>
34+
<div class="form-group">
35+
<%= f.search_field :service_name_cont, class: "form-control" %>
36+
</div>
37+
<%= f.submit class: "btn btn-default small" %>
2338
<% end %>
24-
</div>
39+
</form>
2540
</div>
41+
<% if @points.empty? %>
42+
<p>No points to display at this time</p>
43+
<% else %>
44+
<%= render "table_points", points: @points %>
45+
<% end %>
46+
<%= paginate @points %>
2647
</div>
27-
<br>
28-
<% if @points.empty? %>
29-
<p>There are no points to display at this time!</p>
30-
<% else %>
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>
66-
<% end %>
6748
</div>
6849
</div>
69-
<%= paginate @points %>
7050
<% end %>

app/views/shared/_navbar.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<strong class="label label-warning">STAGING ENVIRONMENT</strong>
1717
<% end %>
1818
<% unless current_user.nil? %>
19-
<%= link_to "Find a service to annotate", services_path, class: "btn btn-primary btn-sm" %>
19+
<%= link_to "Annotate a service", services_path, class: "btn btn-primary btn-sm" %>
2020
<% end %>
2121

2222

0 commit comments

Comments
 (0)