# HG changeset patch # User luisf # Date 1380558692 -3600 # Node ID 35732ac4324acfd1287706e42eda6e7b9851e4c8 # Parent 5cb7eeccede15bc5fc58ce63927554ba28ea42ea hiding some fields; deleted unused code; fixed bug in ajax autocomplete function. diff -r 5cb7eeccede1 -r 35732ac4324a plugins/redmine_bibliography/app/models/authorship.rb --- a/plugins/redmine_bibliography/app/models/authorship.rb Mon Sep 30 13:53:20 2013 +0100 +++ b/plugins/redmine_bibliography/app/models/authorship.rb Mon Sep 30 17:31:32 2013 +0100 @@ -52,10 +52,6 @@ @search_author_class || aclass end - # def search_author_class=(search_author_class) - # @search_author_class = search_author_class - # end - def search_author_id if self.author.nil? authid = "" @@ -99,44 +95,42 @@ private def set_author - # if an author, simply associates with it - # if an user, checks if it has already an author associated with it - # if so, assicoates with that author - # otherwise, creates a new author + # do we want to associate the authorship + # with an existing author/user? + if @search_author_tie + # if an author, simply associates with it + # if an user, checks if it has already an author associated with it + # if so, associates with that author + # otherwise, creates a new author - logger.error { "%%%%%%%%%%%%%%% Associate Author User %%%%%%%%%%%%%%" } + case @search_author_class + when "" + author = Author.new + author.save - logger.error { "Me #{self.to_yaml}" } - logger.error { "Class: #{@search_author_class}" } - logger.error { "ID #{@search_author_id}" } + when "User" + user = User.find(@search_author_id) - case @search_author_class - when "" - logger.debug { "Adding new author to the database." } + if user.author.nil? + # User w/o author: + # create new author and update user + author = Author.new + author.save + user.author = author + user.save + else + author = user.author + end + + when "Author" + author = Author.find(@search_author_id) + end + + # if we don't want to associate with an existing author/user + else + # todo: should we delete any previously existing relationship? author = Author.new author.save - - when "User" - # get user id - user = User.find(@search_author_id) - logger.error { "Found user with this ID: #{user.id}" } - - if user.author.nil? - logger.error { "The user has no author... creating one!" } - - # User w/o author: - # create new author and update user - author = Author.new - author.save - user.author = author - user.save - else - logger.error { "found an author!" } - author = user.author - end - - when "Author" - author = Author.find(@search_author_id) end self.author = author diff -r 5cb7eeccede1 -r 35732ac4324a plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb --- a/plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb Mon Sep 30 13:53:20 2013 +0100 +++ b/plugins/redmine_bibliography/app/views/publications/_authorship_fields.html.erb Mon Sep 30 17:31:32 2013 +0100 @@ -5,13 +5,13 @@

<%= f.text_field :institution -%>

<%= f.text_field :email -%>

-

- <%= f.check_box :search_author_tie, :style => "float:left;" -%> +

+ <%= f.check_box :search_author_tie -%>

- <%= f.text_field :search_author_class -%> - <%= f.text_field :search_author_id -%> + <%= f.hidden_field :search_author_class -%> + <%= f.hidden_field :search_author_id -%>
diff -r 5cb7eeccede1 -r 35732ac4324a plugins/redmine_bibliography/assets/javascripts/authors.js --- a/plugins/redmine_bibliography/assets/javascripts/authors.js Mon Sep 30 13:53:20 2013 +0100 +++ b/plugins/redmine_bibliography/assets/javascripts/authors.js Mon Sep 30 17:31:32 2013 +0100 @@ -28,8 +28,6 @@ $this.closest('div').find("input[id$='search_author_id']").val(ui.item.search_author_id); $this.closest('div').find("input[id$='search_author_tie']").attr('checked', 'checked'); - - // triggers the save button $this.closest('div').next('div').find('.author_save_btn').click(); } @@ -37,7 +35,7 @@ .data( "autocomplete" )._renderItem = function( ul, item ) { return $( "
  • " ) .data("item.autocomplete", item ) - .append( "" + item.label + "
    " + item.email + "
    " + item.intitution + "
    " ) + .append( "" + item.label + "
    " + item.email + "
    " + item.institution + "
    " ) .appendTo(ul); }; }); diff -r 5cb7eeccede1 -r 35732ac4324a plugins/redmine_bibliography/assets/stylesheets/bibliography.css --- a/plugins/redmine_bibliography/assets/stylesheets/bibliography.css Mon Sep 30 13:53:20 2013 +0100 +++ b/plugins/redmine_bibliography/assets/stylesheets/bibliography.css Mon Sep 30 17:31:32 2013 +0100 @@ -66,6 +66,7 @@ background-image: url(../../../images/loading.gif); } -.author_edit_btn { - display:none; +.authorship_tie { + display: none; + float: left; }