Mercurial > hg > soundsoftware-site
changeset 1364:4d5d25039a5f luisf
Fixes Bug #668 - reordering of authors in the publication's detail view is working again.
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Mon, 19 Aug 2013 15:47:51 +0100 |
parents | 855b4ae5ecdd |
children | 72b6d7a2383d |
files | plugins/redmine_bibliography/app/controllers/authorships_controller.rb plugins/redmine_bibliography/app/models/authorship.rb plugins/redmine_bibliography/app/views/publications/show.html.erb plugins/redmine_bibliography/config/routes.rb |
diffstat | 4 files changed, 21 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/redmine_bibliography/app/controllers/authorships_controller.rb Mon Aug 19 13:40:58 2013 +0100 +++ b/plugins/redmine_bibliography/app/controllers/authorships_controller.rb Mon Aug 19 15:47:51 2013 +0100 @@ -1,10 +1,15 @@ class AuthorshipsController < ApplicationController - - def index - - end - - def update - end + def sort + @authorships = Authorship.find(params['authorship']) + + @authorships.each do |authorship| + + # note: auth_order is usually called position (default column name in the acts_as_list plugin ) + authorship.auth_order = params['authorship'].index(authorship.id.to_s) + 1 + authorship.save + end + + render :nothing => true, :status => 200 + end end
--- a/plugins/redmine_bibliography/app/models/authorship.rb Mon Aug 19 13:40:58 2013 +0100 +++ b/plugins/redmine_bibliography/app/models/authorship.rb Mon Aug 19 15:47:51 2013 +0100 @@ -10,7 +10,8 @@ validates_presence_of :name_on_paper attr_accessor :search_author_class, :search_author_id, :search_name, :search_results, :identify_author - before_save :associate_author_user + + before_create :associate_author_user # tod: review scope of ordering acts_as_list :column => 'auth_order'
--- a/plugins/redmine_bibliography/app/views/publications/show.html.erb Mon Aug 19 13:40:58 2013 +0100 +++ b/plugins/redmine_bibliography/app/views/publications/show.html.erb Mon Aug 19 15:47:51 2013 +0100 @@ -1,3 +1,5 @@ +<%= javascript_include_tag 'order_authorships', :plugin => 'redmine_bibliography' %> + <h2><%=l(:label_publication_show)%></h2> <div class="box">
--- a/plugins/redmine_bibliography/config/routes.rb Mon Aug 19 13:40:58 2013 +0100 +++ b/plugins/redmine_bibliography/config/routes.rb Mon Aug 19 15:47:51 2013 +0100 @@ -9,6 +9,11 @@ match "publications/autocomplete_for_project", :to => 'publications#autocomplete_for_project' + resources :authorships do + collection do + post 'sort', :action => 'sort' + end + end resources :publications end \ No newline at end of file