Module: LabelsHelper

Defined in:
app/helpers/labels_helper.rb

Instance Method Summary collapse

Instance Method Details

#label_header(label) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
# File 'app/helpers/labels_helper.rb', line 61

def label_header(label)
  desc = label.class.model_name.human

  if label.expired_at
    desc += " #{t('txt.views.concepts.expired_at', date: l(label.expired_at, format: :long))} "
  end

  title = label.value .present? ? label.value : label.origin

  page_header title: title.to_s, desc: desc.html_safe
end

#label_view_data(label) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/helpers/labels_helper.rb', line 35

def label_view_data(label)
  res = {'main' => {}}

  res['main'][10] = render 'labels/language', label: label

  res['main'][400] = render 'labels/details', label: label

  Iqvoc::Concept.labeling_classes.keys.each do |labeling_class|
    render_label_association(res, label, labeling_class)
  end

  Iqvoc::XLLabel.relation_classes.each do |relation_class|
    render_label_association(res, label, relation_class)
  end

  Iqvoc::XLLabel.note_classes.each do |note_class|
    render_label_association(res, label, note_class)
  end

  Iqvoc::XLLabel.additional_association_classes.keys.each do |assoc_class|
    render_label_association(res, label, assoc_class)
  end

  res
end

#render_label_association(hash, label, association_class, further_options = {}) ⇒ Object



29
30
31
32
33
# File 'app/helpers/labels_helper.rb', line 29

def render_label_association(hash, label, association_class, further_options = {})
  return unless association_class.partial_name(label)
  ((hash[association_class.view_section(label)] ||= {})[association_class.view_section_sort_key(label)] ||= '') <<
    render(association_class.partial_name(label), further_options.merge(label: label, klass: association_class))
end

#render_label_rdf(document, label) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/helpers/labels_helper.rb', line 2

def render_label_rdf(document, label)
  document << label.build_rdf_subject do |c|

    c.Schema::expires(label.expired_at.to_s) if label.expired_at

    c.Owl::deprecated(true) if label.expired?

    c.Skosxl::literalForm(label.value, lang: label.language)

    label.relations.each do |relation|
      relation.build_rdf(document, c)
    end

    if Iqvoc::rdf_show_change_notes
      label.notes.each do |note|
        note.build_rdf(document, c)
      end
    end

    Iqvoc::XLLabel.additional_association_class_names.keys.each do |class_name|
      label.send(class_name.to_relation_name).each do |additional_object|
        additional_object.build_rdf(document, c)
      end
    end
  end
end