Module: AnnotationsHelper
- Defined in:
- app/helpers/annotations_helper.rb
Overview
Helpers that wrap sets of annotations of different types.
Instance Method Summary collapse
- #annotation_id(object) ⇒ Object
- #annotations_exist(object) ⇒ Object
- 
  
    
      #annotations_summary_tag(object)  ⇒ String 
    
    
  
  
  
  
  
  
  
  
  
    Assumes the context is the object, not a multi-object summary. 
- 
  
    
      #klass_and_labels(klass_names)  ⇒ Array 
    
    
  
  
  
  
  
  
  
  
  
    Of { ClassName => human name }. 
- 
  
    
      #klass_annotations  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Models name as key, annotator names as Array of values see /metadata/annotators.json. 
- #radial_annotator(object, pulse = false, showCount = false) ⇒ Object
- #radial_annotator_otu(object, pulse = false, showCount = false) ⇒ Object
Instance Method Details
#annotation_id(object) ⇒ Object
| 63 64 65 | # File 'app/helpers/annotations_helper.rb', line 63 def annotation_id(object) "annotation_anchor_#{object..class.name}_#{object.id}" end | 
#annotations_exist(object) ⇒ Object
| 52 53 54 55 56 57 58 59 60 61 | # File 'app/helpers/annotations_helper.rb', line 52 def annotations_exist(object) return (object.has_citations? && object.citations.any?) || (object.has_identifiers? && object.identifiers.visible(sessions_current_project_id).any?) || (object.has_data_attributes? && object.data_attributes.any?) || (object.has_notes? && object.notes.any?) || (object. && object..load.any?) || (object.has_alternate_values? && object.alternate_values.any?) || (object.has_confidences? && object.confidences.any?) || (object.has_attribution? && object.attribution) end | 
#annotations_summary_tag(object) ⇒ String
Assumes the context is the object, not a multi-object summary
| 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | # File 'app/helpers/annotations_helper.rb', line 27 def annotations_summary_tag(object) v = [confidence_list_tag(object), citation_list_tag(object), identifier_list_tag(object), data_attribute_list_tag(object), note_list_tag(object), tag_list_tag(object), alternate_values_list_tag(object), attribution_list_tag(object) ].compact tag.div(class: %w{item panel separate-bottom}) do tag.div(class: [:content]) do tag.div(class: ['information-panel']) do tag.h2('Annotations') + ( v.count > 0 ? tag.div(v.join.html_safe, class: :annotations_summary_list, 'data-annotator-list-object-id' => object.id) : tag.em('None')) end end end # depictions # confidences # protocols end | 
#klass_and_labels(klass_names) ⇒ Array
Returns of { ClassName => human name }.
| 77 78 79 | # File 'app/helpers/annotations_helper.rb', line 77 def klass_and_labels(klass_names) klass_names.index_with{|n| n.tableize.humanize} end | 
#klass_annotations ⇒ Object
Models name as key, annotator names as Array of values
see /metadata/annotators.json
| 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # File 'app/helpers/annotations_helper.rb', line 7 def klass_annotations j = {} ::Project::MANIFEST.sort.each do |m| k = m.safe_constantize if k.respond_to?(:available_annotation_types) j[k.name] = k.available_annotation_types end end # Community classes that can be referenced in Filters # at minimum need to be here j.merge!( 'Source' => Source.available_annotation_types ) j end | 
#radial_annotator(object, pulse = false, showCount = false) ⇒ Object
| 67 68 69 | # File 'app/helpers/annotations_helper.rb', line 67 def radial_annotator(object, pulse = false, showCount = false) content_tag(:div, '', data: { 'global-id' => object.to_global_id.to_s, 'radial-annotator' => 'true', 'show-count' => showCount, 'pulse' => pulse }) end | 
#radial_annotator_otu(object, pulse = false, showCount = false) ⇒ Object
| 71 72 73 | # File 'app/helpers/annotations_helper.rb', line 71 def radial_annotator_otu(object, pulse = false, showCount = false) content_tag(:div, '', data: { 'taxon-name-id' => object.id.to_s, 'otu-radial-annotator' => 'true' }) end |