changeset 1102:e5b80648aaa5 bibplugin_bibtex

Creates independent sets of radio buttons for each author.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Mon, 03 Dec 2012 12:55:16 +0000
parents 5392783ea417
children 6d85e9ea961c
files vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb vendor/plugins/redmine_bibliography/app/views/publications/_suggest_author.html.erb vendor/plugins/redmine_bibliography/app/views/publications/parse_bibtex.rjs
diffstat 3 files changed, 22 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb	Fri Nov 30 17:39:34 2012 +0000
+++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb	Mon Dec 03 12:55:16 2012 +0000
@@ -152,17 +152,21 @@
     s
   end
 
-  def display_suggested_author(author)
-    s = radio_button_tag("suggested", author.id, false)
-    # todo. maybe not a safe assumption?
-    s << author.authorships.first.name_on_paper
+  def create_author_suggestion_radio(radio_object, author)
+    s = radio_button_tag(radio_object, author.id, false)
+    # todo: returns first non empty name...
+    author.authorships.each do |auth|
+      unless auth.name_on_paper.nil?
+        s << auth.name_on_paper
+        break
+      end
+    end
     s << '<br />'
     s
   end
 
-
-  def display_suggested_user(user)
-    s = radio_button_tag("suggested", user.id, false)
+  def create_user_suggestion_radio(radio_object, user)
+    s = radio_button_tag(radio_object, user.id, false)
     s << user.name
     s << '<br />'
     s
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_suggest_author.html.erb	Fri Nov 30 17:39:34 2012 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/_suggest_author.html.erb	Mon Dec 03 12:55:16 2012 +0000
@@ -1,17 +1,15 @@
+
+<% logger.error { "index #{index}//" } %>
+
 <p>
-  Author: <%= h(author[0]) -%>
+  Suggestions for Author: <%= h(suggestions[0]) -%>
 <br />
-  Authors:
+  <%- suggestions[1][:authors].each do |auth| -%>
+    <%= create_author_suggestion_radio("author_#{index}", auth) -%>
+  <%- end -%>
 <br />
-  <%- author[1][:authors].each do |auth| -%>
-    <%= display_suggested_author(auth) %>
-  <%- end -%>
-
-  <br />
-  Users:
-<br />
-  <%- author[1][:users].each do |usr| -%>
-    <%= display_suggested_user(usr) %>
+  <%- suggestions[1][:users].each do |usr| -%>
+    <%= create_user_suggestion_radio("author_#{index}", usr) -%>
   <%- end -%>
 <br />
 </p>
--- a/vendor/plugins/redmine_bibliography/app/views/publications/parse_bibtex.rjs	Fri Nov 30 17:39:34 2012 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/parse_bibtex.rjs	Mon Dec 03 12:55:16 2012 +0000
@@ -2,13 +2,12 @@
   page.insert_html :bottom, :ieee_prev, @ieee_prev
   page.insert_html :top, :content, '<div class="flash notice">Successfully Parsed BibTeX</div>'
 
-  @suggested_authors.each do |auth|
-    page.insert_html :bottom, :suggest_bibtex_authors, :partial => "suggest_author" , :locals => {:author => auth}
+  @suggested_authors.each_with_index do |auth, idx|
+    page.insert_html :bottom, :suggest_bibtex_authors, :partial => "suggest_author" , :locals => {:suggestions => auth, :index => idx}
   end
 
 else
   page.insert_html :top, :content, '<div class="flash error">Error parsing BibTeX.</div>'
 end
 
-
 flash.discard
\ No newline at end of file