about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/settings_controller.rb9
-rw-r--r--app/lib/themes.rb6
-rw-r--r--app/models/form/admin_settings.rb4
-rw-r--r--app/views/admin/settings/edit.html.haml2
4 files changed, 19 insertions, 2 deletions
diff --git a/app/controllers/admin/settings_controller.rb b/app/controllers/admin/settings_controller.rb
index 46e9b2c07..fe2720c48 100644
--- a/app/controllers/admin/settings_controller.rb
+++ b/app/controllers/admin/settings_controller.rb
@@ -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)
diff --git a/app/lib/themes.rb b/app/lib/themes.rb
index 55824a5c4..2147904e4 100644
--- a/app/lib/themes.rb
+++ b/app/lib/themes.rb
@@ -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
diff --git a/app/models/form/admin_settings.rb b/app/models/form/admin_settings.rb
index 9ea4ed322..8a39e09b7 100644
--- a/app/models/form/admin_settings.rb
+++ b/app/models/form/admin_settings.rb
@@ -48,4 +48,8 @@ class Form::AdminSettings
     :custom_css=,
     to: Setting
   )
+
+  def flavour_and_skin
+    "#{Setting.flavour}/#{Setting.skin}"
+  end
 end
diff --git a/app/views/admin/settings/edit.html.haml b/app/views/admin/settings/edit.html.haml
index 361e249e0..b82555534 100644
--- a/app/views/admin/settings/edit.html.haml
+++ b/app/views/admin/settings/edit.html.haml
@@ -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