Mercurial > hg > soundsoftware-site
changeset 699:2b665b7e67f4 feature_36
Bug #297 - Simplified JS; no more need to have BibtexEntryType.all_fields; solves the "Please Select" bug in New Publication view.
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Mon, 19 Sep 2011 16:44:12 +0100 |
parents | 614b2d1580d0 |
children | c7306033ba7a |
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 vendor/plugins/redmine_bibliography/assets/javascripts/authors.js |
diffstat | 5 files changed, 68 insertions(+), 68 deletions(-) [+] |
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Mon Sep 19 12:49:31 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Mon Sep 19 16:44:12 2011 +0100 @@ -64,21 +64,21 @@ def get_bibtex_required_fields - fields = BibtexEntryType.fields(params[:value]) - all_fields = BibtexEntryType.all_fields + unless params[:value].empty? + fields = BibtexEntryType.fields(params[:value]) + end respond_to do |format| format.js { - render(:update) {|page| - all_fields.each_with_index do |field, idx| - unless fields.include? field - page["publication_bibtex_entry_attributes_#{field}"].up('p').hide() - else - page["publication_bibtex_entry_attributes_#{field}"].up('p').show() - end + render(:update) {|page| + if params[:value].empty? + page << "hideOnLoad();" + else + page << "show_required_bibtex_fields(#{fields.to_json()});" end } } + end end
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb Mon Sep 19 12:49:31 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb Mon Sep 19 16:44:12 2011 +0100 @@ -8,73 +8,73 @@ :onChange => remote_function( :url => { :controller => :publications, :action => :get_bibtex_required_fields}, :with => "'value=' + value" ) %> </p> -<p> - <%= f.text_field :year, :size => 4, :class => 'bibtex' %> + +<p class="bibtex hol"> + <%= f.text_field :year, :size => 4 %> </p> -<p> - <%= f.text_field :month, :size => 4, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :month, :size => 4%> </p> -<p> - <%= f.text_field :chapter, :size => 15, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :chapter, :size => 15%> </p> -<p> - <%= f.text_field :editor, :size => 33, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :editor, :size => 33 %> </p> -<p> - <%= f.text_field :booktitle, :size => 33, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :booktitle, :size => 33 %> </p> -<p> - <%= f.text_field :publisher,:size => 33, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :publisher,:size => 33 %> </p> -<p> - <%= f.text_field :pages, :size => 12, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :pages, :size => 12 %> </p> -<p> - <%= f.text_field :address, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :address %> </p> -<p> - <%= f.text_field :annote, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :annote %> </p> -<p> - <%= f.text_field :crossref, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :crossref %> </p> -<p> - <%= f.text_field :edition, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :edition %> </p> -<p> - <%= f.text_field :eprint, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :eprint %> </p> -<p> - <%= f.text_field :howpublished, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :howpublished %> </p> -<p> - <%= f.text_field :journal, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :journal %> </p> -<p> - <%= f.text_field :key, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :key %> </p> -<p> - <%= f.text_field :note, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :note %> </p> -<p> - <%= f.text_field :number, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :number %> </p> -<p> - <%= f.text_field :organization, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :organization %> </p> -<p> - <%= f.text_field :school, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :school %> </p> -<p> - <%= f.text_field :series, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :series %> </p> -<p> - <%= f.text_field :type, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :type %> </p> -<p> - <%= f.text_field :url, :class => 'bibtex' %> +<p class="bibtex hol"> + <%= f.text_field :url %> </p> -<p> - <%= f.text_field :volume, :class => 'bibtex' %> -</p> - +<p class="bibtex hol"> + <%= f.text_field :volume %> +</p> \ No newline at end of file
--- a/vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb Mon Sep 19 12:49:31 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb Mon Sep 19 16:44:12 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", function(e){show_all_required_bibtex_fields(' + @bibtype_fields.to_json + ')});' %> + <%= javascript_tag 'Event.observe(window, "load", function(e){show_required_bibtex_fields(' + @bibtype_fields.to_json + ')});' %> <% end %> <h2><%=l(:label_publication_show)%></h2>
--- a/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb Mon Sep 19 12:49:31 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb Mon Sep 19 16:44:12 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>
--- a/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Mon Sep 19 12:49:31 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Mon Sep 19 16:44:12 2011 +0100 @@ -57,16 +57,17 @@ toggle_div("publication_authorships_attributes_" + form_object_id +"_search_author"); } -function edit_author(form_object_id){} +function hide_all_bibtex_required_fields(){$$('p.bibtex').each(function(s){s.hide()})} -function hide_all_bibtex_required_fields() { - $$('input.bibtex').each(function(s){ - s.up('p').hide(); - })} - -function show_all_required_bibtex_fields(entrytype_fields) { - $$('input.bibtex').each(function(s){ - if(entrytype_fields.indexOf(s.id.split('_').last()) == -1){s.up('p').hide()}; +// entrytype_fields is a jsno array with the fields requires by the selected bibtex entry +function show_required_bibtex_fields(entrytype_fields) { + $$('p.bibtex').each(function(s){ + if(entrytype_fields.indexOf(s.down('input').id.split('_').last()) != -1){ + s.show(); + } + else { + s.hide(); + } }) } \ No newline at end of file