diff --git a/app/controllers/admin/post_statuses_controller.rb b/app/controllers/admin/post_statuses_controller.rb new file mode 100644 index 00000000..9d3109d6 --- /dev/null +++ b/app/controllers/admin/post_statuses_controller.rb @@ -0,0 +1,34 @@ +module Admin + class PostStatusesController < Admin::ApplicationController + # Overwrite any of the RESTful controller actions to implement custom behavior + # For example, you may want to send an email after a foo is updated. + # + # def update + # foo = Foo.find(params[:id]) + # foo.update(params[:foo]) + # send_foo_updated_email + # end + + # Override this method to specify custom lookup behavior. + # This will be used to set the resource for the `show`, `edit`, and `update` + # actions. + # + # def find_resource(param) + # Foo.find_by!(slug: param) + # end + + # Override this if you have certain roles that require a subset + # this will be used to set the records shown on the `index` action. + # + # def scoped_resource + # if current_user.super_admin? + # resource_class + # else + # resource_class.with_less_stuff + # end + # end + + # See https://administrate-prototype.herokuapp.com/customizing_controller_actions + # for more information + end +end diff --git a/app/dashboards/post_status_dashboard.rb b/app/dashboards/post_status_dashboard.rb new file mode 100644 index 00000000..d64b9eba --- /dev/null +++ b/app/dashboards/post_status_dashboard.rb @@ -0,0 +1,64 @@ +require "administrate/base_dashboard" + +class PostStatusDashboard < 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 = { + id: Field::Number, + name: Field::String, + color: ColorField, + 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[ + name + color + ].freeze + + # SHOW_PAGE_ATTRIBUTES + # an array of attributes that will be displayed on the model's show page. + SHOW_PAGE_ATTRIBUTES = %i[ + id + name + color + 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[ + name + color + ].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) { where(open: true) } + # }.freeze + COLLECTION_FILTERS = {}.freeze + + # Overwrite this method to customize how post statuses are displayed + # across all pages of the admin dashboard. + # + # def display_resource(post_status) + # "PostStatus ##{post_status.id}" + # end +end diff --git a/app/fields/color_field.rb b/app/fields/color_field.rb new file mode 100644 index 00000000..1ba760c5 --- /dev/null +++ b/app/fields/color_field.rb @@ -0,0 +1,7 @@ +require "administrate/field/base" + +class ColorField < Administrate::Field::Base + def to_s + data.to_s + end +end diff --git a/app/views/fields/color_field/_form.html.erb b/app/views/fields/color_field/_form.html.erb new file mode 100644 index 00000000..b0955f5b --- /dev/null +++ b/app/views/fields/color_field/_form.html.erb @@ -0,0 +1,6 @@ +