changeset 1103:6d85e9ea961c bibplugin_bibtex

(dev commit) added a submit button; correctly posts the form's data. Started working on the create from bibtex action.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Mon, 03 Dec 2012 17:53:15 +0000
parents e5b80648aaa5
children c018d0c89c94
files vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb vendor/plugins/redmine_bibliography/app/models/publication.rb vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb vendor/plugins/redmine_bibliography/app/views/publications/new/_bibtex.html.erb
diffstat 5 files changed, 33 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Mon Dec 03 12:55:16 2012 +0000
+++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Mon Dec 03 17:53:15 2012 +0000
@@ -7,7 +7,7 @@
   unloadable
 
   model_object Publication
-  before_filter :find_model_object, :except => [:parse_bibtex, :new, :create, :index, :get_bibtex_required_fields, :autocomplete_for_project, :add_author, :sort_author_order, :autocomplete_for_author, :get_user_info ]
+  before_filter :find_model_object, :except => [:parse_bibtex, :new, :create, :create_from_bibtex, :index, :get_bibtex_required_fields, :autocomplete_for_project, :add_author, :sort_author_order, :autocomplete_for_author, :get_user_info ]
   before_filter :find_project_by_project_id, :authorize, :only => [ :edit, :new, :update, :create ]
 
   def new
@@ -50,18 +50,25 @@
           @ieee_prev = CiteProc.process bib.to_citeproc, :style => :ieee, :format => :html
           bibtex_parsed_authors = bib[0].authors
 
+          # todo: need to create a bibtex object
+          ## and add it to the session hash
+
+          # creates stucture with author suggestions
           bibtex_parsed_authors.each do |auth|
             @suggested_authors[auth] = suggest_authors(auth.last)
           end
-
-          logger.error { "Suggested Authors: #{@suggested_authors}" }
-
         end
 
         format.js
     end
   end
 
+  def create_from_bibtex
+    find_project_by_project_id
+    logger.error { "INSIDE CREATE FROM BIBTEX" }
+
+  end
+
 
   def create
     @project = Project.find(params[:project_id])
--- a/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb	Mon Dec 03 12:55:16 2012 +0000
+++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb	Mon Dec 03 17:53:15 2012 +0000
@@ -153,7 +153,7 @@
   end
 
   def create_author_suggestion_radio(radio_object, author)
-    s = radio_button_tag(radio_object, author.id, false)
+    s = radio_button_tag(radio_object, "author_#{author.id}", false)
     # todo: returns first non empty name...
     author.authorships.each do |auth|
       unless auth.name_on_paper.nil?
@@ -166,7 +166,7 @@
   end
 
   def create_user_suggestion_radio(radio_object, user)
-    s = radio_button_tag(radio_object, user.id, false)
+    s = radio_button_tag(radio_object, "user_#{user.id}", false)
     s << user.name
     s << '<br />'
     s
--- a/vendor/plugins/redmine_bibliography/app/models/publication.rb	Mon Dec 03 12:55:16 2012 +0000
+++ b/vendor/plugins/redmine_bibliography/app/models/publication.rb	Mon Dec 03 17:53:15 2012 +0000
@@ -37,7 +37,6 @@
                 :description => Proc.new {|o| o.print_entry(:ieee)},
                 :url => Proc.new {|o| {:controller => 'publications', :action => 'show', :id => o.id }}
 
-
   # Ensure error message uses proper text instead of
   # bibtex_entry.entry_type (#268).  There has to be a better way to
   # do this!
--- a/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb	Mon Dec 03 12:55:16 2012 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb	Mon Dec 03 17:53:15 2012 +0000
@@ -7,5 +7,4 @@
 <div id="ajax-indicator" style="display:none;"><span><%= l(:label_loading) %></span></div>
 
 <h2><%=l(:label_publication_new)%></h2>
-
-<%= render_tabs create_publication_tabs %>
+<%= render_tabs create_publication_tabs -%>
--- a/vendor/plugins/redmine_bibliography/app/views/publications/new/_bibtex.html.erb	Mon Dec 03 12:55:16 2012 +0000
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/new/_bibtex.html.erb	Mon Dec 03 17:53:15 2012 +0000
@@ -1,17 +1,23 @@
-<div class="splitcontentleft">
-  <div>
-    <h3>Paste your bibtex entry</h3>
-    <div class="box">
-      <%= text_area_tag :bibtex_paste, "Please paste your bibtex entry here" , :class => "wiki", :style => 'width:90%; height:100px;' -%>
-      <br />
-      <%= link_to_remote "Parse BiBTeX", :url =>  { :project_id  => @project, :action => :parse_bibtex}, :with => "'bibtex_paste=' + $('bibtex_paste').value" -%>
+<% form_for @publication, :url => { :project_id  => @project, :action => :create_from_bibtex }, :builder => TabularFormBuilder do |f| -%>
+
+  <div class="splitcontentleft">
+    <div>
+      <h3>Paste your bibtex entry</h3>
+      <div class="box">
+        <%= text_area_tag :bibtex_paste, "Please paste your bibtex entry here" , :class => "wiki", :style => 'width:90%; height:100px;' -%>
+        <br />
+        <%= link_to_remote "Parse BiBTeX", :url =>  { :project_id  => @project, :action => :parse_bibtex}, :with => "'bibtex_paste=' + $('bibtex_paste').value" -%>
+      </div>
     </div>
   </div>
-</div>
 
-<div class="splitcontentright">
-  <h3>Preview and correct</h3>
+  <div class="splitcontentright">
+    <h3>Preview and correct</h3>
 
-  <div class="box" id="ieee_prev"><h3>Preview</h3></div>
-  <div class="box" id="suggest_bibtex_authors"><h3>Authors</h3></div>
-</div>
\ No newline at end of file
+    <div class="box" id="ieee_prev"><h3>Preview</h3></div>
+    <div class="box" id="suggest_bibtex_authors"><h3>Authors</h3></div>
+  </div>
+
+  <%= f.submit %>
+
+<%- end -%>