Module: ConceptsHelper

Defined in:
app/helpers/concepts_helper.rb

Overview

Copyright 2011 innoQ Deutschland GmbH

Licensed under the Apache License, Version 2.0 (the “License”); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an “AS IS” BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Instance Method Summary collapse

Instance Method Details

#concept_header(concept) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
# File 'app/helpers/concepts_helper.rb', line 70

def concept_header(concept)
  desc = concept.class.model_name.human

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

  title = concept.pref_label || concept.origin

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

#concept_view_data(concept) ⇒ Object

Renders associated objects of a given concept to a hash structure. This hash is taken by view/layouts/_sections to be rendered.



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'app/helpers/concepts_helper.rb', line 40

def concept_view_data(concept)
  res = {}

  render_concept_association(res, concept, Collection::Member::Concept)

  Iqvoc::Concept.labeling_classes.each do |labeling_class, languages|
    (languages || Iqvoc.available_languages).each do |lang|
      render_concept_association(res, concept, labeling_class, :lang => lang)
    end
  end

  Iqvoc::Concept.relation_classes.each do |relation_class|
    render_concept_association(res, concept, relation_class)
  end

  Iqvoc::Concept.match_classes.each do |match_class|
    render_concept_association(res, concept, match_class)
  end

  Iqvoc::Concept.note_classes.each do |note_class|
    render_concept_association(res, concept, note_class)
  end

  Iqvoc::Concept.additional_association_classes.keys.each do |assoc_class|
    render_concept_association(res, concept, assoc_class)
  end

  res
end

#letter_selector(&block) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/helpers/concepts_helper.rb', line 25

def letter_selector(&block)
  letters = ('A'..'Z').to_a +
    (0..9).to_a +
    ['[']

   :ul, :class => 'letter-selector unstyled' do
    letters.map do |letter|
       :li, link_to(letter, yield(letter)),
        :class => ('active' if params[:prefix] == letter.to_s.downcase)
    end.join("").html_safe
  end
end

#treeview(concepts, broader = false) ⇒ Object

if ‘broader` is supplied, the tree’s direction is reversed (descendants represent broader relations)



20
21
22
23
# File 'app/helpers/concepts_helper.rb', line 20

def treeview(concepts, broader = false)
  render :partial => "concepts/hierarchical/treeview",
    :locals => { :concepts => concepts, :broader => broader }
end