diff --git a/assets/javascripts/discourse/components/wizard-custom-step.js.es6 b/assets/javascripts/discourse/components/wizard-custom-step.js.es6
index a18743dd..b09ad462 100644
--- a/assets/javascripts/discourse/components/wizard-custom-step.js.es6
+++ b/assets/javascripts/discourse/components/wizard-custom-step.js.es6
@@ -1,15 +1,9 @@
import Component from "@ember/component";
import { default as discourseComputed } from 'discourse-common/utils/decorators';
-import { wizardFieldList } from '../lib/wizard';
export default Component.extend({
classNames: 'wizard-custom-step',
- @discourseComputed('wizard.steps', 'step.id')
- descriptionWizardFields(steps, stepId) {
- return wizardFieldList(steps, { upTo: stepId });
- },
-
actions: {
bannerUploadDone(upload) {
this.set("step.banner", upload.url);
diff --git a/assets/javascripts/discourse/templates/components/wizard-custom-step.hbs b/assets/javascripts/discourse/templates/components/wizard-custom-step.hbs
index be064200..a5c99be3 100644
--- a/assets/javascripts/discourse/templates/components/wizard-custom-step.hbs
+++ b/assets/javascripts/discourse/templates/components/wizard-custom-step.hbs
@@ -29,8 +29,7 @@
{{wizard-text-editor
- value=step.raw_description
- wizardFields=descriptionWizardFields}}
+ value=step.raw_description}}
diff --git a/lib/custom_wizard/builder.rb b/lib/custom_wizard/builder.rb
index f1a35bc8..6084ad5f 100644
--- a/lib/custom_wizard/builder.rb
+++ b/lib/custom_wizard/builder.rb
@@ -56,7 +56,11 @@ class CustomWizard::Builder
step.banner = step_template['banner'] if step_template['banner']
if step_template['description']
- step.description = mapper.interpolate(step_template['description'])
+ step.description = mapper.interpolate(
+ step_template['description'],
+ user: true,
+ value: true
+ )
end
step.key = step_template['key'] if step_template['key']
diff --git a/lib/custom_wizard/mapper.rb b/lib/custom_wizard/mapper.rb
index 70391907..3c16ef70 100644
--- a/lib/custom_wizard/mapper.rb
+++ b/lib/custom_wizard/mapper.rb
@@ -92,7 +92,7 @@ class CustomWizard::Mapper
operator = map_operator(connector)
value = cast_value(
key,
- interpolate(map_field(pair['value'], pair['value_type'])),
+ map_field(pair['value'], pair['value_type']),
connector
)
@@ -178,32 +178,42 @@ class CustomWizard::Mapper
end
end
- def interpolate(string)
- string.gsub!(/u\{(.*?)\}/) do |match|
- result = ''
- result = user.send($1) if USER_FIELDS.include?($1)
- result = user.user_profile.send($1) if PROFILE_FIELDS.include?($1)
- result
+ def interpolate(string, opts={ user: true, wizard: true, value: true })
+ return string if string.blank?
+
+ if opts[:user]
+ string.gsub!(/u\{(.*?)\}/) do |match|
+ result = ''
+ result = user.send($1) if USER_FIELDS.include?($1)
+ result = user.user_profile.send($1) if PROFILE_FIELDS.include?($1)
+ result
+ end
end
- string.gsub(/v\{(.*?)\}/) do |match|
- attrs = $1.split(':')
- key = attrs.first
- value = data[key]
- format = attrs.last if attrs.length > 1
- result = nil
-
- if key == 'time'
- time_format = value.present? ? value : "%B %-d, %Y"
- return Time.now.strftime(time_format)
+ if opts[:wizard]
+ string.gsub!(/w\{(.*?)\}/) do |match|
+ value = recurse(data, [*$1.split('.')])
+ value.present? ? value : ''
end
-
- if value.present?
- return recurse(value, [*$1.split('.')])
- end
-
- result
end
+
+ if opts[:value]
+ string.gsub!(/v\{(.*?)\}/) do |match|
+ attrs = $1.split(':')
+ key = attrs.first
+ format = attrs.last if attrs.length > 1
+ result = ''
+
+ if key == 'time' &&
+ time_format = format.present? ? format : "%B %-d, %Y"
+ result = Time.now.strftime(time_format)
+ end
+
+ result
+ end
+ end
+
+ string
end
def recurse(data, keys)