discourse/lib/wizard/field.rb
Penar Musaraj efee8ea4fc
UX: One step wizard (#36082)
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>
2025-11-25 13:35:32 -05:00

38 lines
740 B
Ruby

# frozen_string_literal: true
class Wizard
class Choice
attr_reader :id, :label, :data, :extra_label
attr_accessor :field
def initialize(id, opts)
@id = id
@data = opts[:data]
@label = opts[:label]
@extra_label = opts[:extra_label]
end
end
class Field
attr_reader :id, :type, :required, :value, :choices
attr_accessor :step
def initialize(attrs)
attrs = attrs || {}
@id = attrs[:id]
@type = attrs[:type]
@required = !!attrs[:required]
@value = attrs[:value]
@choices = []
end
def add_choice(id, opts = nil)
choice = Choice.new(id, opts || {})
choice.field = self
@choices << choice
choice
end
end
end