# HG changeset patch # User luisf # Date 1368205152 -3600 # Node ID e9bfba17e791b46719b9a40eca0b8af1a565b325 # Parent bdecc47b65b88c64b174928b0b1a98cfd2c3edf7 changes to the authors search ajax (not finished). diff -r bdecc47b65b8 -r e9bfba17e791 plugins/redmine_bibliography/app/helpers/publications_helper.rb --- a/plugins/redmine_bibliography/app/helpers/publications_helper.rb Fri May 10 17:50:56 2013 +0100 +++ b/plugins/redmine_bibliography/app/helpers/publications_helper.rb Fri May 10 17:59:12 2013 +0100 @@ -37,7 +37,6 @@ if @results.size > 0 s = select_tag( form_tag_name(object_name, :author_search_results), options_for_select(@author_options), { :id => form_tag_id(object_name, :author_search_results), :size => 3} ) - s << observe_field( form_tag_id(object_name, :author_search_results), :on => 'click', :function => "alert('Element changed')", :with => 'q') else s = "No Authors found that match your search… sorry!" end diff -r bdecc47b65b8 -r e9bfba17e791 plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb --- a/plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb Fri May 10 17:50:56 2013 +0100 +++ b/plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb Fri May 10 17:59:12 2013 +0100 @@ -1,21 +1,18 @@ -<%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %> - +<% content_for :header_tags do %> + <%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %> +<% end %>
- +
> +

+ <%= f.text_field :search_name, :size => 25, :class => "author_search" %> +

-
> -

- <%= f.text_field :search_name, :size => 25 %> -

- <%= f.select :search_results, options_for_select(@author_options) %> -

+

+

+
-

-

-
- -
+

diff -r bdecc47b65b8 -r e9bfba17e791 plugins/redmine_bibliography/assets/javascripts/authors.js --- a/plugins/redmine_bibliography/assets/javascripts/authors.js Fri May 10 17:50:56 2013 +0100 +++ b/plugins/redmine_bibliography/assets/javascripts/authors.js Fri May 10 17:59:12 2013 +0100 @@ -14,6 +14,30 @@ $(link).closest(".fields").hide(); } +$(".author_search").live('keyup.autocomplete', function(){ + $this = $(this); + + $.ajax({ + type: "POST", + url: "/publications/autocomplete_for_author", + dataType: "json", + data: { + q: $this.val() + }, + + success: function(data, type) { + console.log("OK: " + data); + items = data; + response(items); + }, + + error: function(data, type){ + console.log("ERROR: " + type); + } + }); +}); + + function identify_author_status(status, object_id) { $('publication_authorships_attributes_' + object_id + '_edit_author_info').select('input').each(function(s) { if(status == "no"){