Wizard - Color Scheme Step

This commit is contained in:
Robin Ward
2016-09-02 11:42:14 -04:00
parent 9f12b571ef
commit 3f6e3b9aff
21 changed files with 343 additions and 23 deletions

View File

@@ -1,7 +1,7 @@
class Wizard
class Field
attr_reader :id, :type, :required, :value, :options
attr_reader :id, :type, :required, :value, :options, :option_data
attr_accessor :step
def initialize(attrs)
@@ -12,10 +12,12 @@ class Wizard
@required = !!attrs[:required]
@value = attrs[:value]
@options = []
@option_data = {}
end
def add_option(id)
def add_option(id, data=nil)
@options << id
@option_data[id] = data
end
end

View File

@@ -23,6 +23,34 @@ class Wizard
update_setting(:site_contact_username, fields, :site_contact_username)
end
def update_colors(fields)
scheme_name = fields[:color_scheme]
theme = ColorScheme.themes.find {|s| s[:id] == scheme_name }
colors = []
theme[:colors].each do |name, hex|
colors << {name: name, hex: hex[1..-1] }
end
attrs = {
enabled: true,
name: I18n.t("wizard.step.colors.fields.color_scheme.options.#{scheme_name}"),
colors: colors
}
scheme = ColorScheme.where(via_wizard: true).first
if scheme.present?
attrs[:colors] = colors
revisor = ColorSchemeRevisor.new(scheme, attrs)
revisor.revise
else
attrs[:via_wizard] = true
scheme = ColorScheme.new(attrs)
scheme.save!
end
end
def success?
@errors.blank?
end