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 = {
id: Field::Number,
lectures: Field::HasMany,
recordings: Field::HasMany,
panopto_folders: Field::String.with_options(searchable: false),
semester_start_date: Field::Date,
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.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[
id
title
unit_code
lectures
panopto_folders
semester_start_date
recordings
].freeze
# SHOW_PAGE_ATTRIBUTES
# an array of attributes that will be displayed on the model's show page.
SHOW_PAGE_ATTRIBUTES = %i[
id
lectures
title
unit_code
panopto_folders
semester_start_date
title
toggl_project
unit_code
lectures
recordings
created_at
updated_at
].freeze
@ -49,12 +51,11 @@ class CourseDashboard < Administrate::BaseDashboard
# an array of attributes that will be displayed
# on the model's form (`new` and `edit`) pages.
FORM_ATTRIBUTES = %i[
lectures
title
unit_code
panopto_folders
semester_start_date
title
toggl_project
unit_code
].freeze
# COLLECTION_FILTERS
@ -72,7 +73,7 @@ class CourseDashboard < Administrate::BaseDashboard
# Overwrite this method to customize how courses are displayed
# across all pages of the admin dashboard.
#
# def display_resource(course)
# "Course ##{course.id}"
# end
def display_resource(course)
course.title
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.
# Feel free to add, remove, or rearrange items.
COLLECTION_ATTRIBUTES = %i[
id
attendance
title
course
event_uuid
start_time
recording
].freeze
# SHOW_PAGE_ATTRIBUTES
@ -72,7 +72,7 @@ class LectureDashboard < Administrate::BaseDashboard
# Overwrite this method to customize how lectures are displayed
# across all pages of the admin dashboard.
#
# def display_resource(lecture)
# "Lecture ##{lecture.id}"
# end
def display_resource(lecture)
lecture.title
end
end

View File

@ -1,3 +1,7 @@
class Course < ApplicationRecord
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