Add homepage admin section
This commit is contained in:
12
app/controllers/admin/homepage_controller.rb
Normal file
12
app/controllers/admin/homepage_controller.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class Admin::HomepageController < Admin::BaseController
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def load_settings
|
||||
settings = /feature.homepage.widgets/
|
||||
@settings = Setting.select {|setting| setting.key =~ /#{settings}/ }
|
||||
end
|
||||
end
|
||||
@@ -11,7 +11,7 @@ class Admin::SettingsController < Admin::BaseController
|
||||
def update
|
||||
@setting = Setting.find(params[:id])
|
||||
@setting.update(settings_params)
|
||||
redirect_to admin_settings_path, notice: t("admin.settings.flash.updated")
|
||||
redirect_to request.referer, notice: t("admin.settings.flash.updated")
|
||||
end
|
||||
|
||||
def update_map
|
||||
|
||||
10
app/controllers/admin/widget/base_controller.rb
Normal file
10
app/controllers/admin/widget/base_controller.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class Admin::Widget::BaseController < Admin::BaseController
|
||||
helper_method :namespace
|
||||
|
||||
private
|
||||
|
||||
def namespace
|
||||
"admin"
|
||||
end
|
||||
|
||||
end
|
||||
@@ -167,6 +167,10 @@
|
||||
</a>
|
||||
<ul <%= "class=is-active" if menu_customization? &&
|
||||
controller.class.parent != Admin::Poll::Questions::Answers %>>
|
||||
<li <%= "class=active" if controller_name == "homepage" %>>
|
||||
<%= link_to "Homepage", admin_homepage_path %>
|
||||
</li>
|
||||
|
||||
<li <%= "class=active" if controller_name == "pages" %>>
|
||||
<%= link_to t("admin.menu.site_customization.pages"), admin_site_customization_pages_path %>
|
||||
</li>
|
||||
@@ -179,6 +183,7 @@
|
||||
<li <%= "class=active" if controller_name == "content_blocks" %>>
|
||||
<%= link_to t("admin.menu.site_customization.content_blocks"), admin_site_customization_content_blocks_path%>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
||||
11
app/views/admin/homepage/_setting.html.erb
Normal file
11
app/views/admin/homepage/_setting.html.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
<div id="<%= dom_id(setting) %>">
|
||||
<%= form_for(setting, url: admin_setting_path(setting), method: :put) do |f| %>
|
||||
|
||||
<%= f.hidden_field :value,
|
||||
value: (setting.enabled? ? "" : "active") %>
|
||||
|
||||
<%= f.submit(t("admin.settings.index.features.#{setting.enabled? ? 'disable' : 'enable'}"),
|
||||
class: "button expanded #{setting.enabled? ? 'hollow alert' : 'success'}",
|
||||
data: {confirm: t("admin.actions.confirm")}) %>
|
||||
<% end %>
|
||||
</div>
|
||||
11
app/views/admin/homepage/show.html.erb
Normal file
11
app/views/admin/homepage/show.html.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
<h1>Homepage</h1>
|
||||
|
||||
<p>The active modules appear in the homepage in the same order as here.</p>
|
||||
<% @settings.each do |setting| %>
|
||||
|
||||
<div>
|
||||
<strong><%= t("settings.#{setting.key}") %></strong>
|
||||
</div>
|
||||
|
||||
<%= render "setting", setting: setting %>
|
||||
<% end %>
|
||||
1
app/views/admin/widget/_menu.html.erb
Normal file
1
app/views/admin/widget/_menu.html.erb
Normal file
@@ -0,0 +1 @@
|
||||
<%= render "admin/menu" %>
|
||||
Reference in New Issue
Block a user