Allow selecting both default flavour and theme

Fixes #672
master
Thibaut Girka 6 years ago committed by ThibG
parent fac529975b
commit 3d5d899094
  1. 9
      app/controllers/admin/settings_controller.rb
  2. 6
      app/lib/themes.rb
  3. 4
      app/models/form/admin_settings.rb
  4. 2
      app/views/admin/settings/edit.html.haml

@ -18,6 +18,7 @@ module Admin
bootstrap_timeline_accounts
flavour
skin
flavour_and_skin
thumbnail
hero
mascot
@ -54,7 +55,13 @@ module Admin
def update
authorize :settings, :update?
settings_params.each do |key, value|
settings = settings_params
flavours_and_skin = settings.delete('flavour_and_skin')
if flavours_and_skin
settings['flavour'], settings['skin'] = flavours_and_skin.split('/', 2)
end
settings.each do |key, value|
if UPLOAD_SETTINGS.include?(key)
upload = SiteUpload.where(var: key).first_or_initialize(var: key)
upload.update(file: value)

@ -80,4 +80,10 @@ class Themes
def skins_for(name)
@conf[name]['skin'].keys
end
def flavours_and_skins
flavours.map do |flavour|
[flavour, skins_for(flavour).map{ |skin| [flavour, skin] }]
end
end
end

@ -48,4 +48,8 @@ class Form::AdminSettings
:custom_css=,
to: Setting
)
def flavour_and_skin
"#{Setting.flavour}/#{Setting.skin}"
end
end

@ -7,7 +7,7 @@
= f.input :site_title, wrapper: :with_label, label: t('admin.settings.site_title')
.fields-group
= f.input :flavour, collection: Themes.instance.flavours, label_method: lambda { |flavour| I18n.t("flavours.#{flavour}.name", default: flavour) }, wrapper: :with_label, include_blank: false
= f.input :flavour_and_skin, collection: Themes.instance.flavours_and_skins, group_label_method: lambda { |(flavour, _)| I18n.t("flavours.#{flavour}.name", default: flavour) }, wrapper: :with_label, include_blank: false, as: :grouped_select, label_method: :last, value_method: lambda { |value| value.join('/') }, group_method: :last
.fields-row
.fields-row__column.fields-row__column-6.fields-group

Loading…
Cancel
Save