# HG changeset patch # User luisf # Date 1313681559 -3600 # Node ID 8fc59e8ddd6340cf7482aecaae03517d12bb2e54 # Parent 48c027b305765139718372ff4aa21c80c6127285 Edit/Save Author Button working correctly. diff -r 48c027b30576 -r 8fc59e8ddd63 vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml --- a/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Thu Aug 18 15:05:16 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Thu Aug 18 16:32:39 2011 +0100 @@ -43,7 +43,8 @@ - <%= button_to l(:label_save_author), {}, :onclick => "toggle_save_author(#{form_object_id(f.object_name)}); return false;" %> + + <%= 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 %> - \ No newline at end of file + diff -r 48c027b30576 -r 8fc59e8ddd63 vendor/plugins/redmine_bibliography/assets/javascripts/authors.js --- a/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Thu Aug 18 15:05:16 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Thu Aug 18 16:32:39 2011 +0100 @@ -27,16 +27,31 @@ Effect.toggle(div_id, "appear", {duration:0.3}); } -function toggle_input_field(field_id){ - field_id.addClassName('readonly').next('em').hide(); - field_id.readOnly = true; +function toggle_input_field(field){ + if(field.readOnly == false){ + field.readOnly = true; + field.addClassName('readonly').next('em').hide(); + } else{ + field.readOnly = false; + field.removeClassName('readonly').next('em').show(); + }; } -function toggle_save_author(form_object_id){ +function toggle_edit_save_button(object_id){ + $button = $('publication_authorships_attributes_' + object_id + '_edit_save_button'); + if($button.value == "Save Author"){ + $button.value = "Edit Author"; + } else { + $button.value = "Save Author"; + }; +} + +function toggle_save_author(form_object_id, $this){ $('publication_authorships_attributes_' + form_object_id + '_edit_author_info').select('input').each(function(s) { - toggle_input_field(s); + toggle_input_field(s, $this); }); + toggle_edit_save_button(form_object_id); toggle_div("publication_authorships_attributes_" + form_object_id +"_search_author"); }