Mercurial > hg > soundsoftware-site
changeset 480:19efecf4561a feature_36
new controller logic.
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Thu, 30 Jun 2011 18:19:52 +0100 |
parents | 7be2c5d9ffa5 |
children | dd242ea99fd3 |
files | vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml vendor/plugins/redmine_bibliography/app/views/publications/_identify_author_form.html.erb vendor/plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.rhtml |
diffstat | 5 files changed, 44 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Thu Jun 30 12:54:10 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Thu Jun 30 18:19:52 2011 +0100 @@ -10,10 +10,10 @@ @publication = Publication.new # we'll always want a new publication to have its bibtex entry - @publication.build_bibtex_entry + # @publication.build_bibtex_entry # and at least one author - @publication.authorships.build.build_author + # @publication.authorships.build.build_author @project_id = params[:project_id] @current_user = User.current @@ -212,8 +212,20 @@ end def autocomplete_for_author - @authors = Author.like(params[:q]).find(:all, :limit => 100) - logger.debug "Query for \"#{params[:q]}\" returned \"#{@authors.size}\" results" + @authors = [] + + authors_list = Author.like(params[:q]).find(:all, :limit => 100) + users_list = User.active.like(params[:q]).find(:all, :limit => 100) + + logger.debug "Query for \"#{params[:q]}\" returned \"#{authors_list.size}\" authors and \"#{users_list.size}\"" + + # need to subtract both lists + # give priority to the users + + authors_list.each do |author| + @authors << author unless author.user_id.nil? + end + render :layout => false end
--- a/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Thu Jun 30 12:54:10 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Thu Jun 30 18:19:52 2011 +0100 @@ -9,15 +9,14 @@ s end - def link_to_author(author, options={}, html_options = nil) - #TODO luisf - h(author.name) + def identify_author(author) + link_to_function(author.name, "console.log($(this).up('div').up('div').select('input[id$=name_on_paper]'))") end - def authors_check_box_tags(name, authors) + def choose_author_link(name, authors) s = '' authors.sort.each do |author| - s << "<label>#{ check_box_tag name, author.id, false } #{link_to_author author}</label>\n" + s << "#{identify_author author}\n" end s end
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Thu Jun 30 12:54:10 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Thu Jun 30 18:19:52 2011 +0100 @@ -1,11 +1,10 @@ <div class="fields"> - <p> + <p> <%= f.label :name_on_paper, l("name") %> <%= f.text_field :name_on_paper %><br /> <em><%= h l("text_author_name_on_paper") %></em><br /> - <%= render :partial => 'identify_author_form' %> - </br> + <%= render :partial => 'identify_author_form' %></br> <%= f.label :institution, l("institution") %> <%= f.text_field :institution %><br /> @@ -17,5 +16,6 @@ <%= f.hidden_field :_destroy %> <%= link_to_remove_fields l("remove_author"), f %> + </p> </div> \ No newline at end of file
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_identify_author_form.html.erb Thu Jun 30 12:54:10 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_identify_author_form.html.erb Thu Jun 30 18:19:52 2011 +0100 @@ -1,35 +1,25 @@ -<% form_remote_for(:publication, - :url => {:controller => 'publications', :action => 'identify_author', :id => @publication, :project_id => @project}, - :method => :post, - :html => { :id => 'add_project_form' }, - :loading => "$('project-add-submit').disable()", - :complete => "$('project-add-submit').enable()") do |f| %> - - <legend><%= "Identify Authors in the system…" %></legend> +<legend><%= "Identify Authors in the system…" %></legend> - <%= link_to_remote "It's me!", - { :url => { :controller => 'publications', - :action => 'add_me_as_author', - :project_id => @project }, :method => 'post'}, - { :class => 'icon icon-add', :id => "add_me_as_author" } %> +<%= link_to_remote "It's me!", + { :url => { :controller => 'publications', + :action => 'add_me_as_author', + :project_id => @project }, :method => 'post'}, + { :class => 'icon icon-add', :id => "add_me_as_author" } %> - <p> - <%= label_tag "author_search", l(:label_project_search) %><%= text_field_tag 'author_search', nil %> - </p> +<p> + <%= label_tag "author_search", l(:label_project_search) %><%= text_field_tag 'author_search', nil %> +</p> - <%= observe_field(:author_search, - :frequency => 0.5, - :update => :projects, - :url => { :controller => 'publications', :action => 'autocomplete_for_author' }, - :with => 'q') - %> +<%= observe_field(:author_search, + :frequency => 0.5, + :update => :identify_author, + :url => { :controller => 'publications', :action => 'autocomplete_for_author' }, + :with => 'q') +%> - <div id="projects"> - <% if params[:q] && params[:q].length > 1 %> - <%= authors_check_box_tags 'author[author_ids][]', @projects %> - <% end %> - </div> +<div id="identify_author"> + <% if params[:q] && params[:q].length > 1 %> + <%= select_author_links 'author[author_ids][]', @authors %> + <% end %> +</div> - <p><%= submit_tag l(:button_add), :id => 'project-add-submit' %></p> - - <% end %>
--- a/vendor/plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.rhtml Thu Jun 30 12:54:10 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.rhtml Thu Jun 30 18:19:52 2011 +0100 @@ -1,3 +1,3 @@ <% if params[:q] && params[:q].length > 1 %> - <%= authors_check_box_tags 'publication[author_ids][]', @authors %> + <%= choose_author_link 'publication[author_ids][]', @authors %> <% end %>