changeset 1391:8580d1d1150e luisf

Adding 2 new js scripts; added the code removed from the partials. Minor cleaning.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Wed, 25 Sep 2013 17:44:48 +0100
parents ac480b6a13cf
children d262df85ac97
files plugins/redmine_bibliography/app/views/publications/edit.html.erb plugins/redmine_bibliography/app/views/publications/new.html.erb
diffstat 2 files changed, 46 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/redmine_bibliography/app/views/publications/edit.html.erb	Wed Sep 25 17:44:05 2013 +0100
+++ b/plugins/redmine_bibliography/app/views/publications/edit.html.erb	Wed Sep 25 17:44:48 2013 +0100
@@ -1,19 +1,37 @@
 <% content_for :header_tags do %>
-    <%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %>
-    <%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %>
-    <%= javascript_tag "$(document).ready(function() { $('#publication_bibtex_entry_attributes_entry_type').trigger('change'); });" %>
+  <%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' -%>
+  <%= javascript_include_tag 'bibliography', :plugin => 'redmine_bibliography' -%>
+  <%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' -%>
+
+  <%= javascript_include_tag 'edit_publication', :plugin => 'redmine_bibliography' -%>
+
+  <%= javascript_tag "$('#publication_bibtex_entry_attributes_entry_type').live('change', function() {
+                        $this = $(this);
+                        $.ajax({
+                            type: 'get',
+                            url: '#{url_for(:controller => :publications, :action => :show_bibtex_fields)}',
+                            data: {
+                                value: $this.val()
+                            },
+                            dataType: 'script'
+                        }); return false; });" -%>
+
 <% end %>
 
+<%= error_messages_for 'publication' %>
+
 <h2><%=l(:label_publication_show)%></h2>
 
 <%= labelled_form_for @publication, :url => { :project_id  => @project, :action => :update } do |f| -%>
-  <%= render :partial => 'form', :locals => { :f => f }  %>
 
-  <div style="clear:both"></div>
-  <%= f.submit %>
+    <%= render :partial => 'form', :locals => { :f => f }  %>
+
+    <div style="clear:both"></div>
+    <%= f.submit %>
 <% end %>
+
 <p>
-  <%= link_to l(:label_publication_show), { :controller => "publications", :action => "show", :id => @publication, :project_id => @project_id } %> |
-  <%= link_to l(:label_publication_index), { :controller => "publications", :action => "index", :project_id => @project } %>
+    <%= link_to l(:label_publication_show), { :controller => "publications", :action => "show", :id => @publication, :project_id => @project_id } %> |
+    <%= link_to l(:label_publication_index), { :controller => "publications", :action => "index", :project_id => @project } %>
 </p>
 
--- a/plugins/redmine_bibliography/app/views/publications/new.html.erb	Wed Sep 25 17:44:05 2013 +0100
+++ b/plugins/redmine_bibliography/app/views/publications/new.html.erb	Wed Sep 25 17:44:48 2013 +0100
@@ -1,12 +1,32 @@
 <% content_for :header_tags do %>
     <%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %>
     <%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %>
+    <%= javascript_include_tag 'bibliography', :plugin => 'redmine_bibliography' -%>
+    <%= javascript_include_tag 'new_publication', :plugin => 'redmine_bibliography' -%>
+    <%= javascript_tag "
+      $('#publication_bibtex_entry_attributes_entry_type').live('change', function() {
+          $this = $(this);
+          $.ajax({
+              type: 'get',
+              url: '#{url_for(:controller => :publications, :action => :show_bibtex_fields)}',
+              data: {
+                  value: $this.val()
+              },
+              dataType: 'script'
+          });
+          return false;
+      });"-%>
+
 <% end %>
 
+<%= error_messages_for 'publication' %>
+
 <h2><%=l(:label_publication_new)%></h2>
 
 <%= labelled_form_for @publication, :url => { :project_id  => @project, :action => :create } do |f| -%>
+
     <%= render :partial => 'form', :locals => { :f => f }  %>
+
     <div style="clear:both"></div>
     <%= f.submit %>
 <% end %>