# HG changeset patch # User luisf # Date 1312300222 -3600 # Node ID 026c9747fe9b33e02fd5037b8f6f6f7bd94a1d2f # Parent e25c069ab3b824b7d612cbde5f9fc7367068e14c Addresses Feature #228. Already able to remove projects associated with a publication. diff -r e25c069ab3b8 -r 026c9747fe9b vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb --- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Mon Aug 01 21:18:37 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Tue Aug 02 16:50:22 2011 +0100 @@ -232,6 +232,26 @@ end render :nothing => true end + + def remove_from_project_list + pub = Publication.find(params[:id]) + proj = Project.find(params[:project_id]) + + if pub.projects.length > 1 + if pub.projects.exists? proj + pub.projects.delete proj if request.post? + end + else + logger.error { "Cannot remove project from publication list" } + end + + respond_to do |format| + format.js { render(:update) {|page| page.replace_html "list_projects", :partial => 'list_projects', :id => pub} } + end + + + end + def identify_author diff -r e25c069ab3b8 -r 026c9747fe9b vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb --- a/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Mon Aug 01 21:18:37 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Tue Aug 02 16:50:22 2011 +0100 @@ -70,18 +70,12 @@ def render_projects_list(publication) s = "" - projs = [] publication.projects.each do |proj| - projs << link_to_project(proj) + s << link_to_project(proj) + link_to_remote(l(:button_delete), { :url => { :controller => 'publications', :action => 'remove_from_project_list', :id => publication, :project_id => proj }, :method => :post }, :class => 'icon icon-del') + "
" end - if projs.size < 3 - s << '' << projs.join(', ') << '' - else - s << projs.join(', ') - end - s + s end def show_bibtex_fields(bibtex_entry) diff -r e25c069ab3b8 -r 026c9747fe9b vendor/plugins/redmine_bibliography/app/views/publications/_list_projects.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/_list_projects.html.erb Mon Aug 01 21:18:37 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_list_projects.html.erb Tue Aug 02 16:50:22 2011 +0100 @@ -1,1 +1,3 @@ -<%= render_projects_list(@publication) %> \ No newline at end of file +<% publication = Publication.find(params[:id]) %> + +<%= render_projects_list(publication) %> \ No newline at end of file