# HG changeset patch # User Chris Cannam # Date 1318867001 -3600 # Node ID 378aca14739fc31c518601017b34452d062cb607 # Parent fce7374e48b781c1353c8554a3e547d7c9afc136# Parent ebca856bd627a5ae0904ed6f1e1523534e19aaf7 Merge from branch "feature_36" diff -r fce7374e48b7 -r 378aca14739f vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb --- a/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Tue Oct 04 10:55:00 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb Mon Oct 17 16:56:41 2011 +0100 @@ -64,21 +64,21 @@ def get_bibtex_required_fields - fields = BibtexEntryType.fields(params[:value]) - all_fields = BibtexEntryType.all_fields + unless params[:value].empty? + fields = BibtexEntryType.fields(params[:value]) + end respond_to do |format| format.js { - render(:update) {|page| - all_fields.each_with_index do |field, idx| - unless fields.include? field - page["publication_bibtex_entry_attributes_#{field}"].up('p').hide() - else - page["publication_bibtex_entry_attributes_#{field}"].up('p').show() - end + render(:update) {|page| + if params[:value].empty? + page << "hideOnLoad();" + else + page << "show_required_bibtex_fields(#{fields.to_json()});" end } } + end end diff -r fce7374e48b7 -r 378aca14739f vendor/plugins/redmine_bibliography/app/helpers/authorships_helper.rb --- a/vendor/plugins/redmine_bibliography/app/helpers/authorships_helper.rb Tue Oct 04 10:55:00 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/helpers/authorships_helper.rb Mon Oct 17 16:56:41 2011 +0100 @@ -1,2 +1,21 @@ +# -*- coding: undecided -*- module AuthorshipsHelper + + # Generates a link to either author or user, depending on which is + # available + def link_to_authorship(authorship) + s = '' + if authorship.author.nil? + # legacy reasons… + s << h(authorship.name_on_paper) + else + if authorship.author.user.nil? + s << link_to(authorship.name_on_paper, :controller => 'authors', :action => 'show', :id => authorship.author) + else + s << link_to(authorship.name_on_paper, :controller => 'users', :action => 'show', :id => authorship.author.user) + end + end + s + end + end diff -r fce7374e48b7 -r 378aca14739f vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb --- a/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Tue Oct 04 10:55:00 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb Mon Oct 17 16:56:41 2011 +0100 @@ -2,6 +2,7 @@ require 'bibtex' module PublicationsHelper + include AuthorshipsHelper def link_to_publication(publication, options={}, html_options = nil) url = {:controller => 'publications', :action => 'show', :id => publication}.merge(options) @@ -11,8 +12,12 @@ def projects_check_box_tags(name, projects) s = '' projects.sort.each do |project| - s << "\n" + if User.current.allowed_to?(:edit_publication, project) + s << "\n" + s << '
' + end end + s end @@ -42,12 +47,12 @@ f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)", :class => 'icon icon-del') end - def link_to_add_fields(name, f, association) + def link_to_add_author_fields(name, f, association, action) new_object = f.object.class.reflect_on_association(association).klass.new fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| render(association.to_s.singularize + "_fields", :f => builder) end - link_to_function(name, h("add_fields(this, '#{association}', '#{escape_javascript(fields)}')"), { :class => 'icon icon-add', :id => "add_another_author" }) + link_to_function(name, h("add_author_fields(this, '#{association}', '#{escape_javascript(fields)}', '#{action}')"), { :class => 'icon icon-add', :id => "add_another_author" }) end def sanitized_object_name(object_name) @@ -72,29 +77,40 @@ str = object_name.split("\[").last().gsub("\]","") str.to_sym end + + def render_authorships_list(publication) + s = '

' + + publication.authorships.each do |authorship| + s << link_to_authorship(authorship) + s << "
#{authorship.institution}

" + end + + s + end - def render_projects_list(publication) - logger.error { "PROJECT NAME #{@project.name unless @project.nil?}" } - s = "" - - publication.projects.each do |proj| + def render_projects_list(publication, show_delete_icon) + s= "" + + publication.projects.visible.each do |proj| 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') + + if show_delete_icon + 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 end - s << "
" - - end - + s << "
" + end + s end diff -r fce7374e48b7 -r 378aca14739f vendor/plugins/redmine_bibliography/app/models/bibtex_entry_type.rb --- a/vendor/plugins/redmine_bibliography/app/models/bibtex_entry_type.rb Tue Oct 04 10:55:00 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/models/bibtex_entry_type.rb Mon Oct 17 16:56:41 2011 +0100 @@ -1,7 +1,5 @@ class BibtexEntryType < ActiveRecord::Base - @@all_fields = [ "editor", "publisher", "chapter", "pages", "volume", "series", "address", "edition", "month", "year", "type", "note", "number", "journal", "howpublished", "key", "school" ] - @@fields = Hash['article', ['journal', 'year', 'volume', 'number', 'pages', 'month', 'note' ], 'book' , [ 'editor', 'publisher', 'volume', 'series', 'address', 'edition', 'month', 'year', 'note' ], 'booklet' , [ 'howpublished', 'address', 'year', 'month', 'note', 'key' ], @@ -28,8 +26,4 @@ def self.fields (type) @@fields[ self.find(type).name ] end - - def self.all_fields - @@all_fields - end end diff -r fce7374e48b7 -r 378aca14739f vendor/plugins/redmine_bibliography/app/views/authors/show.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/authors/show.html.erb Tue Oct 04 10:55:00 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/authors/show.html.erb Mon Oct 17 16:56:41 2011 +0100 @@ -1,6 +1,6 @@

<%=l(:label_authors_show)%>

-
+
@@ -21,4 +21,8 @@ <% end %>
-
\ No newline at end of file +
+ +<% content_for :sidebar do %> +<% end %> + diff -r fce7374e48b7 -r 378aca14739f vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml --- a/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Tue Oct 04 10:55:00 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_authorship_fields.rhtml Mon Oct 17 16:56:41 2011 +0100 @@ -19,11 +19,11 @@

-
+
-
+
-
+

@@ -45,12 +45,11 @@

- <% if params[:action] == 'new' %> - <%= 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 )} %> - <% else %> -<%= button_to_function l(:label_edit_author), {}, { :onclick => "toggle_save_author(#{form_object_id(f.object_name)}); return false;", :id => form_tag_id( f.object_name, :edit_save_button )} %> - - <% end %> + <%- if params[:action] == 'new' -%> + <%= 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 )} %> + <%- else -%> + <%= button_to_function l(:label_edit_author), {}, { :onclick => "toggle_save_author(#{form_object_id(f.object_name)}); return false;", :id => form_tag_id( f.object_name, :edit_save_button )} %> + <%- end -%> <%= link_to_remove_fields l("remove_author"), f %> diff -r fce7374e48b7 -r 378aca14739f vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb Tue Oct 04 10:55:00 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb Mon Oct 17 16:56:41 2011 +0100 @@ -8,73 +8,73 @@ :onChange => remote_function( :url => { :controller => :publications, :action => :get_bibtex_required_fields}, :with => "'value=' + value" ) %>

-

- <%= f.text_field :year, :size => 4, :class => 'bibtex' %> + +

+ <%= f.text_field :year, :size => 4 %>

-

- <%= f.text_field :month, :size => 4, :class => 'bibtex' %> +

+ <%= f.text_field :month, :size => 4%>

-

- <%= f.text_field :chapter, :size => 15, :class => 'bibtex' %> +

+ <%= f.text_field :chapter, :size => 15%>

-

- <%= f.text_field :editor, :size => 33, :class => 'bibtex' %> +

+ <%= f.text_field :editor, :size => 33 %>

-

- <%= f.text_field :booktitle, :size => 33, :class => 'bibtex' %> +

+ <%= f.text_field :booktitle, :size => 33 %>

-

- <%= f.text_field :publisher,:size => 33, :class => 'bibtex' %> +

+ <%= f.text_field :publisher,:size => 33 %>

-

- <%= f.text_field :pages, :size => 12, :class => 'bibtex' %> +

+ <%= f.text_field :pages, :size => 12 %>

-

- <%= f.text_field :address, :class => 'bibtex' %> +

+ <%= f.text_field :address %>

-

- <%= f.text_field :annote, :class => 'bibtex' %> +

+ <%= f.text_field :annote %>

-

- <%= f.text_field :crossref, :class => 'bibtex' %> +

+ <%= f.text_field :crossref %>

-

- <%= f.text_field :edition, :class => 'bibtex' %> +

+ <%= f.text_field :edition %>

-

- <%= f.text_field :eprint, :class => 'bibtex' %> +

+ <%= f.text_field :eprint %>

-

- <%= f.text_field :howpublished, :class => 'bibtex' %> +

+ <%= f.text_field :howpublished %>

-

- <%= f.text_field :journal, :class => 'bibtex' %> +

+ <%= f.text_field :journal %>

-

- <%= f.text_field :key, :class => 'bibtex' %> +

+ <%= f.text_field :key %>

-

- <%= f.text_field :note, :class => 'bibtex' %> +

+ <%= f.text_field :note %>

-

- <%= f.text_field :number, :class => 'bibtex' %> +

+ <%= f.text_field :number %>

-

- <%= f.text_field :organization, :class => 'bibtex' %> +

+ <%= f.text_field :organization %>

-

- <%= f.text_field :school, :class => 'bibtex' %> +

+ <%= f.text_field :school %>

-

- <%= f.text_field :series, :class => 'bibtex' %> +

+ <%= f.text_field :series %>

-

- <%= f.text_field :type, :class => 'bibtex' %> +

+ <%= f.text_field :type %>

-

- <%= f.text_field :url, :class => 'bibtex' %> +

+ <%= f.text_field :url %>

-

- <%= f.text_field :volume, :class => 'bibtex' %> -

- +

+ <%= f.text_field :volume %> +

\ No newline at end of file diff -r fce7374e48b7 -r 378aca14739f vendor/plugins/redmine_bibliography/app/views/publications/_form.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/_form.html.erb Tue Oct 04 10:55:00 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_form.html.erb Mon Oct 17 16:56:41 2011 +0100 @@ -24,7 +24,7 @@ <% f.fields_for :authorships do |builder| -%> <%= render "authorship_fields", :f => builder %> <%- end -%> - <%= link_to_add_fields l(:label_add_an_author), f, :authorships %> + <%= link_to_add_author_fields l(:label_add_an_author), f, :authorships, params[:action] %> diff -r fce7374e48b7 -r 378aca14739f vendor/plugins/redmine_bibliography/app/views/publications/_list_projects.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/_list_projects.html.erb Tue Oct 04 10:55:00 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/_list_projects.html.erb Mon Oct 17 16:56:41 2011 +0100 @@ -1,1 +1,1 @@ -<%= render_projects_list(@publication) %> +<%= render_projects_list(@publication, true) %> diff -r fce7374e48b7 -r 378aca14739f vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb Tue Oct 04 10:55:00 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb Mon Oct 17 16:56:41 2011 +0100 @@ -1,7 +1,7 @@ <% content_for :header_tags do %> <%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %> <%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %> - <%= javascript_tag 'Event.observe(window, "load", function(e){show_all_required_bibtex_fields(' + @bibtype_fields.to_json + ')});' %> + <%= javascript_tag 'Event.observe(window, "load", function(e){show_required_bibtex_fields(' + @bibtype_fields.to_json + ')});' %> <% end %>

<%=l(:label_publication_show)%>

diff -r fce7374e48b7 -r 378aca14739f vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb Tue Oct 04 10:55:00 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/index.html.erb Mon Oct 17 16:56:41 2011 +0100 @@ -5,9 +5,9 @@ <% if @project %> -

<%= l(:label_all_publications_for_project, :project => @project.name) %>

+

<%= l(:label_all_publications_for_project, :project => @project.name) %>

<% else %> -

<%= l(:label_all_publications) %>

+

<%= l(:label_all_publications) %>

<% end %>
@@ -15,25 +15,23 @@ <%= l(:title) %> <%= l(:authors) %> - <%= l(:year) %> + <%= l(:year) %> + <%= l(:associated_projects) %> - <% @publications.each do |publication| %> - - <%= link_to publication.title, :controller => "publications", :action => "show", :id => publication, :project_id => @project %> - - <% 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 %> - - <%= authorship.institution %>
- <% end %> - <%= publication.bibtex_entry.year %> - - <% end %> + <%- @publications.each do |publication| -%> + <%- if publication.projects.visible.length > 0 -%> + + <%= link_to publication.title, :controller => "publications", :action => "show", :id => publication, :project_id => @project %> + + <%= render_authorships_list(publication) %> + <%= publication.bibtex_entry.year %> + + <%= render_projects_list(publication, false) %> + + + <%- end -%> + <%- end -%>
diff -r fce7374e48b7 -r 378aca14739f vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb Tue Oct 04 10:55:00 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb Mon Oct 17 16:56:41 2011 +0100 @@ -1,7 +1,6 @@ <% content_for :header_tags do %> <%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %> <%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %> - <%= javascript_tag 'Event.observe(window, "load", hide_all_bibtex_required_fields);' %> <% end %>

<%=l(:label_publication_new)%>

diff -r fce7374e48b7 -r 378aca14739f vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb --- a/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb Tue Oct 04 10:55:00 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb Mon Oct 17 16:56:41 2011 +0100 @@ -14,7 +14,7 @@ <%- if User.current.allowed_to?(:edit_publication, @project) && @publication.authorships.length > 1 -%> [drag to reorder] <%- end -%> - <%= h authorship.name_on_paper %> <%= h authorship.institution %>
+ <%= link_to_authorship authorship %> <%= h authorship.institution %>
<%- end -%> <%- end -%> diff -r fce7374e48b7 -r 378aca14739f vendor/plugins/redmine_bibliography/app/views/users/show.rhtml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/plugins/redmine_bibliography/app/views/users/show.rhtml Mon Oct 17 16:56:41 2011 +0100 @@ -0,0 +1,105 @@ +<%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %> + +
+<%= link_to(l(:button_edit), edit_user_path(@user), :class => 'icon icon-edit') if User.current.admin? %> +
+ +

<%= avatar @user, :size => "50" %> <%=h @user.name %>

+ +
+ + +

<%=l(:label_ssamr_description)%>

+<%= textilizable @description %> + +

<%=l(:label_ssamr_institution)%>

+

<%= h @institution_name %>

+ + +<% unless @memberships.empty? %> +

<%=l(:label_project_plural)%>

+ +<% end %> +<%= call_hook :view_account_left_bottom, :user => @user %> +
+ +
+ + <% if @user.author %> +
+ <% @publications = Publication.all(:include => :authors, :conditions => "authors.id = #{@user.author.id}") %> + +

<%=l(:publications) %> <%= "(" + @publications.count.to_s + ")" %>

+ + <% @publications.each do |publication|%> +
+ <%= link_to publication.title, :controller => 'publications', :action => 'show', :id => publication %> +
+ +
+ + <%= publication.authorships.map { |a| h a.name_on_paper }.join(', ') %> + + <% if publication.bibtex_entry.year.to_s != "" %> + + <%= publication.bibtex_entry.year %> + + <% end %> +
+ <% end %> +
+ <% end %> + + +<% unless @events_by_day.empty? %> +

<%= link_to l(:label_activity), :controller => 'activities', :action => 'index', :id => nil, :user_id => @user, :from => @events_by_day.keys.first %>

+ +

+<%=l(:label_reported_issues)%>: <%= Issue.count(:conditions => ["author_id=?", @user.id]) %> +

+ +
+<% @events_by_day.keys.sort.reverse.each do |day| %> +

<%= format_activity_day(day) %>

+
+<% @events_by_day[day].sort {|x,y| y.event_datetime <=> x.event_datetime }.each do |e| -%> +
+ <%= format_time(e.event_datetime, false) %> + <%= content_tag('span', h(e.project), :class => 'project') %> + <%= link_to format_activity_title(e.event_title), e.event_url %>
+
<%= format_activity_description(e.event_description) %>
+<% end -%> +
+<% end -%> +
+ +<% other_formats_links do |f| %> + <%= f.link_to 'Atom', :url => {:controller => 'activities', :action => 'index', :id => nil, :user_id => @user, :key => User.current.rss_key} %> +<% end %> + +<% content_for :header_tags do %> + <%= auto_discovery_link_tag(:atom, :controller => 'activities', :action => 'index', :user_id => @user, :format => :atom, :key => User.current.rss_key) %> +<% end %> +<% end %> +<%= call_hook :view_account_right_bottom, :user => @user %> +
+ +<% html_title @user.name %> diff -r fce7374e48b7 -r 378aca14739f vendor/plugins/redmine_bibliography/assets/javascripts/authors.js --- a/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Tue Oct 04 10:55:00 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/assets/javascripts/authors.js Mon Oct 17 16:56:41 2011 +0100 @@ -3,12 +3,15 @@ $(link).up(".fields").hide(); } -function add_fields(link, association, content) { - var new_id = new Date().getTime(); - var regexp = new RegExp("new_" + association, "g") - $(link).insert({ - before: content.replace(regexp, new_id) - }); +function add_author_fields(link, association, content, action) { + var new_id = new Date().getTime(); + var regexp = new RegExp("new_" + association, "g"); + $(link).insert({ + before: content.replace(regexp, new_id) + }); + if(action != "new"){ + toggle_save_author(new_id, $(link)); + }; } function identify_author_status(status, object_id) { @@ -57,16 +60,17 @@ toggle_div("publication_authorships_attributes_" + form_object_id +"_search_author"); } -function edit_author(form_object_id){} +function hide_all_bibtex_required_fields(){$$('p.bibtex').each(function(s){s.hide()})} -function hide_all_bibtex_required_fields() { - $$('input.bibtex').each(function(s){ - s.up('p').hide(); - })} - -function show_all_required_bibtex_fields(entrytype_fields) { - $$('input.bibtex').each(function(s){ - if(entrytype_fields.indexOf(s.id.split('_').last()) == -1){s.up('p').hide()}; +// entrytype_fields is a jsno array with the fields requires by the selected bibtex entry +function show_required_bibtex_fields(entrytype_fields) { + $$('p.bibtex').each(function(s){ + if(entrytype_fields.indexOf(s.down('input').id.split('_').last()) != -1){ + s.show(); + } + else { + s.hide(); + } }) } \ No newline at end of file diff -r fce7374e48b7 -r 378aca14739f vendor/plugins/redmine_bibliography/config/locales/en.yml --- a/vendor/plugins/redmine_bibliography/config/locales/en.yml Tue Oct 04 10:55:00 2011 +0100 +++ b/vendor/plugins/redmine_bibliography/config/locales/en.yml Mon Oct 17 16:56:41 2011 +0100 @@ -7,9 +7,12 @@ author: "Author" name: "Name" year: "Year" + associated_projects: "Associated Projects" publications_box: "My Publications" label_my_publications_box: "My Publications" view_all_publications: "View All Project's Publications" + publications: Publications + identify_author_question: Is the right person selected above? identify_author_yes: "Yes" @@ -20,12 +23,12 @@ label_all_publications: All Publications label_all_publications_for_project: Publications associated with %{project} - label_authors_show: "Authorships by this author" + label_authors_show: "Authorships associated with 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_publication_title: "Publication" + field_authorship_name: "Name on Paper" + field_authorship_email: "Email" field_authorship_institution: "Institution" field_external_url: "External URL" @@ -83,7 +86,7 @@ field_publication_id: "Publication_id" field_address: "Address" field_annote: "Annote" - field_booktitle: "Book Title" + field_booktitle: "Title of Book or Proceedings" field_chapter: "Chapter" field_crossref: "Cross Reference" field_edition: "Edition"