changeset 679:31739bb8e563 feature_36_testing

Dead end solution regarding Feature #238: Ajax called RJS cannot access the instance variables that were initialized with the form helper.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Wed, 14 Sep 2011 09:58:44 +0100
parents 97815d819fd3
children 60773bbfe050
files vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb
diffstat 4 files changed, 8 insertions(+), 32 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Tue Sep 13 18:13:06 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Wed Sep 14 09:58:44 2011 +0100
@@ -62,40 +62,16 @@
     end
   end
 
+
   def get_bibtex_required_fields
-    all_fields = ["editor", "publisher", "chapter", "pages", "volume", "series", "address", "edition", "year", "note", "institution", "type", "number", "month", "journal", "howpublished", "key", "school"]
-
-    fields = Hash.new
-    fields[ 'article' ] = [ 'journal', 'year', 'volume', 'number', 'pages', 'month', 'note' ]
-    fields[ 'book' ] = [ 'editor', 'publisher', 'volume', 'series', 'address', 'edition', 'month', 'year', 'note' ]
-    fields[ 'booklet' ] = [ 'howpublished', 'address', 'year', 'month', 'note', 'key' ]
-    fields[ 'conference' ] = [ 'booktitle', 'year', 'editor', 'pages', 'organization', 'publisher', 'address', 'month', 'note' ]
-    fields[ 'inbook' ] = [ 'editor', 'publisher', 'chapter', 'pages', 'volume', 'series', 'address', 'edition', 'year', 'note' ]
-    fields[ 'incollection' ] = [ 'editor', 'publisher', 'chapter', 'pages', 'volume', 'series', 'address', 'edition', 'year', 'note' ]
-    fields[ 'inproceedings' ] = [ 'booktitle', 'year', 'editor', 'pages', 'organization', 'publisher', 'address', 'month', 'note' ]
-    fields[ 'manual' ] = [ 'organization', 'address', 'edition', 'month', 'year', 'note' ]
-    fields[ 'masterthesis' ] = [ 'school', 'year', 'address', 'month', 'note' ]
-    fields[ 'misc' ] = [ 'howpublished', 'month', 'year', 'note' ]
-    fields[ 'phdthesis' ] = [ 'school', 'year', 'address', 'month', 'note' ]
-    fields[ 'proceedings' ] = [ 'booktitle', 'year', 'editor', 'pages', 'organization', 'publisher', 'address', 'month', 'note' ]
-    fields[ 'techreport' ] = [ 'institution', 'year', 'type', 'number', 'address', 'month', 'note' ]
-    fields[ 'unpublished' ] = [ 'note', 'month', 'year' ]
-
     entrytype = BibtexEntryType.find(params[:value]).name
     
+    logger.error ("Vai chamar o #{entrytype}")
+
     respond_to do |format|
       format.js {
         render(:update) {|page| 
-          all_fields.each do |field|
-            
-            
-            
-            unless fields[entrytype].include? field
-                page["publication_bibtex_entry_attributes_#{field}"].up('p').hide()
-              else
-                page["publication_bibtex_entry_attributes_#{field}"].up('p').show()
-            end            
-          end
+          page.replace_html :bibtex_entry_fields, :partial => "bibtex_entries/#{entrytype}"
         }
       }
     end
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb	Tue Sep 13 18:13:06 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb	Wed Sep 14 09:58:44 2011 +0100
@@ -9,6 +9,8 @@
 	%>
 </p>
 
-<%- if params[:action] == "edit" || params[:action] == 'create' -%>
+<div id="bibtex_entry_fields">
+  <%- if params[:action] == "edit" || params[:action] == 'create' -%>
   <%= render :partial => 'bibtex_entries/article', :locals => { :f => f }  %>
-<%- end -%>
\ No newline at end of file
+  <%- end -%>
+</div>
--- a/vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb	Tue Sep 13 18:13:06 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb	Wed Sep 14 09:58:44 2011 +0100
@@ -1,7 +1,6 @@
 <% content_for :header_tags do %>
     <%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %>
     <%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %>
-    <%= javascript_tag 'Event.observe(window, "load", hide_all_empty_bibtex_fields);' %>
 <% end %>
 
 <h2><%=l(:label_publication_show)%></h2>
--- a/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb	Tue Sep 13 18:13:06 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb	Wed Sep 14 09:58:44 2011 +0100
@@ -1,7 +1,6 @@
 <% content_for :header_tags do %>
     <%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %>
     <%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %>
-    <%= javascript_tag 'Event.observe(window, "load", hide_all_bibtex_required_fields);' %>
 <% end %>
 
 <h2><%=l(:label_publication_new)%></h2>