Skip to content

Commit

Permalink
Merge d544362 into 4bde041
Browse files Browse the repository at this point in the history
  • Loading branch information
gbp committed Apr 19, 2024
2 parents 4bde041 + d544362 commit 76f2567
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 9 deletions.
6 changes: 5 additions & 1 deletion app/assets/stylesheets/responsive/_header_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
// Hide menu items by default on mobile
#logged_in_bar,
#topnav,
#subnav,
#user_locale_switcher,
#navigation_search{
display:none;
Expand Down Expand Up @@ -94,6 +95,7 @@
// Show menu items when menu is targeted
#logged_in_bar,
#topnav,
#subnav,
#user_locale_switcher,
#navigation_search{
display:block;
Expand All @@ -107,6 +109,7 @@
#banner_nav,
#logged_in_bar,
#topnav,
#subnav,
#user_locale_switcher,
#navigation_search{
display:block;
Expand Down Expand Up @@ -143,7 +146,8 @@
}


#topnav{
#topnav,
#subnav{
padding: 0 0 1em 0;
@include respond-min( $main_menu-mobile_menu_cutoff ){
padding: 0;
Expand Down
21 changes: 20 additions & 1 deletion app/assets/stylesheets/responsive/_request_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -393,4 +393,23 @@ input.cplink__field {
&:last-child {
padding-bottom: 1.2em;
}
}
}

.request-category_container {
display: block;
margin: 0 -10px;

@include respond-min($main_menu-mobile_menu_cutoff) {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
}

.request-category {
padding: 10px;

@include respond-min($main_menu-mobile_menu_cutoff) {
flex: 1 1 30%;
}
}
3 changes: 2 additions & 1 deletion app/assets/stylesheets/responsive/_search_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#general_search,
#general_search_redirect,
#public_body_show,
#request_list {
#request_list,
#request_index {
@include grid-row($behavior: nest);
}

Expand Down
8 changes: 6 additions & 2 deletions app/controllers/request_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class RequestController < ApplicationController
MAX_RESULTS = 500
PER_PAGE = 25

def index
@title = _('Browse requests by category')
end

def select_authority
# Check whether we force the user to sign in right at the start, or we allow her
# to start filling the request anonymously
Expand Down Expand Up @@ -145,9 +149,9 @@ def list
count: @results[:matches_estimated],
tag_name: @tag)
elsif @page > 1
@title = _("Browse and search requests (page {{count}})", count: @page)
@title = _("Search requests (page {{count}})", count: @page)
else
@title = _('Browse and search requests')
@title = _('Search requests')
end

@track_thing = TrackThing.create_track_for_search_query(InfoRequestEvent.make_query_from_params(@filters))
Expand Down
2 changes: 1 addition & 1 deletion app/views/alaveteli_pro/general/_nav_items.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
</li>

<li class="<%= 'selected' if controller?('request') && !action?('new', 'select_authority', 'show') %>">
<%= link_to _("Browse public requests"),
<%= link_to _("View public requests"),
request_list_successful_path,
:onclick => track_analytics_event(
AnalyticsEvent::Category::PRO_NAV_CLICK,
Expand Down
2 changes: 1 addition & 1 deletion app/views/general/_nav_items.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</li>

<li class="<%= 'selected' if controller?('request') && !action?('new', 'select_authority') %>">
<%= link_to _("Browse requests"), request_list_successful_path %>
<%= link_to _("View requests"), request_list_successful_path %>
</li>

<li class="<%= 'selected' if controller?('public_body') %>">
Expand Down
8 changes: 8 additions & 0 deletions app/views/general/_responsive_topnav.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@
<% end %>
</ul>
</div>

<% if content_for? :subnav %>
<div id="subnav" class="subnav">
<ul id="navigation" class="navigation" role="navigation">
<%= yield :subnav %>
</ul>
</div>
<% end %>
8 changes: 8 additions & 0 deletions app/views/request/_tabs.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<% content_for :subnav do %>
<li class="<%= 'selected' unless current_page?(requests_path) %>">
<%= link_to _('Search requests'), request_list_path %>
</li>
<li class="<%= 'selected' if current_page?(requests_path) %>">
<%= link_to _('Browse by category'), requests_path %>
</li>
<% end %>
20 changes: 20 additions & 0 deletions app/views/request/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<%= render partial: 'tabs' %>

<h1><%= @title %></h1>

<div class="request-category_container">
<% InfoRequest.categories.each do |heading| %>
<% next unless heading.children.present? %>
<div class="request-category">
<h3><%= heading.title %></h3>
<ul>
<% heading.children.each do |category| %>
<% next unless category.category_tag.present? %>
<li>
<%= link_to category.title, request_list_path(tag: category.category_tag) %>
</li>
<% end %>
</ul>
</div>
<% end %>
</div>
2 changes: 2 additions & 0 deletions app/views/request/list.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<%= render partial: 'tabs' %>

<div id="header_left" class="header_left">
<h1><%= @title %></h1>
<%= render :partial => 'request/request_search_form',
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def matches?(request)
get '/body_statistics' => redirect('/statistics#public_bodies'), :as => :public_bodies_statistics

##### Request controller
get '/browse' => 'request#index', as: :requests
get '/list/all' => redirect('/list')
get '/list/recent' => redirect('/list')
match '/list(/:tag)/successful' => 'request#list',
Expand Down
1 change: 1 addition & 0 deletions doc/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Highlighted Features

* Allow requests to be browsed by category (Graeme Porteous)
* Allow requests to be listed and filtered by tag (Graeme Porteous)
* Allow categories to have notes associated with them (Graeme Porteous)
* Add styling option and rich text editor to the notes admin (Graeme Porteous)
Expand Down
21 changes: 19 additions & 2 deletions spec/controllers/request_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
require 'spec_helper'

RSpec.describe RequestController, "when listing request categories" do
it "should be successful" do
get :index
expect(response).to be_successful
end

it "should render with 'index' template" do
get :index
expect(response).to render_template('index')
end

it 'sets title based on page' do
get :index
expect(assigns[:title]).to eq('Browse requests by category')
end
end

RSpec.describe RequestController, "when listing recent requests" do
it "should be successful" do
get :list, params: { view: 'all' }
Expand Down Expand Up @@ -30,10 +47,10 @@

it 'sets title based on page' do
get :list, params: { view: 'all' }
expect(assigns[:title]).to eq('Browse and search requests')
expect(assigns[:title]).to eq('Search requests')

get :list, params: { view: 'all', page: 2 }
expect(assigns[:title]).to eq('Browse and search requests (page 2)')
expect(assigns[:title]).to eq('Search requests (page 2)')
end

it 'sets title based on if tag matches an request category' do
Expand Down

0 comments on commit 76f2567

Please sign in to comment.