Module: TagsHelper

Defined in:
app/helpers/tags_helper.rb

Instance Method Summary (collapse)

Instance Method Details

tag_object is to be tagged



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

def add_tag_link(object: nil, attribute: nil) # tag_object is to be tagged
  link_to('Add tag',
          new_tag_path(tag_object_id: object.id, tag_object_type: object.class.name, tag_object_attribute: attribute),
          id: "tag_splat_#{object.class}_#{object.id}"
          # José - icon via class and or data-attribute here
         )
end


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

def destroy_tag_link(tag)
  destroy_object_link(tag)
end


21
22
23
# File 'app/helpers/tags_helper.rb', line 21

def link_to_destroy_tag(link_text, tag)
  link_to(link_text, '', class: 'tag-destroy', tag_id: tag.id)
end


16
17
18
19
# File 'app/helpers/tags_helper.rb', line 16

def tag_link(tag)
  return nil if tag.nil?
  link_to(tag_tag(tag), metamorphosize_if(tag.tag_object))
end

- (String (html)?) tag_list_tag(object)

Returns a ul/li of tags for the object

Returns:

  • (String (html), nil)

    a ul/li of tags for the object



45
46
47
48
49
50
51
52
# File 'app/helpers/tags_helper.rb', line 45

def tag_list_tag(object)
  if object.tags.any?
    (:h3, 'Tags') +
    (:ul, class: 'tag_list') do
      object.tags.collect { |a| (:li, tag_tag(a)) }.join.html_safe
    end
  end
end

- (Object) tag_tag(tag)



3
4
5
6
7
8
9
10
# File 'app/helpers/tags_helper.rb', line 3

def tag_tag(tag)
  return nil if tag.nil?

  [tag.keyword.name,
   tag.tag_object_type,
   object_tag(tag.tag_object)
  ].compact.join(' : ')
end

- (True) tags_recent_objects_partial

Returns indicates a custom partial should be used, see list_helper.rb

Returns:

  • (True)

    indicates a custom partial should be used, see list_helper.rb



39
40
41
# File 'app/helpers/tags_helper.rb', line 39

def tags_recent_objects_partial
  true
end

- (Object) tags_search_form



12
13
14
# File 'app/helpers/tags_helper.rb', line 12

def tags_search_form
  render '/tags/quick_search_form'
end