Module: TagsHelper

Defined in:
app/helpers/tags_helper.rb

Instance Method Summary (collapse)

Instance Method Details

tag_object is to be tagged



37
38
39
40
41
42
43
# File 'app/helpers/tags_helper.rb', line 37

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


45
46
47
# File 'app/helpers/tags_helper.rb', line 45

def destroy_tag_link(tag)
  destroy_object_link(tag)
end


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

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

- (Object) tag_annotation_tag(tag)



9
10
11
12
# File 'app/helpers/tags_helper.rb', line 9

def tag_annotation_tag(tag)
  return nil if tag.nil?
  (:span, controlled_vocabulary_term_tag(tag.keyword), class: [:annotation__tag])
end


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

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



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

def tag_list_tag(object)
  return nil unless object.has_tags? && object.tags.any?
  (:h3, 'Tags') +
    (:ul, class: 'annotations__tag_list') do
    object.tags.collect { |a| (:li, tag_annotation_tag(a)) }.join.html_safe
  end
end

- (Object) tag_tag(tag)



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

def tag_tag(tag)
  return nil if tag.nil?
  pieces =  [controlled_vocabulary_term_tag(tag.keyword), tag.tag_object_type, object_tag(tag.tag_object)]
  pieces.compact.join(': ').html_safe
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



51
52
53
# File 'app/helpers/tags_helper.rb', line 51

def tags_recent_objects_partial
  true
end

- (Object) tags_search_form



24
25
26
# File 'app/helpers/tags_helper.rb', line 24

def tags_search_form
  render '/tags/quick_search_form'
end