Revision 1432:ebda59ca84db plugins/redmine_bibliography/app/helpers

View differences:

plugins/redmine_bibliography/app/helpers/publications_helper.rb
21 21
    s.html_safe
22 22
  end
23 23

  
24

  
25

  
26

  
27 24
  def link_to_remove_fields(name, f)
28 25
    f.hidden_field(:_destroy) + link_to_function(name, "remove_fields(this)", :class => 'icon icon-del')
29 26
  end
......
31 28
  def link_to_add_author_fields(name, f, association, action)
32 29
    new_object = f.object.class.reflect_on_association(association).klass.new
33 30
    fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder|
31
      # renders _authorship_fields.html.erb
34 32
      render(association.to_s.singularize + "_fields", :f => builder)
35 33
    end
34

  
36 35
    link_to_function(name, "add_author_fields(this, '#{association}', '#{escape_javascript(fields)}', '#{action}')", { :class => 'icon icon-add', :id => "add_another_author" })
37 36
  end
38 37

  
......
59 58
    str.to_sym
60 59
  end
61 60

  
62
  #######
63
  ### DELETE ME
64

  
65
  def choose_author_link(object_name, items)
66
    # called by autocomplete_for_author (publications' action/view)
67
    # creates the select list based on the results array
68
    # results is an array with both Users and Authorships objects
69

  
70
    @author_options = []
71
    @results.each do |result|
72
      email_bit = result.mail.partition('@')[2]
73
      if email_bit != ""
74
          email_bit = "(@#{email_bit})"
75
      end
76
      @author_options << ["#{result.name} #{email_bit}", "#{result.class.to_s}_#{result.id.to_s}"]
77
    end
78

  
79
   if @results.size > 0
80
     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} )
81
   else
82
     s = "<em>No Authors found that match your search… sorry!</em>"
83
   end
84
  end
85

  
86

  
87

  
88 61
  def render_authorships_list(publication)
89 62
    s = '<p>'
90 63

  
......
133 106
    end
134 107
  end
135 108

  
136

  
137 109
  def show_bibtex_fields(bibtex_entry)
138 110
    s = ""
139 111
    bibtex_entry.attributes.keys.sort.each do |key|
......
152 124
  end
153 125
end
154 126

  
127

  
128
def render_authorship_link(link_class, link_id)
129

  
130
  # Renders a link for an author used when adding authors for a publication
131
  # link_class can be either User or Author
132
  # link_id will be the id of the Author/User we wish to link
133

  
134
  s= ""
135

  
136
  if link_class == "Author"
137
    url = {:controller => 'authors', :action => 'show', :id => link_id}
138
    s << link_to(h(Author.find(link_id).name), url)
139
  else
140
    url = {:controller => 'users', :action => 'show', :id => link_id}
141
    s << link_to(h(User.find(link_id).name), url)
142
  end
143

  
144
  s.html_safe
145
end
146

  

Also available in: Unified diff