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