Add sdg management header controller
This commit is contained in:
committed by
Javi Martín
parent
ba4b1a91e1
commit
c217af9f4b
29
app/controllers/sdg_management/header_controller.rb
Normal file
29
app/controllers/sdg_management/header_controller.rb
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
class SDGManagement::HeaderController < SDGManagement::BaseController
|
||||||
|
include Admin::Widget::CardsActions
|
||||||
|
helper_method :index_path
|
||||||
|
|
||||||
|
before_action :load_cardable
|
||||||
|
load_and_authorize_resource :header,
|
||||||
|
class: "Widget::Card",
|
||||||
|
through: :cardable,
|
||||||
|
singleton: true,
|
||||||
|
instance_name: :card
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def load_cardable
|
||||||
|
@cardable = WebSection.find_by!(name: "sdg")
|
||||||
|
end
|
||||||
|
|
||||||
|
def index_path
|
||||||
|
sdg_management_homepage_path
|
||||||
|
end
|
||||||
|
|
||||||
|
def form_path
|
||||||
|
sdg_management_homepage_header_path
|
||||||
|
end
|
||||||
|
|
||||||
|
def header_params
|
||||||
|
card_params
|
||||||
|
end
|
||||||
|
end
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
class WebSection < ApplicationRecord
|
class WebSection < ApplicationRecord
|
||||||
has_many :sections
|
has_many :sections
|
||||||
has_many :banners, through: :sections
|
has_many :banners, through: :sections
|
||||||
|
has_one :header, class_name: "Widget::Card", as: :cardable, dependent: :destroy
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ namespace :sdg_management do
|
|||||||
resources :goals, only: [:index]
|
resources :goals, only: [:index]
|
||||||
resources :targets, only: [:index]
|
resources :targets, only: [:index]
|
||||||
resources :local_targets, except: [:show]
|
resources :local_targets, except: [:show]
|
||||||
resource :homepage, controller: :homepage, only: [:show]
|
resource :homepage, controller: :homepage, only: [:show] do
|
||||||
|
resource :header, controller: :header, only: [:new, :create, :edit, :update, :destroy]
|
||||||
|
end
|
||||||
|
|
||||||
resources :phases, only: [], as: :sdg_phases do
|
resources :phases, only: [], as: :sdg_phases do
|
||||||
resources :cards, except: [:index, :show], as: :widget_cards
|
resources :cards, except: [:index, :show], as: :widget_cards
|
||||||
|
|||||||
Reference in New Issue
Block a user