Explorar o código

Cook field labels

Angus McLeod %!s(int64=6) %!d(string=hai) anos
pai
achega
b73b39370f

+ 1 - 1
assets/javascripts/wizard/templates/components/wizard-field.hbs

@@ -1,6 +1,6 @@
 <label for={{field.id}}>
   {{#if field.label}}
-    <span class='label-value'>{{field.label}}</span>
+    <span class='label-value'>{{{field.label}}}</span>
   {{/if}}
 </label>
 

+ 5 - 1
assets/stylesheets/wizard/wizard_custom.scss

@@ -125,8 +125,12 @@
       flex-flow: wrap;
       align-items: center;
 
-      .field-label {
+      .label-value {
         width: 100%;
+
+        p {
+          margin: 0;
+        }
       }
 
       .field-image {

+ 6 - 4
lib/wizard_edits.rb

@@ -28,12 +28,10 @@ end
   attr_accessor :dropdown_none
 
   def initialize(attrs)
-    attrs = attrs || {}
-
+    @attrs = attrs || {}
     @id = attrs[:id]
     @type = attrs[:type]
     @required = !!attrs[:required]
-    @label = attrs[:label]
     @description = attrs[:description]
     @image = attrs[:image]
     @key = attrs[:key]
@@ -42,6 +40,10 @@ end
     @choices = []
     @dropdown_none = attrs[:dropdown_none]
   end
+
+  def label
+    @label ||= PrettyText.cook(@attrs[:label], keep_emoji_images: true)
+  end
 end
 
 ::Wizard::Choice.class_eval do
@@ -54,7 +56,7 @@ end
   end
 
   def label
-    @label ||= PrettyText.cook(@opts[:label], keep_emoji_images: true, postProcessTag: '<div>')
+    @label ||= PrettyText.cook(@opts[:label], keep_emoji_images: true)
   end
 end