Mercurial > hg > soundsoftware-site
changeset 1281:e9bfba17e791 redmine-2.2-integration
changes to the authors search ajax (not finished).
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Fri, 10 May 2013 17:59:12 +0100 |
parents | bdecc47b65b8 |
children | 8d30e7644b75 |
files | plugins/redmine_bibliography/app/helpers/publications_helper.rb plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb plugins/redmine_bibliography/assets/javascripts/authors.js |
diffstat | 3 files changed, 35 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- 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 = "<em>No Authors found that match your search… sorry!</em>" end
--- 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 %> <div id="authors" class="fields"> -<!-- <h4><%= l("label_author_1") %></h4> --> + <div id="<%= form_tag_id( f.object_name, :search_author ) %>" style=<%= "display:none;" unless params[:action] == "new" %> > + <p> + <%= f.text_field :search_name, :size => 25, :class => "author_search" %> + </p> - <div id="<%= form_tag_id( f.object_name, :search_author ) %>" style=<%= "display:none;" unless params[:action] == "new" %> > - <p> - <%= f.text_field :search_name, :size => 25 %> - <p> - <%= f.select :search_results, options_for_select(@author_options) %> - </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 /> - <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 /> - - <label class='inline'><%= radio_button_tag(:identify_author, "correct", false, :name => form_tag_name(f.object_name,:identify_author ), :id => form_tag_id( f.object_name, :identify_author_corrections ), :onchange => "identify_author_status($(this).value, #{form_object_id(f.object_name) });") %> <%= l(:identify_author_correct) %> </label><br /> + <label class='inline'><%= radio_button_tag(:identify_author, "correct", false, :name => form_tag_name(f.object_name,:identify_author ), :id => form_tag_id( f.object_name, :identify_author_corrections ), :onchange => "identify_author_status($(this).value, #{form_object_id(f.object_name) });") %> <%= l(:identify_author_correct) %> </label><br /> <label class='inline'><%= radio_button_tag(:identify_author, "no", true, :name => form_tag_name(f.object_name,:identify_author ), :id => form_tag_id( f.object_name, :identify_author_no ), :onchange => "identify_author_status($(this).value, #{form_object_id(f.object_name) });") %> <%= l(:identify_author_no) %> </label><br /> </p>
--- 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"){