Customise dashboards

This commit is contained in:
Joshua Coles 2023-10-01 20:00:23 +01:00
parent d44460df93
commit d8a6f27734
3 changed files with 23 additions and 18 deletions

View File

@ -10,6 +10,7 @@ class CourseDashboard < Administrate::BaseDashboard
ATTRIBUTE_TYPES = { ATTRIBUTE_TYPES = {
id: Field::Number, id: Field::Number,
lectures: Field::HasMany, lectures: Field::HasMany,
recordings: Field::HasMany,
panopto_folders: Field::String.with_options(searchable: false), panopto_folders: Field::String.with_options(searchable: false),
semester_start_date: Field::Date, semester_start_date: Field::Date,
title: Field::String, title: Field::String,
@ -25,22 +26,23 @@ class CourseDashboard < Administrate::BaseDashboard
# By default, it's limited to four items to reduce clutter on index pages. # By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items. # Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[ COLLECTION_ATTRIBUTES = %i[
id title
unit_code
lectures lectures
panopto_folders recordings
semester_start_date
].freeze ].freeze
# SHOW_PAGE_ATTRIBUTES # SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page. # an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = %i[ SHOW_PAGE_ATTRIBUTES = %i[
id id
lectures title
unit_code
panopto_folders panopto_folders
semester_start_date semester_start_date
title
toggl_project toggl_project
unit_code lectures
recordings
created_at created_at
updated_at updated_at
].freeze ].freeze
@ -49,12 +51,11 @@ class CourseDashboard < Administrate::BaseDashboard
# an array of attributes that will be displayed # an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages. # on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = %i[ FORM_ATTRIBUTES = %i[
lectures title
unit_code
panopto_folders panopto_folders
semester_start_date semester_start_date
title
toggl_project toggl_project
unit_code
].freeze ].freeze
# COLLECTION_FILTERS # COLLECTION_FILTERS
@ -72,7 +73,7 @@ class CourseDashboard < Administrate::BaseDashboard
# Overwrite this method to customize how courses are displayed # Overwrite this method to customize how courses are displayed
# across all pages of the admin dashboard. # across all pages of the admin dashboard.
# #
# def display_resource(course) def display_resource(course)
# "Course ##{course.id}" course.title
# end end
end end

View File

@ -25,10 +25,10 @@ class LectureDashboard < Administrate::BaseDashboard
# By default, it's limited to four items to reduce clutter on index pages. # By default, it's limited to four items to reduce clutter on index pages.
# Feel free to add, remove, or rearrange items. # Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[ COLLECTION_ATTRIBUTES = %i[
id title
attendance
course course
event_uuid start_time
recording
].freeze ].freeze
# SHOW_PAGE_ATTRIBUTES # SHOW_PAGE_ATTRIBUTES
@ -72,7 +72,7 @@ class LectureDashboard < Administrate::BaseDashboard
# Overwrite this method to customize how lectures are displayed # Overwrite this method to customize how lectures are displayed
# across all pages of the admin dashboard. # across all pages of the admin dashboard.
# #
# def display_resource(lecture) def display_resource(lecture)
# "Lecture ##{lecture.id}" lecture.title
# end end
end end

View File

@ -1,3 +1,7 @@
class Course < ApplicationRecord class Course < ApplicationRecord
has_many :lectures has_many :lectures
# A course has a standalone connection to its recordings. To be shown they must be associated with a lecture but we
# track those not associated with a lecture to avoid duplication.
has_many :recordings
end end