changeset 467:c1ecc16cf38e feature_36

addin/removing authors - not finished
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Wed, 22 Jun 2011 19:42:31 +0100
parents a7dc708d48a1
children 0bb9c7baed07
files vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb vendor/plugins/redmine_bibliography/app/views/publications/_authors_fields.html.erb vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb vendor/plugins/redmine_bibliography/assets/javascripts/authors.js vendor/plugins/redmine_bibliography/config/locales/en.yml
diffstat 5 files changed, 37 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Wed Jun 22 13:10:59 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Wed Jun 22 19:42:31 2011 +0100
@@ -3,7 +3,7 @@
 class PublicationsController < ApplicationController
   unloadable
   
-  before_filter :find_project_by_project_id, :except => [:autocomplete_for_project]
+  before_filter :find_project_by_project_id, :except => [:autocomplete_for_project, :add_author]
   
   
   def new
@@ -16,12 +16,8 @@
     @publication.authors.build
     
     @project_id = params[:project_id]
-    
-    # the step we're at in the form
-    #    @publication.current_step = session[:publication_step]
+    @current_user = User.current
 
-    @new_publications = []
-    session[:publications] ||= {}
   end
 
   def create
@@ -68,6 +64,16 @@
     
   end
 
+  def add_author
+    if (request.xhr?)
+      render :text => User.find(params[:user_id]).name
+    else
+      # No?  Then render an action.
+      #render :action => 'view_attribute', :attr => @name
+      logger.error { "ERRO ADD AUTHOR" }
+    end
+  end
+
 
   def edit    
     @publication = Publication.find(params[:id])
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_authors_fields.html.erb	Wed Jun 22 13:10:59 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/_authors_fields.html.erb	Wed Jun 22 19:42:31 2011 +0100
@@ -1,7 +1,5 @@
-<p>
+<p class="author_fields">
   <%= f.label :name, l("name") %> <%= f.text_field :name %>            
+  <%= f.hidden_field :_destroy %>
+  <%= link_to_function "Remove", "remove_author(this)" %>  
 </p>
-<%= f.check_box :_destroy %>
-<%= f.label :_destroy, l("remove") %>
-  
-
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb	Wed Jun 22 13:10:59 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb	Wed Jun 22 19:42:31 2011 +0100
@@ -1,10 +1,24 @@
+<% content_for :header_tags do %>
+    <%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %>
+<% end %>
+
+
 <% form_for @publication, :url => { :project_id  => @project_id, :action => :create } do |f| -%>
 
   <%= f.error_messages %>
   
   <p><%= f.label :title, l(:title) %>  <%= f.text_field :title %></p>
 
-  <h3><%= l(:authors) %></h3>  
+  <h3><%= l(:authors) %></h3>    
+  <%= link_to_remote l(:add_me_as_author), {:url => { :controller => 'publications', :action => 'add_author', :user_id => @current_user}, :update => 'users_div' }, { :id => 'add_me_as_an_author', :class => 'icon icon-add' } %>  
+
+  <div id='users_div'>aaa</div>
+  
+  
+  
+  
+  
+  
   <%- f.fields_for :authors do |builder| -%>
     <%= render :partial => 'authors_fields', :locals => { :f => builder} %>
   <%- end -%>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js	Wed Jun 22 19:42:31 2011 +0100
@@ -0,0 +1,4 @@
+function remove_author(link){
+	$(link).previous("input[type=hidden]").value = 1;
+	$(link).up(".author_fields").hide();
+}
\ No newline at end of file
--- a/vendor/plugins/redmine_bibliography/config/locales/en.yml	Wed Jun 22 13:10:59 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/config/locales/en.yml	Wed Jun 22 19:42:31 2011 +0100
@@ -4,6 +4,9 @@
   authors: "Authors"
   author: "Author"
   name: "Name"
+  
+  add_me_as_author: "Add me as an author"
+  add_another_author: "Add another author"
 
   remove: "Remove"