mirror of
https://gh.wpcy.net/https://github.com/discourse/discourse.git
synced 2026-05-26 01:04:55 +08:00
Consolidates all three wizard screens into one. Cleans up some leftover, unused wizard elements (checkbox, image, canvas inputs). Internal ticket: t/164852 <img width="2880" height="2376" alt="CleanShot 2025-11-25 at 10 35 43@2x" src="https://github.com/user-attachments/assets/f824a172-38b0-4fda-922a-3732335b93b2" /> --------- Co-authored-by: Jordan Vidrine <jordan@jordanvidrine.com>
73 lines
1.3 KiB
Ruby
Vendored
73 lines
1.3 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
class WizardFieldSerializer < ApplicationSerializer
|
|
attributes :id, :type, :required, :value, :label, :placeholder, :description, :extra_description
|
|
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 include_choices?
|
|
object.type == "dropdown" || object.type == "radio"
|
|
end
|
|
end
|