Skip to content

Commit

Permalink
Simplify citation sidebar logic
Browse files Browse the repository at this point in the history
* Always show the context text
* Use the same CTA irrespective of existing citations
  • Loading branch information
garethrees authored and gbp committed Oct 11, 2024
1 parent 5a9a07f commit bf75167
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
18 changes: 10 additions & 8 deletions app/views/info_request_batch/_citations.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@
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>
<% end %>
</div>
<% end %>
18 changes: 10 additions & 8 deletions app/views/request/_citations.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@
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>
<% end %>
</div>
<% end %>
14 changes: 5 additions & 9 deletions spec/views/info_request_batch/_citations.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ def render_view
expect(rendered).to match(/FOI in Action/)
end

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

it 'renders the citations' do
expect(rendered).to match(/citations-list/)
end
Expand All @@ -84,16 +80,16 @@ def render_view
expect(rendered).to match(/FOI in Action/)
end

it 'does not render the blank slate text' do
expect(rendered).not_to match(/Has this request been referenced/)
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
10 changes: 5 additions & 5 deletions spec/views/request/_citations.html.erb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,16 @@ def render_view
expect(rendered).to match(/FOI in Action/)
end

it 'does not render the blank slate text' do
expect(rendered).not_to match(/Has this request been referenced/)
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

0 comments on commit bf75167

Please sign in to comment.