# HG changeset patch # User luisf # Date 1308768151 -3600 # Node ID c1ecc16cf38e028b3731b79326e46fa68cd8fda0 # Parent a7dc708d48a183c63589afabd4d90d0c4c53f8e9 addin/removing authors - not finished diff -r a7dc708d48a1 -r c1ecc16cf38e vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb --- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Wed Jun 22 13:10:59 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Wed Jun 22 19:42:31 2011 +0100 @@ -3,7 +3,7 @@ class PublicationsController < ApplicationController unloadable - before_filter :find_project_by_project_id, :except => [:autocomplete_for_project] + before_filter :find_project_by_project_id, :except => [:autocomplete_for_project, :add_author] def new @@ -16,12 +16,8 @@ @publication.authors.build @project_id = params[:project_id] - - # the step we're at in the form - # @publication.current_step = session[:publication_step] + @current_user = User.current - @new_publications = [] - session[:publications] ||= {} end def create @@ -68,6 +64,16 @@ end + def add_author + if (request.xhr?) + render :text => User.find(params[:user_id]).name + else + # No? Then render an action. + #render :action => 'view_attribute', :attr => @name + logger.error { "ERRO ADD AUTHOR" } + end + end + def edit @publication = Publication.find(params[:id]) diff -r a7dc708d48a1 -r c1ecc16cf38e vendor/plugins/redmine_bibliography/app/views/publications/_authors_fields.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/_authors_fields.html.erb Wed Jun 22 13:10:59 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_authors_fields.html.erb Wed Jun 22 19:42:31 2011 +0100 @@ -1,7 +1,5 @@ -

+

<%= f.label :name, l("name") %> <%= f.text_field :name %> + <%= f.hidden_field :_destroy %> + <%= link_to_function "Remove", "remove_author(this)" %>

-<%= f.check_box :_destroy %> -<%= f.label :_destroy, l("remove") %> - - diff -r a7dc708d48a1 -r c1ecc16cf38e vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb Wed Jun 22 13:10:59 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb Wed Jun 22 19:42:31 2011 +0100 @@ -1,10 +1,24 @@ +<% content_for :header_tags do %> + <%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %> +<% end %> + + <% form_for @publication, :url => { :project_id => @project_id, :action => :create } do |f| -%> <%= f.error_messages %>

<%= f.label :title, l(:title) %> <%= f.text_field :title %>

-

<%= l(:authors) %>

+

<%= 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' } %> + +
aaa
+ + + + + + <%- f.fields_for :authors do |builder| -%> <%= render :partial => 'authors_fields', :locals => { :f => builder} %> <%- end -%> diff -r a7dc708d48a1 -r c1ecc16cf38e vendor/plugins/redmine_bibliography/assets/javascripts/authors.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Wed Jun 22 19:42:31 2011 +0100 @@ -0,0 +1,4 @@ +function remove_author(link){ + $(link).previous("input[type=hidden]").value = 1; + $(link).up(".author_fields").hide(); +} \ No newline at end of file diff -r a7dc708d48a1 -r c1ecc16cf38e vendor/plugins/redmine_bibliography/config/locales/en.yml --- a/vendor/plugins/redmine_bibliography/config/locales/en.yml Wed Jun 22 13:10:59 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/config/locales/en.yml Wed Jun 22 19:42:31 2011 +0100 @@ -4,6 +4,9 @@ authors: "Authors" author: "Author" name: "Name" + + add_me_as_author: "Add me as an author" + add_another_author: "Add another author" remove: "Remove"