Mercurial > hg > soundsoftware-site
changeset 640:47b21bb3fa03 cannam_integration
Merge from branch "feature_36"
author | Chris Cannam <chris.cannam@soundsoftware.ac.uk> |
---|---|
date | Tue, 06 Sep 2011 12:23:51 +0100 |
parents | 031d70972601 (current diff) d0fec261c169 (diff) |
children | b4e9410882f1 |
files | |
diffstat | 26 files changed, 617 insertions(+), 314 deletions(-) [+] |
line wrap: on
line diff
--- a/public/stylesheets/application.css Tue Aug 09 16:02:08 2011 +0100 +++ b/public/stylesheets/application.css Tue Sep 06 12:23:51 2011 +0100 @@ -251,6 +251,11 @@ border: 1px solid #e4e4e4; } +.box h4 { +margin-top: 0; +padding-top: 0; +} + div.square { border: 1px solid #999; float: left; @@ -400,13 +405,16 @@ p.pagination {margin-top:8px;} /***** Tabular forms ******/ -.tabular p{ +.tabular p, .tabular ul{ margin: 0; padding: 5px 0 8px 0; padding-left: 180px; /*width of left column containing the label elements*/ height: 1%; clear:left; } +.tabular ul{ +margin-top: -4px; +} html>body .tabular p {overflow:hidden;} @@ -419,6 +427,15 @@ margin*/ } +.tabular .splitcontentleft .box p, .tabular .splitcontentright .box p, .splitcontentleft .tabular p, .splitcontentright .tabular p, .tabular .splitcontentleft .box ul, .tabular .splitcontentright .box ul, .splitcontentleft .tabular ul, .splitcontentright .tabular ul { +padding-left: 120px; +} + +.tabular .splitcontentleft .box label, .tabular .splitcontentright .box label, .splitcontentleft .tabular label, .splitcontentright .tabular label { +margin-left: -120px; +width: 115px; +} + .tabular label.floating{ font-weight: normal; margin-left: 0px;
--- a/vendor/plugins/redmine_bibliography/app/controllers/authors_controller.rb Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/authors_controller.rb Tue Sep 06 12:23:51 2011 +0100 @@ -1,7 +1,13 @@ class AuthorsController < ApplicationController + helper :publications + include PublicationsHelper def index @authors = Author.find(:all) end + def show + @author = Author.find(params[:id]) + end + end
--- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Tue Sep 06 12:23:51 2011 +0100 @@ -1,12 +1,12 @@ +# -*- coding: utf-8 -*- # vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb class PublicationsController < ApplicationController 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_project, :except => [:autocomplete_for_project, :add_author, :sort_authors, :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_by_project_id, :authorize, :only => [ :edit, :new, :update, :create ] def new find_project_by_project_id @@ -16,26 +16,25 @@ @publication.build_bibtex_entry # and at least one author - # @publication.authorships.build.build_author - - @project_id = params[:project_id] - @current_user = User.current + # @publication.authorships.build.build_author + @author_options = [["#{User.current.name} (#{User.current.mail})", "#{User.current.class.to_s}_#{User.current.id.to_s}"]] + + end + def create + @project = Project.find(params[:project_id]) - def create - find_project_by_project_id - + @author_options = [["#{User.current.name} (#{User.current.mail})", "#{User.current.class.to_s}_#{User.current.id.to_s}"]] + @publication = Publication.new(params[:publication]) - - # @project = Project.find(params[:project_id]) @publication.projects << @project unless @project.nil? if @publication.save flash[:notice] = "Successfully created publication." - redirect_to :action => :show, :id => @publication, :project_id => @project.id + redirect_to :action => :show, :id => @publication, :project_id => @project else - render :action => 'new' + render :action => 'new', :project_id => @project end end @@ -73,14 +72,23 @@ def edit find_project_by_project_id unless params[:project_id].nil? - + + @edit_view = true; + + @options = [["#{User.current.name} (#{User.current.mail})", "#{User.current.class.to_s}_#{User.current.id.to_s}"]] @publication = Publication.find(params[:id]) - @selected_bibtex_entry_type_id = @publication.bibtex_entry.entry_type + @selected_bibtex_entry_type_id = @publication.bibtex_entry.entry_type + + # todo: should be removed? + @author_options = [["#{User.current.name} (#{User.current.mail})", "#{User.current.class.to_s}_#{User.current.id.to_s}"]] end def update @publication = Publication.find(params[:id]) + # todo: should be removed? + @author_options = [["#{User.current.name} (#{User.current.mail})", "#{User.current.class.to_s}_#{User.current.id.to_s}"]] + logger.error { "INSIDE THE UPDATE ACTION IN THE PUBLICATION CONTROLLER" } if @publication.update_attributes(params[:publication]) @@ -99,11 +107,9 @@ def show find_project_by_project_id unless params[:project_id].nil? - @publication = Publication.find(params[:id]) - if @publication.nil? - @publications = Publication.all - render "index", :alert => 'The publication was not found!' + @publications = Publication.all + render "index", :alert => 'The publication was not found!' else @authors = @publication.authors @bibtext_entry = @publication.bibtex_entry @@ -189,17 +195,6 @@ end - def add_project - @projects = Project.find(params[:publication][:project_ids]) - @publication = Publication.find(params[:id]) - @publication.projects << @projects - - # TODO luisf should also respond to HTML??? - respond_to do |format| - format.js - end - end - def autocomplete_for_project @publication = Publication.find(params[:id]) @@ -208,25 +203,65 @@ render :layout => false end - def autocomplete_for_author + def autocomplete_for_author @results = [] - authors_list = Author.like(params[:q]).find(:all, :limit => 100) + object_id = params[:object_id] + @object_name = "publications[authorships_attributes][#{object_id}][search_results]" + + authorships_list = Authorship.like_unique(params[:q]).find(:all, :limit => 100) users_list = User.active.like(params[:q]).find(:all, :limit => 100) - logger.debug "Query for \"#{params[:q]}\" returned \"#{authors_list.size}\" authors and \"#{users_list.size}\" users" + logger.debug "Query for \"#{params[:q]}\" returned \"#{authorships_list.size}\" authorships and \"#{users_list.size}\" users" - # need to subtract both lists - # give priority to the users - users_list.each do |user| - @results << user + @results = users_list + + # TODO: can be optimized… + authorships_list.each do |authorship| + flag = true + + users_list.each do |user| + if authorship.name == user.name && authorship.email == user.mail && authorship.institution == user.institution + Rails.logger.debug { "Rejecting Authorship #{authorship.id}" } + flag = false + break + end + end + + @results << authorship if flag end + + render :layout => false + end + + + def get_user_info + object_id = params[:object_id] + value = params[:value] + classname = Kernel.const_get(value.split('_')[0]) + + 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 + institution_field = "publication_authorships_attributes_#{object_id}_institution".to_sym - authors_list.each do |author| - @results << author unless users_list.include?(author.user) + yes_radio = "publication_authorships_attributes_#{object_id}_identify_author_yes".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 + page[institution_field].value = item.institution + + page[yes_radio].checked = true + page[name_field].readOnly = true + page[email_field].readOnly = true + page[institution_field].readOnly = true + } + } end - - render :layout => false end def sort_author_order @@ -235,26 +270,44 @@ end render :nothing => true end + + def add_project + @projects = Project.find(params[:publication][:project_ids]) + @publication.projects << @projects + @project = Project.find(params[:project_id]) + + # TODO luisf should also respond to HTML??? + respond_to do |format| + format.html { redirect_to :back } + format.js { + render(:update) {|page| + page[:add_project_form].reset + page.replace_html :list_projects, :partial => 'list_projects' + } + } + end + end - def remove_from_project_list - pub = Publication.find(params[:id]) - proj = Project.find(params[:project_id]) + + def remove_project + @project = Project.find(params[:project_id]) + proj = Project.find(params[:remove_project_id]) - if pub.projects.length > 1 - if pub.projects.exists? proj - pub.projects.delete proj if request.post? + if @publication.projects.length > 1 + if @publication.projects.exists? proj + @publication.projects.delete proj if request.post? end else logger.error { "Cannot remove project from publication list" } end - respond_to do |format| - format.js { render(:update) {|page| page.replace_html "list_projects", :partial => 'list_projects', :id => pub} } - end + logger.error { "CURRENT project name#{proj.name} and wanna delete #{@project.name}" } + + render(:update) {|page| + page.replace_html "list_projects", :partial => 'list_projects', :id => @publication + } + end - - end - def destroy find_project_by_project_id @@ -264,10 +317,6 @@ redirect_to :controller => :publications, :action => 'index', :project_id => @project end - def identify_author - - end - private end
--- a/vendor/plugins/redmine_bibliography/app/helpers/authors_helper.rb Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/helpers/authors_helper.rb Tue Sep 06 12:23:51 2011 +0100 @@ -17,4 +17,12 @@ s end + + # Generates a link to an author + # todo: test options + def link_to_author(author, options={}, html_options = nil) + url = {:controller => 'authors', :action => 'show', :id => author}.merge(options) + link_to(h(author.name), url, html_options) + end + end
--- a/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Tue Sep 06 12:23:51 2011 +0100 @@ -1,6 +1,13 @@ +# -*- coding: utf-8 -*- require 'bibtex' module PublicationsHelper + + def link_to_publication(publication, options={}, html_options = nil) + url = {:controller => 'publications', :action => 'show', :id => publication}.merge(options) + link_to(h(publication.title), url, html_options) + end + def projects_check_box_tags(name, projects) s = '' projects.sort.each do |project| @@ -9,49 +16,26 @@ s end - def identify_author(author) - if author.class == User - - Rails.logger.debug { "Identify Author: USER" } - - author_info = { - :name_on_paper => author.name, - :email => author.mail, - :user_id => author.id, - :institution => "", - :is_user => "1" - } - - unless author.ssamr_user_detail.nil? - author_info[:institution] = author.ssamr_user_detail.institution_name - end + def choose_author_link(object_name, items) + # called by autocomplete_for_author (publications' action/view) + # creates the select list based on the results array + # results is an array with both Users and Authorships objects + + @author_options = [] + @results.each do |result| + @author_options << ["#{result.name} (#{result.mail})", "#{result.class.to_s}_#{result.id.to_s}"] + end - else - if author.class == Author - Rails.logger.debug { "Identify Author: AUTHOR" } - - author_info = { - :name_on_paper => author.name, - :user_id => author.user_id, - :id => author.id, - :is_user => "0" - } - end - end - - link_to_function(author.name, "update_author_info(this," + author_info.to_json + ")") - end - - def choose_author_link(name, authors_users) - s = '' - authors_users.sort.each do |author_user| - s << "#{identify_author author_user}\n" - end - s + if @results.size > 0 + s = select_tag( form_tag_name(object_name, :author_search_results), options_for_select(@author_options), { :id => form_tag_id(object_name, :author_search_results), :size => 3} ) + s << observe_field( form_tag_id(object_name, :author_search_results), :on => 'click', :function => "alert('Element changed')", :with => 'q') + else + s = "<em>No Authors found that match your search… sorry!</em>" + end end def link_to_remove_fields(name, f) - f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)") + f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)", :class => 'icon icon-del') end def link_to_add_fields(name, f, association) @@ -69,17 +53,42 @@ def sanitized_method_name(method_name) method_name.sub(/\?$/, "") end - + + def form_tag_name(object_name, method_name) + str = "#{object_name.to_s}[#{sanitized_method_name(method_name.to_s)}]" + str.to_sym + end + def form_tag_id(object_name, method_name) str = "#{sanitized_object_name(object_name.to_s)}_#{sanitized_method_name(method_name.to_s)}" str.to_sym end + def form_object_id(object_name) + str = object_name.split("\[").last().gsub("\]","") + str.to_sym + end + def render_projects_list(publication) + logger.error { "PROJECT NAME #{@project.name unless @project.nil?}" } + s = "" - + publication.projects.each do |proj| - s << link_to_project(proj) + link_to_remote(l(:button_delete), { :url => { :controller => 'publications', :action => 'remove_from_project_list', :id => publication, :project_id => proj }, :method => :post }, :class => 'icon icon-del') + "<br />" + s << link_to_project(proj, {}, :class => 'publication_project') + + if User.current.allowed_to?(:edit_publication, @project) + if @project == proj + confirm_msg = 'Are you sure you want to remove the current project from this publication\'s projects list?' + else + confirm_msg = false + end + + s << link_to_remote(l(:button_delete), { :url => { :controller => 'publications', :action => 'remove_project', :id => publication, :remove_project_id => proj, :project_id => @project }, :method => :post, :confirm => confirm_msg }, :class => 'icon icon-del') + end + + s << "<br />" + end s @@ -87,17 +96,17 @@ def show_bibtex_fields(bibtex_entry) s = "" - - bibtex_entry.attributes.each do |field| - if field[1] != nil - s << "<h4>" + field[0].titleize + "</h4>" - - if field[0] == "entry_type" - s << bibtex_entry.entry_type_name.capitalize - else - s << bibtex_entry.attributes[field[0]].to_s - end + bibtex_entry.attributes.keys.sort.each do |key| + value = bibtex_entry.attributes[key].to_s + next if key == 'id' or key == 'publication_id' or value == "" + s << "<h4>" + l("field_#{key}") + "</h4>" + s << "<p>" + if key == "entry_type" + s << bibtex_entry.entry_type_label + else + s << value end + s << "</p>" end s end
--- a/vendor/plugins/redmine_bibliography/app/models/authorship.rb Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/models/authorship.rb Tue Sep 06 12:23:51 2011 +0100 @@ -7,36 +7,63 @@ accepts_nested_attributes_for :author accepts_nested_attributes_for :publication - attr_accessor :is_user, :author_user_id + attr_accessor :is_user, :author_user_id, :search_name, :identify_author, :search_results before_save :associate_author_user + + named_scope :like_unique, lambda {|q| + s = "%#{q.to_s.strip.downcase}%" + {:conditions => ["LOWER(name_on_paper) LIKE :s OR LOWER(email) LIKE :s", {:s => s}], + :order => 'name_on_paper', + :group => "name_on_paper, institution, email" + } + } + + named_scope :like, lambda {|q| + s = "%#{q.to_s.strip.downcase}%" + {:conditions => ["LOWER(name_on_paper) LIKE :s OR LOWER(email) LIKE :s", {:s => s}], + :order => 'name_on_paper' + } + } + + def name + return self.name_on_paper + end + + def <=>(authorship) + name.downcase <=> authorship.name.downcase + end + + def mail + return self.email + end protected def associate_author_user - logger.error { "Before Save: associate_author_user" } - - case self.is_user - when "0" - author = Author.find(self.author_user_id) - self.author_id = author.id - when "1" - user = User.find(self.author_user_id) - - if user.author.nil? - author = Author.new :name => self.name_on_paper - author.save - self.author_id = author.id - user.author = author - user.save - else - author = user.author - self.author_id = author.id - end - else - author = Author.new :name => self.name_on_paper - logger.error { "SAVED AUTHOR" } + case self.identify_author + when "no" + author = Author.new author.save self.author_id = author.id - - end + else + selected = self.search_results + selected_classname = Kernel.const_get(selected.split('_')[0]) + selected_id = selected.split('_')[1] + object = selected_classname.find(selected_id) + + if object.respond_to? :name_on_paper + # Authorship + self.author_id = object.author.id + else + # User + unless object.author.nil? + self.author_id = object.author.id + else + author = Author.new + object.author = author + object.save + self.author_id = object.author.id + end + end + end end end
--- a/vendor/plugins/redmine_bibliography/app/models/bibtex_entry.rb Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/models/bibtex_entry.rb Tue Sep 06 12:23:51 2011 +0100 @@ -9,6 +9,9 @@ BibtexEntryType.find(entry_type).name end - + def entry_type_label + entry_type = self.entry_type + BibtexEntryType.find(entry_type).label + end end
--- a/vendor/plugins/redmine_bibliography/app/models/bibtex_entry_type.rb Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/models/bibtex_entry_type.rb Tue Sep 06 12:23:51 2011 +0100 @@ -1,2 +1,8 @@ class BibtexEntryType < ActiveRecord::Base + def redundant? + name == 'conference' # conference is a duplicate of inproceedings + end + def label + l("field_bibtex_#{name}") + end end
--- a/vendor/plugins/redmine_bibliography/app/views/authors/index.html.erb Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/authors/index.html.erb Tue Sep 06 12:23:51 2011 +0100 @@ -1,4 +1,4 @@ -<h2>Authors#index</h2> +<h2><%=l(:label_authors_index)%></h2> <table class="list authors"> <thead><tr> @@ -11,7 +11,7 @@ <% @authors.each do |author|%> <tr id="author-<%= author.id %>" class="<%= cycle('odd', 'even') %>"> <td class="title"> - <%= h author.name %> + <%= link_to_author author %> </td> <td class="username "> <%= link_to author.user unless author.user.nil? %>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/authors/show.html.erb Tue Sep 06 12:23:51 2011 +0100 @@ -0,0 +1,24 @@ +<h2><%=l(:label_authors_show)%></h2> + +<div class="splitcontentleft"> + <table class="list authors"> + <thead> + <tr> + <th><%=l(:field_authorship_publication_title)%></th> + <th><%=l(:field_authorship_name)%></th> + <th><%=l(:field_authorship_email)%></th> + <th><%=l(:field_authorship_institution)%></th> + </tr> + </thead> + + <% @author.authorships.each do |authorship| %> + <tr id="authorship-<%= authorship.id %>" class="<%= cycle('odd', 'even') %>"> + <td class="title"><%= link_to_publication(authorship.publication) %></td> + <td class="name"><%= h authorship.name_on_paper %></td> + <td class="email"><%= h authorship.email %></td> + <td class="institution"><%= h authorship.institution %></td> + </tr> + <% end %> + </tbody> + </table> +</div> \ No newline at end of file
--- a/vendor/plugins/redmine_bibliography/app/views/projects/show.rhtml Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/projects/show.rhtml Tue Sep 06 12:23:51 2011 +0100 @@ -4,7 +4,9 @@ <% end %> <% if @project.module_enabled? :redmine_bibliography %> - <%= link_to l(:label_add_publication_to_project), {:controller => 'publications', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %> + <% if User.current.allowed_to?(:add_publication, @project) %> + <%= link_to l(:label_add_publication_to_project), {:controller => 'publications', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %> + <% end %> <% end %> </div>
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Tue Sep 06 12:23:51 2011 +0100 @@ -1,29 +1,52 @@ +<%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %> + + <div id="authors" class="fields"> - <p> - <%= f.text_field :name_on_paper %><br /> - <em><%= h l("text_author_name_on_paper") %></em><br /> - - <%= link_to_function "Add Me as Author", "update_author_info(this," + User.current.get_author_info.to_json + ")", :class => 'icon icon-add', :id => "add_me_as_author" %> + <h4><%= l("label_author_1") %></h4> - <%= observe_field( form_tag_id(f.object_name, :name_on_paper), :frequency => 0.5, :update => form_tag_id(f.object_name, :identify_author), :url => { :controller => 'publications', :action => 'autocomplete_for_author' }, :with => 'q') - %> - - <div id="<%= form_tag_id(f.object_name, :identify_author) %>"> - <% if params[:q] && params[:q].length > 1 %> - <%= select_author_links 'author[author_ids][]', @authors %> - <% end %> - </div> - - <%= f.text_field :institution, :size => 60 %><br /> - <em><%= h l("text_author_institution") %></em><br /> + <div id="<%= form_tag_id( f.object_name, :search_author ) %>" style=<%= "display:none;" unless params[:action] == "new" %> > + <p> + <%= f.text_field :search_name, :size => 25 %> + <%= observe_field( form_tag_id(f.object_name, :search_name), :frequency => 0.5, :update => form_tag_id( f.object_name, :search_results), :url => { :controller => 'publications', :action => 'autocomplete_for_author', :object_name => form_object_id(f.object_name) }, :with => 'q' ) %> + </p> + <%# link_to_function l(:label_author_is_me), "update_author_info(this," + User.current.get_author_info.to_json + ")", :id => "add_me_as_author" %> - <%= f.text_field :email, :size => 60 %><br /> - <em><%= h l("text_author_email") %></em><br /> - - <%= f.hidden_field :is_user %> - <%= f.text_field :author_user_id %> - - <%= link_to_remove_fields l("remove_author"), f %> - + <p> + <%= f.select :search_results, options_for_select(@author_options), {}, {:size => 5, + :onChange => remote_function( :url => { :controller => :publications, :action => :get_user_info, :object_id => form_object_id(f.object_name) }, :with => "'value=' + + value" )} %> + </p> + + <p style="margin-bottom: -2.5em; padding-bottom; 0"><label><%= l(:identify_author_question) %></label></p> + <p class="author_identify"> + <label class='inline'><%= radio_button_tag(:identify_author, "yes", false, :name => form_tag_name(f.object_name,:identify_author ), :id => form_tag_id( f.object_name, :identify_author_yes ), :onclick => "identify_author_status($(this).value, #{form_object_id(f.object_name) });") %> <%= l(:identify_author_yes) %> </label><br /> + + <label class='inline'><%= radio_button_tag(:identify_author, "correct", false, :name => form_tag_name(f.object_name,:identify_author ), :id => form_tag_id( f.object_name, :identify_author_corrections ), :onclick => "identify_author_status($(this).value, #{form_object_id(f.object_name) });") %> <%= l(:identify_author_correct) %> </label><br /> + + <label class='inline'><%= radio_button_tag(:identify_author, "no", true, :name => form_tag_name(f.object_name,:identify_author ), :id => form_tag_id( f.object_name, :identify_author_no ), :onclick => "identify_author_status($(this).value, #{form_object_id(f.object_name) });") %> <%= l(:identify_author_no) %> </label><br /> + </p> + </div> + + <div class='author_edit' id="<%= form_tag_id( f.object_name, :edit_author_info ) %>"> + <p> + <%= f.text_field :name_on_paper, {:class => ("readonly" unless params[:action] == "new") } %></p> + <p class='description' style=<%= "display:none;" unless params[:action] == "new" %>><%= h l("text_author_name_on_paper") %></p> + <p><%= f.text_field :institution, {:class => ("readonly" unless params[:action] == "new") } %></p> + <p class='description' style=<%= "display:none;" unless params[:action] == "new" %>><%= h l("text_author_institution") %></p> + <p><%= f.text_field :email, {:class => ("readonly" unless params[:action] == "new") } %></p> + <p class='description' style=<%= "display:none;" unless params[:action] == "new" %>><%= h l("text_author_email") %></p> + </p> + </div> + + + <div class="box" id="<%= form_tag_id( f.object_name, :show_author_info ) %>" style="display: none"> + + </div> + + <p> + <%= button_to_function l(:label_save_author), {}, { :onclick => "toggle_save_author(#{form_object_id(f.object_name)}); return false;", :id => form_tag_id( f.object_name, :edit_save_button )} %> + + <%= link_to_remove_fields l("remove_author"), f %> </p> -</div> \ No newline at end of file +</div> +<br/>
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb Tue Sep 06 12:23:51 2011 +0100 @@ -1,26 +1,21 @@ -<div class="box"> - <p><label for="bibtex_entry_type"><%=l("field_entry_type")%> <span class="required">*</span></label> - <%= f.collection_select(:entry_type, BibtexEntryType.find(:all), :id, :name, {:selected => @selected_bibtex_entry_type_id, :prompt => true}) %> + <%= f.collection_select(:entry_type, BibtexEntryType.find(:all).reject { |x| x.redundant? }, :id, :label, {:selected => @selected_bibtex_entry_type_id, :prompt => true}) %> </p> <p> - <%= f.text_field :year, :size => 60 %> + <%= f.text_field :year, :size => 4 %> + </p><p> + <%= f.text_field :chapter, :size => 15 %> </p> <p> - <%= f.text_field :chapter, :size => 60 %> + <%= f.text_field :editor, :size => 33 %> </p> <p> - <%= f.text_field :editor, :size => 60 %> + <%= f.text_field :booktitle,:size => 33 %> </p> <p> - <%= f.text_field :booktitle,:size => 60 %> + <%= f.text_field :publisher,:size => 33 %> </p> <p> - <%= f.text_field :publisher,:size => 60 %> - </p> - <p> - <%= f.text_field :pages, :size => 60 %> + <%= f.text_field :pages, :size => 12 %> </p> - -</div> \ No newline at end of file
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_form.html.erb Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_form.html.erb Tue Sep 06 12:23:51 2011 +0100 @@ -1,30 +1,24 @@ +<%= f.error_messages %> -<div class="splitcontentleft"> - <%= f.error_messages %> - <p> - <%= f.text_field :title, :required => true, :size => 60 %> - </p> +<h3><%= f.text_field :title, :required => true, :size => 70 %></h3> - <h3><%= l(:authors) %></h3> - <% f.fields_for :authorships do |builder| %> - <%= render "authorship_fields", :f => builder %> - <% end %> - - <p><%= link_to_add_fields l(:label_add_another_author), f, :authorships %></p> - +<div class="splitcontentleft"> + <h3><%= l(:label_publication_other_details) %></h3> + <div class="box tabular"> + <% f.fields_for :bibtex_entry do |builder| -%> + <%= render :partial => 'bibtex_fields', :locals => { :f => builder} %> + <%- end -%> + </div> </div> -<div class="splitcontentright"> - <h3>Other Details</h3> - <% f.fields_for :bibtex_entry do |builder| -%> - <%= render :partial => 'bibtex_fields', :locals => { :f => builder} %> - <%- end -%> +<div class="splitcontentright"> + <h3><%= l(:authors) %></h3> + <div class="box tabular"> + <% f.fields_for :authorships do |builder| -%> + <%= render "authorship_fields", :f => builder %> + <%- end -%> + <%= link_to_add_fields l(:label_add_an_author), f, :authorships %> + </div> </div> -<% content_for :sidebar do %> - placeholder - -<% end %> - -
--- a/vendor/plugins/redmine_bibliography/app/views/publications/_list_projects.html.erb Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_list_projects.html.erb Tue Sep 06 12:23:51 2011 +0100 @@ -1,3 +1,1 @@ -<% publication = Publication.find(params[:id]) %> - -<%= render_projects_list(publication) %> \ No newline at end of file +<%= render_projects_list(@publication) %>
--- a/vendor/plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.rhtml Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/autocomplete_for_author.rhtml Tue Sep 06 12:23:51 2011 +0100 @@ -1,3 +1,4 @@ <% if params[:q] && params[:q].length > 1 %> - <%= choose_author_link 'publication[author_ids][]', @results %> + <%= choose_author_link @object_name, @results %> <% end %> +
--- a/vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb Tue Sep 06 12:23:51 2011 +0100 @@ -1,15 +1,17 @@ <% content_for :header_tags do %> <%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %> + <%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %> <% end %> <h2><%=l(:label_publication_show)%></h2> -<% form_for @publication, :url => { :project_id => @project_id, :action => :update }, :builder => TabularFormBuilder do |f| -%> +<% form_for @publication, :url => { :project_id => @project, :action => :update }, :builder => TabularFormBuilder do |f| -%> <%= render :partial => 'form', :locals => { :f => f } %> - + + <div style="clear:both"></div> <%= f.submit %> <% end %> <p> - <%= link_to l(:label_publication_show), { :controller => "publications", :action => "show", :id => @publication, :project_id => @project } %> | + <%= link_to l(:label_publication_show), { :controller => "publications", :action => "show", :id => @publication, :project_id => @project_id } %> | <%= link_to l(:label_publication_index), { :controller => "publications", :action => "index", :project_id => @project } %> </p>
--- a/vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb Tue Sep 06 12:23:51 2011 +0100 @@ -2,32 +2,39 @@ <%= link_to l(:label_publication_new), {:controller => 'publications', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %> </div> -<div class="splitcontentleft"> - <h3>Publications#index</h3> + <% if @project %> + <h3><%= l(:label_all_publications_for_project, :project => @project.name) %></h3> + <% else %> + <h3><%= l(:label_all_publications) %></h3> + <% end %> - - <table> - <tr> - <th>Number</th> - <th>Title</th> - </tr> + <div class="autoscroll"> + <table class="list publications"> + <thead><tr> + <th><%= l(:title) %></th> + <th><%= l(:authors) %></th> + <th><%= l(:year) %></th> + </tr></thead> <% @publications.each do |publication| %> - <tr> - <td><%= publication.id %></td> - <td><%= link_to publication.title, :controller => "publications", :action => "show", :id => publication, :project_id => @project %></td> - </tr> + <tr class="<%= cycle('odd', 'even') %>"> + <td class="firstcol title" align="top"><%= link_to publication.title, :controller => "publications", :action => "show", :id => publication, :project_id => @project %></td> + <td class="authors" align="top"> + <% publication.authorships.each do |authorship| %> + <%# if authorship.author.user.nil? || !authorship.author.user.active? %> + <%= h authorship.name_on_paper %> + <%# else %> + <%#= link_to(authorship.name_on_paper, :controller => 'users', :action => 'show', :id => authorship.author.user) %> + <%# end %> + + <em><%= authorship.institution %></em><br/> + <% end %> + <td class="year"><%= publication.bibtex_entry.year %></td> + </tr> <% end %> </table> - -</div> - -<div class="splitcontentright"> - placeholder div -</div> - + </div> <% content_for :sidebar do %> - Sidebar <% end %> - \ No newline at end of file +
--- a/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb Tue Sep 06 12:23:51 2011 +0100 @@ -1,10 +1,12 @@ <% content_for :header_tags do %> <%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %> + <%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %> <% end %> <h2><%=l(:label_publication_new)%></h2> -<% form_for @publication, :url => { :project_id => @project_id, :action => :create }, :builder => TabularFormBuilder do |f| -%> +<% form_for @publication, :url => { :project_id => @project, :action => :create }, :builder => TabularFormBuilder do |f| -%> <%= render :partial => 'form', :locals => { :f => f } %> + <div style="clear:both"></div> <%= f.submit %> -<% end %> \ No newline at end of file +<% end %>
--- a/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb Tue Sep 06 12:23:51 2011 +0100 @@ -2,44 +2,49 @@ <h2><%=l(:label_publication_show)%></h2> -<div class="splitcontentleft"> -<h4>Title</h4> -<%= h @publication.title %> +<div class="box"> +<h3> + <%= h @publication.title %> +</h3> <h4><%= l(:authors) %></h4> <ul id="authorships"> <% for authorship in @publication.authorships.find(:all, :order => :auth_order) %> <% content_tag_for :li, authorship do %> - <span class="handle">[drag to reorder]</span> - <%= h authorship.name_on_paper %> <br /> - <%= h authorship.institution %> <br /> - <% end %> - <% end %> + <%- if User.current.allowed_to?(:edit_publication, @project) && @publication.authorships.length > 1 -%> + <span class="handle">[drag to reorder]</span> + <%- end -%> + <%= h authorship.name_on_paper %> <em><%= h authorship.institution %></em> <br /> + <%- end -%> + <%- end -%> </ul> -<%= sortable_element("authorships", :url => { :controller => :publications, :action => :sort_author_order }, :handle => "handle") %> - -<br /> +<%- if User.current.allowed_to?(:edit_publication, @project) && @publication.authorships.length > 1 -%> + <%= sortable_element("authorships", :url => { :controller => :publications, :action => :sort_author_order }, :handle => "handle") %> +<%- end -%> <%- if @publication.bibtex_entry != nil -%> <%= show_bibtex_fields(@publication.bibtex_entry) %> <%- end -%> -<p> - <%= link_to l(:label_publication_edit), { :controller => "publications", :action => "edit", :id => @publication, :project_id => @project } %> | - <%= link_to "Delete", {:controller => 'publications', :action => 'destroy', :id => @publication, :project_id => @project }, +<br / > + <% if User.current.allowed_to?(:add_publication, @project) %> + <%= link_to l(:label_publication_edit), { :controller => "publications", :action => "edit", :id => @publication, :project_id => @project } %> | + <%= link_to "Delete", {:controller => 'publications', :action => 'destroy', :id => @publication, :project_id => @project }, :confirm => l(:text_are_you_sure), :method => :delete, :title => l(:button_delete) %> | - <%= link_to "View All", publications_path %> -</p> + <% end %> + <%= link_to l(:view_all_publications), publications_path %> </div> - <% projects = Project.active.find(:all, :limit => 100, :order => 'name ASC') - @publication.projects %> -<div class="splitcontentright"> - - <h4><%=l(:label_publication_project_index)%></h4> +<% content_for :sidebar do %> + <h3><%=l(:label_publication_project_index)%></h3> + <p id="list_projects"> <%= render :partial => 'list_projects' %> </p> + + <%- if User.current.allowed_to?(:edit_publication, @project) -%> <%= render :partial => 'add_project_form' %> -</div> \ No newline at end of file + <%- end -%> +<% end %>
--- a/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Tue Sep 06 12:23:51 2011 +0100 @@ -1,24 +1,64 @@ function remove_fields(link) { - $(link).previous("input[type=hidden]").value = "1"; - $(link).up(".fields").hide(); + $(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).up().insert({ - before: content.replace(regexp, new_id) - }); + var new_id = new Date().getTime(); + var regexp = new RegExp("new_" + association, "g") + $(link).insert({ + before: content.replace(regexp, new_id) + }); } -function update_author_info(link, author_info){ - - $(link).up('div').up('div').select('input[id^=publication_authorships_attributes]').each( - function(e){ - key = e.name.split("[").last().trim().sub(']',''); - - // test for undefined - e.value = author_info[key]; - } - ) -} \ No newline at end of file +function identify_author_status(status, object_id) { + $('publication_authorships_attributes_' + object_id + '_edit_author_info').select('input').each(function(s) { + if(status == "no"){ + s.value = ""; + s.readOnly = false; + }; + + if(status == "correct"){s.readOnly = false;}; + if(status == "yes"){s.readOnly = true;}; + }); +} + +function toggle_div(div_id){ + Effect.toggle(div_id, "appear", {duration:0.3}); +} + +function toggle_input_field(field){ + if (field.classNames().inspect().include("readonly") == false){ + field.readOnly = true; + field.addClassName('readonly'); + } else { + field.readOnly = false; + field.removeClassName('readonly'); + }; +} + +function toggle_edit_save_button(object_id){ + $button = $('publication_authorships_attributes_' + object_id + '_edit_save_button'); + if ($button.value == "Edit author"){ + $button.value = "Save author"; + } else { + $button.value = "Edit author"; + }; +} + +function toggle_save_author(form_object_id, $this){ + $('publication_authorships_attributes_' + form_object_id + '_edit_author_info').select('input').each(function(s) { + toggle_input_field(s, $this); + }); + $('publication_authorships_attributes_' + form_object_id + '_edit_author_info').select('p.description').each(function(s) { + s.toggle(); + }); + toggle_edit_save_button(form_object_id); + toggle_div("publication_authorships_attributes_" + form_object_id +"_search_author"); +} + +function edit_author(form_object_id){ + + +} +
--- a/vendor/plugins/redmine_bibliography/assets/stylesheets/bibliography.css Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/assets/stylesheets/bibliography.css Tue Sep 06 12:23:51 2011 +0100 @@ -1,5 +1,29 @@ li .handle { - font-size: 12px; - cursor: move; - color: #777; -} \ No newline at end of file + font-size: 12px; + cursor: move; + color: #777; +} + +input.readonly { + border: none; + padding: 0; + margin: 0; + background-color: transparent; +} + +.tabular .author_identify label { + font-weight: normal; +} + +.tabular .author_edit p { + padding-bottom: 0; +} + +.tabular .author_edit .description { + padding-top: 0; + font-style: italic; +} + +.publication_project { + margin-right: 18px; +}
--- a/vendor/plugins/redmine_bibliography/config/locales/en.yml Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/config/locales/en.yml Tue Sep 06 12:23:51 2011 +0100 @@ -4,38 +4,66 @@ authors: "Authors" author: "Author" name: "Name" + year: "Year" publications_box: "My Publications" label_my_publications_box: "My Publications" + view_all_publications: "View All Project's Publications" + + identify_author_question: Is the right person selected above? + identify_author_yes: "Yes" + identify_author_correct: "Yes, but I need to correct some details below" + identify_author_no: "No, the author was not found in the search" + + label_all_publications: All Publications + label_all_publications_for_project: Publications associated with %{project} + label_authors_show: "Authorships by this author" + label_authors_index: "List of authors" + + field_authorship_publication_title: "Publication Title" + field_authorship_name: "Name" + field_authorship_email: "Email Address" + field_authorship_institution: "Institution" field_publication_title: Title field_publication_authors: Authors field_publication_projects: "Associated Projects" field_author_name: Author + field_author_user: User Name field_author_username: "Associated User" field_author_publications: "Publications by this Author" + field_identify_author_yes: "Yes" + field_identify_author_correct: "Corrections" + field_identify_author_no: "No" + entry_type: "Bibtex Entry Type" - bibtex_entry: - entry_type: "Bibtex Entry Type" - + label_author_is_me: "(I am this author)" label_add_me_as_author: "Add me as an author" + label_add_an_author: "Add an author" label_add_another_author: "Add another author" + field_search_name: "Search by name" + field_search_results: "" + label_save_author: "Save author" + label_author_information: "Author Information" remove_author: "Remove this author" label_publications_plural: "Publications" label_publication_new: "Create New Publication" label_publication_index: "List of Publication" - label_add_publication_to_project: "Add Publication to this project" + label_add_publication_to_project: "Add publication to this project" label_publication_edit: "Edit Publication" label_publication_show: "Publication Details" - label_add_project_to_publication: "Add Project to Publication" - label_project_search: "Search by name: " + label_add_project_to_publication: "Add this publication to a project" + label_project_search: "Find project by name: " label_publication_project_index: "Projects associated with this publication" label_publication_index: "View all publications" + label_publication_other_details: "Details" + text_author_name_on_paper: "Author's name as it appears on the paper." + text_author_institution: "Author's institution as on the paper." text_author_email: "Author's email address as on the paper." - text_author_institution: "Author's institution name as on paper." - text_author_name_on_paper: "Name of the author as it appears on paper. (In case it applies, please use the autocomplete suggestions.)" + + text_author_search: "Search existing authors" # authorships model field_institution: "Institution" @@ -43,10 +71,9 @@ field_email: "Email Address" # bibtex_entries model - field_entry_type: "Entry Type" + field_entry_type: "Publication Type" field_id: "id" field_publication_id: "Publication_id" - field_entry_type: "Entry Type" field_address: "Address" field_annote: "Annote" field_booktitle: "Book Title" @@ -70,8 +97,43 @@ field_url: "URL" field_volume: "Volume" field_year: "Year" + + field_bibtex_article: Journal article + field_bibtex_book: Book + field_bibtex_booklet: Booklet + field_bibtex_conference: Article in conference proceedings + field_bibtex_inbook: Book chapter or part + field_bibtex_incollection: Part of a collection + field_bibtex_inproceedings: Article in conference proceedings + field_bibtex_manual: Technical manual + field_bibtex_masterthesis: "Master's thesis" + field_bibtex_misc: Other + field_bibtex_phdthesis: "PhD thesis" + field_bibtex_proceedings: Conference proceedings + field_bibtex_techreport: Technical report + field_bibtex_unpublished: Unpublished + label_author_1: First author + label_author_2: Second author + label_author_3: Third author + label_author_4: Fourth author + label_author_5: Fifth author + label_author_6: Sixth author + label_author_7: Seventh author + label_author_8: Eighth author + label_author_9: Ninth author + label_author_10: Tenth author + label_author_11: Eleventh author + label_author_12: Twelfth author + label_author_13: Thirteenth author + label_author_14: Fourteenth author + label_author_15: Fifteenth author + label_author_16: Sixteenth author + label_author_17: Seventeenth author + label_author_18: Eighteenth author + label_author_19: Nineteenth author + label_author_20: Twentieth author + -
--- a/vendor/plugins/redmine_bibliography/db/seed_data/bibtex_entry_types_list.txt Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/db/seed_data/bibtex_entry_types_list.txt Tue Sep 06 12:23:51 2011 +0100 @@ -1,14 +1,14 @@ +inproceedings +conference article +masterthesis +phdthesis book booklet -conference inbook incollection -inproceedings manual -masterthesis +techreport +proceedings +unpublished misc -phdthesis -proceedings -techreport -unpublished
--- a/vendor/plugins/redmine_bibliography/init.rb Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/init.rb Tue Sep 06 12:23:51 2011 +0100 @@ -15,7 +15,6 @@ unless User.included_modules.include? Bibliography::UserAuthorPatch User.send(:include, Bibliography::UserAuthorPatch) end - end @@ -32,12 +31,14 @@ project_module :redmine_bibliography do permission :publications, { :publications => :index }, :public => true - permission :edit_redmine_bibliography, {:redmine_bibliography => [:edit, :update]} - permission :add_publication, {:redmine_bibliography => [:new, :create]} + permission :edit_publication, {:publications => [:edit, :update]} + permission :add_publication, {:publications => [:new, :create]} + permission :delete_publication, {:publications => :destroy} + end # extending the Project Menu menu :project_menu, :publications, { :controller => 'publications', :action => 'index', :path => nil }, :after => :activity, :param => :project_id, :caption => Proc.new { Setting.plugin_redmine_bibliography['menu'] }, :if => Proc.new { !Setting.plugin_redmine_bibliography['menu'].blank? } -end \ No newline at end of file +end
--- a/vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb Tue Aug 09 16:02:08 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/lib/bibliography/user_author_patch.rb Tue Sep 06 12:23:51 2011 +0100 @@ -13,31 +13,29 @@ module InstanceMethods + def institution + unless self.ssamr_user_detail.nil? + institution_name = self.ssamr_user_detail.institution_name + else + institution_name = "No Institution Set" + end + return institution_name + end + def get_author_info + # TODO: DELETE THIS METHOD?? info = { - :name_on_paper => "", - :email => "", + :name_on_paper => self.name, + :email => self.mail, :institution => "", :author_user_id => self.id, :is_user => "1" } - - if self.author.nil? - logger.debug { "Bibliography: The current user has no author associated." } - info[:name_on_paper] = self.name - info[:email] = self.mail - if not self.ssamr_user_detail.nil? - info[:institution] = self.ssamr_user_detail.institution_name - end - else - logger.error { "Bibliography: We've got an author associated with the current user." } - info[:name_on_paper] = self.author.name - if self.author.authorships.length > 0 - info[:email] = self.author.authorships.first.email - info[:institution] = self.author.authorships.first.institution - end - end + if not self.ssamr_user_detail.nil? + info[:institution] = self.ssamr_user_detail.institution_name + end + return info end