瀏覽代碼

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

Angus McLeod 7 年之前
父節點
當前提交
9d8424a35f
共有 2 個文件被更改,包括 8 次插入3 次删除
  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