changeset 684:cd7e10c4ab86 feature_36

Feature #238 - Edit Publication now showing the correct fields.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Fri, 16 Sep 2011 13:17:28 +0100
parents c3e6c51170fa
children 4481db876cdb
files vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb vendor/plugins/redmine_bibliography/assets/javascripts/authors.js
diffstat 3 files changed, 31 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Fri Sep 16 11:14:10 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb	Fri Sep 16 13:17:28 2011 +0100
@@ -63,7 +63,7 @@
   end
 
   def get_bibtex_required_fields
-    all_fields = [ "editor", "publisher", "chapter", "pages", "volume", "series", "address", "edition", "year", "type", "note", "number", "journal", "howpublished", "key", "school", "month" ]
+    all_fields = [ "editor", "publisher", "chapter", "pages", "volume", "series", "address", "edition", "month", "year", "type", "note", "number", "journal", "howpublished", "key", "school" ]
 
     fields = Hash.new
     fields[ 'article' ] = [ 'journal', 'year', 'volume', 'number', 'pages', 'month', 'note' ]
@@ -112,11 +112,32 @@
     find_project_by_project_id unless params[:project_id].nil?
     
     @edit_view = true;
-    
     @publication = Publication.find(params[:id])
     @selected_bibtex_entry_type_id = @publication.bibtex_entry.entry_type
 
     @author_options = []  
+    
+    
+    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' ] = [ 'year', 'type', 'number', 'address', 'month', 'note' ]
+    fields[ 'unpublished' ] = [ 'note', 'month', 'year' ]
+    
+    entrytype = BibtexEntryType.find(@selected_bibtex_entry_type_id).name
+    
+    @bibtype_fields = fields[entrytype]
+    
   end
 
   def update    
@@ -141,7 +162,7 @@
 
   def show
     find_project_by_project_id unless params[:project_id].nil?
-    
+        
     if @publication.nil?
       @publications = Publication.all
       render "index", :alert => 'The publication was not found!'
--- a/vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb	Fri Sep 16 11:14:10 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb	Fri Sep 16 13:17:28 2011 +0100
@@ -1,7 +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);' %>
+    <%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %>  
+    <%= javascript_tag 'Event.observe(window, "load", function(e){show_all_required_bibtex_fields(' + @bibtype_fields.to_json + ')});' %>
 <% end %>
 
 <h2><%=l(:label_publication_show)%></h2>
--- a/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js	Fri Sep 16 11:14:10 2011 +0100
+++ b/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js	Fri Sep 16 13:17:28 2011 +0100
@@ -57,18 +57,16 @@
     toggle_div("publication_authorships_attributes_" + form_object_id +"_search_author");
 }
 
-function edit_author(form_object_id){
-	
-	
-}
+function edit_author(form_object_id){}
 
 function hide_all_bibtex_required_fields() {
 	$$('input.bibtex').each(function(s){
 	    s.up('p').hide();
 		})}
 		
-function hide_all_empty_bibtex_fields() {
+function show_all_required_bibtex_fields(entrytype_fields) {
 	$$('input.bibtex').each(function(s){
-	    if(s.value==""){s.up('p').hide()};
-})}
+    if(entrytype_fields.indexOf(s.id.split('_').last()) == -1){s.up('p').hide()};
+	})
+}
 		
\ No newline at end of file