changeset 1407:00a51e442fe9 biblio_alt_search_auth

Adds a "Keep associated with" checkbox to the authorship view.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Tue, 01 Oct 2013 12:00:45 +0100
parents 20235e6c60c0
children b09744f35f76
files plugins/redmine_bibliography/app/helpers/publications_helper.rb plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.html.erb plugins/redmine_bibliography/assets/javascripts/authors.js plugins/redmine_bibliography/assets/javascripts/bibliography.js plugins/redmine_bibliography/assets/stylesheets/bibliography.css
diffstat 6 files changed, 36 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/redmine_bibliography/app/helpers/publications_helper.rb	Mon Sep 30 18:29:35 2013 +0100
+++ b/plugins/redmine_bibliography/app/helpers/publications_helper.rb	Tue Oct 01 12:00:45 2013 +0100
@@ -123,3 +123,26 @@
     s
   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"
+    s << link_to_author(Author.find(link_id), {}, :class => 'author_link')
+  else
+    s << link_to_user(User.find(link_id), :class => 'publication_project')
+  end
+
+  confirm_msg = "Are you sure you want to remove the link between this publication's author and this code.soundsoftware.ac.uk site user?"
+
+  ## s << link_to(l(:button_delete), { :url => { :controller => 'publications', :action => 'remove_project', :id => publication, :remove_project_id => proj,  :project_id => @project }, :method => :post, :confirm => confirm_msg }, :class => 'icon icon-del', :remote => :true)
+
+  s.html_safe
+end
+
--- a/plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb	Mon Sep 30 18:29:35 2013 +0100
+++ b/plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb	Tue Oct 01 12:00:45 2013 +0100
@@ -6,8 +6,8 @@
     <p><%= f.text_field :email -%></p>
 
     <p class="author_associated search_author_tie">
-      <%= f.check_box :search_author_tie -%>
-      <span class="author_associated_name"></span>
+      <%= f.check_box :search_author_tie, :label => '' -%>
+      <span>Not associated with any SoundSoftware site user.</span>
     </p>
 
     <%= f.hidden_field :search_author_class -%>
--- a/plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.html.erb	Mon Sep 30 18:29:35 2013 +0100
+++ b/plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.html.erb	Tue Oct 01 12:00:45 2013 +0100
@@ -6,6 +6,7 @@
     'search_author_id' => result.id,
     'name' => result.name,
     'institution' => result.institution,
-    'email' => result.mail
+    '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/assets/javascripts/authors.js	Mon Sep 30 18:29:35 2013 +0100
+++ b/plugins/redmine_bibliography/assets/javascripts/authors.js	Tue Oct 01 12:00:45 2013 +0100
@@ -26,7 +26,9 @@
 
             $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);
+
             $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);
 
             // triggers the save button
             $this.closest('div').next('div').find('.author_save_btn').click();
--- a/plugins/redmine_bibliography/assets/javascripts/bibliography.js	Mon Sep 30 18:29:35 2013 +0100
+++ b/plugins/redmine_bibliography/assets/javascripts/bibliography.js	Tue Oct 01 12:00:45 2013 +0100
@@ -8,6 +8,9 @@
 	$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();
 
@@ -22,6 +25,9 @@
     $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();
 
--- a/plugins/redmine_bibliography/assets/stylesheets/bibliography.css	Mon Sep 30 18:29:35 2013 +0100
+++ b/plugins/redmine_bibliography/assets/stylesheets/bibliography.css	Tue Oct 01 12:00:45 2013 +0100
@@ -66,7 +66,7 @@
   background-image: url(../../../images/loading.gif);
 }
 
-.authorship_tie {
+.search_author_tie {
   display: none;
   float: left;
 }