diff options
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/stylesheets/main.scss | 31 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 11 | ||||
-rw-r--r-- | app/views/request/select_authorities.html.erb | 72 |
3 files changed, 113 insertions, 1 deletions
diff --git a/app/assets/stylesheets/main.scss b/app/assets/stylesheets/main.scss index 625245cce..278106d2a 100644 --- a/app/assets/stylesheets/main.scss +++ b/app/assets/stylesheets/main.scss @@ -1777,3 +1777,34 @@ text-decoration:none; the axes black rather than transparent grey for the moment: */ color: #000 !important; } + + +#body_selection .body_list { + width: 45%; +} + +#body_selection .body_list input[type='submit'] { + margin: 10px 0; + width: 45%; +} + +#body_selection .body_list #body_deselect_button{ + float: right; +} + +#body_selection #body_candidates { + float: left; +} + +#body_selection #body_selections { + float: right; +} + +#body_selection #body_submission input[type='submit'] { + margin: 10px 0; + width:100%; +} + +#body_selection .body_select { + width: 100%; +} diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 11e85764a..feac94b92 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -58,6 +58,17 @@ class RequestController < ApplicationController if !@user.can_make_batch_requests? return render_hidden('request/batch_not_allowed') end + if !params[:public_body_query].nil? + @search_bodies = perform_search_typeahead(params[:public_body_query], PublicBody) + end + if !params[:public_body_ids].nil? + if !params[:remove_public_body_ids].nil? + body_ids = params[:public_body_ids] - params[:remove_public_body_ids] + else + body_ids = params[:public_body_ids] + end + @public_bodies = PublicBody.where({:id => body_ids}).all + end end def show diff --git a/app/views/request/select_authorities.html.erb b/app/views/request/select_authorities.html.erb index 80bf93c8c..616cb3f50 100644 --- a/app/views/request/select_authorities.html.erb +++ b/app/views/request/select_authorities.html.erb @@ -1,4 +1,74 @@ <% @title = _("Select the authorities to write to") %> +<h1><%= _('1. Select authorities') %></h1> - <h1><%= _('1. Select the authorities') %></h1> +<p> + <%= _("Search for the authorities you'd like information from:") %> +</p> + +<div> + <%= form_tag(select_authorities_path, {:method => 'get', :id => 'body_search_form'}) do %> + <%= text_field_tag 'public_body_query', params[:public_body_query], { :size => 30, :title => "type your search term here" } %> + <% if !@public_bodies.blank? %> + <%- @public_bodies.each do |public_body| %> + <%= hidden_field_tag "public_body_ids[]", public_body.id, {:id => nil} %> + <%- end %> + <% end %> + <% end %> +</div> + +<div id="body_selection"> + <div id="body_lists"> + <div id="body_candidates" class="body_list"> + <%= form_tag(select_authorities_path, {:id => "body_select_form"}) do %> + <%= submit_tag _(' > '), :id => 'body_select_button' %> + <%= hidden_field_tag "public_body_query", params[:public_body_query], { :id => 'public_body_select_query' } %> + <% if !@public_bodies.blank? %> + <% @public_bodies.each do |public_body| %> + <%= hidden_field_tag "public_body_ids[]", public_body.id, {:id => nil} %> + <% end %> + <% end %> + <select multiple name="public_body_ids[]" id="select_body_candidates" class="body_select" size="15"> + <% if @search_bodies %> + <% @search_bodies.results.each do |result| %> + <% unless (@public_bodies && @public_bodies.include?(result[:model])) %> + <option value="<%= result[:model].id %>"><%= result[:model].name %></option> + <% end %> + <% end %> + <% end %> + </select> + <% end %> + </div> + + <div id="body_selections" class="body_list"> + <%= form_tag(select_authorities_path, {:id => "body_deselect_form"}) do %> + <%= submit_tag _(' < '), :id => 'body_deselect_button' %> + <%= hidden_field_tag "public_body_query", params[:public_body_query], { :id => 'public_body_deselect_query' } %> + <% if @public_bodies %> + <% @public_bodies.each do |public_body| %> + <%= hidden_field_tag "public_body_ids[]", public_body.id, {:id => nil} %> + <% end %> + <% end %> + <select multiple name="remove_public_body_ids[]" id="select_body_selections" class="body_select" size="15"> + <% if @public_bodies %> + <% @public_bodies.each do |public_body| %> + <option value="<%= public_body.id %>"><%= public_body.name %></option> + <% end %> + <% end %> + </select> + <% end %> + + <div id="body_submission"> + <%= form_tag(new_batch_path, {:id => "body_submit_form"}) do %> + <% if @public_bodies %> + <% @public_bodies.each do |public_body| %> + <%= hidden_field_tag "public_body_ids[]", public_body.id , {:id => nil} %> + <% end %> + <% end %> + <%= submit_tag _('Make a request to these authorities'), :id => 'body_submit_button' %> + <% end %> + </div> + + </div> + </div> +</div> |