Mercurial > hg > soundsoftware-site
diff vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb @ 598:c6cfe1f2eac1 feature_36
Correctly updating the fields with the author info.
author | luisf <luis.figueira@eecs.qmul.ac.uk> |
---|---|
date | Tue, 16 Aug 2011 15:36:32 +0100 |
parents | 70f0276fde9a |
children | c3c1091639ad |
line wrap: on
line diff
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Tue Aug 16 12:06:24 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Tue Aug 16 15:36:32 2011 +0100 @@ -4,7 +4,7 @@ unloadable model_object Publication - before_filter :find_model_object, :except => [:new, :create, :index, :autocomplete_for_project, :add_author, :sort_author_order, :autocomplete_for_author] + before_filter :find_model_object, :except => [:new, :create, :index, :autocomplete_for_project, :add_author, :sort_author_order, :autocomplete_for_author, :get_user_info ] # before_filter :find_project, :except => [:autocomplete_for_project, :add_author, :sort_authors, :autocomplete_for_author] @@ -20,12 +20,11 @@ @project_id = params[:project_id] @current_user = User.current - - @author_options = [] - + + # TODO - something more interesting here + @author_options = [["#{User.current.name} (#{User.current.mail})", "#{User.current.class.to_s}_#{User.current.id.to_s}"]] end - def create find_project_by_project_id @@ -204,7 +203,7 @@ @results = [] object_id = params[:object_id] - @object_name = "publications[authorships_attributes][#{object_id}]" + @object_name = "publications[authorships_attributes][#{object_id}][search_results]" logger.error { "OBJECT NAME #{@object_name}" } @@ -236,8 +235,29 @@ end # @results.uniq! + + render :layout => false + end + + + def get_user_info + object_id = params[:object_id] + value = params[:value] + classname = Kernel.const_get(value.split('_')[0]) - render :layout => false + item = classname.find(value.split('_')[1]) + + name_field = "publication_authorships_attributes_#{object_id}_name_on_paper".to_sym + email_field = "publication_authorships_attributes_#{object_id}_email".to_sym + + respond_to do |format| + format.js {logger.error { "JS" } + render(:update) {|page| + page[name_field].value = item.name + page[email_field].value = item.mail + } + } + end end def sort_author_order