Module: WidgetHelper

Defined in:
app/helpers/widget_helper.rb

Instance Method Summary collapse

Instance Method Details

#widget_entities(concept, relation_class) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'app/helpers/widget_helper.rb', line 11

def widget_entities(concept, relation_class)
  origins = concept.concept_relations_by_id(relation_class.name.to_relation_name)
                   .split(InlineDataHelper::SPLITTER)

  Iqvoc::Concept.base_class
                .editor_selectable
                .by_origin(origins)
                .map { |c| concept_widget_data(c) }
                .sort_by { |hash| hash[:name] }
                .to_json
end

#widget_entities_ranked(concept, relation_class) ⇒ Object



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

def widget_entities_ranked(concept, relation_class)
  origins = concept.
    concept_relations_by_id(relation_class.name.to_relation_name).
    split(InlineDataHelper::SPLITTER)

  allowed_concepts = Iqvoc::Concept.base_class
                                   .editor_selectable
                                   .by_origin(origins)

  concepts_with_ranks = concept.concept_relations_by_id_and_rank(relation_class.name.to_relation_name)

  concepts = concepts_with_ranks.reject { |k, v| !allowed_concepts.include?(k) }
  concepts.map { |c, r| concept_widget_data(c, r) }.to_json
end

#widget_values(concept, relation_class) ⇒ Object



2
3
4
# File 'app/helpers/widget_helper.rb', line 2

def widget_values(concept, relation_class)
  concept.concept_relations_by_id(relation_class.name.to_relation_name)
end

#widget_values_ranked(concept, relation_class) ⇒ Object



6
7
8
9
# File 'app/helpers/widget_helper.rb', line 6

def widget_values_ranked(concept, relation_class)
  concepts_with_ranks = concept.concept_relations_by_id_and_rank(relation_class.name.to_relation_name)
  concepts_with_ranks.map { |concept, rank| "#{concept.origin}:#{rank}" }.join(InlineDataHelper::JOINER)
end