# HG changeset patch # User luisf # Date 1368554974 -3600 # Node ID d0d6bbe9f2e0e92be89956b6bb2b2801cc81f9b4 # Parent 22551cc54749e55fb05de4e52b50d4b612de7d39 removed unused code; renamed variables. diff -r 22551cc54749 -r d0d6bbe9f2e0 plugins/redmine_bibliography/app/models/authorship.rb --- a/plugins/redmine_bibliography/app/models/authorship.rb Tue May 14 16:05:54 2013 +0100 +++ b/plugins/redmine_bibliography/app/models/authorship.rb Tue May 14 19:09:34 2013 +0100 @@ -9,7 +9,7 @@ validates_presence_of :name_on_paper - attr_accessor :is_user, :author_user_id, :search_name, :identify_author, :search_results + attr_accessor :search_author_class, :search_author_id, :search_name, :search_results, :identify_author before_save :associate_author_user # todo: review usage of scope --lf.20130108 @@ -43,15 +43,15 @@ protected def associate_author_user - case self.identify_author - when "no" + case self.search_author_class + when "User" author = Author.new author.save self.author_id = author.id else selected = self.search_results - selected_classname = Kernel.const_get(selected.split('_')[0]) - selected_id = selected.split('_')[1] + selected_classname = Kernel.const_get(self.search_author_class) + selected_id = self.search_author_id object = selected_classname.find(selected_id) if object.respond_to? :name_on_paper diff -r 22551cc54749 -r d0d6bbe9f2e0 plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb --- a/plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb Tue May 14 16:05:54 2013 +0100 +++ b/plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb Tue May 14 19:09:34 2013 +0100 @@ -27,8 +27,9 @@

<%= f.text_field :email, {:class => ("readonly" unless params[:action] == "new") } %>

><%= h l("text_author_email") %>

- <%= hidden_field_tag(:object_class, '', :name => form_tag_name(f.object_name,:object_class ), :id => form_tag_id( f.object_name, :object_class )) -%> + <%= hidden_field_tag(:search_author_class, '', :name => form_tag_name(f.object_name,:search_author_class ), :id => form_tag_id( f.object_name, :search_author_class )) -%> + <%= hidden_field_tag(:search_author_id, '', :name => form_tag_name(f.object_name,:search_author_id ), :id => form_tag_id( f.object_name, :search_author_id )) -%> diff -r 22551cc54749 -r d0d6bbe9f2e0 plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.html.erb --- a/plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.html.erb Tue May 14 16:05:54 2013 +0100 +++ b/plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.html.erb Tue May 14 19:09:34 2013 +0100 @@ -1,8 +1,8 @@ <%= raw @results.map {|result| { - 'id' => result.id, 'label' => "#{result.name} (#{result.mail.partition('@')[2]})", 'value' => result.name, - 'object_class' => result.class.name, + 'search_author_class' => result.class.name, + 'search_author_id' => result.id, 'institution' => result.institution, 'email' => result.mail, } diff -r 22551cc54749 -r d0d6bbe9f2e0 plugins/redmine_bibliography/assets/javascripts/authors.js --- a/plugins/redmine_bibliography/assets/javascripts/authors.js Tue May 14 16:05:54 2013 +0100 +++ b/plugins/redmine_bibliography/assets/javascripts/authors.js Tue May 14 19:09:34 2013 +0100 @@ -24,7 +24,8 @@ $this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.value); $this.closest('div').next().find("input[id$='institution']").val(ui.item.institution); $this.closest('div').next().find("input[id$='email']").val(ui.item.email); - $this.closest('div').next().find("input[id$='object_class']").val(ui.item.object_class); + $this.closest('div').next().find("input[id$='search_author_class']").val(ui.item.search_author_class); + $this.closest('div').next().find("input[id$='search_author_id']").val(ui.item.search_author_id); } }); }); @@ -66,10 +67,10 @@ function toggle_edit_save_button(object_id){ $button = $('publication_authorships_attributes_' + object_id + '_edit_save_button'); if ($button.value == "Edit author"){ - $button.value = "Save author"; + $button.value = "Save author"; } else { - $button.value = "Edit author"; - }; + $button.value = "Edit author"; + } } function toggle_save_author(form_object_id, $this){ diff -r 22551cc54749 -r d0d6bbe9f2e0 plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb --- a/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb Tue May 14 16:05:54 2013 +0100 +++ b/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb Tue May 14 19:09:34 2013 +0100 @@ -22,23 +22,6 @@ return institution_name end - def get_author_info - # TODO: DELETE THIS METHOD?? - info = { - :name_on_paper => self.name, - :email => self.mail, - :institution => "", - :author_user_id => self.id, - :is_user => "1" - } - - if not self.ssamr_user_detail.nil? - info[:institution] = self.ssamr_user_detail.institution_name - end - - return info - end - end #InstanceMethods end #UserPublicationsPatch