changeset 1426:7367cd232b1e luisf

Merge.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Mon, 07 Oct 2013 15:42:39 +0100
parents 95bdaaab97ca (current diff) 637ee26ae557 (diff)
children 2c723b9f5b87
files
diffstat 16 files changed, 240 insertions(+), 206 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Mon Sep 30 13:52:14 2013 +0100
+++ b/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Mon Oct 07 15:42:39 2013 +0100
@@ -15,16 +15,11 @@
     # we'll always want a new publication to have its bibtex entry
     @publication.build_bibtex_entry
 
-    # and at least one author
-    # @publication.authorships.build.build_author
-    @author_options = [["#{User.current.name} (@#{User.current.mail.partition('@')[2]})", "#{User.current.class.to_s}_#{User.current.id.to_s}"]]
   end
 
   def create
     @project = Project.find(params[:project_id])
 
-    @author_options = []
-
     @publication = Publication.new(params[:publication])
     @publication.projects << @project unless @project.nil?
 
@@ -91,14 +86,11 @@
     @publication = Publication.find(params[:id])
     @selected_bibtex_entry_type_id = @publication.bibtex_entry.entry_type
 
-    @author_options = []
-
     @bibtype_fields = BibtexEntryType.fields(@selected_bibtex_entry_type_id)
   end
 
   def update
     @publication = Publication.find(params[:id])
-    @author_options = []
 
     if @publication.update_attributes(params[:publication])
       flash[:notice] = "Successfully updated Publication."
@@ -176,9 +168,6 @@
     @publication.bibtex_entry = @bentry
     @publication.save
 
-    # what is this for???
-    # @created_publications << @publication.id
-
     # need to save all authors
     #   and establish the author-publication association
     #   via the authorships table
@@ -199,17 +188,6 @@
     end
   end
 
-  # parses the bibtex file
-  def parse_bibtex_file
-
-  end
-
-  def import
-    @publication = Publication.new
-
-
-  end
-
   def autocomplete_for_project
     @publication = Publication.find(params[:id])
 
@@ -225,60 +203,28 @@
     @object_name = "publications[authorships_attributes][#{object_id}][search_results]"
 
     # cc 20110909 -- revert to like instead of like_unique -- see #289
-    authorships_list = Authorship.like(params[:term]).find(:all, :limit => 100)
+    authorships_list = Authorship.like(params[:term]).group('author_id').find(:all, :limit => 100)
+
+    authors_list = authorships_list.collect do |x| x.author end
+
     users_list = User.active.like(params[:term]).find(:all, :limit => 100)
 
-    logger.debug "Query for \"#{params[:term]}\" returned \"#{authorships_list.size}\" authorships and \"#{users_list.size}\" users"
+    logger.debug "Query for \"#{params[:term]}\" returned \"#{authors_list.size}\" authors and \"#{users_list.size}\" users"
 
-    @results = users_list
+    # will check if any of the members of the users list
+    #  doesn't belong to the authors list
 
-    # TODO: can be optimized…
-    authorships_list.each do |authorship|
-      flag = true
+    @results = authors_list
 
-      users_list.each do |user|
-        if authorship.name == user.name && authorship.email == user.mail && authorship.institution == user.institution
-          Rails.logger.debug { "Rejecting Authorship #{authorship.id}" }
-          flag = false
-          break
-        end
-      end
-
-      @results << authorship if flag
+    users_list.each do |user|
+      @results << user unless authors_list.include?(user.author)
     end
 
+    logger.debug { "Autocomplete_for_author results --> #{@results}" }
+
     render :layout => false
   end
 
-  def get_user_info
-    object_id = params[:object_id]
-    value = params[:value]
-    classname = Kernel.const_get(value.split('_')[0])
-
-    item = classname.find(value.split('_')[1])
-
-    name_field = "publication_authorships_attributes_#{object_id}_name_on_paper".to_sym
-    email_field = "publication_authorships_attributes_#{object_id}_email".to_sym
-    institution_field = "publication_authorships_attributes_#{object_id}_institution".to_sym
-
-    yes_radio = "publication_authorships_attributes_#{object_id}_identify_author_yes".to_sym
-
-    respond_to do |format|
-      format.js {
-        render(:update) {|page|
-          page[name_field].value = item.name
-          page[email_field].value = item.mail
-          page[institution_field].value = item.institution
-
-          page[yes_radio].checked = true
-          page[name_field].readOnly = true
-          page[email_field].readOnly = true
-          page[institution_field].readOnly = true
-        }
-      }
-    end
-  end
-
   def sort_author_order
     params[:authorships].each_with_index do |id, index|
       Authorship.update_all(['auth_order=?', index+1], ['id=?', id])
@@ -303,7 +249,6 @@
     end
   end
 
-
   def remove_project
     @project = Project.find(params[:project_id])
     proj = Project.find(params[:remove_project_id])
@@ -324,7 +269,8 @@
   end
 
   def destroy
-    find_project_by_project_id
+    find_project_by_project_id unless params[:project_id].nil?
+    @publication = Publication.find(params[:id])
 
     @publication.destroy
 
--- a/plugins/redmine_bibliography/app/helpers/publications_helper.rb	Mon Sep 30 13:52:14 2013 +0100
+++ b/plugins/redmine_bibliography/app/helpers/publications_helper.rb	Mon Oct 07 15:42:39 2013 +0100
@@ -106,7 +106,6 @@
     end
   end
 
-
   def show_bibtex_fields(bibtex_entry)
     s = ""
     bibtex_entry.attributes.keys.sort.each do |key|
@@ -125,3 +124,23 @@
   end
 end
 
+
+def render_authorship_link(link_class, link_id)
+
+  # Renders a link for an author used when adding authors for a publication
+  # link_class can be either User or Author
+  # link_id will be the id of the Author/User we wish to link
+
+  s= ""
+
+  if link_class == "Author"
+    url = {:controller => 'authors', :action => 'show', :id => link_id}
+    s << link_to(h(Author.find(link_id).name), url)
+  else
+    url = {:controller => 'users', :action => 'show', :id => link_id}
+    s << link_to(h(User.find(link_id).name), url)
+  end
+
+  s.html_safe
+end
+
--- a/plugins/redmine_bibliography/app/models/author.rb	Mon Sep 30 13:52:14 2013 +0100
+++ b/plugins/redmine_bibliography/app/models/author.rb	Mon Oct 07 15:42:39 2013 +0100
@@ -18,4 +18,29 @@
     }
   }
 
+  def institution
+    if self.authorships.first.nil?
+      ""
+    else
+      self.authorships.first.institution
+    end
+  end
+
+  def mail
+    if self.authorships.first.nil?
+      ""
+    else
+      self.authorships.first.mail
+    end
+  end
+
+  # todo: need to fix the name getter
+  def name
+    if self.authorships.first.nil?
+      ""
+    else
+      self.authorships.first.name
+    end
+  end
+
 end
--- a/plugins/redmine_bibliography/app/models/authorship.rb	Mon Sep 30 13:52:14 2013 +0100
+++ b/plugins/redmine_bibliography/app/models/authorship.rb	Mon Oct 07 15:42:39 2013 +0100
@@ -9,9 +9,13 @@
 
   validates_presence_of :name_on_paper
 
-  attr_accessor :search_author_class, :search_author_id, :search_name, :search_results, :identify_author
+  attr_writer :search_author_id , :search_author_class
+  attr_writer :search_author_tie
 
-  before_create :associate_author_user
+  ### attr_accessor :search_results, :identify_author
+  ## attr_writer :search_author_class
+
+  before_save :set_author
   before_update :delete_publication_cache
 
   # tod: review scope of ordering
@@ -34,6 +38,40 @@
     }
   }
 
+  def search_author_class
+    # Authorship must always have an Author
+    # unless it hasn't been saved yet
+    # using default setter (attr_writer)
+
+    if self.author.nil?
+      aclass = ""
+    else
+      aclass = "Author"
+    end
+
+    @search_author_class || aclass
+  end
+
+  def search_author_id
+    if self.author.nil?
+      authid = ""
+    else
+      authid = author_id
+    end
+
+    @search_author_id || authid
+  end
+
+  def search_author_tie
+    if self.author.nil?
+      auth_tie = false
+    else
+      auth_tie = true
+    end
+
+    @search_author_tie || auth_tie
+  end
+
   def name
     return self.name_on_paper
   end
@@ -54,35 +92,47 @@
     Rails.cache.delete "publication-#{publication.id}-bibtex"
   end
 
-  def associate_author_user
-    case self.search_author_class
-    when ""
-      logger.debug { "Unknown Author to be added..." }
-    when "User"
+  private
+
+  def set_author
+    # do we want to associate the authorship
+    #  with an existing author/user?
+    if @search_author_tie
+      # if an author, simply associates with it
+      # if an user, checks if it has already an author associated with it
+      #   if so, associates with that author
+      #   otherwise, creates a new author
+
+      case @search_author_class
+      when ""
+        author = Author.new
+        author.save
+
+      when "User"
+        user = User.find(@search_author_id)
+
+        if user.author.nil?
+          # User w/o author:
+          # create new author and update user
+          author = Author.new
+          author.save
+          user.author = author
+          user.save
+        else
+          author = user.author
+        end
+
+      when "Author"
+        author = Author.find(@search_author_id)
+      end
+
+    # if we don't want to associate with an existing author/user
+    else
+      # todo: should we delete any previously existing relationship?
       author = Author.new
       author.save
-      self.author_id = author.id
+    end
 
-    when "Author"
-      selected = self.search_results
-      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
-        # Authorship
-        self.author_id = object.author.id
-      else
-        # User
-        unless object.author.nil?
-          self.author_id = object.author.id
-        else
-          author = Author.new
-          object.author = author
-          object.save
-          self.author_id = object.author.id
-        end
-      end
-    end
+    self.author = author
   end
 end
--- a/plugins/redmine_bibliography/app/models/bibtex_entry_type.rb	Mon Sep 30 13:52:14 2013 +0100
+++ b/plugins/redmine_bibliography/app/models/bibtex_entry_type.rb	Mon Oct 07 15:42:39 2013 +0100
@@ -1,7 +1,7 @@
 class BibtexEntryType < ActiveRecord::Base
   unloadable
 
-  @@fields = Hash['article', ['journal', 'year', 'volume', 'number', 'pages', 'month', 'note' ], 
+  @@fields = Hash['article', ['journal', 'year', 'volume', 'number', 'pages', 'month', 'note' ],
                   'book' , [ 'editor', 'publisher', 'volume', 'series', 'address', 'edition', 'month', 'year', 'note' ],
                   'booklet' , [ 'howpublished', 'address', 'year', 'month', 'note', 'key' ],
                   'conference', [ 'booktitle', 'year', 'editor', 'pages', 'organization', 'publisher', 'address', 'month', 'note' ],
@@ -25,6 +25,6 @@
   end
 
   def self.fields (type)
-    @@fields[ self.find(type).name ]    
+    @@fields[ self.find(type).name ]
   end
 end
--- a/plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb	Mon Sep 30 13:52:14 2013 +0100
+++ b/plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb	Mon Oct 07 15:42:39 2013 +0100
@@ -1,42 +1,26 @@
 <div id="authors" class="fields">
-  <div id="<%= form_tag_id( f.object_name, :search_author ) %>" >
-    <p>
-      <%= f.text_field :search_name, :size => 25, :class => "author_search" %>
+  <div class="author_edit" id="<%= form_tag_id( f.object_name, :edit_author_info ) %>">
+
+    <p><%= f.label :name_on_paper %><%= f.text_field :name_on_paper, :class => "author_name_on_paper" -%></p>
+    <p><%= f.label :institution %><%= f.text_field :institution -%></p>
+    <p><%= f.label :email %><%= f.text_field :email -%></p>
+
+    <p class="author_associated search_author_tie">
+      <%= f.check_box :search_author_tie, :label => '' -%>
+      <span>Not associated with any SoundSoftware site user.</span>
     </p>
 
-    <p style="margin-bottom: -2.5em; padding-bottom; 0"><label><%= l(:identify_author_question) %></label></p>
-
-    <p class="author_identify">
-      <label class='inline'><%= radio_button_tag(:identify_author, "yes", false, :name => form_tag_name(f.object_name,:identify_author ), :id => form_tag_id( f.object_name, :identify_author_yes )) %> <%= l(:identify_author_yes) %> </label><br />
-
-      <label class='inline'><%= radio_button_tag(:identify_author, "correct", false, :name => form_tag_name(f.object_name,:identify_author ), :id => form_tag_id( f.object_name, :identify_author_corrections )) %> <%= l(:identify_author_correct) %> </label><br />
-
-      <label class='inline'><%= radio_button_tag(:identify_author, "no", true, :name => form_tag_name(f.object_name,:identify_author ), :id => form_tag_id( f.object_name, :identify_author_no )) %> <%= l(:identify_author_no) %> </label><br />
-    </p>
-  </div>
-
-  <div class='author_edit' id="<%= form_tag_id( f.object_name, :edit_author_info ) %>">
-    <p><%= f.text_field :name_on_paper -%></p>
-    <p class="description"><%= h l("text_author_name_on_paper") -%></p>
-
-    <p><%= f.text_field :institution -%></p>
-    <p class="description"><%= h l("text_author_institution") %></p>
-
-    <p><%= f.text_field :email -%></p>
-    <p class="description"><%= h l("text_author_email") %></p>
-
-    <%= 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 )) -%>
+    <%= f.hidden_field :search_author_class -%>
+    <%= f.hidden_field :search_author_id -%>
   </div>
 
   <div>
     <p>
       <%= button_to_function l(:label_save_author), '', :id => form_tag_id(f.object_name, :edit_save_button), :class => 'author_save_btn' -%>
 
-      <%= button_to_function l(:label_edit_author), '', :id => form_tag_id(f.object_name, :edit_button), :class => 'author_edit_btn' -%>
+      <%= button_to_function l(:label_edit_author), '', :id => form_tag_id(f.object_name, :edit_button), :class => 'author_edit_btn', :style => "display:none;" -%>
 
       <%= link_to_remove_fields l("remove_author"), f %>
     </p>
   </div>
-</div>
-
+</div>
\ No newline at end of file
--- a/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb	Mon Sep 30 13:52:14 2013 +0100
+++ b/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb	Mon Oct 07 15:42:39 2013 +0100
@@ -1,5 +1,5 @@
 <p>
-  <label for="bibtex_entry_type"><%=l("field_entry_type")%> <span class="required">*</span></label>
+  <label for="publication_bibtex_entry_attributes_entry_type"><%=l("field_entry_type")%> <span class="required">*</span></label>
 	<%= f.collection_select :entry_type,
 	        BibtexEntryType.find(:all).reject { |x| x.redundant? },
 	        :id,
@@ -8,71 +8,71 @@
 </p>
 
 <p class="bibtex hol">
-  <%= f.text_field :year, :size => 4 %>
+  <%= f.label :year %><%= f.text_field :year, :size => 5 -%>
 </p>
 <p class="bibtex hol">
-  <%= f.text_field :month, :size => 4%>
+  <%= f.label :month %><%= f.text_field :month, :size => 5 -%>
 </p>
 <p class="bibtex hol">
-  <%= f.text_field :chapter, :size => 15%>
+  <%= f.label :chapter %><%= f.text_field :chapter, :size => 5 -%>
 </p>
 <p class="bibtex hol">
-  <%= f.text_field :editor, :size => 33  %>
+  <%= f.label :editor %><%= f.text_field :editor -%>
 </p>
 <p class="bibtex hol">
-  <%= f.text_field :booktitle, :size => 33  %>
+  <%= f.label :booktitle %><%= f.text_field :booktitle -%>
 </p>
 <p class="bibtex hol">
-  <%= f.text_field :publisher,:size => 33  %>
+  <%= f.label :publisher %><%= f.text_field :publisher -%>
 </p>
 <p class="bibtex hol">
-  <%= f.text_field :pages, :size => 12 %>
+  <%= f.label :pages %><%= f.text_field :pages, :size => 5 -%>
 </p>
 <p class="bibtex hol">
- <%= f.text_field :address %>
+ <%= f.label :address %><%= f.text_field :address -%>
 </p>
 <p class="bibtex hol">
- <%= f.text_field :annote %>
+ <%= f.label :annote %><%= f.text_field :annote -%>
 </p>
 <p class="bibtex hol">
- <%= f.text_field :crossref %>
+ <%= f.label :crossref %><%= f.text_field :crossref -%>
 </p>
 <p class="bibtex hol">
- <%= f.text_field :edition %>
+ <%= f.label :edition %><%= f.text_field :edition -%>
 </p>
 <p class="bibtex hol">
- <%= f.text_field :eprint %>
+ <%= f.label :eprint %><%= f.text_field :eprint -%>
 </p>
 <p class="bibtex hol">
- <%= f.text_field :howpublished %>
+ <%= f.label :howpublished %><%= f.text_field :howpublished -%>
 </p>
 <p class="bibtex hol">
- <%= f.text_field :journal %>
+ <%= f.label :journal %><%= f.text_field :journal -%>
 </p>
 <p class="bibtex hol">
- <%= f.text_field :key %>
+ <%= f.label :key %><%= f.text_field :key -%>
 </p>
 <p class="bibtex hol">
- <%= f.text_field :note %>
+ <%= f.label :note %><%= f.text_field :note -%>
 </p>
 <p class="bibtex hol">
- <%= f.text_field :number %>
+ <%= f.label :number %><%= f.text_field :number, :size => 5 -%>
 </p>
 <p class="bibtex hol">
- <%= f.text_field :organization %>
+ <%= f.label :organization %><%= f.text_field :organization %>
 </p>
 <p class="bibtex hol">
- <%= f.text_field :school %>
+ <%= f.label :school %><%= f.text_field :school %>
 </p>
 <p class="bibtex hol">
- <%= f.text_field :series %>
+ <%= f.label :series %><%= f.text_field :series %>
 </p>
 <p class="bibtex hol">
- <%= f.text_field :type %>
+ <%= f.label :type %><%= f.text_field :type %>
 </p>
 <p class="bibtex hol">
- <%= f.text_field :url %>
+ <%= f.label :url %><%= f.text_field :url %>
 </p>
 <p class="bibtex hol">
- <%= f.text_field :volume %>
+ <%= f.label :volume %><%= f.text_field :volume %>
 </p>
\ No newline at end of file
--- a/plugins/redmine_bibliography/app/views/publications/_form.html.erb	Mon Sep 30 13:52:14 2013 +0100
+++ b/plugins/redmine_bibliography/app/views/publications/_form.html.erb	Mon Oct 07 15:42:39 2013 +0100
@@ -1,4 +1,4 @@
-<h3><%= f.text_field :title, :required => true, :size => 70 %></h3>
+<h3><%= f.label :title %>&nbsp;<span class="required">*</span>&nbsp;<%= f.text_field :title, :required => true, :size => 70 %></h3>
 
 <div class="splitcontentleft">
   <h3><%= l(:label_publication_other_details) %></h3>
@@ -8,12 +8,12 @@
     <%- end -%>
 
     <p>
-      <%= f.text_field :external_url, :size => 70 %>
+      <%= f.label :external_url %><%= f.text_field :external_url -%>
       <br />
-      <em><%= l(:text_external_url) %></em>
+      <em><%= l(:text_external_url) -%></em>
     </p>
     <p>
-      <%= f.text_field :doi, :size => 70 %>
+      <%= f.label :doi %><%= f.text_field :doi -%>
       <br />
       <em><%= l(:text_doi) %></em>
     </p>
--- a/plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.html.erb	Mon Sep 30 13:52:14 2013 +0100
+++ b/plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.html.erb	Mon Oct 07 15:42:39 2013 +0100
@@ -1,4 +1,5 @@
-<%= raw @results.map {|result| {
+<%= raw @results.map { |result|
+    {
     'label' => result.name,
     'value' => result.name,
     'search_author_class' => result.class.name,
@@ -6,5 +7,6 @@
     'name' => result.name,
     'institution' => result.institution,
     'email' => result.mail,
+    'authorship_link' => " Keep associated with #{render_authorship_link(result.class.name, result.id)}"
     }
 }.to_json %>
\ No newline at end of file
--- a/plugins/redmine_bibliography/app/views/publications/edit.html.erb	Mon Sep 30 13:52:14 2013 +0100
+++ b/plugins/redmine_bibliography/app/views/publications/edit.html.erb	Mon Oct 07 15:42:39 2013 +0100
@@ -16,13 +16,15 @@
                             dataType: 'script'
                         }); return false; });" -%>
 
+  <%= javascript_tag "authorship_autocomplete('#{url_for :controller => :publications, :action => :autocomplete_for_author}');" -%>
+
 <% end %>
 
 <%= error_messages_for 'publication' %>
 
 <h2><%=l(:label_publication_show)%></h2>
 
-<%= labelled_form_for @publication, :url => { :project_id  => @project, :action => :update } do |f| -%>
+<%= form_for @publication, :url => { :project_id  => @project, :action => :update } do |f| -%>
 
     <%= render :partial => 'form', :locals => { :f => f }  %>
 
--- a/plugins/redmine_bibliography/app/views/publications/new.html.erb	Mon Sep 30 13:52:14 2013 +0100
+++ b/plugins/redmine_bibliography/app/views/publications/new.html.erb	Mon Oct 07 15:42:39 2013 +0100
@@ -3,6 +3,7 @@
     <%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %>
     <%= javascript_include_tag 'bibliography', :plugin => 'redmine_bibliography' -%>
     <%= javascript_include_tag 'new_publication', :plugin => 'redmine_bibliography' -%>
+
     <%= javascript_tag "
       $('#publication_bibtex_entry_attributes_entry_type').live('change', function() {
           $this = $(this);
@@ -17,13 +18,15 @@
           return false;
       });"-%>
 
+  <%= javascript_tag "authorship_autocomplete('#{url_for :controller => :publications, :action => :autocomplete_for_author}');" -%>
+
 <% end %>
 
 <%= error_messages_for 'publication' %>
 
 <h2><%=l(:label_publication_new)%></h2>
 
-<%= labelled_form_for @publication, :url => { :project_id  => @project, :action => :create } do |f| -%>
+<%= form_for @publication, :url => { :project_id  => @project, :action => :create } do |f| -%>
 
     <%= render :partial => 'form', :locals => { :f => f }  %>
 
--- a/plugins/redmine_bibliography/assets/javascripts/authors.js	Mon Sep 30 13:52:14 2013 +0100
+++ b/plugins/redmine_bibliography/assets/javascripts/authors.js	Mon Oct 07 15:42:39 2013 +0100
@@ -10,41 +10,36 @@
   $(link).closest(".fields").hide();
 }
 
-$(".author_search").live('keyup.autocomplete', function(){
-     $this = $(this);
+function authorship_autocomplete(url){
+    $(".author_name_on_paper").live('keyup.autocomplete', function(){
+         $this = $(this);
 
-     $this.autocomplete({
-        source: '/publications/autocomplete_for_author',
-        minLength: 2,
-        focus: function(event, ui) {
-            $this.val(ui.item.label);
-            return false;
-        },
-        select: function(event, ui){
-            $this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.name);
-            $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$='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);
-        }
-        })
-        .data( "autocomplete" )._renderItem = function( ul, item ) {
-            return $( "<li>" )
-                .data("item.autocomplete", item )
-                .append( "<a>" + item.label + "<br><em>" + item.email + "</em><br>" + item.intitution + "</a>" )
-                .appendTo(ul);
-            };
-        });
+         $this.autocomplete({
+            source: url,
+            minLength: 2,
+            focus: function(event, ui) {
+                $this.val(ui.item.label);
+                return false;
+            },
+            select: function(event, ui){
+                $this.closest('div').find("input[id$='institution']").val(ui.item.institution);
+                $this.closest('div').find("input[id$='email']").val(ui.item.email);
 
+                $this.closest('div').find("input[id$='search_author_class']").val(ui.item.  search_author_class);
+                $this.closest('div').find("input[id$='search_author_id']").val(ui.item. search_author_id);
 
-$("input[id$='identify_author_yes']").live("click", function() {
-    console.log("aaaa");
-});
+                $this.closest('div').find("input[id$='search_author_tie']").attr('checked', '   checked');
+                $this.closest('div').find("input[id$='search_author_tie']").next('span').   replaceWith(ui.item.authorship_link);
 
-$("input[id$='identify_author_no']").live("click", function() {
-    $this.closest('div').next().find("input[id$='name_on_paper']").val('');
-    $this.closest('div').next().find("input[id$='institution']").val('');
-    $this.closest('div').next().find("input[id$='email']").val('');
-    $this.closest('div').next().find("input[id$='search_author_class']").val('');
-});
-
+                // triggers the save button
+                $this.closest('div').next('div').find('.author_save_btn').click();
+            }
+            })
+            .data( "autocomplete" )._renderItem = function( ul, item ) {
+                return $( "<li>" )
+                    .data("item.autocomplete", item )
+                    .append( "<a>" + item.label + "<br><em>" + item.email + "</em><br>" + item. institution + "</a>" )
+                    .appendTo(ul);
+                };
+            });
+}
--- a/plugins/redmine_bibliography/assets/javascripts/bibliography.js	Mon Sep 30 13:52:14 2013 +0100
+++ b/plugins/redmine_bibliography/assets/javascripts/bibliography.js	Mon Oct 07 15:42:39 2013 +0100
@@ -2,11 +2,15 @@
 
 function disable_fields(){
 	$this = $(this);
+
 	$author_info = $this.closest('div').prev();
-	$author_info.children('.description').toggle();
+//    $author_info.children('.description').toggle();
 	$author_info.find('p :input').attr("readonly", true);
     $author_info.find('p :input').addClass('readonly');
 
+    // Always hides on save
+    $this.closest('div').prev().find('p.search_author_tie').hide();
+
     $this.siblings('.author_edit_btn').show();
     $this.hide();
 
@@ -15,13 +19,18 @@
 
 function enable_fields(){
     $this = $(this);
+
     $author_info = $this.closest('div').prev();
-    $author_info.children('.description').toggle();
+//    $author_info.children('.description').toggle();
     $author_info.find('p :input').attr("readonly", false);
     $author_info.find('p :input').removeClass('readonly');
 
+    // Always shows on edit
+    $this.closest('div').prev().find('p.search_author_tie').show();
+
     $this.siblings('.author_save_btn').show();
     $this.hide();
 
     return false;
 }
+
--- a/plugins/redmine_bibliography/assets/javascripts/new_publication.js	Mon Sep 30 13:52:14 2013 +0100
+++ b/plugins/redmine_bibliography/assets/javascripts/new_publication.js	Mon Oct 07 15:42:39 2013 +0100
@@ -4,4 +4,6 @@
     // adds the events to the edit/save authorship button
     $('.author_save_btn').live('click', disable_fields);
     $('.author_edit_btn').live('click', enable_fields);
+
+
 });
\ No newline at end of file
--- a/plugins/redmine_bibliography/assets/stylesheets/bibliography.css	Mon Sep 30 13:52:14 2013 +0100
+++ b/plugins/redmine_bibliography/assets/stylesheets/bibliography.css	Mon Oct 07 15:42:39 2013 +0100
@@ -20,19 +20,14 @@
 }
 
 .tabular .author_edit .description {
-    padding-top: 0;
     font-style: italic;
+    font-size: small;
 }
 
 .publication_project {
     margin-right: 18px;
 }
 
-#authors select {
-    min-width: 150px;
-}
-
-
 div#bibliography dd { margin-bottom: 1em; font-size: 0.9em; }
 
 div#bibliography dd .authors { font-style: italic; }
@@ -71,7 +66,11 @@
   background-image: url(../../../images/loading.gif);
 }
 
-.author_edit_btn {
-  display:none;
+.search_author_tie {
+  display: none;
+  float: left;
 }
 
+.author_edit_btn {
+  display: none;
+}
--- a/plugins/redmine_tags/lib/redmine_tags/patches/projects_helper_patch.rb	Mon Sep 30 13:52:14 2013 +0100
+++ b/plugins/redmine_tags/lib/redmine_tags/patches/projects_helper_patch.rb	Mon Oct 07 15:42:39 2013 +0100
@@ -116,8 +116,6 @@
           s = []
           if projects.any?
             tokens = RedmineProjectFiltering.calculate_tokens(question, custom_fields)
-            debugger
-
 
             ancestors = []
             original_project = @project