diff options
Diffstat (limited to 'app/views/request')
-rw-r--r-- | app/views/request/_list_results.html.erb | 12 | ||||
-rw-r--r-- | app/views/request/batch_not_allowed.html.erb | 1 | ||||
-rw-r--r-- | app/views/request/list.html.erb | 22 | ||||
-rw-r--r-- | app/views/request/new.html.erb | 142 | ||||
-rw-r--r-- | app/views/request/preview.html.erb | 24 | ||||
-rw-r--r-- | app/views/request/select_authorities.html.erb | 77 | ||||
-rw-r--r-- | app/views/request/select_authority.html.erb | 7 | ||||
-rw-r--r-- | app/views/request/show.html.erb | 6 |
8 files changed, 217 insertions, 74 deletions
diff --git a/app/views/request/_list_results.html.erb b/app/views/request/_list_results.html.erb new file mode 100644 index 000000000..4da042816 --- /dev/null +++ b/app/views/request/_list_results.html.erb @@ -0,0 +1,12 @@ + <% @results = InfoRequest.request_list(@filters, @page, @per_page, @max_results) %> + <% if @results[:results].empty? %> + <p> <%= _('No requests of this sort yet.')%></p> + <% else %> + <h2 class="foi_results"><%= _('{{count}} FOI requests found', :count => @results[:matches_estimated]) %></h2> + <div class="results_block"> + <% @results[:results].each do |result| %> + <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result, :info_request => result.info_request } %> + <% end %> + </div> + <% end %> + <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @results[:show_no_more_than]) %> diff --git a/app/views/request/batch_not_allowed.html.erb b/app/views/request/batch_not_allowed.html.erb new file mode 100644 index 000000000..156fa9ae1 --- /dev/null +++ b/app/views/request/batch_not_allowed.html.erb @@ -0,0 +1 @@ +<%= _('Users cannot usually make batch requests to multiple authorities at once because we don’t want public authorities to be bombarded with large numbers of inappropriate requests. Please <a href="{{url}}">contact us</a> if you think you have good reason to send the same request to multiple authorities at once.', :url => help_contact_path.html_safe) %> diff --git a/app/views/request/list.html.erb b/app/views/request/list.html.erb index 062b77c3e..a465f03ba 100644 --- a/app/views/request/list.html.erb +++ b/app/views/request/list.html.erb @@ -14,21 +14,11 @@ <div style="clear:both"></div> <div class="results_section"> - <% # TODO: Cache for 5 minutes %> - <% if @list_results.empty? %> - <p> <%= _('No requests of this sort yet.')%></p> - <% else %> - <h2 class="foi_results"><%= _('{{count}} FOI requests found', :count => @matches_estimated) %></h2> - <div class="results_block"> - <% for result in @list_results%> - <% if result.class.to_s == 'InfoRequestEvent' %> - <%= render :partial => 'request/request_listing_via_event', :locals => { :event => result, :info_request => result.info_request } %> - <% else %> - <p><strong><%= _('Unexpected search result type') %> <%=result.class.to_s%></strong></p> - <% end %> - <% end %> - </div> + <% if key = request_list_cache_key %> + <% cache_if_caching_fragments(key, :expires_in => 5.minutes) do %> + <%= render :partial => 'list_results' %> <% end %> - - <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @show_no_more_than) %> + <% else %> + <%= render :partial => 'list_results' %> + <% end %> </div> diff --git a/app/views/request/new.html.erb b/app/views/request/new.html.erb index 849a94216..7f1332464 100644 --- a/app/views/request/new.html.erb +++ b/app/views/request/new.html.erb @@ -1,23 +1,27 @@ -<script type="text/javascript"> - $(document).ready(function(){ - // Avoid triggering too often (on each keystroke) by using the debounce jQuery plugin: - // http://benalman.com/projects/jquery-throttle-debounce-plugin/ - $("#typeahead_search").keypress($.debounce( 300, function() { - $("#typeahead_response").load("<%=search_ahead_url%>?q="+encodeURI(this.value), function() { - // When following links in typeahead results, open new tab/window - $("#typeahead_response a").attr("target","_blank"); - - // Update the public body site search link - $("#body-site-search-link").attr("href", "http://www.google.com/#q="+encodeURI($("#typeahead_search").val())+ - "+site:<%= @info_request.public_body.calculated_home_page %>"); - }); - })); - - }); -</script> - -<% @title = _("Make an {{law_used_short}} request to '{{public_body_name}}'",:law_used_short=>h(@info_request.law_used_short),:public_body_name=>h(@info_request.public_body.name)) %> - +<% unless @batch %> + <script type="text/javascript"> + $(document).ready(function(){ + // Avoid triggering too often (on each keystroke) by using the debounce jQuery plugin: + // http://benalman.com/projects/jquery-throttle-debounce-plugin/ + $("#typeahead_search").keypress($.debounce( 300, function() { + $("#typeahead_response").load("<%=search_ahead_url%>?q="+encodeURI(this.value), function() { + // When following links in typeahead results, open new tab/window + $("#typeahead_response a").attr("target","_blank"); + + // Update the public body site search link + $("#body-site-search-link").attr("href", "http://www.google.com/#q="+encodeURI($("#typeahead_search").val())+ + "+site:<%= @info_request.public_body.calculated_home_page %>"); + }); + })); + + }); + </script> +<% end %> +<% if @batch %> + <% @title = _("Make an {{law_used_short}} request", :law_used_short=>h(@info_request.law_used_short)) %> +<% else %> + <% @title = _("Make an {{law_used_short}} request to '{{public_body_name}}'",:law_used_short=>h(@info_request.law_used_short),:public_body_name=>h(@info_request.public_body.name)) %> +<% end %> <h1><%= _('2. Ask for Information') %></h1> <% if @existing_request %> @@ -29,53 +33,82 @@ </li> </ul></div> <% end %> + <% if @existing_batch %> + <div class="errorExplanation" id="errorExplanation"><ul> + <li> + <%= _('You already created the same batch of requests on {{date}}. You can either view the <a href="{{existing_batch}}">existing batch</a>, or edit the details below to make a new but similar batch of requests.', :date=>simple_date(@existing_batch.created_at), :existing_batch=>info_request_batch_path(@existing_batch)) %> + </li> + </ul></div> + <% end %> <%= foi_error_messages_for :info_request, :outgoing_message %> - <%= form_for(@info_request, :url => new_request_path, :html => { :id => 'write_form' } ) do |f| %> + <%= form_for(@info_request, :url => (@batch ? new_batch_path : new_request_path), :html => { :id => 'write_form' } ) do |f| %> <div id="request_header"> <div id="request_header_body"> <label class="form_label"><%= _('To:') %></label> - <span id="to_public_body"><%=h(@info_request.public_body.name)%></span> - <div class="form_item_note"> - <% if @info_request.public_body.info_requests.size > 0 %> - <%= _("Browse <a href='{{url}}'>other requests</a> to '{{public_body_name}}' for examples of how to word your request.", :public_body_name=>h(@info_request.public_body.name), :url=>public_body_path(@info_request.public_body)) %> - <% else %> - <%= _("Browse <a href='{{url}}'>other requests</a> for examples of how to word your request.", :url=>request_list_url) %> - <% end %> - </div> - <% if @info_request.public_body.has_notes? %> - <div id="request_header_text"> - <h3><%= _('Special note for this authority!') %></h3> - <p><%= @info_request.public_body.notes_as_html.html_safe %></p> - </div> + <% if @batch %> + <span id="to_public_body"> + <%= _("Your selected authorities") %> + <span class="batch_public_body_toggle" data-hidetext="<%= _("(hide)") %>" data-showtext="<%= _("(show)") %>"><a class="toggle-message"></a></span> + </span> + + <div class="batch_public_body_list"> + <ul> + <% @public_bodies.each do |public_body| %> + <li><%= public_body.name %></li> + <% end %> + </ul> + </div> + + <% else %> + <span id="to_public_body"> + <%=h(@info_request.public_body.name)%> + </span> <% end %> - <% if @info_request.public_body.eir_only? %> - <h3><%= _('Please ask for environmental information only') %></h3> + <% unless @batch %> + <div class="form_item_note"> + <% if @info_request.public_body.info_requests.size > 0 %> + <%= _("Browse <a href='{{url}}'>other requests</a> to '{{public_body_name}}' for examples of how to word your request.", :public_body_name=>h(@info_request.public_body.name), :url=>public_body_path(@info_request.public_body)) %> + <% else %> + <%= _("Browse <a href='{{url}}'>other requests</a> for examples of how to word your request.", :url=>request_list_url) %> + <% end %> + </div> + + <% if @info_request.public_body.has_notes? %> + <div id="request_header_text"> + <h3><%= _('Special note for this authority!') %></h3> + <p><%= @info_request.public_body.notes_as_html.html_safe %></p> + </div> + <% end %> + + <% if @info_request.public_body.eir_only? %> + <h3><%= _('Please ask for environmental information only') %></h3> - <p><%= _('The Freedom of Information Act <strong>does not apply</strong> to') %> <%=h(@info_request.public_body.name)%>. - <%= _('However, you have the right to request environmental + <p><%= _('The Freedom of Information Act <strong>does not apply</strong> to') %> <%=h(@info_request.public_body.name)%>. + <%= _('However, you have the right to request environmental information under a different law') %> (<a href="/help/requesting#eir">explanation</a>). - <%= _('This covers a very wide spectrum of information about the state of + <%= _('This covers a very wide spectrum of information about the state of the <strong>natural and built environment</strong>, such as:') %> - <ul> - <li><%= _('Air, water, soil, land, flora and fauna (including how these effect + <ul> + <li><%= _('Air, water, soil, land, flora and fauna (including how these effect human beings)') %></li> - <li><%= _('Information on emissions and discharges (e.g. noise, energy, + <li><%= _('Information on emissions and discharges (e.g. noise, energy, radiation, waste materials)') %></li> - <li><%= _('Human health and safety') %></li> - <li><%= _('Cultural sites and built structures (as they may be affected by the + <li><%= _('Human health and safety') %></li> + <li><%= _('Cultural sites and built structures (as they may be affected by the environmental factors listed above)') %></li> - <li><%= _('Plans and administrative measures that affect these matters') %></li> - </ul> + <li><%= _('Plans and administrative measures that affect these matters') %></li> + </ul> - <p><%= _('Please only request information that comes under those categories, <strong>do not waste your + <p><%= _('Please only request information that comes under those categories, <strong>do not waste your time</strong> or the time of the public authority by requesting unrelated information.') %></p> - <% end %> + <% end %> + <% end %> </div> <div id="request_header_subject"> @@ -132,7 +165,13 @@ </p> <div class="form_button"> - <%= f.hidden_field(:public_body_id, { :value => @info_request.public_body_id } ) %> + <% if @batch %> + <% params[:public_body_ids].each do |public_body_id| %> + <%= hidden_field_tag("public_body_ids[]", public_body_id)%> + <% end %> + <% else %> + <%= f.hidden_field(:public_body_id, { :value => @info_request.public_body_id } ) %> + <% end %> <%= hidden_field_tag(:submitted_new_request, 1 ) %> <%= hidden_field_tag(:preview, 1 ) %> <%= submit_tag _("Preview your public request") %> @@ -150,5 +189,6 @@ </div> <% end %> - - +<% if @batch %> + <%= javascript_include_tag 'new-request.js' %> +<% end %> diff --git a/app/views/request/preview.html.erb b/app/views/request/preview.html.erb index 243dc90a9..0265d0328 100644 --- a/app/views/request/preview.html.erb +++ b/app/views/request/preview.html.erb @@ -1,6 +1,9 @@ -<% @title = "Preview new " + h(@info_request.law_used_short) + " request to '" + h(@info_request.public_body.name) + "'" %> - -<%= form_for(@info_request, :url => new_request_path, :html => { :id => 'preview_form' } ) do |f| %> +<% if @batch %> + <% @title = _("Preview new {{law_used_short}} request", :law_used_short => h(@info_request.law_used_short)) %> +<% else %> + <% @title = _("Preview new {{law_used_short}} request to '{{public_body_name}}", :law_used_short => h(@info_request.law_used_short), :public_body_name => h(@info_request.public_body.name)) %> +<% end %> +<%= form_for(@info_request, :url => (@batch ? new_batch_path : new_request_path), :html => { :id => 'preview_form' } ) do |f| %> <h1><%= _('3. Now check your request') %></h1> <ul> @@ -14,7 +17,12 @@ <div class="correspondence" id="outgoing-0"> <p class="preview_subject"> - <strong><%= _('To:') %></strong> <%=h @info_request.public_body.name %> + <strong><%= _('To:') %></strong> + <% if @batch %> + <%= _("Your selected authorities")%> + <% else %> + <%=h(@info_request.public_body.name)%> + <% end %> <br><strong><%= _('Subject:') %></strong> <%=h @info_request.email_subject_request %> </p> @@ -33,7 +41,13 @@ <p> <%= f.hidden_field(:title) %> - <%= f.hidden_field(:public_body_id, { :value => @info_request.public_body_id } ) %> + <% if @batch %> + <% params[:public_body_ids].each do |public_body_id| %> + <%= hidden_field_tag("public_body_ids[]", public_body_id)%> + <% end %> + <% else %> + <%= f.hidden_field(:public_body_id, { :value => @info_request.public_body_id } ) %> + <% end %> <%= f.hidden_field(:tag_string) %> <%= hidden_field_tag(:submitted_new_request, 1) %> <%= hidden_field_tag(:preview, 0 ) %> diff --git a/app/views/request/select_authorities.html.erb b/app/views/request/select_authorities.html.erb new file mode 100644 index 000000000..e16bcc191 --- /dev/null +++ b/app/views/request/select_authorities.html.erb @@ -0,0 +1,77 @@ +<% @title = _("Select the authorities to write to") %> +<h1><%= _('1. Select 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', :remote => true, "data-type" => 'json'}) 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_all_button', :class => 'select_all_button' %> + <%= 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' %> + <%= submit_tag _(' << '), :id => 'body_deselect_all_button', :class => 'select_all_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> +<%= javascript_include_tag 'jquery_ujs.js', 'select-authorities.js' %> diff --git a/app/views/request/select_authority.html.erb b/app/views/request/select_authority.html.erb index 4f117ee75..83abdb184 100644 --- a/app/views/request/select_authority.html.erb +++ b/app/views/request/select_authority.html.erb @@ -40,6 +40,13 @@ <%= hidden_field_tag 'bodies', 1 %> <%= submit_tag _('Search') %> </div> + <% if AlaveteliConfiguration.allow_batch_requests && @user && @user.can_make_batch_requests? %> + <div id="batch_request_link"> + <p> + <%= _('Or make a <a href="{{url}}">batch request</a> to <strong>multiple authorities</strong> at once.', :url => select_authorities_path) %> + </p> + </div> + <% end %> <% end %> <div id="typeahead_response"> diff --git a/app/views/request/show.html.erb b/app/views/request/show.html.erb index c520ce40c..153b0b861 100644 --- a/app/views/request/show.html.erb +++ b/app/views/request/show.html.erb @@ -34,14 +34,16 @@ <p class="subtitle"> <% if !@user.nil? && @user.admin_page_links? %> <%= _('{{user}} ({{user_admin_link}}) made this {{law_used_full}} request (<a href="{{request_admin_url}}">admin</a>) to {{public_body_link}} (<a href="{{public_body_admin_url}}">admin</a>)', - :user => @info_request.is_external? ? (@info_request.user_name || _('An anonymous user')) : user_link(@info_request.user), + :user => request_user_link(@info_request, _('An anonymous user')), :law_used_full => h(@info_request.law_used_full), :user_admin_link => user_admin_link_for_request(@info_request, _('external'), _('admin')), :request_admin_url => admin_request_show_url(@info_request), :public_body_link => public_body_link(@info_request.public_body), :public_body_admin_url => admin_body_show_url(@info_request.public_body)) %> <% else %> - <%= _('{{user}} made this {{law_used_full}} request',:user=>@info_request.is_external? ? (@info_request.user_name || _('An anonymous user')) : user_link(@info_request.user), :law_used_full=>h(@info_request.law_used_full)) %> + <%= _('{{user}} made this {{law_used_full}} request', + :user=>request_user_link(@info_request, _('An anonymous user')), + :law_used_full=>h(@info_request.law_used_full)) %> <%= _('to {{public_body}}',:public_body=>public_body_link(@info_request.public_body)) %> <% end %> </p> |