Sha256: 3134a4f6eed053fe6c5558377cb71cee402f9f5c113ba5b7a8c071d7dda832e9

Contents?: true

Size: 1.26 KB

Versions: 7

Compression:

Stored size: 1.26 KB

Contents

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

  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

  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) }.
      to_json
  end

  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
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
iqvoc-4.11.1 app/helpers/widget_helper.rb
iqvoc-4.11.0 app/helpers/widget_helper.rb
iqvoc-4.10.0 app/helpers/widget_helper.rb
iqvoc-4.9.0 app/helpers/widget_helper.rb
iqvoc-4.8.2 app/helpers/widget_helper.rb
iqvoc-4.8.1 app/helpers/widget_helper.rb
iqvoc-4.8.0 app/helpers/widget_helper.rb