Revision 724:b96d3005ee79

View differences:

vendor/plugins/redmine_bibliography/app/controllers/publications_controller.rb
64 64

  
65 65
  def get_bibtex_required_fields
66 66

  
67
    fields = BibtexEntryType.fields(params[:value])
68
    all_fields = BibtexEntryType.all_fields
67
    unless params[:value].empty?
68
      fields = BibtexEntryType.fields(params[:value]) 
69
    end
69 70

  
70 71
    respond_to do |format|
71 72
      format.js {
72
        render(:update) {|page| 
73
          all_fields.each_with_index do |field, idx|            
74
            unless fields.include? field
75
              page["publication_bibtex_entry_attributes_#{field}"].up('p').hide()
76
            else
77
              page["publication_bibtex_entry_attributes_#{field}"].up('p').show()
78
            end            
73
        render(:update) {|page|       
74
          if params[:value].empty?
75
            page << "hideOnLoad();"
76
          else
77
            page << "show_required_bibtex_fields(#{fields.to_json()});"
79 78
          end
80 79
        }
81 80
      }
81
    
82 82
    end
83 83
  end
84 84

  
vendor/plugins/redmine_bibliography/app/helpers/authorships_helper.rb
1
# -*- coding: undecided -*-
1 2
module AuthorshipsHelper
3

  
4
  # Generates a link to either author or user, depending on which is
5
  # available
6
  def link_to_authorship(authorship)
7
    s = ''
8
    if authorship.author.nil?
9
      # legacy reasons…
10
      s << h(authorship.name_on_paper)
11
    else
12
      if authorship.author.user.nil?      
13
        s << link_to(authorship.name_on_paper, :controller => 'authors', :action => 'show', :id => authorship.author)
14
      else
15
        s << link_to(authorship.name_on_paper, :controller => 'users', :action => 'show', :id => authorship.author.user)
16
      end
17
    end
18
    s
19
  end
20

  
2 21
end
vendor/plugins/redmine_bibliography/app/helpers/publications_helper.rb
2 2
require 'bibtex'
3 3

  
4 4
module PublicationsHelper
5
  include AuthorshipsHelper
5 6

  
6 7
  def link_to_publication(publication, options={}, html_options = nil)
7 8
    url = {:controller => 'publications', :action => 'show', :id => publication}.merge(options)
......
77 78
    s = '<p>'
78 79
    
79 80
    publication.authorships.each do |authorship|
80
    
81
    if authorship.author.nil?
82
      # legacy reasons…
83
      s << h(authorship.name_on_paper)
84
    else
85
      if authorship.author.user.nil?      
86
        s << link_to(authorship.name_on_paper, :controller => 'authors', :action => 'show', :id => authorship.author)
87
      else
88
        s << link_to(authorship.name_on_paper, :controller => 'users', :action => 'show', :id => authorship.author.user)
89
      end
90
    end
81
      s << link_to_authorship(authorship)
91 82
      s << "<br /><em>#{authorship.institution}</em></p>"
92 83
    end    
93 84

  
vendor/plugins/redmine_bibliography/app/models/bibtex_entry_type.rb
1 1
class BibtexEntryType < ActiveRecord::Base
2 2

  
3
  @@all_fields = [ "booktitle", "editor", "publisher", "chapter", "pages", "volume", "series", "address", "edition", "month", "year", "type", "note", "number", "journal", "howpublished", "key", "school" ]
4

  
5 3
  @@fields = Hash['article', ['journal', 'year', 'volume', 'number', 'pages', 'month', 'note' ], 
6 4
                  'book' , [ 'editor', 'publisher', 'volume', 'series', 'address', 'edition', 'month', 'year', 'note' ],
7 5
                  'booklet' , [ 'howpublished', 'address', 'year', 'month', 'note', 'key' ],
......
28 26
  def self.fields (type)
29 27
    @@fields[ self.find(type).name ]    
30 28
  end
31

  
32
  def self.all_fields
33
    @@all_fields
34
  end
35 29
end
vendor/plugins/redmine_bibliography/app/views/authors/show.html.erb
1 1
<h2><%=l(:label_authors_show)%></h2>
2 2

  
3
<div class="splitcontentleft">
3
<div class="autoscroll">
4 4
  <table class="list authors">		
5 5
  	<thead>
6 6
  	  <tr>
......
21 21
    <% end %>
22 22
  	</tbody>
23 23
  </table>
24
</div>
24
</div>
25

  
26
<% content_for :sidebar do %>
27
<% end %>
28
  
vendor/plugins/redmine_bibliography/app/views/publications/_bibtex_fields.html.erb
8 8
	        :onChange => remote_function( :url => { :controller => :publications, :action => :get_bibtex_required_fields}, :with => "'value=' + value" )	              
9 9
	%>
10 10
</p>
11
<p> 
12
  <%= f.text_field :year, :size => 4, :class => 'bibtex' %> 
11

  
12
<p class="bibtex hol"> 
13
  <%= f.text_field :year, :size => 4 %> 
13 14
</p>
14
<p> 
15
  <%= f.text_field :month, :size => 4, :class => 'bibtex' %> 
15
<p class="bibtex hol"> 
16
  <%= f.text_field :month, :size => 4%> 
16 17
</p>
17
<p> 
18
  <%= f.text_field :chapter, :size => 15, :class => 'bibtex' %>  
18
<p class="bibtex hol">  
19
  <%= f.text_field :chapter, :size => 15%>  
19 20
</p>  
20
<p>   
21
  <%= f.text_field :editor, :size => 33, :class => 'bibtex'  %>  
21
<p class="bibtex hol"> 
22
  <%= f.text_field :editor, :size => 33  %>  
22 23
</p>  
23
<p>   
24
  <%= f.text_field :booktitle, :size => 33, :class => 'bibtex'  %>  
24
<p class="bibtex hol"> 
25
  <%= f.text_field :booktitle, :size => 33  %>  
25 26
</p>  
26
<p>   
27
  <%= f.text_field :publisher,:size => 33, :class => 'bibtex'  %>  
27
<p class="bibtex hol"> 
28
  <%= f.text_field :publisher,:size => 33  %>  
28 29
</p>  
29
<p>   
30
  <%= f.text_field :pages, :size => 12, :class => 'bibtex'  %>  
30
<p class="bibtex hol"> 
31
  <%= f.text_field :pages, :size => 12 %>  
31 32
</p>
32
<p>
33
 <%= f.text_field :address, :class => 'bibtex' %>
33
<p class="bibtex hol"> 
34
 <%= f.text_field :address %>
34 35
</p>
35
<p>
36
 <%= f.text_field :annote, :class => 'bibtex' %>
36
<p class="bibtex hol"> 
37
 <%= f.text_field :annote %>
37 38
</p>
38
<p>
39
 <%= f.text_field :crossref, :class => 'bibtex' %>
39
<p class="bibtex hol"> 
40
 <%= f.text_field :crossref %>
40 41
</p>
41
<p>
42
 <%= f.text_field :edition, :class => 'bibtex' %>
42
<p class="bibtex hol"> 
43
 <%= f.text_field :edition %>
43 44
</p>
44
<p>
45
 <%= f.text_field :eprint, :class => 'bibtex' %>
45
<p class="bibtex hol"> 
46
 <%= f.text_field :eprint %>
46 47
</p>
47
<p>
48
 <%= f.text_field :howpublished, :class => 'bibtex' %>
48
<p class="bibtex hol"> 
49
 <%= f.text_field :howpublished %>
49 50
</p>
50
<p>
51
 <%= f.text_field :journal, :class => 'bibtex' %>
51
<p class="bibtex hol"> 
52
 <%= f.text_field :journal %>
52 53
</p>
53
<p>
54
 <%= f.text_field :key, :class => 'bibtex' %>
54
<p class="bibtex hol"> 
55
 <%= f.text_field :key %>
55 56
</p>
56
<p>
57
 <%= f.text_field :note, :class => 'bibtex' %>
57
<p class="bibtex hol"> 
58
 <%= f.text_field :note %>
58 59
</p>
59
<p>
60
 <%= f.text_field :number, :class => 'bibtex' %>
60
<p class="bibtex hol"> 
61
 <%= f.text_field :number %>
61 62
</p>
62
<p>
63
 <%= f.text_field :organization, :class => 'bibtex' %>
63
<p class="bibtex hol"> 
64
 <%= f.text_field :organization %>
64 65
</p>
65
<p>
66
 <%= f.text_field :school, :class => 'bibtex' %>
66
<p class="bibtex hol"> 
67
 <%= f.text_field :school %>
67 68
</p>
68
<p>
69
 <%= f.text_field :series, :class => 'bibtex' %>
69
<p class="bibtex hol"> 
70
 <%= f.text_field :series %>
70 71
</p>
71
<p>
72
 <%= f.text_field :type, :class => 'bibtex' %>
72
<p class="bibtex hol"> 
73
 <%= f.text_field :type %>
73 74
</p>
74
<p>
75
 <%= f.text_field :url, :class => 'bibtex' %>
75
<p class="bibtex hol"> 
76
 <%= f.text_field :url %>
76 77
</p>
77
<p>
78
 <%= f.text_field :volume, :class => 'bibtex' %>
79
</p>
80

  
78
<p class="bibtex hol"> 
79
 <%= f.text_field :volume %>
80
</p>
vendor/plugins/redmine_bibliography/app/views/publications/edit.html.erb
1 1
<% content_for :header_tags do %>
2 2
    <%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %>
3 3
    <%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %>  
4
    <%= javascript_tag 'Event.observe(window, "load", function(e){show_all_required_bibtex_fields(' + @bibtype_fields.to_json + ')});' %>
4
    <%= javascript_tag 'Event.observe(window, "load", function(e){show_required_bibtex_fields(' + @bibtype_fields.to_json + ')});' %>
5 5
<% end %>
6 6

  
7 7
<h2><%=l(:label_publication_show)%></h2>
vendor/plugins/redmine_bibliography/app/views/publications/new.html.erb
1 1
<% content_for :header_tags do %>
2 2
    <%= javascript_include_tag 'authors', :plugin => 'redmine_bibliography' %>
3 3
    <%= stylesheet_link_tag 'bibliography', :plugin => 'redmine_bibliography' %>
4
    <%= javascript_tag 'Event.observe(window, "load", hide_all_bibtex_required_fields);' %>
5 4
<% end %>
6 5

  
7 6
<h2><%=l(:label_publication_new)%></h2>
vendor/plugins/redmine_bibliography/app/views/publications/show.html.erb
14 14
      <%- if User.current.allowed_to?(:edit_publication, @project) && @publication.authorships.length > 1 -%>    
15 15
        <span class="handle">[drag to reorder]</span>
16 16
      <%- end -%>
17
      <%= h authorship.name_on_paper %> <em><%= h authorship.institution %></em> <br />
17
      <%= link_to_authorship authorship %> <em><%= h authorship.institution %></em> <br />
18 18
    <%- end -%>
19 19
  <%- end -%>
20 20
</ul>
vendor/plugins/redmine_bibliography/app/views/users/show.rhtml
43 43

  
44 44
<div class="splitcontentright">
45 45

  
46
  <% if @user.author %>
46 47
  <div id="bibliography">
47 48
    <% @publications = Publication.all(:include => :authors, :conditions => "authors.id = #{@user.author.id}") %>
48 49

  
......
65 66
      </dd>
66 67
  	<% end %>
67 68
  </div>
68

  
69
  <% end %>
69 70

  
70 71

  
71 72
<% unless @events_by_day.empty? %>
vendor/plugins/redmine_bibliography/assets/javascripts/authors.js
57 57
    toggle_div("publication_authorships_attributes_" + form_object_id +"_search_author");
58 58
}
59 59

  
60
function edit_author(form_object_id){}
60
function hide_all_bibtex_required_fields(){$$('p.bibtex').each(function(s){s.hide()})}
61 61

  
62
function hide_all_bibtex_required_fields() {
63
	$$('input.bibtex').each(function(s){
64
	    s.up('p').hide();
65
		})}
66
		
67
function show_all_required_bibtex_fields(entrytype_fields) {
68
	$$('input.bibtex').each(function(s){
69
    if(entrytype_fields.indexOf(s.id.split('_').last()) == -1){s.up('p').hide()};
62
// entrytype_fields is a jsno array with the fields requires by the selected bibtex entry 
63
function show_required_bibtex_fields(entrytype_fields) {
64
	$$('p.bibtex').each(function(s){
65
		if(entrytype_fields.indexOf(s.down('input').id.split('_').last()) != -1){
66
			s.show();
67
			}
68
		else {
69
			s.hide();
70
			}
70 71
	})
71 72
}
72 73
		
vendor/plugins/redmine_bibliography/config/locales/en.yml
23 23

  
24 24
  label_all_publications: All Publications
25 25
  label_all_publications_for_project: Publications associated with %{project}
26
  label_authors_show: "Authorships by this author"
26
  label_authors_show: "Authorships associated with this author"
27 27
  label_authors_index: "List of authors"
28 28
  
29
  field_authorship_publication_title: "Publication Title"
30
  field_authorship_name: "Name"
31
  field_authorship_email: "Email Address"
29
  field_authorship_publication_title: "Publication"
30
  field_authorship_name: "Name on Paper"
31
  field_authorship_email: "Email"
32 32
  field_authorship_institution: "Institution"
33 33
  
34 34
  field_external_url: "External URL"
......
86 86
  field_publication_id: "Publication_id"
87 87
  field_address: "Address"
88 88
  field_annote: "Annote"
89
  field_booktitle: "Book Title"
89
  field_booktitle: "Title of Book or Proceedings"
90 90
  field_chapter: "Chapter"
91 91
  field_crossref: "Cross Reference"
92 92
  field_edition: "Edition"

Also available in: Unified diff