-
Notifications
You must be signed in to change notification settings - Fork 5
605: Add user origin to school dashboard, fix relationships #556
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fe3513f
97a1b1f
8e59868
b3d442c
e9b7808
74798a7
2685ad3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The student and teacher dashboards only show the profile id owing to complications around pulling in user info from profile, this is out of scope of this issue and will need to be expanded in the future...this at least allows things to render, and a dev can look up the user_id if need be. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'administrate/base_dashboard' | ||
|
||
class ClassStudentDashboard < 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 = { | ||
school_class: Field::HasOne, | ||
student_id: 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[ | ||
student_id | ||
created_at | ||
updated_at | ||
].freeze | ||
|
||
# SHOW_PAGE_ATTRIBUTES | ||
# an array of attributes that will be displayed on the model's show page. | ||
SHOW_PAGE_ATTRIBUTES = %i[ | ||
student_id_changed | ||
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[].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 = {}.freeze | ||
|
||
# Overwrite this method to customize how school classes are displayed | ||
# across all pages of the admin dashboard. | ||
# | ||
# def display_resource(school_class) | ||
# "SchoolClass ##{school_class.id}" | ||
# end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# frozen_string_literal: true | ||
|
||
require 'administrate/base_dashboard' | ||
|
||
class ClassTeacherDashboard < 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 = { | ||
school_class: Field::HasOne, | ||
teacher_id: 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[ | ||
teacher_id | ||
created_at | ||
updated_at | ||
].freeze | ||
|
||
# SHOW_PAGE_ATTRIBUTES | ||
# an array of attributes that will be displayed on the model's show page. | ||
SHOW_PAGE_ATTRIBUTES = %i[ | ||
teacher_id | ||
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[].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 = {}.freeze | ||
|
||
# Overwrite this method to customize how school classes are displayed | ||
# across all pages of the admin dashboard. | ||
# | ||
# def display_resource(class_teacher) | ||
# class_teacher.teacher.name | ||
# end | ||
end |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without this, administrate tries to treat enums as select fields and will error, since the data is not in the expected format |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
class EnumField < Administrate::Field::Select | ||
def to_s | ||
# Use Rails' i18n for enums | ||
return if data.blank? | ||
|
||
I18n.t( | ||
"activerecord.attributes.#{resource.class.model_name.i18n_key}.#{attribute}_values.#{data}", | ||
default: data.humanize | ||
) | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div class="field-unit__label"> | ||
<%= f.label field.attribute %> | ||
</div> | ||
<div class="field-unit__field"> | ||
<%= f.text_field field.attribute %> | ||
</div> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= field.to_s %> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%= field.to_s %> |
Uh oh!
There was an error while loading. Please reload this page.