|
| 1 | +require "administrate/base_dashboard" |
| 2 | +require "administrate/field/jsonb" |
| 3 | + |
| 4 | +class ProgrammeActivityGroupingDashboard < Administrate::BaseDashboard |
| 5 | + # ATTRIBUTE_TYPES |
| 6 | + # a hash that describes the type of each of the model's fields. |
| 7 | + # |
| 8 | + # Each different type represents an Administrate::Field object, |
| 9 | + # which determines how the attribute is displayed |
| 10 | + # on pages throughout the dashboard. |
| 11 | + ATTRIBUTE_TYPES = { |
| 12 | + id: Field::String, |
| 13 | + activities: Field::HasMany, |
| 14 | + community: Field::Boolean, |
| 15 | + metadata: Field::String.with_options(searchable: false), |
| 16 | + objectives: Field::String.with_options(searchable: false), |
| 17 | + programme: Field::BelongsTo, |
| 18 | + programme_activities: Field::HasMany, |
| 19 | + progress_bar_title: Field::String, |
| 20 | + required_for_completion: Field::Number, |
| 21 | + sort_key: Field::Number, |
| 22 | + title: Field::String, |
| 23 | + web_copy: ProgrammeActivityGroupingJsonViewerField, |
| 24 | + created_at: Field::DateTime, |
| 25 | + updated_at: Field::DateTime |
| 26 | + }.freeze |
| 27 | + |
| 28 | + # COLLECTION_ATTRIBUTES |
| 29 | + # an array of attributes that will be displayed on the model's index page. |
| 30 | + # |
| 31 | + # By default, it's limited to four items to reduce clutter on index pages. |
| 32 | + # Feel free to add, remove, or rearrange items. |
| 33 | + COLLECTION_ATTRIBUTES = %i[ |
| 34 | + title |
| 35 | + programme |
| 36 | + activities |
| 37 | + community |
| 38 | + ].freeze |
| 39 | + |
| 40 | + # SHOW_PAGE_ATTRIBUTES |
| 41 | + # an array of attributes that will be displayed on the model's show page. |
| 42 | + SHOW_PAGE_ATTRIBUTES = %i[ |
| 43 | + title |
| 44 | + progress_bar_title |
| 45 | + programme |
| 46 | + web_copy |
| 47 | + community |
| 48 | + metadata |
| 49 | + objectives |
| 50 | + programme_activities |
| 51 | + ].freeze |
| 52 | + |
| 53 | + # FORM_ATTRIBUTES |
| 54 | + # an array of attributes that will be displayed |
| 55 | + # on the model's form (`new` and `edit`) pages. |
| 56 | + FORM_ATTRIBUTES = %i[ |
| 57 | + title |
| 58 | + activities |
| 59 | + community |
| 60 | + metadata |
| 61 | + objectives |
| 62 | + programme |
| 63 | + programme_activities |
| 64 | + progress_bar_title |
| 65 | + required_for_completion |
| 66 | + sort_key |
| 67 | + web_copy |
| 68 | + ].freeze |
| 69 | + |
| 70 | + # COLLECTION_FILTERS |
| 71 | + # a hash that defines filters that can be used while searching via the search |
| 72 | + # field of the dashboard. |
| 73 | + # |
| 74 | + # For example to add an option to search for open resources by typing "open:" |
| 75 | + # in the search field: |
| 76 | + # |
| 77 | + # COLLECTION_FILTERS = { |
| 78 | + # open: ->(resources) { resources.where(open: true) } |
| 79 | + # }.freeze |
| 80 | + COLLECTION_FILTERS = {}.freeze |
| 81 | + |
| 82 | + # Overwrite this method to customize how programme activity groupings are displayed |
| 83 | + # across all pages of the admin dashboard. |
| 84 | + # |
| 85 | + def display_resource(programme_activity_grouping) |
| 86 | + "#{programme_activity_grouping.title}" |
| 87 | + end |
| 88 | +end |
0 commit comments