# HG changeset patch # User luisf # Date 1308924690 -3600 # Node ID 49fb7a9ef79c5915049263e462609a9fdffb4bea # Parent 30b36ab6f15a364751cb2ce601e10d835a0f080e Using Authorships instead of Authors in the new/show actions of the publication controller. diff -r 30b36ab6f15a -r 49fb7a9ef79c vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb --- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Fri Jun 24 11:41:01 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Fri Jun 24 15:11:30 2011 +0100 @@ -3,7 +3,7 @@ class PublicationsController < ApplicationController unloadable - before_filter :find_project_by_project_id, :except => [:autocomplete_for_project, :add_author] + before_filter :find_project_by_project_id, :except => [:autocomplete_for_project, :add_author, :sort_authors] def new @@ -13,7 +13,7 @@ @publication.build_bibtex_entry # and at least one author - 3.times {@publication.authors.build} + @publication.authorships.build.build_author @project_id = params[:project_id] @current_user = User.current @@ -52,16 +52,6 @@ if bibtex_entry parse_bibtex_list bibtex_entry end - - # form's flow control - if params[:back_button] - @publication.previous_step - else - @publication.next_step - end - - session[:publication_step] = @publication.current_step - end def add_author @@ -186,7 +176,6 @@ end - def add_project @projects = Project.find(params[:publication][:project_ids]) @@ -209,6 +198,15 @@ logger.debug "Query for \"#{params[:q]}\" returned \"#{@projects.size}\" results" render :layout => false end + + + def sort_authors + params[:authors].each_with_index do |id, index| + Author.update_all(['order=?', index+1], ['id=?', id]) + end + render :nothing => true + end + private diff -r 30b36ab6f15a -r 49fb7a9ef79c vendor/plugins/redmine_bibliography/app/views/publications/_author_fields.rhtml --- a/vendor/plugins/redmine_bibliography/app/views/publications/_author_fields.rhtml Fri Jun 24 11:41:01 2011 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -
-

- <%= f.label :name, l("name") %> - <%= f.text_field :name %> - <%= f.hidden_field :_destroy %> - <%= link_to_remove_fields "remove", f %>
-

-
\ No newline at end of file diff -r 30b36ab6f15a -r 49fb7a9ef79c vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Fri Jun 24 15:11:30 2011 +0100 @@ -0,0 +1,12 @@ +
+

+ <%= f.label :name_on_paper, l("name") %> + <%= f.text_field :name_on_paper %>
+ <%= h l("text_name_on_paper") %>
+ <%= f.label :institution, l("institution") %> + <%= f.text_field :institution %>
+ <%= h l("text_institution") %>
+ <%= f.hidden_field :_destroy %> + <%= link_to_remove_fields l("remove_author"), f %> +

+
\ No newline at end of file diff -r 30b36ab6f15a -r 49fb7a9ef79c vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb Fri Jun 24 11:41:01 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb Fri Jun 24 15:11:30 2011 +0100 @@ -11,15 +11,12 @@

<%= l(:authors) %>

- <%= link_to_remote l(:add_me_as_author), {:url => { :controller => 'publications', :action => 'add_author', :user_id => @current_user}, :update => 'users_div' }, { :id => 'add_me_as_an_author', :class => 'icon icon-add' } %> - - <% f.fields_for :authors do |builder| %> - <%= render "author_fields", :f => builder %> + <% f.fields_for :authorships do |builder| %> + <%= render "authorship_fields", :f => builder %> <% end %> -

<%= link_to_add_fields l(:add_another_author), f, :authors %>

+

<%= link_to_add_fields l(:add_another_author), f, :authorships %>

Other Details

- <% f.fields_for :bibtex_entry do |builder| -%> <%= render :partial => 'bibtex_fields', :locals => { :f => builder} %> <%- end -%> diff -r 30b36ab6f15a -r 49fb7a9ef79c vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb Fri Jun 24 11:41:01 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb Fri Jun 24 15:11:30 2011 +0100 @@ -4,10 +4,17 @@

Title

<%= h @publication.title %> -

Authors

- <% for author in @publication.authors %> - <%= h author.name %>
+

<%= l(:authors) %>

+ +<%= sortable_element("authorships", :url => { :controller => :publications, :action => :sort_authors }) %> +
<%- if @publication.bibtex_entry != nil -%> diff -r 30b36ab6f15a -r 49fb7a9ef79c vendor/plugins/redmine_bibliography/config/locales/en.yml --- a/vendor/plugins/redmine_bibliography/config/locales/en.yml Fri Jun 24 11:41:01 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/config/locales/en.yml Fri Jun 24 15:11:30 2011 +0100 @@ -8,15 +8,22 @@ add_me_as_author: "Add me as an author" add_another_author: "Add another author" - remove: "Remove" + remove_author: "Remove this author" label_publications_plural: "Publications" label_publication_new: "Add Publication" label_add_project_to_publication: "Add Project to Publication" label_project_search: "Search by name: " + text_institution: "Please insert the institution as it appears on the paper." + text_name_on_paper: "Please insert the name of the author as it appears on the paper." + + # authorships model + institution: "Institution" + naem_on_paper: "Name" + - # bibtex_entries strings + # bibtex_entries model id: "id" publication_id: "Publication_id" entry_type: "Entry Type" diff -r 30b36ab6f15a -r 49fb7a9ef79c vendor/plugins/redmine_bibliography/config/routes.rb --- a/vendor/plugins/redmine_bibliography/config/routes.rb Fri Jun 24 11:41:01 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/config/routes.rb Fri Jun 24 15:11:30 2011 +0100 @@ -1,3 +1,3 @@ ActionController::Routing::Routes.draw do |map| - map.resources :publications + map.resources :publications, :collection => { :sort_authors => :post } end \ No newline at end of file