diff options
Diffstat (limited to 'app')
30 files changed, 313 insertions, 252 deletions
diff --git a/app/assets/stylesheets/admin.scss b/app/assets/stylesheets/admin.scss index 863a6c808..104f10c75 100644 --- a/app/assets/stylesheets/admin.scss +++ b/app/assets/stylesheets/admin.scss @@ -35,8 +35,8 @@ body.admin { @import "bootstrap"; #main { + margin-bottom: 50px; padding-top: 50px; - } .form-inline { diff --git a/app/assets/stylesheets/main.scss b/app/assets/stylesheets/main.scss index 8aa8010ae..b063b0d77 100644 --- a/app/assets/stylesheets/main.scss +++ b/app/assets/stylesheets/main.scss @@ -586,26 +586,22 @@ width:40%; width:26em; } -#authority_preview { -width:45%; -float:right; -background-color:#FFFFE0; -padding-left:1em; -padding-right:1em; -overflow:hidden; -margin-top:-67px; -} - -#authority_preview #header_left,#authority_preview.request_left,#authority_preview #stepwise_make_request { -width:95%; -} - #request_advice { float:right; width:250px; margin-top:1em; } +#select_authority_help { +background-color: #FEF1F6; +float: right; +margin-top: 31px; +overflow: hidden; +padding-left: 1em; +padding-right: 1em; +width: 45%; +} + #request_advice ul { margin:0 auto; } @@ -1717,16 +1713,11 @@ width:575px; padding-right:50px; } -#authority_preview .request_left, -#authority_preview #header_left { - width: 100%; -} - #request_sidebar h2,.list-filter-item { margin-bottom:10px; } -div.ff-icon-printfix,.comment_in_request_text img.comment_quote,body.front #other-country-notice,#other-country-notice,#authority_preview .public-body-name-prefix,#authority_preview #list-filter,#authority_preview h2.foi_results,div#show_response_view p.event_actions, div.batch_public_body_toggle { +div.ff-icon-printfix,.comment_in_request_text img.comment_quote,body.front #other-country-notice,#other-country-notice,div#show_response_view p.event_actions, div.batch_public_body_toggle { display:none; } diff --git a/app/assets/stylesheets/responsive/_new_request_layout.scss b/app/assets/stylesheets/responsive/_new_request_layout.scss index aba4ffc29..a8b24e1b1 100644 --- a/app/assets/stylesheets/responsive/_new_request_layout.scss +++ b/app/assets/stylesheets/responsive/_new_request_layout.scss @@ -11,6 +11,9 @@ @include lte-ie7 { width: 27.125em; } + #query { + width: 80%; + } } } @@ -18,46 +21,19 @@ @include grid-row($behavior: nest); } -#authority_preview { +#select_authority_help { @include grid-column(12); - @include respond-min( $main_menu-mobile_menu_cutoff ){ + @include respond-min( $main_menu-mobile_menu_cutoff ) { @include grid-column(6); - margin-top:-67px; - @include ie8{ + @include ie8 { padding-right: 0.9375em; } @include lte-ie7 { width: 26.188em; } - /* Don't nest public body grid row in this context */ - #public_body_show { - @include grid-row(); - } - - } - - /* Hide some elements of the public body that aren't appropriate in this - context */ - #list-filter, h2.foi_results, .public-body-name-prefix { - display: none; - } - - /* Compact request list for viewing in authority preview column */ - .request_left, #header_left { - @include grid-column(12, $collapse: true); - } - - .request_right { - @include grid-column(12, $collapse: true); - } - - span.desc { - background:none; - line-height:18px; - padding: 0; } - } + /* /new/[body_name] page */ #request_header { @include grid-row; @@ -82,6 +58,10 @@ } } +#typeahead_response .close-button { + float: right; +} + /* Advice sits on right hand side */ #request_advice { diff --git a/app/assets/stylesheets/responsive/_new_request_style.scss b/app/assets/stylesheets/responsive/_new_request_style.scss index ab144b39f..86e17cbfe 100644 --- a/app/assets/stylesheets/responsive/_new_request_style.scss +++ b/app/assets/stylesheets/responsive/_new_request_style.scss @@ -1,5 +1,12 @@ /* Styles for pages in making a new request */ +/* /select_authority page */ +#select_authority_help { + .info { + font-style: italic; + } +} + /* /new/[body_name] page */ .new_info_request { label { 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/help_controller.rb b/app/controllers/help_controller.rb index 9033198a0..93215ccad 100644 --- a/app/controllers/help_controller.rb +++ b/app/controllers/help_controller.rb @@ -11,6 +11,10 @@ class HelpController < ApplicationController before_filter :long_cache before_filter :catch_spam, :only => [:contact] + def index + redirect_to help_about_path + end + def unhappy @info_request = nil if params[:url_title] 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/comment.rb b/app/models/comment.rb index a286aa1f5..cc8d0e94b 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -91,9 +91,9 @@ class Comment < ActiveRecord::Base def check_body_uses_mixed_capitals unless MySociety::Validate.uses_mixed_capitals(body) - msg = 'Please write your annotation using a mixture of capital and ' \ - 'lower case letters. This makes it easier for others to read.' - errors.add(:body, _(msg)) + msg = _('Please write your annotation using a mixture of capital and ' \ + 'lower case letters. This makes it easier for others to read.') + errors.add(:body, msg) end end diff --git a/app/models/incoming_message.rb b/app/models/incoming_message.rb index 135a6bdaf..db6722976 100644 --- a/app/models/incoming_message.rb +++ b/app/models/incoming_message.rb @@ -693,8 +693,10 @@ class IncomingMessage < ActiveRecord::Base self.reload # get the main body part from the set of attachments we just created, - # not from the self.foi_attachments association - some of the total set of - # self.foi_attachments may now be obsolete + # not from the self.foi_attachments association - some of the total set + # of self.foi_attachments may now be obsolete. Sometimes (e.g. when + # parsing mail from Apple Mail) we can end up with less attachments + # because the hexdigest of an attachment is identical. main_part = get_main_body_text_part(attachments) # we don't use get_main_body_text_internal, as we want to avoid charset # conversions, since /usr/bin/uudecode needs to deal with those. 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/public_body/_search_ahead.html.erb b/app/views/public_body/_search_ahead.html.erb index 2de638034..b5632bccd 100644 --- a/app/views/public_body/_search_ahead.html.erb +++ b/app/views/public_body/_search_ahead.html.erb @@ -2,9 +2,6 @@ <% if !@xapian_requests.nil? %> <% if @xapian_requests.results.size > 0 %> <h3><%= _('Top search results:') %></h3> - <p> - <%= _('Select one to see more information about the authority.')%> - </p> <% else %> <h3><%= _('No results found.') %></h3> <% end %> @@ -14,5 +11,4 @@ <% end %> </div> <%= will_paginate WillPaginate::Collection.new(@page, @per_page, @xapian_requests.matches_estimated), :params => {:controller=>"request", :action => "select_authority"} %> - <p><%= raw(_('<a href="{{browse_url}}">Browse all</a> or <a href="{{add_url}}">ask us to add one</a>.', :browse_url => list_public_bodies_default_path.html_safe, :add_url => (help_requesting_path + '#missing_body').html_safe)) %></p> <% end %> 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/request/select_authority.html.erb b/app/views/request/select_authority.html.erb index ed072cf64..134648264 100644 --- a/app/views/request/select_authority.html.erb +++ b/app/views/request/select_authority.html.erb @@ -1,60 +1,60 @@ <script type="text/javascript"> - $(document).ready(function(){ - $("#authority_preview").hide(); - - // Avoid triggering too often (on each keystroke) by using the debounce jQuery plugin: + $(document).ready(function() { + // Avoid triggering too often (on each keystroke) by using the debounce + // jQuery plugin: // http://benalman.com/projects/jquery-throttle-debounce-plugin/ $("#query").keypress($.debounce( 300, function() { // Do a type ahead search and display results - $("#typeahead_response").load("<%=search_ahead_bodies_url%>?query="+encodeURI(this.value), function() { - $("#authority_preview").hide(); // Hide the preview, since results have changed - - }); + $("#typeahead_response").load("<%= search_ahead_bodies_url %>?query="+encodeURI(this.value)); })); - // We're using the existing body list: we intercept the clicks on the titles to - // display a preview on the right hand side of the screen - $("#typeahead_response .head a").live('click', function() { - $("#authority_preview").load(this.href+" #public_body_show", function() { - $("#authority_preview").show(); - $(window).scrollTop($("#banner").height()); - $("#authority_preview #header_right").hide(); - location.hash = '#header_left'; - }); - return false; - }); }); </script> <% @title = _("Select the authority to write to") %> - <h1 style="clear: left"><%= _('1. Select an authority') %></h1> - - <div id="authority_selection"> - <%= form_tag({:controller => "request", :action => "select_authority"}, {:id => "search_form", :method => "get"}) do %> - <div> - <p> - <%= _('First, type in the <strong>name of the UK public authority</strong> you\'d - like information from. <strong>By law, they have to respond</strong> - (<a href="{{url}}">why?</a>).', :url => (help_about_path + "#whybother_them").html_safe) %> - </p> - <%= text_field_tag 'query', params[:query], { :size => 30, :title => "type your search term here" } %> - <%= 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 %> +<h1 style="clear: left"><%= _('1. Select an authority') %></h1> + +<div id="authority_selection"> + <%= form_tag select_authority_path, { :id => 'search_form', :method => 'get' } do %> + <div> + <p> + <%= _(%Q(First, type in the <strong>name of the UK public authority</strong> you'd + like information from. <strong>By law, they have to respond</strong> + (<a href="{{url}}">why?</a>).), :url => (help_about_path(:anchor => 'whybother_them')).html_safe) %> + </p> + + <%= text_field_tag :query, + params[:query], + { :size => 30, + :title => _('type your search term here'), + :placeholder => _('e.g. Ministry of Defence') } %> + <%= 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"> - <%= render :partial => 'public_body/search_ahead' %> - </div> + <div id="typeahead_response"> + <%= render :partial => 'public_body/search_ahead' %> </div> - <div id="authority_preview"> - </div> +</div> + +<div id="select_authority_help"> + <p class="info"><%= _("Can't find the one you want?") %></p> + <p class="actions"> + <%= raw _('<a href="{{browse_url}}">Browse all</a> or <a href="{{add_url}}">ask us to add one</a>.', + :browse_url => list_public_bodies_default_path.html_safe, + :add_url => help_requesting_path(:anchor => 'missing_body') + ).html_safe %> + </p> +</div> |