# HG changeset patch # User luisf # Date 1308911003 -3600 # Node ID ae87ae455cfb2b69d4cbd3ec8861f7d6529cf666 # Parent 0bb9c7baed073332b6b18e0363b03beff799d275 correctly saving authors. diff -r 0bb9c7baed07 -r ae87ae455cfb vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb --- a/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Thu Jun 23 18:52:30 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Fri Jun 24 11:23:23 2011 +0100 @@ -1,7 +1,6 @@ require 'bibtex' module PublicationsHelper - def projects_check_box_tags(name, projects) s = '' projects.sort.each do |project| @@ -10,6 +9,10 @@ s end + def link_to_remove_fields(name, f) + f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)") + end + def link_to_add_fields(name, f, association) new_object = f.object.class.reflect_on_association(association).klass.new fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| diff -r 0bb9c7baed07 -r ae87ae455cfb vendor/plugins/redmine_bibliography/app/views/publications/_author_fields.rhtml --- a/vendor/plugins/redmine_bibliography/app/views/publications/_author_fields.rhtml Thu Jun 23 18:52:30 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_author_fields.rhtml Fri Jun 24 11:23:23 2011 +0100 @@ -1,8 +1,8 @@ -
- <% fields_for :authors do |author_form| -%> - <%= author_form.label :name, l("name") %> <%= author_form.text_field :name %> - <%= author_form.hidden_field :_destroy %> - - <%= link_to_function "Remove", "remove_author(this)" %> - <% end -%> -
+
+

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

+
\ No newline at end of file diff -r 0bb9c7baed07 -r ae87ae455cfb vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb Thu Jun 23 18:52:30 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_edit.html.erb Fri Jun 24 11:23:23 2011 +0100 @@ -4,19 +4,19 @@ <% form_for @publication, :url => { :project_id => @project_id, :action => :create } do |f| -%> - <%= f.error_messages %> - -

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

+ <%= f.error_messages %> +

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

<%= 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' } %> - -
- <%= link_to_add_fields l(:add_another_author), f, :authors %> - - <%= render :partial => 'author_fields', :collection => @publication.authors %> -
+ <% f.fields_for :authors do |builder| %> + <%= render "author_fields", :f => builder %> + <% end %> +

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

Other Details

diff -r 0bb9c7baed07 -r ae87ae455cfb vendor/plugins/redmine_bibliography/assets/javascripts/authors.js --- a/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Thu Jun 23 18:52:30 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Fri Jun 24 11:23:23 2011 +0100 @@ -3,8 +3,15 @@ $(link).up('.author_fields').remove(); } +function remove_fields(link) { + $(link).previous("input[type=hidden]").value = "1"; + $(link).up(".fields").hide(); +} + function add_fields(link, association, content) { var new_id = new Date().getTime(); var regexp = new RegExp("new_" + association, "g") - $(link).parent().before(content.replace(regexp, new_id)); + $(link).up().insert({ + before: content.replace(regexp, new_id) + }); } \ No newline at end of file