diff --git a/app/controllers/admin/boards_controller.rb b/app/controllers/admin/boards_controller.rb new file mode 100644 index 00000000..a7c0d41d --- /dev/null +++ b/app/controllers/admin/boards_controller.rb @@ -0,0 +1,34 @@ +module Admin + class BoardsController < 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/controllers/application_controller.rb b/app/controllers/application_controller.rb index bbe0963e..75f2992a 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,5 +1,6 @@ class ApplicationController < ActionController::Base before_action :configure_permitted_parameters, if: :devise_controller? + before_action :load_boards protected @@ -7,4 +8,8 @@ class ApplicationController < ActionController::Base devise_parameter_sanitizer.permit(:sign_up, keys: [:full_name]) devise_parameter_sanitizer.permit(:account_update, keys: [:full_name]) end + + def load_boards + @boards = Board.all.only(:id, :name) + end end diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb new file mode 100644 index 00000000..25b93589 --- /dev/null +++ b/app/controllers/boards_controller.rb @@ -0,0 +1,5 @@ +class BoardsController < ApplicationController + def show + @board = Board.find(params[:id]) + end +end diff --git a/app/dashboards/board_dashboard.rb b/app/dashboards/board_dashboard.rb new file mode 100644 index 00000000..cdbe8632 --- /dev/null +++ b/app/dashboards/board_dashboard.rb @@ -0,0 +1,64 @@ +require "administrate/base_dashboard" + +class BoardDashboard < 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, + description: Field::Text, + 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 + description + ].freeze + + # SHOW_PAGE_ATTRIBUTES + # an array of attributes that will be displayed on the model's show page. + SHOW_PAGE_ATTRIBUTES = %i[ + id + name + description + 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 + description + ].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 boards are displayed + # across all pages of the admin dashboard. + # + # def display_resource(board) + # "Board ##{board.id}" + # end +end diff --git a/app/helpers/boards_helper.rb b/app/helpers/boards_helper.rb new file mode 100644 index 00000000..8b8af150 --- /dev/null +++ b/app/helpers/boards_helper.rb @@ -0,0 +1,2 @@ +module BoardsHelper +end diff --git a/app/models/board.rb b/app/models/board.rb new file mode 100644 index 00000000..bd144a01 --- /dev/null +++ b/app/models/board.rb @@ -0,0 +1,4 @@ +class Board < ApplicationRecord + validates :name, presence: true, uniqueness: true + validates :description, length: { in: 0..1024 }, allow_nil: true +end diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb new file mode 100644 index 00000000..54272a5e --- /dev/null +++ b/app/views/boards/show.html.erb @@ -0,0 +1,2 @@ +
<%= @board.description %>
diff --git a/app/views/layouts/_boards_menu_section.html.erb b/app/views/layouts/_boards_menu_section.html.erb new file mode 100644 index 00000000..abae5c41 --- /dev/null +++ b/app/views/layouts/_boards_menu_section.html.erb @@ -0,0 +1,5 @@ +<% boards.each do |board| %> +