# HG changeset patch # User Chris Cannam # Date 1315930680 -3600 # Node ID ec6c2f6a33c4b42fe94a0139d2de8738c86c2134 # Parent 4fcd6ca1825c79b5f7caa02d8b67a4f6567e8f04 Transplant rev fccacd8505e3 from live branch diff -r 4fcd6ca1825c -r ec6c2f6a33c4 vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb --- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Tue Sep 13 17:17:27 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Tue Sep 13 17:18:00 2011 +0100 @@ -5,7 +5,7 @@ unloadable model_object Publication - before_filter :find_model_object, :except => [:new, :create, :index, :autocomplete_for_project, :add_author, :sort_author_order, :autocomplete_for_author, :get_user_info ] + before_filter :find_model_object, :except => [:new, :create, :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 @@ -62,13 +62,52 @@ 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 + + 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 + } + } + end + end + def add_author if (request.xhr?) render :text => User.find(params[:user_id]).name else # No? Then render an action. #render :action => 'view_attribute', :attr => @name - logger.error { "ERRO ADD AUTHOR" } + logger.error { "Error while adding Author to publication." } end end @@ -249,7 +288,7 @@ yes_radio = "publication_authorships_attributes_#{object_id}_identify_author_yes".to_sym respond_to do |format| - format.js {logger.error { "JS" } + format.js { render(:update) {|page| page[name_field].value = item.name page[email_field].value = item.mail diff -r 4fcd6ca1825c -r ec6c2f6a33c4 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 17:17:27 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb Tue Sep 13 17:18:00 2011 +0100 @@ -1,21 +1,77 @@ +
+ + <%= f.collection_select :entry_type, + BibtexEntryType.find(:all).reject { |x| x.redundant? }, + :id, + :label, + { :selected => @selected_bibtex_entry_type_id, :prompt => true }, + :onChange => remote_function( :url => { :controller => :publications, :action => :get_bibtex_required_fields}, :with => "'value=' + value" ) + %> +
++ <%= f.text_field :year, :size => 4, :class => 'bibtex' %> +
++ <%= f.text_field :chapter, :size => 15, :class => 'bibtex' %> +
++ <%= f.text_field :editor, :size => 33, :class => 'bibtex' %> +
++ <%= f.text_field :booktitle, :size => 33, :class => 'bibtex' %> +
++ <%= f.text_field :publisher,:size => 33, :class => 'bibtex' %> +
++ <%= f.text_field :pages, :size => 12, :class => 'bibtex' %> +
++ <%= f.text_field :address, :class => 'bibtex' %> +
++ <%= f.text_field :annote, :class => 'bibtex' %> +
++ <%= f.text_field :crossref, :class => 'bibtex' %> +
++ <%= f.text_field :edition, :class => 'bibtex' %> +
++ <%= f.text_field :eprint, :class => 'bibtex' %> +
++ <%= f.text_field :howpublished, :class => 'bibtex' %> +
++ <%= f.text_field :journal, :class => 'bibtex' %> +
++ <%= f.text_field :key, :class => 'bibtex' %> +
++ <%= f.text_field :note, :class => 'bibtex' %> +
++ <%= f.text_field :number, :class => 'bibtex' %> +
++ <%= f.text_field :organization, :class => 'bibtex' %> +
++ <%= f.text_field :school, :class => 'bibtex' %> +
++ <%= f.text_field :series, :class => 'bibtex' %> +
++ <%= f.text_field :type, :class => 'bibtex' %> +
++ <%= f.text_field :url, :class => 'bibtex' %> +
++ <%= f.text_field :volume, :class => 'bibtex' %> +
-- <%= f.collection_select(:entry_type, BibtexEntryType.find(:all).reject { |x| x.redundant? }, :id, :label, {:selected => @selected_bibtex_entry_type_id, :prompt => true}) %> -
-- <%= f.text_field :year, :size => 4 %> -
- <%= f.text_field :chapter, :size => 15 %> -
-- <%= f.text_field :editor, :size => 33 %> -
-- <%= f.text_field :booktitle,:size => 33 %> -
-- <%= f.text_field :publisher,:size => 33 %> -
-- <%= f.text_field :pages, :size => 12 %> -
diff -r 4fcd6ca1825c -r ec6c2f6a33c4 vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb Tue Sep 13 17:17:27 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb Tue Sep 13 17:18:00 2011 +0100 @@ -1,6 +1,7 @@ <% 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 %>