# HG changeset patch # User Chris Cannam # Date 1316512663 -3600 # Node ID 7fd36e4a99a1ff8902adeba857bf03fee1f54469 # Parent 065041087084cf9984f964ae3554c26025ff42d9# Parent 37e39e437b2c30e83598befa496dc6133483c46a Merge from branch live diff -r 37e39e437b2c -r 7fd36e4a99a1 vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb --- a/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Tue Sep 20 10:57:26 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Tue Sep 20 10:57:43 2011 +0100 @@ -43,12 +43,12 @@ f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)", :class => 'icon icon-del') end - def link_to_add_fields(name, f, association) + def link_to_add_author_fields(name, f, association, action) new_object = f.object.class.reflect_on_association(association).klass.new fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| render(association.to_s.singularize + "_fields", :f => builder) end - link_to_function(name, h("add_fields(this, '#{association}', '#{escape_javascript(fields)}')"), { :class => 'icon icon-add', :id => "add_another_author" }) + link_to_function(name, h("add_author_fields(this, '#{association}', '#{escape_javascript(fields)}', '#{action}')"), { :class => 'icon icon-add', :id => "add_another_author" }) end def sanitized_object_name(object_name) diff -r 37e39e437b2c -r 7fd36e4a99a1 vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml --- a/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Tue Sep 20 10:57:26 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Tue Sep 20 10:57:43 2011 +0100 @@ -19,11 +19,11 @@

-
+
-
+
-
+

@@ -45,12 +45,11 @@

- <% if params[:action] == 'new' %> - <%= button_to_function 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 )} %> - <% else %> -<%= button_to_function l(:label_edit_author), {}, { :onclick => "toggle_save_author(#{form_object_id(f.object_name)}); return false;", :id => form_tag_id( f.object_name, :edit_save_button )} %> - - <% end %> + <%- if params[:action] == 'new' -%> + <%= button_to_function 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 )} %> + <%- else -%> + <%= button_to_function l(:label_edit_author), {}, { :onclick => "toggle_save_author(#{form_object_id(f.object_name)}); return false;", :id => form_tag_id( f.object_name, :edit_save_button )} %> + <%- end -%> <%= link_to_remove_fields l("remove_author"), f %> diff -r 37e39e437b2c -r 7fd36e4a99a1 vendor/plugins/redmine_bibliography/app/views/publications/_form.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/_form.html.erb Tue Sep 20 10:57:26 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_form.html.erb Tue Sep 20 10:57:43 2011 +0100 @@ -24,7 +24,7 @@ <% f.fields_for :authorships do |builder| -%> <%= render "authorship_fields", :f => builder %> <%- end -%> - <%= link_to_add_fields l(:label_add_an_author), f, :authorships %> + <%= link_to_add_author_fields l(:label_add_an_author), f, :authorships, params[:action] %> diff -r 37e39e437b2c -r 7fd36e4a99a1 vendor/plugins/redmine_bibliography/assets/javascripts/authors.js --- a/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Tue Sep 20 10:57:26 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Tue Sep 20 10:57:43 2011 +0100 @@ -3,12 +3,15 @@ $(link).up(".fields").hide(); } -function add_fields(link, association, content) { - var new_id = new Date().getTime(); - var regexp = new RegExp("new_" + association, "g") - $(link).insert({ - before: content.replace(regexp, new_id) - }); +function add_author_fields(link, association, content, action) { + var new_id = new Date().getTime(); + var regexp = new RegExp("new_" + association, "g"); + $(link).insert({ + before: content.replace(regexp, new_id) + }); + if(action != "new"){ + toggle_save_author(new_id, $(link)); + }; } function identify_author_status(status, object_id) {