# HG changeset patch # User luisf # Date 1308616061 -3600 # Node ID b02b2eb2a312a6ccdd215a61a43ef890e790a1d1 # Parent 841b2e40895dc1cea6f6f00460de5d805987fd40 Searching for publications via AJAX call; the publication ID is not being sent correctly, so still shows the current publication's associated projects in the select list. diff -r 841b2e40895d -r b02b2eb2a312 vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb --- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Fri Jun 17 18:59:49 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Tue Jun 21 01:27:41 2011 +0100 @@ -3,7 +3,8 @@ class PublicationsController < ApplicationController unloadable - before_filter :find_project_by_project_id + before_filter :find_project_by_project_id, :except => [:autocomplete_for_project] + def new @publication = Publication.new @@ -193,10 +194,10 @@ def autocomplete_for_project - # TODO luisf - Should This Be HERE??? @publication = Publication.find(params[:id]) - @projects = Project.active.like(params[:q]).find(:all, :limit => 100) - @publication.projects + +# @projects = Project.active.like(params[:q]).find(:all, :limit => 100) logger.debug "Query for \"#{params[:q]}\" returned \"#{@projects.size}\" results" render :layout => false end diff -r 841b2e40895d -r b02b2eb2a312 vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb --- a/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Fri Jun 17 18:59:49 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Tue Jun 21 01:27:41 2011 +0100 @@ -2,4 +2,11 @@ module PublicationsHelper + def projects_check_box_tags(name, projects) + s = '' + projects.sort.each do |project| + s << "\n" + end + s + end end diff -r 841b2e40895d -r b02b2eb2a312 vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb Fri Jun 17 18:59:49 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb Tue Jun 21 01:27:41 2011 +0100 @@ -16,18 +16,22 @@ :method => :post, :loading => "$('project-add-submit').disable()", :complete => "$('project-add-submit').enable()") do |f| %> - -
<%=l(:label_add_project_to_publication)%> - +
<%=l(:label_add_project_to_publication)%>

<%= label_tag "project_search", l(:label_project_search) %><%= text_field_tag 'project_search', nil %>

<%= observe_field(:project_search, :frequency => 0.5, :update => :projects, - :url => { :controller => 'publications', :action => 'autocomplete_for_project', :id => @publication, :project_id => @project}, + :url => { :controller => 'publications', :action => 'autocomplete_for_project', :id => @publication }, :with => 'q') %> +
+ <% if params[:q] && params[:q].length > 1 %> + <%= projects_check_box_tags 'project[project_ids][]', @projects %> + <% end %> +
+

<%= submit_tag l(:button_add), :id => 'project-add-submit' %>

diff -r 841b2e40895d -r b02b2eb2a312 vendor/plugins/redmine_bibliography/lib/bibliography/project_publications_patch.rb --- a/vendor/plugins/redmine_bibliography/lib/bibliography/project_publications_patch.rb Fri Jun 17 18:59:49 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/lib/bibliography/project_publications_patch.rb Tue Jun 21 01:27:41 2011 +0100 @@ -8,7 +8,7 @@ named_scope :like, lambda {|q| s = "%#{q.to_s.strip.downcase}%" - {:conditions => ["LOWER(name) LIKE :s OR LOWER(description) LIKE :s OR LOWER(homepage) LIKE :s", {:s => s}], + {:conditions => ["LOWER(name) LIKE :s OR LOWER(homepage) LIKE :s", {:s => s}], :order => 'name' } }