# HG changeset patch # User luisf # Date 1309881630 -3600 # Node ID ea8b8768b4a0a5530f44dca47ced4aae9f7a5036 # Parent dd242ea99fd3fb72190689775ba6baaa9edf2051 correctly adds multiple authors; correctly sets user_id in the form diff -r dd242ea99fd3 -r ea8b8768b4a0 vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb --- a/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Mon Jul 04 18:56:45 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Tue Jul 05 17:00:30 2011 +0100 @@ -9,8 +9,17 @@ s end - def identify_author(author) - link_to_function(author.name, "update_author_info(this)") + def identify_author(author) + + if author.class == Author + author_info = { + :name_on_paper => author.name, + :user_id => author.user_id, + :id => author.id + } + end + + link_to_function(author.name, "update_author_info(this," + author_info.to_json + ")") end def choose_author_link(name, authors) diff -r dd242ea99fd3 -r ea8b8768b4a0 vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml --- a/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Mon Jul 04 18:56:45 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Tue Jul 05 17:00:30 2011 +0100 @@ -4,9 +4,6 @@ <%= f.text_field :name_on_paper %>
<%= h l("text_author_name_on_paper") %>
- - - <%= "Identify Authors in the system…" %> <%= link_to_remote "It's me!", @@ -20,10 +17,10 @@ <%= f.text_field :author_search %>

- <%= observe_field( form_tag_id(f.object_name, :author_search), :frequency => 0.5, :update => :identify_author, :url => { :controller => 'publications', :action => 'autocomplete_for_author' }, :with => 'q') + <%= observe_field( form_tag_id(f.object_name, :author_search), :frequency => 0.5, :update => form_tag_id(f.object_name, :identify_author), :url => { :controller => 'publications', :action => 'autocomplete_for_author' }, :with => 'q') %> -
+
<% if params[:q] && params[:q].length > 1 %> <%= select_author_links 'author[author_ids][]', @authors %> <% end %> @@ -37,7 +34,10 @@ <%= f.text_field :email %>
<%= h l("text_author_email") %>
- <%= f.hidden_field :_destroy %> + <% f.fields_for :author do |author| %> + <%= author.hidden_field :user_id %> + <% end %> + <%= link_to_remove_fields l("remove_author"), f %>

diff -r dd242ea99fd3 -r ea8b8768b4a0 vendor/plugins/redmine_bibliography/assets/javascripts/authors.js --- a/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Mon Jul 04 18:56:45 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Tue Jul 05 17:00:30 2011 +0100 @@ -11,6 +11,11 @@ }); } -function update_author_info(link){ - $(link).up('div').up('div').select('input[id$=name_on_paper]').each(function(e){e.value='aaaaa'}) +function update_author_info(link, author_info){ + $(link).up('div').up('div').select('input[id^=publication_authorships_attributes]').each( + function(e){ + key = e.name.split("[").last().trim().sub(']',''); + e.value = author_info[key]; + } + ) } \ No newline at end of file