0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-22 17:30:29 +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:
Faizaan Gagan 2021-04-23 17:21:41 +05:30 committet von GitHub
Ursprung 7d38337c84
Commit f05d859007
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
4 geänderte Dateien mit 25 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -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'])

Datei anzeigen

@ -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

Datei anzeigen

@ -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)

Datei anzeigen

@ -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 couldnt 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": [