Class: GacoCms::FieldGroup

Inherits:
ApplicationRecord show all
Includes:
BuddyTranslatable, UnionScope
Defined in:
app/models/gaco_cms/field_group.rb

Instance Method Summary collapse

Methods inherited from ApplicationRecord

#activestorage_url, #cache_key_locale, human_name

Instance Method Details

#available_recordsObject



36
37
38
39
40
41
42
43
# File 'app/models/gaco_cms/field_group.rb', line 36

def available_records
  map_data = ->(item) { [item.title, "#{item.class.name}/#{item.id}"] }
  {
    Page.human_name(count: 2) => GacoCms::Page.title_ordered.select(:title, :id).map(&map_data),
    'All Pages Under' => PageType.title_ordered.select(:title, :id).map(&map_data),
    Theme.human_name(count: 2) => GacoCms::Theme.ordered.map(&map_data)
  }
end

#record_labelObject



49
50
51
52
53
# File 'app/models/gaco_cms/field_group.rb', line 49

def record_label
  return "All pages under \"#{record.title}\"" if record_type.include?('PageType')

  "#{record.class.human_name} => \"#{record.title}\""
end

#selected_recordObject



45
46
47
# File 'app/models/gaco_cms/field_group.rb', line 45

def selected_record
  "#{record_type}/#{record_id}"
end