# frozen_string_literal: true class SunriseFormatService < Sunrise::AbstractModel self.resource_name = 'Formats::Service' available_index_views [:thumbs] index :thumbs do scope { Formats::Service.includes(:categories) } field :color_theme_id group :search do field :title end end show do field :title field :description field :categories, label: 'Service categories', url: lambda { |record| { model_name: :format_categories, action: :index, search: { service_id: record.id } } } field :categories, label: 'Service categories', content: lambda { |record| record.categories.map(&:title).join(', ') } field :items, label: 'Service items', items: lambda { |record| record.default_category.items.map do |item| [ { image: item.icon.try(:url, :thumb) || 'sunrise/default_ava.png' }, { url: { model_name: :format_items, action: :show, id: item.id }, class: 'item-title', content: -> { item.title }, style: 'display: block; float: left; width: 590px; overflow: hidden;' }, { tag: :div, content: lambda { "
".html_safe } } ] end } end form do field :title, as: :text, translate: true, input_html: { rows: 2, style: 'width:800px;' } field :color_theme_id, collection: -> { Formats::ColorTheme.all }, include_blank: false field :description, as: :ckeditor, translate: true, input_html: { height: 400, width: 900 } end end