Skip to content

Commit c1c595e

Browse files
committed
implements crud views for document_types
1 parent fa172b6 commit c1c595e

File tree

8 files changed

+313
-0
lines changed

8 files changed

+313
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<%= simple_form_for [document_type] do |f| %>
2+
<span class="lighter">
3+
<%= f.input :name, hint: "The name classifies the type of document. It should be unique and specific.", placeholder: "e.g., EU Privacy Policy, as opposed to just Privacy Policy" %>
4+
<br>
5+
<%= f.input :description, as: :text, placeholder: "e.g., concerns EU end user’s personal data", class: "lighter" %>
6+
<br>
7+
<% if current_user.admin || current_user.curator %>
8+
<%= f.input :status, collection: ["approved", "declined", "pending"], selected: document_type.status || "pending", class: "lighter" %>
9+
<% end %>
10+
</span>
11+
<br>
12+
<%= f.submit submit_text, class: 'btn btn-default lighter' %>
13+
<% end %>
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<div class="container-fluid">
2+
<!-- Collect the nav links, forms, and other content for toggling -->
3+
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
4+
<% if current_user %>
5+
<ul class="nav navbar-nav">
6+
<% if document_type.user == current_user || (current_user.admin || current_user.curator) %>
7+
<li><%= link_to 'Edit', edit_document_type_path(document_type) %></li>
8+
<% end %>
9+
<% if current_user.admin || current_user.curator %>
10+
<li class="dropdown">
11+
<a href="#" class="dropdown-toggle lighter" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Review <span class="caret"></span></a>
12+
<ul class="dropdown-menu">
13+
<li class="lighter small"><%= link_to 'Approve', document_type_review_path(document_type, status: 'approved'), method: :post %></li>
14+
<li class="lighter small"><%= link_to 'Decline', document_type_review_path(document_type, status: 'declined'), method: :post %></li>
15+
<li class="lighter small"><%= link_to 'Revert to pending', document_type_review_path(document_type, status: 'pending'), method: :post %></li>
16+
</ul>
17+
</li>
18+
<% end %>
19+
</ul>
20+
<ul class="nav navbar-nav navbar-right">
21+
<li class="lighter small"><%= link_to 'All document types', document_types_path %></li>
22+
</ul>
23+
<% end %>
24+
<% unless current_user %>
25+
<ul class="nav navbar-nav navbar-right">
26+
<li>
27+
<li class="lighter small"><%= link_to 'Inspect all document types', document_types_path %></li>
28+
</li>
29+
</ul>
30+
<% end %>
31+
</div><!-- /.navbar-collapse -->
32+
</div><!-- /.container-fluid -->
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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">Name</th>
7+
<th scope="col" class="lighter">Description</th>
8+
<th scope="col" class="lighter">Status</th>
9+
</tr>
10+
</thead>
11+
<tbody>
12+
<% document_types.each do |d| %>
13+
<%
14+
if d.status == "approved"
15+
status_color = "bg-success"
16+
elsif d.status == "declined"
17+
status_color = "bg-danger"
18+
elsif d.status
19+
status_color = "bg-warning"
20+
end
21+
%>
22+
<tr>
23+
<td class="small lighter"><%= link_to d.name, document_type_path(d) %></td>
24+
<td class="small"><mark><%= d.description %></mark></td>
25+
<td class="small <%= status_color %>"><%= d.status %></td>
26+
</tr>
27+
<% end %>
28+
</tbody>
29+
</table>
30+
</div>
31+
</div>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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">Inspect</th>
8+
<th scope="col" class="lighter">Web location</th>
9+
<th scope="col" class="lighter"></th>
10+
</tr>
11+
</thead>
12+
<tbody>
13+
<% documents.each do |d| %>
14+
<tr>
15+
<td class="small lighter"><%= link_to d.service.name, service_path(d.service) %></td>
16+
<td class="small"><mark><%= link_to d.document_type ? d.document_type.name : d.name, document_path(d) %></mark></td>
17+
<td class="small"><%= truncate(d.url, length: 30) %></td>
18+
<td class="small text-right">
19+
<%= link_to annotate_service_path(d.service.id) + '?#doc_' + d.id.to_s do %>
20+
<i class="fa fa-pen"></i>
21+
<% end %>
22+
</td>
23+
</tr>
24+
<% end %>
25+
</tbody>
26+
</table>
27+
</div>
28+
</div>
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<% content_for :title do %>
2+
<title>Edit <%= @document_type.name %></title>
3+
<% end %>
4+
5+
<div>
6+
<div>
7+
<ul class="nav navbar-nav navbar-right">
8+
<li class="lighter small"><%= link_to 'Back', document_type_path(@document_type) %></li>
9+
</ul>
10+
</div>
11+
<br>
12+
<br>
13+
<div class="container">
14+
<div class="panel panel-default">
15+
<div class="panel-heading">
16+
<small>Document types <mark>classify</mark> legal documents. For more information, please inspect our <%= link_to 'documentation', 'https://github.com/tosdr/terms-types' %>.</small>
17+
</div>
18+
<div class="panel-body">
19+
<span class="lighter">
20+
<h4>
21+
Update <%= @document_type.name %>
22+
</h4>
23+
</span>
24+
</div>
25+
</div>
26+
<div class="panel panel-default">
27+
<div class="panel-heading">
28+
<small>Document types allow us to <mark>normalize</mark> and <mark>organize</mark> documents. For a broader dictionary of <mark>individual documents</mark> and their <mark>document type</mark> classification, inspect our <%= link_to 'source code', 'https://github.com/tosdr/terms-dictionary/blob/master/type.rb'%>.</small>
29+
</div>
30+
<div class="panel-body">
31+
<br>
32+
<%= render 'form', document_type: @document_type, submit_text: @submit_text %>
33+
<br>
34+
</div>
35+
</div>
36+
</div>
37+
</div>
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<% content_for :title do %>
2+
<title>Document types</title>
3+
<% end %>
4+
5+
<div class="container">
6+
<div class="panel panel-default">
7+
<div class="panel-heading">
8+
<small>We <mark>explicitly define</mark> document types to better <mark>standardize</mark> and <mark>organize</mark> our data. For more information, please inspect our <%= link_to 'documentation', 'https://github.com/tosdr/terms-types' %>.</small>
9+
</div>
10+
<div class="panel-body">
11+
<span class="lighter">
12+
<h3>Document types
13+
<% if current_user %>
14+
<small>
15+
Can't find what you're looking for?
16+
<% if current_user.admin || current_user.curator %>
17+
<%= link_to 'Create', new_document_type_path %>
18+
<% else %>
19+
<%= link_to 'Request', new_document_type_path %>
20+
<% end %>
21+
a new type
22+
</small>
23+
<% end %>
24+
</h3>
25+
</span>
26+
</div>
27+
</div>
28+
<div class="panel panel-default">
29+
<div class="panel-body">
30+
<br>
31+
<div class="row">
32+
<form class="navbar-form navbar-left" role="search">
33+
<%= search_form_for @q do |f| %>
34+
<div>
35+
<%= f.label :name_cont, class: "small lighter" %>
36+
</div>
37+
<div class="form-group">
38+
<%= f.search_field :name_cont, class: "form-control" %>
39+
</div>
40+
<%= f.submit class: "btn btn-default small" %>
41+
<% end %>
42+
</form>
43+
<form class="navbar-form navbar-left" role="search">
44+
<%= search_form_for @q do |f| %>
45+
<div>
46+
<%= f.label :description_cont, class: "small lighter" %>
47+
</div>
48+
<div class="form-group">
49+
<%= f.search_field :description_cont, class: "form-control" %>
50+
</div>
51+
<%= f.submit class: "btn btn-default small" %>
52+
<% end %>
53+
</form>
54+
<form class="navbar-form navbar-left" role="search">
55+
<%= search_form_for @q do |f| %>
56+
<div>
57+
<%= f.label 'Status', class: "small lighter" %>
58+
</div>
59+
<%= f.select :status_eq, options_for_select(DocumentType.pluck(:status).uniq, @q.status_eq), { include_blank: true }, { class: 'form-control' } %>
60+
<%= f.submit class: "btn btn-default small" %>
61+
<% end %>
62+
</form>
63+
64+
</div>
65+
<% if @document_types.empty? %>
66+
<p>No document types to display at this time</p>
67+
<% else %>
68+
<%= render "table_document_types", document_types: @document_types %>
69+
<% end %>
70+
<%= paginate @document_types %>
71+
</div>
72+
</div>
73+
</div>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<% content_for :title do %>
2+
<title>New document type</title>
3+
<% end %>
4+
5+
<div>
6+
<div>
7+
<ul class="nav navbar-nav navbar-right">
8+
<li class="lighter small"><%= link_to 'Back', document_types_path %></li>
9+
</ul>
10+
</div>
11+
<br>
12+
<br>
13+
<div class="container">
14+
<div class="panel panel-default">
15+
<div class="panel-heading">
16+
<small>Document types <mark>classify</mark> legal documents. For more information, please inspect our <%= link_to 'documentation', 'https://github.com/tosdr/terms-types' %>.</small>
17+
</div>
18+
<div class="panel-body">
19+
<span class="lighter">
20+
<h4>
21+
New document type
22+
</h4>
23+
</span>
24+
</div>
25+
</div>
26+
<div class="panel panel-default">
27+
<div class="panel-heading">
28+
<small>Document types allow us to <mark>normalize</mark> and <mark>organize</mark> documents. An example would be <mark>Corporate Social Responsibility</mark>, or CSR.
29+
<br>
30+
<br>
31+
Many service documents concern CSR. Documents that address diversity policies, environmental practices, corruption prevention, and human trafficking prevention would all fall under the <mark>document type</mark> of <mark>Corporate Social Responsibility</mark>.
32+
<br>
33+
<br>
34+
For a broader dictionary of <mark>individual documents</mark> and their <mark>document type</mark> classification, inspect our <%= link_to 'source code', 'https://github.com/tosdr/terms-dictionary/blob/master/type.rb'%>.</small>
35+
</div>
36+
<div class="panel-body">
37+
<br>
38+
<%= render 'form', document_type: @document_type, submit_text: @submit_text %>
39+
<br>
40+
</div>
41+
</div>
42+
</div>
43+
</div>
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<% content_for :title do %>
2+
<title><%= @document_type.name %></title>
3+
<% end %>
4+
<br>
5+
<div class="container">
6+
<%= render "nav", document_type: @document_type %>
7+
8+
<div class="panel panel-default">
9+
<div class="panel-heading">
10+
<small>Document types <mark>classify</mark> legal documents. For more information, please inspect our <%= link_to 'documentation', 'https://github.com/tosdr/terms-types' %>.</small>
11+
</div>
12+
<div class="panel-body">
13+
<span class="lighter">
14+
<div class="row">
15+
<div class="col-md-3">
16+
<h4>
17+
<%= @document_type.name %>
18+
</h4>
19+
</div>
20+
<div class="col-md-6">
21+
<small>
22+
<%= @document_type.description %>
23+
</small>
24+
</div>
25+
<% if @document_type.status == 'approved' %>
26+
<% status_color = 'text-success' %>
27+
<% elsif @document_type.status == 'pending' %>
28+
<% status_color = 'text-warning' %>
29+
<% elsif @document_type.status == 'declined' %>
30+
<% status_color = 'text-danger' %>
31+
<% end %>
32+
<div class="col-md-3 text-right">
33+
<span class="<%= status_color %>">
34+
<small> status: <%= @document_type.status %>
35+
</span>
36+
</div>
37+
</div>
38+
<div>
39+
</div>
40+
</span>
41+
</div>
42+
</div>
43+
44+
<div class="panel panel-default">
45+
<div class="panel-heading">
46+
<small>
47+
Many <mark>individual documents</mark> can correspond to a single <mark>document type</mark>. For a broader dictionary of <mark>individual documents</mark> and their <mark>document type</mark>, inspect our <%= link_to 'source code', 'https://github.com/tosdr/terms-dictionary/blob/master/type.rb'%>.
48+
</small>
49+
</div>
50+
<div class="panel-body">
51+
<br>
52+
<%= render "table_documents", documents: @documents %>
53+
<br>
54+
</div>
55+
</div>
56+
</div>

0 commit comments

Comments
 (0)