Bladeren bron

Cook dropdown choices

Angus McLeod 6 jaren geleden
bovenliggende
commit
5e936036e6
3 gewijzigde bestanden met toevoegingen van 19 en 1 verwijderingen
  1. 4 0
      assets/stylesheets/wizard/wizard_custom.scss
  2. 1 1
      lib/builder.rb
  3. 14 0
      lib/wizard_edits.rb

+ 4 - 0
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 {

+ 1 - 1
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'])

+ 14 - 0
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: '<div>')
+  end
+end
+
 class ::Wizard::Step
   attr_accessor :title, :description, :key
 end