mirror of
https://github.com/discourse/discourse.git
synced 2024-12-03 08:13:40 +08:00
10f200a5d3
* FEATURE: revamped wizard * UX: Wizard redesign (#17381) * UX: Step 1-2 * swap out images * UX: Finalize all steps * UX: mobile * UX: Fix test * more test * DEV: remove unneeded wizard components * DEV: fix wizard tests * DEV: update rails tests for new wizard * Remove empty hbs files that were created because of rebase * Fixes for rebase * Fix wizard image link * More rebase fixes * Fix rails tests * FIX: Update preview for new color schemes: (#17481) * UX: make layout more responsive, update images * fix typo * DEV: move discourse logo svg to template only component * DEV: formatting improvements * Remove unneeded files * Add tests for privacy step * Fix banner image height for step "ready" Co-authored-by: Jordan Vidrine <30537603+jordanvidrine@users.noreply.github.com> Co-authored-by: awesomerobot <kris.aubuchon@discourse.org>
90 lines
1.5 KiB
Ruby
90 lines
1.5 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
class WizardFieldSerializer < ApplicationSerializer
|
|
attributes :id, :type, :required, :value, :label, :placeholder, :description, :extra_description, :icon, :show_in_sidebar
|
|
has_many :choices, serializer: WizardFieldChoiceSerializer, embed: :objects
|
|
|
|
def id
|
|
object.id
|
|
end
|
|
|
|
def type
|
|
object.type
|
|
end
|
|
|
|
def required
|
|
object.required
|
|
end
|
|
|
|
def value
|
|
object.value
|
|
end
|
|
|
|
def include_value?
|
|
object.value.present?
|
|
end
|
|
|
|
def i18n_key
|
|
@i18n_key ||= "wizard.step.#{object.step.id}.fields.#{object.id}".underscore
|
|
end
|
|
|
|
def translate(sub_key, vars = nil)
|
|
key = "#{i18n_key}.#{sub_key}"
|
|
return nil unless I18n.exists?(key)
|
|
|
|
vars.nil? ? I18n.t(key) : I18n.t(key, vars)
|
|
end
|
|
|
|
def label
|
|
translate("label")
|
|
end
|
|
|
|
def include_label?
|
|
label.present?
|
|
end
|
|
|
|
def placeholder
|
|
translate("placeholder")
|
|
end
|
|
|
|
def include_placeholder?
|
|
placeholder.present?
|
|
end
|
|
|
|
def description
|
|
translate("description", base_path: Discourse.base_path)
|
|
end
|
|
|
|
def include_description?
|
|
description.present?
|
|
end
|
|
|
|
def extra_description
|
|
translate("extra_description", base_path: Discourse.base_path)
|
|
end
|
|
|
|
def include_extra_description?
|
|
extra_description.present?
|
|
end
|
|
|
|
def icon
|
|
object.icon
|
|
end
|
|
|
|
def include_icon?
|
|
object.icon.present?
|
|
end
|
|
|
|
def show_in_sidebar
|
|
object.show_in_sidebar
|
|
end
|
|
|
|
def include_show_in_sidebar?
|
|
object.show_in_sidebar.present?
|
|
end
|
|
|
|
def include_choices?
|
|
object.type == "dropdown" || object.type == "radio"
|
|
end
|
|
end
|