# HG changeset patch # User luisf # Date 1315990724 -3600 # Node ID 31739bb8e563930fcd4dd997aa2a949e19473936 # Parent 97815d819fd3cf1ea1a2957fe45d282e535c350d Dead end solution regarding Feature #238: Ajax called RJS cannot access the instance variables that were initialized with the form helper. diff -r 97815d819fd3 -r 31739bb8e563 vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb --- 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 diff -r 97815d819fd3 -r 31739bb8e563 vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb --- 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 @@ %>

-<%- if params[:action] == "edit" || params[:action] == 'create' -%> +
+ <%- if params[:action] == "edit" || params[:action] == 'create' -%> <%= render :partial => 'bibtex_entries/article', :locals => { :f => f } %> -<%- end -%> \ No newline at end of file + <%- end -%> +
diff -r 97815d819fd3 -r 31739bb8e563 vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb --- 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 %>

<%=l(:label_publication_show)%>

diff -r 97815d819fd3 -r 31739bb8e563 vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb --- 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 %>

<%=l(:label_publication_new)%>