Module: AnnotationsHelper

Defined in:
app/helpers/annotations_helper.rb

Overview

Helpers that wrap sets of annotations of different types.

Instance Method Summary collapse

Instance Method Details

#annotation_id(object) ⇒ Object



43
44
45
# File 'app/helpers/annotations_helper.rb', line 43

def annotation_id(object)
  "annotation_anchor_#{object.metamorphosize.class.name}_#{object.id}"
end

#annotations_exist(object) ⇒ Object



32
33
34
35
36
37
38
39
40
41
# File 'app/helpers/annotations_helper.rb', line 32

def annotations_exist(object)
  return (object.has_citations? && object.citations.any?) || 
    (object.has_identifiers? && object.identifiers.any?) ||
    (object.has_data_attributes? && object.data_attributes.any?) ||
    (object.has_notes? && object.notes.any?) ||
    (object.has_tags? && object.tags.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

Returns:

  • (String)


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/helpers/annotations_helper.rb', line 6

def annotations_summary_tag(object)
  (:div, class: %w{item panel separate-bottom}) do
    (:div, class: [:content]) do
      (:div, class: ['information-panel']) do
        (:h2, 'Annotations') +
          (:div,
          [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),
           confidence_list_tag(object),
           attribution_list_tag(object)
        ].compact.join.html_safe, class: :annotations_summary_list, 'data-annotator-list-object-id' => object.id)

      end
    end
  end

  # depictions
  # confidences
  # protocols

end

#klass_and_labels(klass_names) ⇒ Array

Returns of { ClassName => human name }.

Returns:

  • (Array)

    of { ClassName => human name }



53
54
55
# File 'app/helpers/annotations_helper.rb', line 53

def klass_and_labels(klass_names)
  klass_names.collect{|n| [n, n.tableize.humanize]}.to_h
end

#radial_annotator(object, pulse = false, showCount = false) ⇒ Object



47
48
49
# File 'app/helpers/annotations_helper.rb', line 47

def radial_annotator(object, pulse = false, showCount = false)
  (:div, '', data: { 'global-id' => object.to_global_id.to_s, 'radial-annotator' => 'true', 'show-count' => showCount, 'pulse' => pulse })
end