Sha256: d5c6d6c43da2b3028950d2a0f38cb8cab31dd47cc9f61310f9b96cb10eadd5ca

Contents?: true

Size: 1.28 KB

Versions: 10

Compression:

Stored size: 1.28 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(Iqvoc::InlineDataHelper::Joiner)
  end

  def widget_entities(concept, relation_class)
    origins = concept.
      concept_relations_by_id(relation_class.name.to_relation_name).
      split(Iqvoc::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(Iqvoc::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

10 entries across 10 versions & 1 rubygems

Version Path
iqvoc-4.0.8 app/helpers/widget_helper.rb
iqvoc-4.0.7 app/helpers/widget_helper.rb
iqvoc-4.0.6 app/helpers/widget_helper.rb
iqvoc-4.0.5 app/helpers/widget_helper.rb
iqvoc-4.0.4 app/helpers/widget_helper.rb
iqvoc-4.0.3 app/helpers/widget_helper.rb
iqvoc-4.0.2 app/helpers/widget_helper.rb
iqvoc-4.0.1 app/helpers/widget_helper.rb
iqvoc-4.0.0 app/helpers/widget_helper.rb
iqvoc-3.5.7 app/helpers/widget_helper.rb