# HG changeset patch # User luisf # Date 1310659824 -3600 # Node ID b24091590b631b92db5b307a2488e9bccb2e761a # Parent cc267eb9911510fe0fe589f5f12c44694a632594 virtual attribute to handle users; javascript handling users correctly diff -r cc267eb99115 -r b24091590b63 vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb --- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Thu Jul 07 18:20:31 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Thu Jul 14 17:10:24 2011 +0100 @@ -24,6 +24,9 @@ @publication = Publication.new(params[:publication]) @project = Project.find(params[:project_id]) + logger.error { "PARAMS publication" } + logger.error { params[:publication] } + @publication.projects << @project if @publication.save diff -r cc267eb99115 -r b24091590b63 vendor/plugins/redmine_bibliography/app/models/authorship.rb --- a/vendor/plugins/redmine_bibliography/app/models/authorship.rb Thu Jul 07 18:20:31 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/models/authorship.rb Thu Jul 14 17:10:24 2011 +0100 @@ -12,5 +12,18 @@ def author_search=(string) end + + # setter and getter for virtual attribute :user_id + def user_id + logger.error { "USER ID SETTER" } + logger.error { self } + logger.error { "END USER ID SETTER" } + + end + def user_id=(uid) + # process the user id + # test for undefined + + end end diff -r cc267eb99115 -r b24091590b63 vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml --- a/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Thu Jul 07 18:20:31 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Thu Jul 14 17:10:24 2011 +0100 @@ -6,7 +6,7 @@ <%= "Identify Authors in the system…" %> - <%= link_to_function "Add Me as Author", "update_author_info(this," + User.current.to_json + ")", :class => 'icon icon-add', :id => "add_me_as_author" %> + <%= link_to_function "Add Me as Author", "update_author_info(this," + User.current.get_author_info.to_json + ")", :class => 'icon icon-add', :id => "add_me_as_author" %>

<%= f.label :author_search, l(:label_project_search) %> @@ -30,7 +30,7 @@ <%= f.text_field :email %>
<%= h l("text_author_email") %>
- <%= f.hidden_field :author_id %> + <%= f.hidden_field :user_id %> <%= link_to_remove_fields l("remove_author"), f %> diff -r cc267eb99115 -r b24091590b63 vendor/plugins/redmine_bibliography/assets/javascripts/authors.js --- a/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Thu Jul 07 18:20:31 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Thu Jul 14 17:10:24 2011 +0100 @@ -12,9 +12,12 @@ } 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(']',''); + key = e.name.split("[").last().trim().sub(']',''); + + // test for undefined e.value = author_info[key]; } ) diff -r cc267eb99115 -r b24091590b63 vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb --- a/vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb Thu Jul 07 18:20:31 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb Thu Jul 14 17:10:24 2011 +0100 @@ -15,15 +15,37 @@ end module InstanceMethods - def get_author_name - if self.author - self.author.name + + def get_author_info + info = { + :name_on_paper => "", + :email => "", + :institution => "", + :user_id => self.id + } + + unless self.author.nil? + logger.error { "We've got author" } + info[:name_on_paper] = self.author.name + + if self.author.authorships.length > 0 + info[:email] = self.author.authorships.first.email + info[:institution] = self.author.authorships.first.institution + end + else - "No Name" + logger.error { "No author" } + + info[:name_on_paper] = "No Name" + info[:email] = self.mail + if self.ssamr_user_detail + info[:institution] = self.ssamr_user_detail.institution + else + info[:institution] = "No institution" + end end - end - - def get_author_info + + return info end end #InstanceMethods