# HG changeset patch # User luisf # Date 1313768759 -3600 # Node ID 3221b2ab780474243f25f77c08b274614f97bba0 # Parent c7559c3a8d0311f0505923b7f8683128f97ea6ca Fixes Bug #267. New javascript logic to differentiate between edit/new actions (Not finished). diff -r c7559c3a8d03 -r 3221b2ab7804 vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb --- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Thu Aug 18 22:27:19 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Fri Aug 19 16:45:59 2011 +0100 @@ -31,7 +31,7 @@ if @publication.save flash[:notice] = "Successfully created publication." - redirect_to :action => :show, :id => @publication, :project_id => @project.id + redirect_to :action => :show, :id => @publication, :project_id => @project_id else render :action => 'new', :project_id => @project_id end @@ -71,7 +71,10 @@ def edit find_project_by_project_id unless params[:project_id].nil? - + + @edit_view = true; + + @author_options = [] @publication = Publication.find(params[:id]) @selected_bibtex_entry_type_id = @publication.bibtex_entry.entry_type end diff -r c7559c3a8d03 -r 3221b2ab7804 vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml --- a/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Thu Aug 18 22:27:19 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Fri Aug 19 16:45:59 2011 +0100 @@ -4,8 +4,7 @@

<%= l("label_author_1") %>

-
-
+
>

<%= f.text_field :search_name, :size => 25 %> <%= observe_field( form_tag_id(f.object_name, :search_name), :frequency => 0.5, :update => form_tag_id( f.object_name, :search_results), :url => { :controller => 'publications', :action => 'autocomplete_for_author', :object_name => form_object_id(f.object_name) }, :with => 'q' ) %> @@ -18,32 +17,28 @@ <%= f.radio_button :identify_author, "correct", :onClick => "identify_author_status($(this).value, #{form_object_id(f.object_name) });" %><%= f.label :identify_author_correct %>
<%= f.radio_button :identify_author, "no", :onClick => "identify_author_status($(this).value, #{form_object_id(f.object_name) });" %><%= f.label :identify_author_no %>

-
- -
+ <%= f.select :search_results, options_for_select(@author_options), {}, {:size => 5, :onChange => remote_function( :url => { :controller => :publications, :action => :get_user_info, :object_id => form_object_id(f.object_name) }, :with => "'value=' + value" )} %>
+ +
+

+ <%= f.text_field :name_on_paper, {:class => ("readonly" unless params[:action] == "new") } %>
+ ><%= h l("text_author_name_on_paper") %>
+ <%= f.text_field :institution, {:class => ("readonly" unless params[:action] == "new") } %>
+ ><%= h l("text_author_institution") %>
+ <%= f.text_field :email, {:class => ("readonly" unless params[:action] == "new") } %>
+ ><%= h l("text_author_email") %>
+

-
-

- <%= f.text_field :name_on_paper, :size => 25 %>
- <%= h l("text_author_name_on_paper") %>
- <%= f.text_field :institution, :size => 35 %>
- <%= h l("text_author_institution") %>
- <%= f.text_field :email, :size => 35 %>
- <%= h l("text_author_email") %>
-

-
- <%= button_to l(:label_save_author), {}, { :onclick => "toggle_save_author(#{form_object_id(f.object_name)}); return false;", :id => form_tag_id( f.object_name, :edit_save_button )} %> <%= link_to_remove_fields l("remove_author"), f %> diff -r c7559c3a8d03 -r 3221b2ab7804 vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb Thu Aug 18 22:27:19 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb Fri Aug 19 16:45:59 2011 +0100 @@ -10,6 +10,6 @@ <%= f.submit %> <% end %>

- <%= link_to l(:label_publication_show), { :controller => "publications", :action => "show", :id => @publication, :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 } %>

diff -r c7559c3a8d03 -r 3221b2ab7804 vendor/plugins/redmine_bibliography/assets/javascripts/authors.js --- a/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Thu Aug 18 22:27:19 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Fri Aug 19 16:45:59 2011 +0100 @@ -27,6 +27,9 @@ Effect.toggle(div_id, "appear", {duration:0.3}); } + + + function toggle_input_field(field){ if(field.classNames().inspect().include("readonly") == false){ field.readOnly = true;