changeset 605:8fc59e8ddd63 feature_36

Edit/Save Author Button working correctly.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Thu, 18 Aug 2011 16:32:39 +0100
parents 48c027b30576
children 63f92a52a4eb
files vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml vendor/plugins/redmine_bibliography/assets/javascripts/authors.js
diffstat 2 files changed, 23 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- 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 @@
 
   </div>
 
-  <%= 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 %>
-</div>
\ No newline at end of file
+</div>
--- 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");
 }