Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#8314] public citations gr #8404

Merged
merged 5 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/assets/stylesheets/responsive/_citations.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ ul.citations-list {

.citation__title {
flex-basis: 50%;
word-break: break-word;
}

.citation__description {
Expand Down
9 changes: 9 additions & 0 deletions app/helpers/admin/link_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,15 @@ def category_both_links(category)
title: admin_title)
end

def citation_both_links(citation)
title = 'View citation'
icon = eye

link_to(icon, citation.source_url, title: title) + ' ' +
link_to(citation.source_url, edit_admin_citation_path(citation),
title: admin_title)
end

def admin_title
'View full details'
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/citations/_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<div class="row">
<span class="item-title span6">
<%= citation_icon(citation) %>
<tt><%= link_to citation_title(citation), edit_admin_citation_path(citation) %></tt>
<tt><%= both_links(citation) %></tt>
</span>

<span class="item-metadata span6">
Expand Down
6 changes: 5 additions & 1 deletion app/views/citations/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1><%= _('In the News') %></h1>
<h1><%= _('FOI in Action') %></h1>

<p>
<% if @resource.is_a?(InfoRequestBatch) %>
Expand All @@ -8,6 +8,10 @@
<%= _('Has this request been referenced in journalism, campaigning, ' \
'or research?') %>
<% end %>

<%= _('Let us know about great examples of <a href="{{citations_path}}">' \
'FOI in Action</a>.',
citations_path: citations_path) %>
</p>

<%= form_for @citation,
Expand Down
26 changes: 17 additions & 9 deletions app/views/info_request_batch/_citations.html.erb
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
<% if can?(:create_citation, info_request_batch) || citations.any? %>
<div class="sidebar__section citations">
<h2><%= _('In the News') %></h2>
<h2><%= _('FOI in Action') %></h2>

<% if citations.any? %>
<ul class="citations-list--compact">
<%= render partial: 'citations/compact',
collection: citations,
as: :citation %>
</ul>
<% elsif can? :create_citation, info_request_batch %>
<% end %>

<% if can? :create_citation, info_request_batch %>
<p>
<%= _('Has this batch request been referenced in journalism, ' \
'campaigning, or research?') %>
</p>
<% end %>

<% if can? :create_citation, info_request_batch %>
<%= link_to new_info_request_batch_citation_path(info_request_batch),
class: 'citations-new' do %>
<%= citations.any? ? _('New Citation') : _('Let us know') %>
<% end %>
<br>

<%= link_to new_info_request_batch_citation_path(info_request_batch),
class: 'citations-new' do %>
<%= _('Let us know') %>
<% end %>
</p>
<% else %>
<p>
<%= _('See more examples of <a href="{{citations_path}}">' \
'FOI in Action</a>.',
citations_path: citations_path) %>
</p>
<% end %>
</div>
<% end %>
26 changes: 17 additions & 9 deletions app/views/request/_citations.html.erb
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
<% if can?(:create_citation, info_request) || citations.any? %>
<div class="sidebar__section citations">
<h2><%= _('In the News') %></h2>
<h2><%= _('FOI in Action') %></h2>

<% if citations.any? %>
<ul class="citations-list--compact">
<%= render partial: 'citations/compact',
collection: citations,
as: :citation %>
</ul>
<% elsif can? :create_citation, info_request %>
<% end %>

<% if can? :create_citation, info_request %>
<p>
<%= _('Has this request been referenced in journalism, ' \
'campaigning, or research?') %>
</p>
<% end %>

<% if can? :create_citation, info_request %>
<%= link_to new_citation_path(url_title: info_request.url_title),
class: 'citations-new' do %>
<%= citations.any? ? _('New Citation') : _('Let us know') %>
<% end %>
<br>

<%= link_to new_citation_path(url_title: info_request.url_title),
class: 'citations-new' do %>
<%= _('Let us know') %>
<% end %>
</p>
<% else %>
<p>
<%= _('See more examples of <a href="{{citations_path}}">' \
'FOI in Action</a>.',
citations_path: citations_path) %>
</p>
<% end %>
</div>
<% end %>
3 changes: 3 additions & 0 deletions app/views/request/_tabs.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
<li class="<%= 'selected' if current_page?(requests_path) %>">
<%= link_to _('Browse by category'), requests_path %>
</li>
<li>
<%= link_to _('FOI in Action'), citations_path %>
</li>
<% end %>
8 changes: 8 additions & 0 deletions spec/helpers/admin/link_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,13 @@
end
end
end

context 'with a Citation' do
let(:record) { FactoryBot.create(:citation) }

it { is_expected.to include('icon-eye-open') }
it { is_expected.to include(record.source_url) }
it { is_expected.to include(edit_admin_citation_path(record)) }
end
end
end
20 changes: 8 additions & 12 deletions spec/views/info_request_batch/_citations.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def render_view
before { render_view }

it 'renders the section' do
expect(rendered).to match(/In the News/)
expect(rendered).to match(/FOI in Action/)
end

it 'renders the blank slate text' do
Expand All @@ -59,11 +59,7 @@ def render_view
before { render_view }

it 'renders the section' do
expect(rendered).to match(/In the News/)
end

it 'does not render the blank slate text' do
expect(rendered).not_to match(/Has this batch request been referenced/)
expect(rendered).to match(/FOI in Action/)
end

it 'renders the citations' do
Expand All @@ -81,19 +77,19 @@ def render_view
before { render_view }

it 'renders the section' do
expect(rendered).to match(/In the News/)
end

it 'does not render the blank slate text' do
expect(rendered).not_to match(/Has this request been referenced/)
expect(rendered).to match(/FOI in Action/)
end

it 'renders the citations' do
expect(rendered).to match(/citations-list/)
end

it 'renders the blank slate text' do
expect(rendered).to match(/Has this batch request been referenced/)
end

it 'renders the link to add citations' do
expect(rendered).to match('New Citation')
expect(rendered).to match('Let us know')
end
end
end
Expand Down
16 changes: 8 additions & 8 deletions spec/views/request/_citations.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def render_view
before { render_view }

it 'renders the section' do
expect(rendered).to match(/In the News/)
expect(rendered).to match(/FOI in Action/)
end

it 'renders the blank slate text' do
Expand All @@ -57,7 +57,7 @@ def render_view
before { render_view }

it 'renders the section' do
expect(rendered).to match(/In the News/)
expect(rendered).to match(/FOI in Action/)
end

it 'does not render the blank slate text' do
Expand All @@ -79,19 +79,19 @@ def render_view
before { render_view }

it 'renders the section' do
expect(rendered).to match(/In the News/)
end

it 'does not render the blank slate text' do
expect(rendered).not_to match(/Has this request been referenced/)
expect(rendered).to match(/FOI in Action/)
end

it 'renders the citations' do
expect(rendered).to match(/citations-list/)
end

it 'renders the blank slate text' do
expect(rendered).to match(/Has this request been referenced/)
end

it 'renders the link to add citations' do
expect(rendered).to match('New Citation')
expect(rendered).to match('Let us know')
end
end
end
Expand Down
Loading