Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-25 18:50:27 +01:00
Enable templating (#102)
* enabled templating for create topic action * enabled templating for step and field descriptions * FIX: don't run pretty text on step description * FIX: step description should be cooked post template parsing
Dieser Commit ist enthalten in:
Ursprung
7d38337c84
Commit
f05d859007
4 geänderte Dateien mit 25 neuen und 6 gelöschten Zeilen
|
@ -499,7 +499,13 @@ class CustomWizard::Action
|
||||||
).perform
|
).perform
|
||||||
|
|
||||||
params[:raw] = action['post_builder'] ?
|
params[:raw] = action['post_builder'] ?
|
||||||
mapper.interpolate(action['post_template']) :
|
mapper.interpolate(
|
||||||
|
action['post_template'],
|
||||||
|
user: true,
|
||||||
|
value: true,
|
||||||
|
wizard: true,
|
||||||
|
template: true
|
||||||
|
) :
|
||||||
data[action['post']]
|
data[action['post']]
|
||||||
|
|
||||||
params[:import_mode] = ActiveRecord::Type::Boolean.new.cast(action['suppress_notifications'])
|
params[:import_mode] = ActiveRecord::Type::Boolean.new.cast(action['suppress_notifications'])
|
||||||
|
|
|
@ -177,6 +177,16 @@ class CustomWizard::Builder
|
||||||
params[:index] = index.to_i unless index.nil?
|
params[:index] = index.to_i unless index.nil?
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if field_template['description'].present?
|
||||||
|
params[:description] = mapper.interpolate(
|
||||||
|
field_template['description'],
|
||||||
|
user: true,
|
||||||
|
value: true,
|
||||||
|
wizard: true,
|
||||||
|
template: true
|
||||||
|
)
|
||||||
|
end
|
||||||
|
|
||||||
field = step.add_field(params)
|
field = step.add_field(params)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -232,8 +242,11 @@ class CustomWizard::Builder
|
||||||
step.description = mapper.interpolate(
|
step.description = mapper.interpolate(
|
||||||
step_template['description'],
|
step_template['description'],
|
||||||
user: true,
|
user: true,
|
||||||
value: true
|
value: true,
|
||||||
|
wizard: true,
|
||||||
|
template: true
|
||||||
)
|
)
|
||||||
|
step.description = PrettyText.cook(step.description)
|
||||||
end
|
end
|
||||||
|
|
||||||
step
|
step
|
||||||
|
|
|
@ -98,7 +98,7 @@ class CustomWizard::Template
|
||||||
def prepare_data
|
def prepare_data
|
||||||
@data[:steps].each do |step|
|
@data[:steps].each do |step|
|
||||||
if step[:raw_description]
|
if step[:raw_description]
|
||||||
step[:description] = PrettyText.cook(step[:raw_description])
|
step[:description] = step[:raw_description]
|
||||||
end
|
end
|
||||||
|
|
||||||
remove_non_mapped_index(step)
|
remove_non_mapped_index(step)
|
||||||
|
|
6
spec/fixtures/wizard.json
gevendort
6
spec/fixtures/wizard.json
gevendort
|
@ -46,7 +46,7 @@
|
||||||
"type": "text_only"
|
"type": "text_only"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "<p>Text inputs!</p>"
|
"description": "Text inputs!"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "step_2",
|
"id": "step_2",
|
||||||
|
@ -93,7 +93,7 @@
|
||||||
"file_types": ".jpg,.jpeg,.png"
|
"file_types": ".jpg,.jpeg,.png"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "<p>Because I couldn’t think of another name for this step <img src=\"/images/emoji/twitter/slight_smile.png?v=9\" title=\":slight_smile:\" class=\"emoji\" alt=\":slight_smile:\"></p>"
|
"description": "Because I couldn't think of another name for this step :)"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"id": "step_3",
|
"id": "step_3",
|
||||||
|
@ -160,7 +160,7 @@
|
||||||
"type": "user_selector"
|
"type": "user_selector"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"description": "<p>Unfortunately not the edible type <img src=\"/images/emoji/twitter/sushi.png?v=9\" title=\":sushi:\" class=\"emoji\" alt=\":sushi:\"></p>"
|
"description": "Unfortunately not the edible type :sushi: "
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"actions": [
|
"actions": [
|
||||||
|
|
Laden …
In neuem Issue referenzieren