Explorar o código

Allow theme to be added by name && use template when loading wizard for controller

Angus McLeod %!s(int64=7) %!d(string=hai) anos
pai
achega
9d8424a35f
Modificáronse 2 ficheiros con 8 adicións e 3 borrados
  1. 3 3
      controllers/wizard.rb
  2. 5 0
      lib/template.rb

+ 3 - 3
controllers/wizard.rb

@@ -7,15 +7,15 @@ class CustomWizard::WizardController < ::ApplicationController
   helper_method :theme_key
 
   def wizard
-    PluginStore.get('custom_wizard', params[:wizard_id].underscore)
+    CustomWizard::Template.new(PluginStore.get('custom_wizard', params[:wizard_id].underscore))
   end
 
   def wizard_page_title
-    wizard ? (wizard['name'] || wizard['id']) : I18n.t('wizard.custom_title')
+    wizard ? (wizard.name || wizard.id) : I18n.t('wizard.custom_title')
   end
 
   def theme_key
-    wizard ? wizard['theme_key'] : nil
+    wizard ? wizard.theme_key : nil
   end
 
   def index

+ 5 - 0
lib/template.rb

@@ -29,5 +29,10 @@ class CustomWizard::Template
     @after_time_scheduled = data['after_time_scheduled']
     @required = data['required'] || false
     @theme_key = data['theme_key']
+
+    if data['theme']
+      theme = Theme.find_by(name: data['theme'])
+      @theme_key = theme.key if theme
+    end
   end
 end