-
-
Notifications
You must be signed in to change notification settings - Fork 725
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable setting a customized user guide link in general settings #2686
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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,20 @@ def update | |
|
||
redirect_to main_app.edit_admin_content_path | ||
end | ||
|
||
private | ||
|
||
def preference_sections | ||
[ | ||
PreferenceSections::HeaderSection.new, | ||
PreferenceSections::HomePageSection.new, | ||
PreferenceSections::ProducerSignupPageSection.new, | ||
PreferenceSections::HubSignupPageSection.new, | ||
PreferenceSections::GroupSignupPageSection.new, | ||
PreferenceSections::MainLinksSection.new, | ||
PreferenceSections::FooterAndExternalLinksSection.new, | ||
PreferenceSections::UserGuideSection.new | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this misses a bit the point and violates Open-closed principle (sorry, I think the buzzword is relevant in this context), but it is still better than it was, so 👍 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay so it should be open to extension and closed to change, right? View oneClosed to change means that I'm not allowed to change a file. Adding a file is an extension and good. So we just have files following a convention and auto-load them. View twoClasses, files, directories are all data structures. Adding a section is just adding a line here. That's extension, not modification. And if you add a file to a directory, you modify that directory as well. In the end, we want to change the list of sections here and insert one particular section at a certain position. This code makes that really clear. |
||
] | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module PreferenceSections | ||
class FooterAndExternalLinksSection | ||
def name | ||
I18n.t('admin.contents.edit.footer_and_external_links') | ||
end | ||
|
||
def 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 | ||
] | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module PreferenceSections | ||
class GroupSignupPageSection | ||
def name | ||
I18n.t('admin.contents.edit.group_signup_page') | ||
end | ||
|
||
def preferences | ||
[ | ||
:group_signup_pricing_table_html, | ||
:group_signup_case_studies_html, | ||
:group_signup_detail_html | ||
] | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module PreferenceSections | ||
class HeaderSection | ||
def name | ||
I18n.t('admin.contents.edit.header') | ||
end | ||
|
||
def preferences | ||
[ | ||
:logo, | ||
:logo_mobile, | ||
:logo_mobile_svg | ||
] | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module PreferenceSections | ||
class HomePageSection | ||
def name | ||
I18n.t('admin.contents.edit.home_page') | ||
end | ||
|
||
def preferences | ||
[ | ||
:home_hero, | ||
:home_show_stats | ||
] | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module PreferenceSections | ||
class HubSignupPageSection | ||
def name | ||
I18n.t('admin.contents.edit.hub_signup_page') | ||
end | ||
|
||
def preferences | ||
[ | ||
:hub_signup_pricing_table_html, | ||
:hub_signup_case_studies_html, | ||
:hub_signup_detail_html | ||
] | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
module PreferenceSections | ||
class MainLinksSection | ||
def name | ||
I18n.t('admin.contents.edit.main_links') | ||
end | ||
|
||
def 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 | ||
] | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module PreferenceSections | ||
class ProducerSignupPageSection | ||
def name | ||
I18n.t('admin.contents.edit.producer_signup_page') | ||
end | ||
|
||
def preferences | ||
[ | ||
:producer_signup_pricing_table_html, | ||
:producer_signup_case_studies_html, | ||
:producer_signup_detail_html | ||
] | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module PreferenceSections | ||
class UserGuideSection | ||
def name | ||
I18n.t('admin.contents.edit.user_guide') | ||
end | ||
|
||
def preferences | ||
[:user_guide_link] | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
= button_link_to t('.user_guide'), "http://www.openfoodnetwork.org/platform/user-guide/", icon: 'icon-external-link', target: '_blank' | ||
= button_link_to t('.user_guide'), ContentConfig.user_guide_link, icon: 'icon-external-link', target: '_blank' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mkllnk something like this ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I probably would have omitted the
new
here and called it somewhere else to reduce code duplication and separate the two concerns "list the sections" and "initialise a section to use it". But I'm happy with this.