Module: TagsHelper

Defined in:
app/helpers/tags_helper.rb

Overview

Copyright © 2008-2013 Michael Dvorkin and contributors.

Fat Free CRM is freely distributable under the terms of MIT license. See MIT-LICENSE file or www.opensource.org/licenses/mit-license.php


Instance Method Summary collapse

Instance Method Details

#tags_for_dashboard(model) ⇒ Object



23
24
25
26
27
28
29
# File 'app/helpers/tags_helper.rb', line 23

def tags_for_dashboard(model)
  (:ul) do
    model.tag_list.each do |tag|
      concat((:li, tag))
    end
  end.html_safe
end

#tags_for_index(model) ⇒ Object

Generate tag links for use on asset index pages.




10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/tags_helper.rb', line 10

def tags_for_index(model)
  model.tag_list.inject([]) do |arr, tag|
    query = controller.send(:current_query) || ""
    hashtag = "##{tag}"
    if query.empty?
      query = hashtag
    elsif !query.include?(hashtag)
      query += " #{hashtag}"
    end
    arr << link_to_function(tag, "crm.search_tagged('#{query}', '#{model.class.to_s.tableize}')", :title => tag)
  end.join(" ").html_safe
end

#tags_for_show(model) ⇒ Object

Generate tag links for the asset landing page (shown on a sidebar).




33
34
35
36
37
# File 'app/helpers/tags_helper.rb', line 33

def tags_for_show(model)
  model.tag_list.inject([]) do |arr, tag|
    arr << link_to(tag, url_for(:action => "tagged", :id => tag), :title => tag)
  end.join(" ").html_safe
end