diff options
Diffstat (limited to 'app')
27 files changed, 239 insertions, 154 deletions
diff --git a/app/assets/stylesheets/responsive/_new_request_layout.scss b/app/assets/stylesheets/responsive/_new_request_layout.scss index a2ab23060..a8b24e1b1 100644 --- a/app/assets/stylesheets/responsive/_new_request_layout.scss +++ b/app/assets/stylesheets/responsive/_new_request_layout.scss @@ -58,6 +58,10 @@ } } +#typeahead_response .close-button { + float: right; +} + /* Advice sits on right hand side */ #request_advice { diff --git a/app/controllers/admin_censor_rule_controller.rb b/app/controllers/admin_censor_rule_controller.rb index 6f79b5ba1..68ca57510 100644 --- a/app/controllers/admin_censor_rule_controller.rb +++ b/app/controllers/admin_censor_rule_controller.rb @@ -8,23 +8,49 @@ class AdminCensorRuleController < AdminController def new if params[:info_request_id] @info_request = InfoRequest.find(params[:info_request_id]) + @censor_rule = @info_request.censor_rules.build + @form_url = admin_info_request_censor_rules_path(@info_request) end + if params[:user_id] @censor_user = User.find(params[:user_id]) + @censor_rule = @censor_user.censor_rules.build + @form_url = admin_user_censor_rules_path(@censor_user) end + + @censor_rule ||= CensorRule.new + @form_url ||= admin_rule_create_path end def create - params[:censor_rule][:last_edit_editor] = admin_current_user() - @censor_rule = CensorRule.new(params[:censor_rule]) + params[:censor_rule][:last_edit_editor] = admin_current_user + + if params[:info_request_id] + @info_request = InfoRequest.find(params[:info_request_id]) + @censor_rule = @info_request.censor_rules.build(params[:censor_rule]) + @form_url = admin_info_request_censor_rules_path(@info_request) + end + + if params[:user_id] + @censor_user = User.find(params[:user_id]) + @censor_rule = @censor_user.censor_rules.build(params[:censor_rule]) + @form_url = admin_user_censor_rules_path(@censor_user) + end + + @censor_rule ||= CensorRule.new(params[:censor_rule]) + @form_url ||= admin_rule_create_path + if @censor_rule.save if !@censor_rule.info_request.nil? expire_for_request(@censor_rule.info_request) end + if !@censor_rule.user.nil? expire_requests_for_user(@censor_rule.user) end + flash[:notice] = 'CensorRule was successfully created.' + if !@censor_rule.info_request.nil? redirect_to admin_request_show_url(@censor_rule.info_request) elsif !@censor_rule.user.nil? @@ -42,16 +68,20 @@ class AdminCensorRuleController < AdminController end def update - params[:censor_rule][:last_edit_editor] = admin_current_user() + params[:censor_rule][:last_edit_editor] = admin_current_user @censor_rule = CensorRule.find(params[:id]) + if @censor_rule.update_attributes(params[:censor_rule]) - if !@censor_rule.info_request.nil? + unless @censor_rule.info_request.nil? expire_for_request(@censor_rule.info_request) end - if !@censor_rule.user.nil? + + unless @censor_rule.user.nil? expire_requests_for_user(@censor_rule.user) end + flash[:notice] = 'CensorRule was successfully updated.' + if !@censor_rule.info_request.nil? redirect_to admin_request_show_url(@censor_rule.info_request) elsif !@censor_rule.user.nil? @@ -65,19 +95,22 @@ class AdminCensorRuleController < AdminController end def destroy - censor_rule = CensorRule.find(params[:censor_rule_id]) - info_request = censor_rule.info_request - user = censor_rule.user + @censor_rule = CensorRule.find(params[:censor_rule_id]) + info_request = @censor_rule.info_request + user = @censor_rule.user - censor_rule.destroy - if !info_request.nil? + @censor_rule.destroy + + unless info_request.nil? expire_for_request(info_request) end - if !user.nil? + + unless user.nil? expire_requests_for_user(user) end flash[:notice] = "CensorRule was successfully destroyed." + if !info_request.nil? redirect_to admin_request_show_url(info_request) elsif !user.nil? diff --git a/app/controllers/admin_public_body_categories_controller.rb b/app/controllers/admin_public_body_categories_controller.rb index fda09fa4a..5e305dde3 100644 --- a/app/controllers/admin_public_body_categories_controller.rb +++ b/app/controllers/admin_public_body_categories_controller.rb @@ -22,7 +22,8 @@ class AdminPublicBodyCategoriesController < AdminController I18n.with_locale(I18n.default_locale) do if params[:public_body_category][:category_tag] && PublicBody.find_by_tag(@category.category_tag).count > 0 && @category.category_tag != params[:public_body_category][:category_tag] - flash[:notice] = 'There are authorities associated with this category, so the tag can\'t be renamed' + flash[:error] = "There are authorities associated with this category, so the tag can't be renamed" + render :action => 'edit' else if params[:headings] heading_ids = params[:headings].values @@ -48,10 +49,11 @@ class AdminPublicBodyCategoriesController < AdminController if @category.update_attributes(params[:public_body_category]) flash[:notice] = 'Category was successfully updated.' + redirect_to edit_admin_category_path(@category) + else + render :action => 'edit' end end - - render :action => 'edit' end end diff --git a/app/controllers/admin_public_body_headings_controller.rb b/app/controllers/admin_public_body_headings_controller.rb index c7c80e802..e893e760d 100644 --- a/app/controllers/admin_public_body_headings_controller.rb +++ b/app/controllers/admin_public_body_headings_controller.rb @@ -10,8 +10,10 @@ class AdminPublicBodyHeadingsController < AdminController @heading = PublicBodyHeading.find(params[:id]) if @heading.update_attributes(params[:public_body_heading]) flash[:notice] = 'Category heading was successfully updated.' + redirect_to edit_admin_heading_path(@heading) + else + render :action => 'edit' end - render :action => 'edit' end end @@ -54,13 +56,6 @@ class AdminPublicBodyHeadingsController < AdminController @locale = self.locale_from_params() I18n.with_locale(@locale) do heading = PublicBodyHeading.find(params[:id]) - - if heading.public_body_categories.count > 0 - flash[:notice] = "There are categories associated with this heading, so can't destroy it" - redirect_to edit_admin_heading_url(heading) - return - end - heading.destroy flash[:notice] = "Category heading was successfully destroyed." redirect_to admin_categories_url diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 4d3f40d40..1ccf7e5db 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -17,6 +17,9 @@ class ApplicationController < ActionController::Base # assign our own handler method for non-local exceptions rescue_from Exception, :with => :render_exception + # Add some security-related headers (see config/initializers/secure_headers.rb) + ensure_security_headers + # Standard headers, footers and navigation for whole site layout "default" include FastGettext::Translation # make functions like _, n_, N_ etc available) diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 9e2c291dc..346aaf384 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -900,10 +900,18 @@ class RequestController < ApplicationController # Type ahead search def search_typeahead - # Since acts_as_xapian doesn't support the Partial match flag, we work around it - # by making the last work a wildcard, which is quite the same - query = params[:q] - @xapian_requests = perform_search_typeahead(query, InfoRequestEvent) + # Since acts_as_xapian doesn't support the Partial match flag, we work + # around it by making the last word a wildcard, which is quite the same + @query = '' + + if params.key?(:requested_from) + @query << "requested_from:#{ params[:requested_from] } " + end + + @per_page = (params.fetch(:per_page) { 25 }).to_i + + @query << params[:q] + @xapian_requests = perform_search_typeahead(@query, InfoRequestEvent, @per_page) render :partial => "request/search_ahead" end diff --git a/app/models/change_email_validator.rb b/app/models/change_email_validator.rb index 7ee6654bb..65f2fd81c 100644 --- a/app/models/change_email_validator.rb +++ b/app/models/change_email_validator.rb @@ -55,10 +55,20 @@ class ChangeEmailValidator def check_email_is_present_and_valid(email) if !send(email).blank? && !MySociety::Validate.is_valid_email(send(email)) - errors.add(email, _("#{ email.to_s.humanize } doesn't look like a valid address")) + msg_string = check_email_is_present_and_valid_msg_string(email) + errors.add(email, msg_string) end end + def check_email_is_present_and_valid_msg_string(email) + case email.to_sym + when :old_email then _("Old email doesn't look like a valid address") + when :new_email then _("New email doesn't look like a valid address") + else + raise "Unsupported email type #{ email }" + end + end + def email_belongs_to_user?(email) email.downcase == logged_in_user.email.downcase end diff --git a/app/models/public_body_category.rb b/app/models/public_body_category.rb index 8eaecd596..bb83c4c82 100644 --- a/app/models/public_body_category.rb +++ b/app/models/public_body_category.rb @@ -19,9 +19,10 @@ class PublicBodyCategory < ActiveRecord::Base has_many :public_body_headings, :through => :public_body_category_links translates :title, :description - validates_uniqueness_of :category_tag, :message => N_('Tag is already taken') - validates_presence_of :title, :message => N_("Title can't be blank") - validates_presence_of :category_tag, :message => N_("Tag can't be blank") + validates_uniqueness_of :category_tag, :message => 'Tag is already taken' + validates_presence_of :title, :message => "Title can't be blank" + validates_presence_of :category_tag, :message => "Tag can't be blank" + validates_presence_of :description, :message => "Description can't be blank" def self.get locale = I18n.locale.to_s || default_locale.to_s || "" diff --git a/app/models/public_body_category_link.rb b/app/models/public_body_category_link.rb index eb233b56f..ba3ff1f95 100644 --- a/app/models/public_body_category_link.rb +++ b/app/models/public_body_category_link.rb @@ -15,7 +15,7 @@ class PublicBodyCategoryLink < ActiveRecord::Base validates_presence_of :public_body_category validates_presence_of :public_body_heading validates :category_display_order, :numericality => { :only_integer => true, - :message => N_('Display order must be a number') } + :message => 'Display order must be a number' } before_validation :on => :create do unless self.category_display_order diff --git a/app/models/public_body_heading.rb b/app/models/public_body_heading.rb index c38800561..f1916d233 100644 --- a/app/models/public_body_heading.rb +++ b/app/models/public_body_heading.rb @@ -16,10 +16,10 @@ class PublicBodyHeading < ActiveRecord::Base translates :name - validates_uniqueness_of :name, :message => N_('Name is already taken') - validates_presence_of :name, :message => N_('Name can\'t be blank') + validates_uniqueness_of :name, :message => 'Name is already taken' + validates_presence_of :name, :message => 'Name can\'t be blank' validates :display_order, :numericality => { :only_integer => true, - :message => N_('Display order must be a number') } + :message => 'Display order must be a number' } before_validation :on => :create do unless self.display_order diff --git a/app/views/admin_censor_rule/_form.html.erb b/app/views/admin_censor_rule/_form.html.erb index 5035238d6..3f602d2e4 100644 --- a/app/views/admin_censor_rule/_form.html.erb +++ b/app/views/admin_censor_rule/_form.html.erb @@ -4,11 +4,9 @@ <%=_("Applies to")%> <% unless info_request.nil? %> <%= request_both_links(info_request) %> - <%= hidden_field 'censor_rule', 'info_request_id', { :value => info_request.id } %> <% end %> <% unless user.nil? %> <%= user_both_links(user) %> - <%= hidden_field 'censor_rule', 'user_id', { :value => user.id } %> <% end %> </div> diff --git a/app/views/admin_censor_rule/_show.html.erb b/app/views/admin_censor_rule/_show.html.erb index 0d4cece93..46904b3b9 100644 --- a/app/views/admin_censor_rule/_show.html.erb +++ b/app/views/admin_censor_rule/_show.html.erb @@ -1,18 +1,17 @@ - <% if censor_rules.size > 0 %> <table class="table table-condensed"> <tr> <th>Id</th> - <% for column in CensorRule.content_columns %> + <% CensorRule.content_columns.each do |column| %> <th><%= column.human_name %></th> <% end %> <th>Actions</th> </tr> - <% for censor_rule in censor_rules %> + <% censor_rules.each do |censor_rule| %> <tr class="<%= cycle('odd', 'even') %>"> <td><%=h censor_rule.id %></td> - <% for column in CensorRule.content_columns.map { |c| c.name } %> + <% CensorRule.content_columns.map { |c| c.name }.each do |column| %> <td><%=h censor_rule.send(column) %></td> <% end %> <td> @@ -26,10 +25,11 @@ <% end %> <% if defined? info_request %> - <%= link_to "New censor rule (for this request only)", admin_rule_new_path(:info_request_id => info_request.id), :class => "btn btn-info" %> + <%= link_to "New censor rule", new_admin_info_request_censor_rule_path(info_request), :class => "btn btn-info" %> + <span class="label label-info">for this request only</span> <% end %> <% if defined? user %> - <%= link_to "New censor rule", admin_rule_new_path(:user_id => user.id), :class => "btn btn-info" %> <span class="label label-info">for all requests by this user</span> + <%= link_to "New censor rule", new_admin_user_censor_rule_path(user), :class => "btn btn-info" %> + <span class="label label-info">for all requests by this user</span> <% end %> - diff --git a/app/views/admin_censor_rule/new.html.erb b/app/views/admin_censor_rule/new.html.erb index 77d22990c..26b3212be 100644 --- a/app/views/admin_censor_rule/new.html.erb +++ b/app/views/admin_censor_rule/new.html.erb @@ -1,11 +1,11 @@ <% @title = _('New censor rule') %> -<h1><%=@title%></h1> +<h1><%= @title %></h1> -<%= form_tag admin_rule_create_path, :class => "form form-horizontal" do %> +<%= form_for @censor_rule, :url => @form_url, :class => "form form-horizontal" do %> <%= render :partial => 'form', :locals => { :info_request => @info_request, :user => @censor_user } %> + <div class="form-actions"> <%= submit_tag "Create", :class => "btn btn-primary" %> </div> <% end %> - diff --git a/app/views/admin_general/index.html.erb b/app/views/admin_general/index.html.erb index a1f2e1d2d..ba9396ceb 100644 --- a/app/views/admin_general/index.html.erb +++ b/app/views/admin_general/index.html.erb @@ -202,8 +202,11 @@ <div id="update-authorities" class="accordion-body collapse"> <% for @change_request in @body_update_requests %> <%= render :partial => 'change_request_summary' %> + <%= form_tag admin_change_request_update_path(@change_request), :class => "form form-horizontal" do %> + <%= submit_tag 'Close', :class => "btn btn-danger" %> <%= link_to("Close and respond", admin_change_request_edit_path(@change_request), :class => 'btn') %> <%= link_to("Make update", admin_body_edit_path(@change_request.public_body, :change_request_id => @change_request.id), :class => 'btn btn-primary') %> + <% end %> <% end %> </div> </div> diff --git a/app/views/admin_general/stats.html.erb b/app/views/admin_general/stats.html.erb index 27dc25ee0..03268cc14 100644 --- a/app/views/admin_general/stats.html.erb +++ b/app/views/admin_general/stats.html.erb @@ -53,8 +53,3 @@ </div> </div> </div> -<div class="row"> - <div class="span12"> - <h2>Web analytics</h2> - </div> -</div> diff --git a/app/views/admin_public_body_categories/_form.html.erb b/app/views/admin_public_body_categories/_form.html.erb index b0778d371..1f033ac9b 100644 --- a/app/views/admin_public_body_categories/_form.html.erb +++ b/app/views/admin_public_body_categories/_form.html.erb @@ -44,16 +44,23 @@ end </div> </div> -<% if PublicBody.find_by_tag(@category.category_tag).count == 0 or @category.errors.messages.keys.include?(:category_tag) %> - <h3>Common Fields</h3> +<h3>Common Fields</h3> - <div class="control-group"> - <label for="public_body_category_category_tag" class="control-label">Category tag</label> - <div class="controls"> - <%= f.text_field :category_tag, :class => "span4" %> - </div> - </div> -<% end %> +<div class="control-group"> + <label for="public_body_category_category_tag" class="control-label">Category tag</label> + <div class="controls"> + <% if PublicBody.find_by_tag(@category.category_tag).count == 0 or + @category.errors.messages.keys.include?(:category_tag) %> + <%= f.text_field :category_tag, :class => "span4" %> + <% else %> + <%= f.text_field :category_tag, :class => "span4", :disabled => true %> + <span class="help-block"> + This Category already has authorities assigned to it so the tags + cannot be modified. + </span> + <% end %> + </div> +</div> <h3>Headings</h3> <div class="control-group"> diff --git a/app/views/admin_public_body_categories/_heading_list.html.erb b/app/views/admin_public_body_categories/_heading_list.html.erb index 4bd8bdc90..f92f0c9b0 100644 --- a/app/views/admin_public_body_categories/_heading_list.html.erb +++ b/app/views/admin_public_body_categories/_heading_list.html.erb @@ -1,9 +1,12 @@ <div class="accordion" id="category_list"> - <% for heading in category_headings %> - <div class="accordion-group" data-id="headings_<%=heading.id%>"> + <% category_headings.each do |heading| %> + <div class="accordion-group" data-id="headings_<%= heading.id %>"> <div class="accordion-heading accordion-toggle row"> <span class="item-title span6"> - <a href="#heading_<%=heading.id%>_categories" data-toggle="collapse" data-parent="#categories" ><%= chevron_right %></a> + <a href="#heading_<%= heading.id %>_categories" data-toggle="collapse" data-parent="#categories"> + <span class="badge"><%= heading.public_body_categories.size %></span> + <%= chevron_right %> + </a> <strong><%= link_to(heading.name, edit_admin_heading_path(heading), :title => "view full details") %></strong> </span> </div> diff --git a/app/views/admin_public_body_categories/edit.html.erb b/app/views/admin_public_body_categories/edit.html.erb index 95988d688..f83d0768d 100644 --- a/app/views/admin_public_body_categories/edit.html.erb +++ b/app/views/admin_public_body_categories/edit.html.erb @@ -1,30 +1,35 @@ -<h1><%=@title%></h1> +<h1><%= @title %></h1> <div class="row"> - <div class="span8"> - <div id="public_body_category_form"> - <%= form_for @category, :url => admin_category_path(@category), :html => { :class => "form form-horizontal" } do |f| %> - <%= render :partial => 'form', :locals => {:f => f} %> - <div class="form-actions"> - <%= f.submit 'Save', :accesskey => 's', :class => "btn btn-success" %></p> - </div> - <% end %> - </div> -</div> + <div class="span8"> + <div id="public_body_category_form"> + <%= form_for @category, :url => admin_category_path(@category), :html => { :class => "form form-horizontal" } do |f| %> + <%= render :partial => 'form', :locals => { :f => f } %> -<div class="row"> - <div class="span8 well"> - <%= link_to 'List all', admin_categories_path, :class => "btn" %> + <div class="form-actions"> + <%= f.submit 'Save', :accesskey => 's', :class => "btn btn-success" %> + <%= link_to 'List all', admin_categories_path, :class => "btn" %> + </div> + <% end %> + </div> </div> </div> -<% if @tagged_public_bodies.empty? %> - <div class="row"> - <div class="span8"> - <%= form_tag(admin_category_path(@category), :method => 'delete', :class => "form form-inline") do %> - <%= hidden_field_tag(:public_body_id, { :value => @category.id } ) %> - <%= submit_tag "Destroy #{@category.title}", :title => @category.title, :class => "btn btn-danger" %> (this is permanent!) - <% end %> +<hr /> + +<div class="row"> + <div class="span12"> + <div class="well"> + <%= form_for @category, :url => admin_category_path(@category), :method => 'delete', :class => "form form-inline" do |f| %> + <%= f.submit "Destroy #{ @category.title }", + :title => @category.title, + :class => "btn btn-danger", + :confirm => 'Are you sure?' %> + <span class="help-block"> + Destroying a category does not destroy the public authorities + associated with the category. + </span> + <% end %> </div> </div> -<% end %> +</div> diff --git a/app/views/admin_public_body_categories/new.html.erb b/app/views/admin_public_body_categories/new.html.erb index 8b1b1103f..ed9f06d7c 100644 --- a/app/views/admin_public_body_categories/new.html.erb +++ b/app/views/admin_public_body_categories/new.html.erb @@ -1,21 +1,17 @@ <% @title = 'New category' %> -<h1><%=@title%></h1> +<h1><%= @title %></h1> <div class="row"> <div class="span8"> <div id="public_category_form"> - <%= form_for @category, :url => admin_categories_path, :html => {:class => "form form-horizontal"} do |f| %> - <%= render :partial => 'form', :locals => {:f => f} %> + <%= form_for @category, :url => admin_categories_path, :html => { :class => "form form-horizontal" } do |f| %> + <%= render :partial => 'form', :locals => { :f => f } %> <div class="form-actions"> <%= f.submit "Create", :class => "btn btn-primary" %> + <%= link_to 'List all', admin_categories_path, :class => "btn" %> </div> - <% end %> - <div class="row"> - <div class="span8 well"> - <%= link_to 'List all', admin_categories_path, :class => "btn" %> - </div> - </div> + <% end %> </div> </div> </div> diff --git a/app/views/admin_public_body_headings/edit.html.erb b/app/views/admin_public_body_headings/edit.html.erb index eff89285a..d4bc02562 100644 --- a/app/views/admin_public_body_headings/edit.html.erb +++ b/app/views/admin_public_body_headings/edit.html.erb @@ -1,30 +1,39 @@ -<h1><%=@title%></h1> +<h1><%= @title %></h1> <div class="row"> - <div class="span8"> - <div id="public_body_heading_form"> - <%= form_for @heading, :url => admin_heading_path(@heading), :html => { :class => "form form-horizontal" } do |f| %> - <%= render :partial => 'form', :locals => {:f => f} %> - <div class="form-actions"> - <%= f.submit 'Save', :accesskey => 's', :class => "btn btn-success" %></p> - </div> - <% end %> - </div> -</div> + <div class="span8"> + <div id="public_body_heading_form"> + <%= form_for @heading, :url => admin_heading_path(@heading), :html => { :class => "form form-horizontal" } do |f| %> + <%= render :partial => 'form', :locals => { :f => f } %> -<div class="row"> - <div class="span8 well"> - <%= link_to 'List all', admin_categories_path, :class => "btn" %> - </div> + <div class="form-actions"> + <%= f.submit 'Save', :accesskey => 's', :class => "btn btn-success" %> + <%= link_to 'List all', admin_categories_path, :class => "btn" %> + </div> + <% end %> + </div> + </div> </div> -<% if @heading.public_body_categories.empty? %> - <div class="row"> - <div class="span8"> - <%= form_tag(admin_heading_path(@heading), :method => 'delete', :class => "form form-inline") do %> - <%= hidden_field_tag(:public_body_heading_id, { :value => @heading.id } ) %> - <%= submit_tag "Destroy #{@heading.name}", :name => @heading.name, :class => "btn btn-danger" %> (this is permanent!) +<hr /> + +<div class="row"> + <div class="span12"> + <div class="well"> + <%= form_for @heading, :url => admin_heading_path(@heading), :method => 'delete', :class => "form form-inline" do |f| %> + <%= f.submit "Destroy #{ @heading.name }", + :name => @heading.name, + :class => "btn btn-danger", + :confirm => 'Are you sure?' %> + <span class="help-block"> + <ul> + <li>Destroying a category heading only destroys the heading itself.</li> + <li>Child categories assigned to another heading remain assigned to the other heading.</li> + <li>Child categories with no other heading become "Categories with no heading".</li> + <li>Public authorities remain assigned to the categories.</li> + </ul> + </span> <% end %> </div> </div> -<% end %> +</div> diff --git a/app/views/admin_public_body_headings/new.html.erb b/app/views/admin_public_body_headings/new.html.erb index 91d5d4a9d..c6fe514b0 100644 --- a/app/views/admin_public_body_headings/new.html.erb +++ b/app/views/admin_public_body_headings/new.html.erb @@ -1,21 +1,17 @@ <% @title = 'New category heading' %> -<h1><%=@title%></h1> +<h1><%= @title %></h1> <div class="row"> <div class="span8"> <div id="public_heading_form"> - <%= form_for @heading, :url => admin_headings_path, :html => {:class => "form form-horizontal"} do |f| %> - <%= render :partial => 'form', :locals => {:f => f} %> + <%= form_for @heading, :url => admin_headings_path, :html => { :class => "form form-horizontal" } do |f| %> + <%= render :partial => 'form', :locals => { :f => f } %> <div class="form-actions"> <%= f.submit "Create", :class => "btn btn-primary" %> + <%= link_to 'List all', admin_categories_path, :class => "btn" %> </div> - <% end %> - <div class="row"> - <div class="span8 well"> - <%= link_to 'List all', admin_categories_path, :class => "btn" %> - </div> - </div> + <% end %> </div> </div> </div> diff --git a/app/views/general/exception_caught.html.erb b/app/views/general/exception_caught.html.erb index 8d78e2e92..21223dc1e 100644 --- a/app/views/general/exception_caught.html.erb +++ b/app/views/general/exception_caught.html.erb @@ -12,13 +12,10 @@ <%= submit_tag _("Search") %> <% end %> </li> - </ul> + </ul> <% else %> <h1><%= _("Sorry, there was a problem processing this page") %></h1> <p><%= _('You have found a bug. Please <a href="{{contact_url}}">contact us</a> to tell us about the problem', :contact_url => help_contact_path) %></p> <% end %> - <h2><%= _('Technical details') %></h2> - <p><strong><%= h(@exception_class ? @exception_class : _("Unknown")) %></strong></p> - <p><strong><%= h(@exception_message) %></strong></p> </div> diff --git a/app/views/request/_search_ahead.html.erb b/app/views/request/_search_ahead.html.erb index 1e65a5458..4fbe06ebc 100644 --- a/app/views/request/_search_ahead.html.erb +++ b/app/views/request/_search_ahead.html.erb @@ -1,14 +1,20 @@ -<div id="request_search_ahead_results"> - <% if !@xapian_requests.nil? %> - <% if @xapian_requests.results.size > 0 %> +<% unless @xapian_requests.nil? %> + <div id="request_search_ahead_results"> + <% if @xapian_requests.results.any? %> + <span class="close-button">X</span> <h3><%= _("Possibly related requests:") %></h3> - <% end %> - <% for result in @xapian_requests.results %> - <%= render :partial => 'request/request_listing_short_via_event', :locals => { :event => result[:model], :info_request => result[:model].info_request } %> - <% end %> - <p> - <a id="body-site-search-link"><%= _("Or search in their website for this information.") %></a> - </p> - <% end %> -</div> + <% @xapian_requests.results.each do |result| %> + <%= render :partial => 'request/request_listing_short_via_event', + :locals => { :event => result[:model], + :info_request => result[:model].info_request } %> + <% end %> + + <p> + <a id="body-site-search-link"> + <%= _("Search in their website for this information →") %> + </a> + </p> + <% end %> + </div> +<% end %> diff --git a/app/views/request/new.html.erb b/app/views/request/new.html.erb index 7f1332464..51224129e 100644 --- a/app/views/request/new.html.erb +++ b/app/views/request/new.html.erb @@ -1,19 +1,33 @@ <% unless @batch %> <script type="text/javascript"> $(document).ready(function(){ - // Avoid triggering too often (on each keystroke) by using the debounce jQuery plugin: + // 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 %>"); + if ( $('#request_search_ahead_results').text().trim().length > 0) { + $('#typeahead_response').slideUp('fast'); + } + + $("#typeahead_response").load("<%= search_ahead_url %>?q="+encodeURI(this.value)+ + "&requested_from=<%= @info_request.public_body.url_name %>"+ + "&per_page=3", function() { + + if ( $('#request_search_ahead_results').text().trim().length > 0) { + $('#typeahead_response').hide().slideDown('fast'); + + // 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 %>"); + + $('.close-button').click(function() { $(this).parent().hide() }); + } }); })); - }); </script> <% end %> diff --git a/app/views/user/_signin.html.erb b/app/views/user/_signin.html.erb index afc55d249..864951733 100644 --- a/app/views/user/_signin.html.erb +++ b/app/views/user/_signin.html.erb @@ -14,7 +14,7 @@ <p> <label class="form_label" for="user_signin_password"><%= _('Password:')%></label> - <%= password_field 'user_signin', 'password', { :size => 15, :tabindex => 20 } %> + <%= password_field 'user_signin', 'password', { :size => 15, :tabindex => 20, :autocomplete => 'off' } %> </p> <p class="form_note"> diff --git a/app/views/user/signchangeemail.html.erb b/app/views/user/signchangeemail.html.erb index 7308179f4..a99bcb785 100644 --- a/app/views/user/signchangeemail.html.erb +++ b/app/views/user/signchangeemail.html.erb @@ -23,7 +23,7 @@ <p> <label class="form_label" for="signchangeemail_password"> <%= _('Your password:')%></label> - <%= password_field 'signchangeemail', 'password', { :size => 15 } %> + <%= password_field 'signchangeemail', 'password', { :size => 15, :autocomplete => 'off' } %> </p> <p class="form_note"> diff --git a/app/views/user/signchangepassword.html.erb b/app/views/user/signchangepassword.html.erb index 51bcb466d..60f5d2c62 100644 --- a/app/views/user/signchangepassword.html.erb +++ b/app/views/user/signchangepassword.html.erb @@ -13,12 +13,12 @@ <p> <label class="form_label" for="user_password"><%= _('New password:')%></label> - <%= password_field 'user', 'password', { :size => 15 } %> + <%= password_field 'user', 'password', { :size => 15, :autocomplete => 'off' } %> </p> <p> <label class="form_label" for="user_password_confirmation"><%= _('New password: (again)')%></label> - <%= password_field 'user', 'password_confirmation', { :size => 15 } %> + <%= password_field 'user', 'password_confirmation', { :size => 15, :autocomplete => 'off' } %> </p> <div class="form_button"> |