Mercurial > hg > soundsoftware-site
changeset 482:ea8b8768b4a0 feature_36
correctly adds multiple authors; correctly sets user_id in the form
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Tue, 05 Jul 2011 17:00:30 +0100 |
parents | dd242ea99fd3 |
children | cc267eb99115 |
files | vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml vendor/plugins/redmine_bibliography/assets/javascripts/authors.js |
diffstat | 3 files changed, 24 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- 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 %><br /> <em><%= h l("text_author_name_on_paper") %></em><br /> - - - <legend><%= "Identify Authors in the system…" %></legend> <%= link_to_remote "It's me!", @@ -20,10 +17,10 @@ <%= f.text_field :author_search %> </p> - <%= 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') %> - <div id="identify_author"> + <div id="<%= form_tag_id(f.object_name, :identify_author) %>"> <% if params[:q] && params[:q].length > 1 %> <%= select_author_links 'author[author_ids][]', @authors %> <% end %> @@ -37,7 +34,10 @@ <%= f.text_field :email %><br /> <em><%= h l("text_author_email") %></em><br /> - <%= f.hidden_field :_destroy %> + <% f.fields_for :author do |author| %> + <%= author.hidden_field :user_id %> + <% end %> + <%= link_to_remove_fields l("remove_author"), f %> </p>
--- 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