Refacto edit method for content controller and enable custom user guide link

This commit is contained in:
Hugo Daniel
2018-09-12 14:51:53 +02:00
parent 5e0997d03e
commit cc43d789e2
14 changed files with 172 additions and 17 deletions

View File

@@ -1,15 +1,9 @@
module Admin
class ContentsController < Spree::Admin::BaseController
def edit
@preference_sections = [{name: I18n.t('admin.contents.edit.header'), preferences: [:logo, :logo_mobile, :logo_mobile_svg]},
{name: I18n.t('admin.contents.edit.home_page'), preferences: [:home_hero, :home_show_stats]},
{name: I18n.t('admin.contents.edit.producer_signup_page'), preferences: [:producer_signup_pricing_table_html, :producer_signup_case_studies_html, :producer_signup_detail_html]},
{name: I18n.t('admin.contents.edit.hub_signup_page'), preferences: [:hub_signup_pricing_table_html, :hub_signup_case_studies_html, :hub_signup_detail_html]},
{name: I18n.t('admin.contents.edit.group_signup_page'), preferences: [:group_signup_pricing_table_html, :group_signup_case_studies_html, :group_signup_detail_html]},
{name: I18n.t('admin.contents.edit.main_links'), preferences: [:menu_1, :menu_1_icon_name, :menu_2, :menu_2_icon_name, :menu_3, :menu_3_icon_name, :menu_4, :menu_4_icon_name, :menu_5, :menu_5_icon_name, :menu_6, :menu_6_icon_name, :menu_7, :menu_7_icon_name]},
{name: I18n.t('admin.contents.edit.footer_and_external_links'), preferences: [:footer_logo,
:footer_facebook_url, :footer_twitter_url, :footer_instagram_url, :footer_linkedin_url, :footer_googleplus_url, :footer_pinterest_url,
:footer_email, :community_forum_url, :footer_links_md, :footer_about_url]}]
@preference_sections = preference_sections.map do |preference_section|
{ name: preference_section.name, preferences: preference_section.preferences }
end
end
def update
@@ -26,5 +20,14 @@ module Admin
redirect_to main_app.edit_admin_content_path
end
private
def preference_sections
Dir["app/models/preference_sections/*.rb"].map do |filename|
basename = 'PreferenceSections::' + File.basename(filename, '.rb').camelize
basename.constantize.new
end
end
end
end