require "administrate/base_dashboard" class CourseDashboard < Administrate::BaseDashboard # ATTRIBUTE_TYPES # a hash that describes the type of each of the model's fields. # # Each different type represents an Administrate::Field object, # which determines how the attribute is displayed # on pages throughout the dashboard. ATTRIBUTE_TYPES = { id: Field::Number, lectures: Field::HasMany, work_items: Field::HasMany, recordings: Field::HasMany, panopto_folders: Field::String.with_options(searchable: false), semester_start_date: Field::Date, title: Field::String, archived: Field::Boolean, homepage: Field::String, default_live_video_url: Field::Url, toggl_project: Field::Number, unit_code: Field::String, created_at: Field::DateTime, updated_at: Field::DateTime, }.freeze # COLLECTION_ATTRIBUTES # an array of attributes that will be displayed on the model's index page. # # By default, it's limited to four items to reduce clutter on index pages. # Feel free to add, remove, or rearrange items. COLLECTION_ATTRIBUTES = %i[ title unit_code archived homepage lectures default_live_video_url work_items recordings ].freeze # SHOW_PAGE_ATTRIBUTES # an array of attributes that will be displayed on the model's show page. SHOW_PAGE_ATTRIBUTES = %i[ id title unit_code archived homepage panopto_folders semester_start_date toggl_project lectures default_live_video_url work_items recordings created_at updated_at ].freeze # FORM_ATTRIBUTES # an array of attributes that will be displayed # on the model's form (`new` and `edit`) pages. FORM_ATTRIBUTES = %i[ title unit_code archived homepage panopto_folders semester_start_date toggl_project default_live_video_url ].freeze # COLLECTION_FILTERS # a hash that defines filters that can be used while searching via the search # field of the dashboard. # # For example to add an option to search for open resources by typing "open:" # in the search field: # # COLLECTION_FILTERS = { # open: ->(resources) { resources.where(open: true) } # }.freeze COLLECTION_FILTERS = { archived: ->(resources) { resources.where(archived: true) }, active: ->(resources) { resources.where(archived: false) } }.freeze # Overwrite this method to customize how courses are displayed # across all pages of the admin dashboard. # def display_resource(course) course.title end end