mirror of
https://github.com/usetrmnl/terminus.git
synced 2026-08-13 14:29:27 -07:00
As done with templates having many screens, this allows a screen to belong to a template which completes the association. Issue: 321 Milestone: minor
20 lines
598 B
Ruby
20 lines
598 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Terminus
|
|
module Relations
|
|
# The screen relation.
|
|
class Screen < DB::Relation
|
|
schema :screen, infer: true do
|
|
associations do
|
|
belongs_to :model, relation: :model
|
|
belongs_to :template, relation: :screen_template
|
|
has_many :playlist_items, relation: :playlist_item, as: :playlist_items, view: :ordered
|
|
has_many :playlists, through: :playlist_item, relation: :playlist, as: :playlists
|
|
end
|
|
end
|
|
|
|
def ordered = select_append(playlist_item[:position]).order :position
|
|
end
|
|
end
|
|
end
|