Sha256: 66d881bbab751f6855dc7263ae36532e709d1bc6d49f6c5d00fdef9e00b76f24

Contents?: true

Size: 1.26 KB

Versions: 5

Compression:

Stored size: 1.26 KB

Contents

class Label::Relation::Base < ActiveRecord::Base
  class_attribute :rdf_namespace, :rdf_predicate
  self.rdf_namespace = nil
  self.rdf_predicate = nil

  self.table_name ='label_relations'

  belongs_to :domain, class_name: 'Label::Base'
  belongs_to :range,  class_name: 'Label::Base'

  def self.by_domain(domain)
    where(domain_id: domain)
  end

  def self.by_range(range)
    where(range_id: range)
  end

  def self.by_range_origin(origin)
    includes(:range).references(:labels).merge(Label::Base.by_origin(origin))
  end

  def self.range_editor_selectable
    # includes(:range) & Iqvoc::XLLabel.base_class.editor_selectable
    # Doesn't work correctly (kills label_relations.type condition :-( )
    includes(:range).
    where('labels.published_at IS NOT NULL OR (labels.published_at IS NULL AND labels.published_version_id IS NULL) ')
  end

  def self.range_in_edit_mode
    joins(:range).references(:labels).merge(Iqvoc::XLLabel.base_class.in_edit_mode)
  end

  def self.view_section(obj)
    'relations'
  end

  def self.view_section_sort_key(obj)
    100
  end

  def self.partial_name(obj)
    'partials/label/relation/base'
  end

  def self.edit_partial_name(obj)
    'partials/label/relation/edit_base'
  end

  def self.only_one_allowed?
    false
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
iqvoc_skosxl-2.8.1 app/models/label/relation/base.rb
iqvoc_skosxl-2.8.0 app/models/label/relation/base.rb
iqvoc_skosxl-2.7.0 app/models/label/relation/base.rb
iqvoc_skosxl-2.6.0 app/models/label/relation/base.rb
iqvoc_skosxl-2.5.0 app/models/label/relation/base.rb