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