Module: TagsHelper
- Defined in:
- app/helpers/tags_helper.rb
Instance Method Summary collapse
- 
  
    
      #add_tag_link(object: nil, attribute: nil)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    tag_object is to be tagged. 
- #destroy_tag_link(tag) ⇒ Object
- 
  
    
      #inserted_keyword  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Session related helpers. 
- #inserted_keyword_tag_count ⇒ Object
- 
  
    
      #is_default_tagged?(object)  ⇒ Integer, false 
    
    
  
  
  
  
  
  
  
  
  
    True if the object is tagged, and is tagged with the keyword presently defaulted on the pinboard. 
- #link_to_destroy_tag(link_text, tag) ⇒ Object
- #tag_annotation_tag(tag) ⇒ Object
- #tag_default_icon(object) ⇒ Object
- #tag_link(tag) ⇒ Object
- 
  
    
      #tag_list_tag(object)  ⇒ String (html)? 
    
    
  
  
  
  
  
  
  
  
  
    A ul/li of tags for the object. 
- #tag_pills_tag(object) ⇒ Object
- #tag_tag(tag) ⇒ Object
- 
  
    
      #tags_recent_objects_partial  ⇒ True 
    
    
  
  
  
  
  
  
  
  
  
    Indicates a custom partial should be used, see list_helper.rb. 
Instance Method Details
#add_tag_link(object: nil, attribute: nil) ⇒ Object
tag_object is to be tagged
| 47 48 49 50 51 52 53 54 55 56 | # File 'app/helpers/tags_helper.rb', line 47 def add_tag_link(object: nil, attribute: nil) # tag_object is to be tagged if object. 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}" ) else nil end end | 
#destroy_tag_link(tag) ⇒ Object
| 58 59 60 | # File 'app/helpers/tags_helper.rb', line 58 def destroy_tag_link(tag) destroy_object_link(tag) end | 
#inserted_keyword ⇒ Object
Session related helpers
| 70 71 72 | # File 'app/helpers/tags_helper.rb', line 70 def inserted_keyword inserted_pinboard_item_object_for_klass('Keyword') end | 
#inserted_keyword_tag_count ⇒ Object
| 74 75 76 | # File 'app/helpers/tags_helper.rb', line 74 def inserted_keyword_tag_count inserted_keyword.try(:tags).try(:count) end | 
#is_default_tagged?(object) ⇒ Integer, false
Returns true if the object is tagged, and is tagged with the keyword presently defaulted on the pinboard.
| 80 81 82 83 84 85 86 | # File 'app/helpers/tags_helper.rb', line 80 def is_default_tagged?(object) return false if object.blank? keyword = inserted_keyword return false if keyword.blank? t = Tag.where(tag_object: object, keyword: keyword).first.try(:id) t ? t : false end | 
#link_to_destroy_tag(link_text, tag) ⇒ Object
| 43 44 45 | # File 'app/helpers/tags_helper.rb', line 43 def link_to_destroy_tag(link_text, tag) link_to(link_text, '', class: 'tag-destroy', tag_id: tag.id) end | 
#tag_annotation_tag(tag) ⇒ Object
| 9 10 11 12 | # File 'app/helpers/tags_helper.rb', line 9 def tag_annotation_tag(tag) return nil if tag.nil? content_tag(:span, controlled_vocabulary_term_tag(tag.keyword)) end | 
#tag_default_icon(object) ⇒ Object
| 28 29 30 31 32 33 34 35 36 | # File 'app/helpers/tags_helper.rb', line 28 def tag_default_icon(object) content_tag(:span, 'Tag', data: { 'tag-default' => 'true', 'tag-object-global-id' => object.to_global_id.to_s, 'default-tagged-id' => is_default_tagged?(object), 'inserted-keyword-count' => inserted_keyword_tag_count }) end | 
#tag_link(tag) ⇒ Object
| 38 39 40 41 | # File 'app/helpers/tags_helper.rb', line 38 def tag_link(tag) return nil if tag.nil? link_to(tag_tag(tag), (tag.tag_object)) end | 
#tag_list_tag(object) ⇒ String (html)?
Returns a ul/li of tags for the object.
| 16 17 18 19 | # File 'app/helpers/tags_helper.rb', line 16 def tag_list_tag(object) return nil unless object. && object..load.any? content_tag(:h3, 'Tags') + tag_pills_tag(object) end | 
#tag_pills_tag(object) ⇒ Object
| 21 22 23 24 25 26 | # File 'app/helpers/tags_helper.rb', line 21 def tag_pills_tag(object) return nil unless object. && object..load.any? content_tag(:ul, class: 'annotations__tag_list') do object..collect { |a| content_tag(:li, tag_annotation_tag(a)) }.join.html_safe end end | 
#tag_tag(tag) ⇒ Object
| 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 | 
#tags_recent_objects_partial ⇒ True
Returns indicates a custom partial should be used, see list_helper.rb.
| 64 65 66 | # File 'app/helpers/tags_helper.rb', line 64 def true end |