From 5e936036e6572666b0a0c8fd7d622e9722e7703f Mon Sep 17 00:00:00 2001 From: Angus McLeod Date: Sun, 13 May 2018 15:39:28 +1000 Subject: [PATCH] Cook dropdown choices --- assets/stylesheets/wizard/wizard_custom.scss | 4 ++++ lib/builder.rb | 2 +- lib/wizard_edits.rb | 14 ++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/assets/stylesheets/wizard/wizard_custom.scss b/assets/stylesheets/wizard/wizard_custom.scss index 8d7ca087..8bc6209b 100644 --- a/assets/stylesheets/wizard/wizard_custom.scss +++ b/assets/stylesheets/wizard/wizard_custom.scss @@ -215,6 +215,10 @@ .combo-box ul { padding: 0; + + li p { + margin: 0; + } } .wizard-buttons > a, .wizard-buttons > button, .spinner { diff --git a/lib/builder.rb b/lib/builder.rb index 37e6f253..d462cd6a 100644 --- a/lib/builder.rb +++ b/lib/builder.rb @@ -91,7 +91,7 @@ class CustomWizard::Builder if f['choices'] && f['choices'].length > 0 f['choices'].each do |c| - field.add_choice(c['value'], label: c['label']) + field.add_choice(c['key'], label: c['value']) end elsif f['choices_key'] && f['choices_key'].length > 0 choices = I18n.t(f['choices_key']) diff --git a/lib/wizard_edits.rb b/lib/wizard_edits.rb index bfa94e87..d4bfbe12 100644 --- a/lib/wizard_edits.rb +++ b/lib/wizard_edits.rb @@ -44,6 +44,20 @@ end end end +::Wizard::Choice.class_eval do + def initialize(id, opts) + @id = id + @opts = opts + @data = opts[:data] + @extra_label = opts[:extra_label] + @icon = opts[:icon] + end + + def label + @label ||= PrettyText.cook(@opts[:label], keep_emoji_images: true, postProcessTag: '
') + end +end + class ::Wizard::Step attr_accessor :title, :description, :key end