2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-25 13:14:56 -04:00
|
|
|
class WizardSerializer < ApplicationSerializer
|
2020-05-26 13:56:36 -04:00
|
|
|
attributes :start, :completed, :current_color_scheme
|
2016-08-25 13:14:56 -04:00
|
|
|
|
|
|
|
has_many :steps, serializer: WizardStepSerializer, embed: :objects
|
|
|
|
|
|
|
|
def start
|
|
|
|
object.start.id
|
|
|
|
end
|
2018-11-15 14:44:19 -05:00
|
|
|
|
|
|
|
def completed
|
|
|
|
object.completed?
|
|
|
|
end
|
2020-05-26 13:56:36 -04:00
|
|
|
|
|
|
|
def current_color_scheme
|
2020-05-26 16:08:35 -04:00
|
|
|
color_scheme = Theme.where(id: SiteSetting.default_theme_id).first&.color_scheme
|
2020-08-20 20:10:33 -04:00
|
|
|
colors = color_scheme ? color_scheme.colors : ColorScheme.base.colors
|
2020-05-26 13:56:36 -04:00
|
|
|
|
|
|
|
# The frontend expects the color hexs to start with '#'
|
|
|
|
colors_with_hash = {}
|
2020-08-20 20:10:33 -04:00
|
|
|
colors.each { |color| colors_with_hash[color.name] = color.hex_with_hash }
|
2020-05-26 13:56:36 -04:00
|
|
|
colors_with_hash
|
|
|
|
end
|
2016-08-25 13:14:56 -04:00
|
|
|
end
|