-
-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '8314-public-citations' into develop
- Loading branch information
Showing
30 changed files
with
560 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
.citations-types { | ||
border-top: 1px solid #d1d1d1; | ||
border-bottom: 1px solid #d1d1d1; | ||
margin-top: 2em; | ||
margin-bottom: 1em; | ||
} | ||
|
||
ul.citations-list { | ||
list-style: none; | ||
padding-left: 0; | ||
|
||
li.citations-list__citation { | ||
padding: 1em 0; | ||
border-bottom: 1px solid #d1d1d1; | ||
|
||
display: flex; | ||
align-items: flex-start; | ||
gap: 1em; | ||
|
||
.citation_icon { | ||
flex-shrink: 0; | ||
} | ||
|
||
.citation__title { | ||
flex-basis: 50%; | ||
word-break: break-word; | ||
} | ||
|
||
.citation__description { | ||
flex-basis: 50%; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,36 @@ | ||
class Admin::CitationsController < AdminController | ||
before_action :find_citation, except: :index | ||
|
||
def index | ||
@citations = | ||
Citation. | ||
order(created_at: :desc). | ||
paginate(page: params[:page], per_page: 50) | ||
end | ||
|
||
def edit | ||
end | ||
|
||
def update | ||
if @citation.update(citation_params) | ||
redirect_to admin_citations_path, notice: 'Citation updated successfully.' | ||
else | ||
render :edit | ||
end | ||
end | ||
|
||
def destroy | ||
@citation.destroy | ||
redirect_to admin_citations_path, notice: 'Citation deleted successfully.' | ||
end | ||
|
||
private | ||
|
||
def find_citation | ||
@citation = Citation.find(params[:id]) | ||
end | ||
|
||
def citation_params | ||
params.require(:citation).permit(:source_url, :title, :description) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<div class="row"> | ||
<div class="span12"> | ||
<div class="page-header"> | ||
<h1><%= @title = 'Edit citation' %></h1> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<%= form_for [:admin, @citation], class: 'form form-inline' do |f| %> | ||
<div class="control-group"> | ||
<%= f.label :source_url %> | ||
<div class="controls"> | ||
<%= f.text_field :source_url, class: 'form-control' %> | ||
</div> | ||
</div> | ||
|
||
<div class="control-group"> | ||
<%= f.label :title %> | ||
<div class="controls"> | ||
<%= f.text_field :title, class: 'form-control' %> | ||
</div> | ||
</div> | ||
|
||
<div class="control-group"> | ||
<%= f.label :description, class: 'control-label' %> | ||
<div class="controls"> | ||
<%= f.text_area :description, class: 'input-block-level', rows: 10 %> | ||
</div> | ||
</div> | ||
|
||
<div class="form-actions"> | ||
<%= f.submit 'Update ciation', class: 'btn btn-success' %> | ||
</div> | ||
<% end %> | ||
<%= form_for [:admin, @citation], class: 'form form-inline', method: 'delete' do |f| %> | ||
<%= f.submit 'Destroy citation', | ||
class: 'btn btn-danger', | ||
data: { confirm: 'Are you sure? This is irreversible.' } %> | ||
(this is permanent!) | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,29 @@ | ||
<li class="citations-list__citation"> | ||
<%= | ||
MySociety::Format.make_clickable( | ||
citation.source_url, contract: true, nofollow: true | ||
).html_safe | ||
%> | ||
<div class="citation__icon"> | ||
<%= citation_icon(citation) %> | ||
</div> | ||
|
||
<div class="citation__title"> | ||
<strong><%= link_to citation_title(citation), citation.source_url, rel: 'nofollow' %></strong> | ||
<br> | ||
<% case citation.citable %> | ||
<% when InfoRequest %> | ||
<%= _('<a href="{{info_request_url}}">{{title}}</a> requested from <a href="{{public_body_url}}">{{public_body_name}}</a> on {{date}}', | ||
title: citation.citable.title, | ||
info_request_url: request_path(citation.citable), | ||
public_body_name: citation.citable.public_body.name, | ||
public_body_url: public_body_path(citation.citable.public_body), | ||
date: simple_date(citation.citable.created_at)) %> | ||
<% when InfoRequestBatch %> | ||
<%= _('<a href="{{info_request_batch_url}}">{{title}}</a> part of a batch sent to {{count}} authorities on {{date}}', | ||
title: citation.citable.title, | ||
info_request_batch_url: info_request_batch_path(citation.citable), | ||
count: citation.citable.public_bodies.count, | ||
date: simple_date(citation.citable.created_at)) %> | ||
<% end %> | ||
</div> | ||
|
||
<div class="citation__description"> | ||
<%= citation.description %> | ||
</div> | ||
</li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<li class="citations-list__citation--compact"> | ||
<%= link_to citation_title(citation), citation.source_url, rel: 'nofollow' %> | ||
</li> |
Oops, something went wrong.