Mercurial > hg > soundsoftware-site
changeset 580:22262ff56e84 feature_36
Merge from 579:c8552c08687f
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Wed, 10 Aug 2011 16:20:40 +0100 |
parents | 2ada25d4b0a8 (diff) c8552c08687f (current diff) |
children | 7c06dde557ec |
files | vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb |
diffstat | 3 files changed, 25 insertions(+), 26 deletions(-) [+] |
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Wed Aug 10 15:57:05 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Wed Aug 10 16:20:40 2011 +0100 @@ -98,12 +98,10 @@ def show find_project_by_project_id unless params[:project_id].nil? - - @publication = Publication.find(params[:id]) if @publication.nil? - @publications = Publication.all - render "index", :alert => 'The publication was not found!' + @publications = Publication.all + render "index", :alert => 'The publication was not found!' else @authors = @publication.authors @bibtext_entry = @publication.bibtex_entry @@ -228,6 +226,7 @@ def add_project @projects = Project.find(params[:publication][:project_ids]) @publication.projects << @projects + @project = Project.find(params[:project_id]) # TODO luisf should also respond to HTML??? respond_to do |format| @@ -241,32 +240,26 @@ end end + def remove_project - find_project_by_project_id - proj_to_remove = Project.find(params[:remove_project_id]) - - if proj_to_remove == @project - warning = "You are about to remove the current project from the publication's project list. Are you sure?" - end + @project = Project.find(params[:project_id]) + proj = Project.find(params[:remove_project_id]) if @publication.projects.length > 1 - if @publication.projects.exists? proj_to_remove - @publication.projects.delete proj_to_remove if request.post? + if @publication.projects.exists? proj + @publication.projects.delete proj if request.post? end else - logger.error { "Cannot remove project from publication list" } + logger.error { "Cannot remove project from publication list" } end - respond_to do |format| - format.html { redirect_to :back } - format.js { - render(:update) {|page| - page.replace_html :list_projects, :partial => 'list_projects' - } - } - end + logger.error { "CURRENT projectr name#{proj.name} and wanna delete #{@project.name}" } + + render(:update) {|page| + page.replace_html "list_projects", :partial => 'list_projects', :id => @publication + } end - + def destroy find_project_by_project_id
--- a/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Wed Aug 10 15:57:05 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Wed Aug 10 16:20:40 2011 +0100 @@ -93,10 +93,18 @@ end def render_projects_list(publication) + logger.error { "PROJECT NAME #{@project.name unless @project.nil?}" } + s = "" publication.projects.each do |proj| - s << link_to_project(proj) + link_to_remote(l(:button_delete), { :url => { :controller => 'publications', :action => 'remove_project', :id => publication, :remove_project_id => proj, :project_id => @project }, :method => :post }, :class => 'icon icon-del') + "<br />" + if @project == proj + confirm_msg = "Are you sure you want to remove the current project from this publication's projects list?" + else + confirm_msg = false + end + + s << link_to_project(proj) + link_to_remote(l(:button_delete), { :url => { :controller => 'publications', :action => 'remove_project', :id => publication, :remove_project_id => proj, :project_id => @project }, :method => :post, :confirm => confirm_msg }, :class => 'icon icon-del') + "<br />" end s
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_list_projects.html.erb Wed Aug 10 15:57:05 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_list_projects.html.erb Wed Aug 10 16:20:40 2011 +0100 @@ -1,3 +1,1 @@ -<% publication = Publication.find(params[:id]) %> - -<%= render_projects_list(publication) %> \ No newline at end of file +<%= render_projects_list(@publication) %> \ No newline at end of file