changeset 577:e98a5b2fe3b8 feature_36

Merge
author Chris Cannam <chris.cannam@soundsoftware.ac.uk>
date Wed, 10 Aug 2011 14:49:45 +0100
parents c5858d96b9a4 (current diff) 724c97fc03dc (diff)
children c8552c08687f
files
diffstat 4 files changed, 41 insertions(+), 29 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Wed Aug 10 14:49:36 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Wed Aug 10 14:49:45 2011 +0100
@@ -98,7 +98,7 @@
 
   def show
     find_project_by_project_id unless params[:project_id].nil?
-    
+        
     @publication = Publication.find(params[:id])
     
     if @publication.nil?
@@ -189,17 +189,6 @@
     
   end
   
-  def add_project
-    @projects = Project.find(params[:publication][:project_ids])    
-    @publication = Publication.find(params[:id])        
-    @publication.projects << @projects
-    
-    # TODO luisf should also respond to HTML??? 
-    respond_to do |format|
-      format.js      
-    end
-  end
-
   def autocomplete_for_project
     @publication = Publication.find(params[:id])
         
@@ -235,24 +224,47 @@
     end
     render :nothing => true
   end
+
+  def add_project
+    @projects = Project.find(params[:publication][:project_ids])    
+    @publication.projects << @projects
+    
+    # TODO luisf should also respond to HTML??? 
+    respond_to do |format|
+      format.html { redirect_to :back }
+      format.js { 
+        render(:update) {|page| 
+          page[:add_project_form].reset          
+          page.replace_html :list_projects, :partial => 'list_projects'
+        }
+      }
+    end
+  end
   
-  def remove_from_project_list
-    pub = Publication.find(params[:id])
-    proj = Project.find(params[:project_id])
+  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
 
-    if pub.projects.length > 1
-      if pub.projects.exists? proj
-        pub.projects.delete proj if request.post?
+    if @publication.projects.length > 1
+      if @publication.projects.exists? proj_to_remove
+        @publication.projects.delete proj_to_remove 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.js { render(:update) {|page| page.replace_html "list_projects", :partial => 'list_projects', :id  => pub} } 
+      format.html { redirect_to :back }
+      format.js { 
+         render(:update) {|page| 
+           page.replace_html :list_projects, :partial => 'list_projects'
+         }
+       }
     end
-    
-    
   end
   
   def destroy
--- a/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb	Wed Aug 10 14:49:36 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb	Wed Aug 10 14:49:45 2011 +0100
@@ -77,9 +77,9 @@
   
   def render_projects_list(publication)
     s = ""
-    
+
     publication.projects.each do |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') + "<br />"
+      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 />"
     end
     
     s  
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_form.html.erb	Wed Aug 10 14:49:36 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/_form.html.erb	Wed Aug 10 14:49:45 2011 +0100
@@ -8,11 +8,11 @@
     <h3><%= l(:authors) %></h3>    
     <div class="box tabular">
 
-    <% f.fields_for :authorships do |builder| %>
-      <%= render "authorship_fields", :f => builder %>
-    <% end %>
+      <% f.fields_for :authorships do |builder| %>
+        <%= render "authorship_fields", :f => builder %>
+      <% end %>
 
-    <%= link_to_add_fields l(:label_add_another_author), f, :authorships %>
+      <%= link_to_add_fields l(:label_add_another_author), f, :authorships %>
     </div>
 
 </div>
--- a/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js	Wed Aug 10 14:49:36 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js	Wed Aug 10 14:49:45 2011 +0100
@@ -6,7 +6,7 @@
 function add_fields(link, association, content) {
   var new_id = new Date().getTime();
   var regexp = new RegExp("new_" + association, "g")
-  $(link).up().insert({
+  $(link).insert({
     before: content.replace(regexp, new_id)
   });
 }