changeset 1289:7fa299909144 redmine-2.2-integration

fixed a few details.
author luisf <luis.figueira@eecs.qmul.ac.uk>
date Tue, 21 May 2013 17:20:52 +0100
parents 7e89ba7fac48
children dd8b5f835522
files plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.html.erb plugins/redmine_bibliography/assets/javascripts/authors.js
diffstat 3 files changed, 13 insertions(+), 51 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb	Sat May 18 13:41:32 2013 +0100
+++ b/plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb	Tue May 21 17:20:52 2013 +0100
@@ -9,6 +9,7 @@
     </p>
 
     <p style="margin-bottom: -2.5em; padding-bottom; 0"><label><%= l(:identify_author_question) %></label></p>
+
     <p class="author_identify">
       <label class='inline'><%= radio_button_tag(:identify_author, "yes", false, :name => form_tag_name(f.object_name,:identify_author ), :id => form_tag_id( f.object_name, :identify_author_yes ), :onchange => "identify_author_status($(this).value, #{form_object_id(f.object_name) });") %> <%= l(:identify_author_yes) %> </label><br />
 
--- a/plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.html.erb	Sat May 18 13:41:32 2013 +0100
+++ b/plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.html.erb	Tue May 21 17:20:52 2013 +0100
@@ -1,10 +1,10 @@
 <%= raw @results.map {|result| {
-      'label' => "#{result.name} (#{result.mail.partition('@')[2]})",
-      'value' => result.name,
-      'search_author_class' => result.class.name,
-      'search_author_id' => result.id,
-      'institution' => result.institution,
-      'email' => result.mail,
-      }
-    }.to_json
-%>
\ No newline at end of file
+    'label' => "#{result.name} <em>#{result.mail.partition('@')[2]}</em>",
+    'value' => result.name,
+    'search_author_class' => result.class.name,
+    'search_author_id' => result.id,
+    'name' => result.name,
+    'institution' => result.institution,
+    'email' => result.mail,
+    }
+}.to_json %>
\ No newline at end of file
--- a/plugins/redmine_bibliography/assets/javascripts/authors.js	Sat May 18 13:41:32 2013 +0100
+++ b/plugins/redmine_bibliography/assets/javascripts/authors.js	Tue May 21 17:20:52 2013 +0100
@@ -21,7 +21,7 @@
         source: '/publications/autocomplete_for_author',
         minLength: 2,
         focus: function(event, ui) {
-            $this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.value);
+            $this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.name);
             $this.closest('div').next().find("input[id$='institution']").val(ui.item.institution);
             $this.closest('div').next().find("input[id$='email']").val(ui.item.email);
             $this.closest('div').next().find("input[id$='search_author_class']").val(ui.item.search_author_class);
@@ -30,7 +30,7 @@
             return false;
         },
         select: function(event, ui){
-            $this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.value);
+            $this.closest('div').next().find("input[id$='name_on_paper']").val(ui.item.name);
             $this.closest('div').next().find("input[id$='institution']").val(ui.item.institution);
             $this.closest('div').next().find("input[id$='email']").val(ui.item.email);
             $this.closest('div').next().find("input[id$='search_author_class']").val(ui.item.search_author_class);
@@ -40,54 +40,15 @@
         .data( "autocomplete" )._renderItem = function( ul, item ) {
             return $( "<li></li>" )
                 .data( "item.autocomplete", item )
-                .append( "<a>" + item.institution + "</a>" )
+                .append( "<a>" + item.label + "</a>" )
                 .appendTo( ul );
             };
         });
 
-
-
-
-function identify_author_status(status, object_id) {
-    $('publication_authorships_attributes_' + object_id + '_edit_author_info').select('input').each(function(s) {
-
-        if(status == "no"){
-            s.value = "";
-            s.readOnly = false;
-        }
-
-        if(status == "correct"){
-            s.readOnly = false;
-        }
-        if(status == "yes"){
-            s.readOnly = true;
-        }
-    });
-}
-
 function toggle_div(div_id){
     $("#" + div_id).toggle(0.3);
 }
 
-function toggle_input_field(field){
-    if (field.classNames().inspect().include("readonly") === false){
-			field.readOnly = true;
-			field.addClassName('readonly');
-    } else {
-			field.readOnly = false;
-			field.removeClassName('readonly');
-    }
-}
-
-function toggle_edit_save_button(object_id){
-    $button = $('publication_authorships_attributes_' + object_id + '_edit_save_button');
-    if ($button.value == "Edit author"){
-        $button.value = "Save author";
-    } else {
-        $button.value = "Edit 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, $this);