0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 18:50:27 +01:00

Add visible to create_topic action

Dieser Commit ist enthalten in:
Angus McLeod 2020-07-20 14:26:11 +10:00
Ursprung c4eb3e6cff
Commit a0f2d85eff
5 geänderte Dateien mit 53 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -115,6 +115,7 @@ const action = {
post_template: null, post_template: null,
category: null, category: null,
tags: null, tags: null,
visible: null,
custom_fields: null, custom_fields: null,
skip_redirect: null skip_redirect: null
}, },
@ -188,6 +189,7 @@ const action = {
'title', 'title',
'category', 'category',
'tags', 'tags',
'visible',
'custom_fields', 'custom_fields',
'required', 'required',
'recipient', 'recipient',

Datei anzeigen

@ -139,6 +139,24 @@
)}} )}}
</div> </div>
</div> </div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_topic.visible"}}</label>
</div>
<div class="setting-value">
{{wizard-mapper
inputs=action.visible
property='visible'
onUpdate=(action 'mappedFieldUpdated')
options=(hash
wizardFieldSelection=true
userFieldSelection=true
context='action'
)}}
</div>
</div>
{{/if}} {{/if}}
{{#if sendMessage}} {{#if sendMessage}}

Datei anzeigen

@ -205,6 +205,7 @@ en:
label: "Create Topic" label: "Create Topic"
category: "Category" category: "Category"
tags: "Tags" tags: "Tags"
visible: "Visible"
open_composer: open_composer:
label: "Open Composer" label: "Open Composer"
update_profile: update_profile:

Datei anzeigen

@ -125,6 +125,7 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController
category: mapped_params, category: mapped_params,
tags: mapped_params, tags: mapped_params,
custom_fields: mapped_params, custom_fields: mapped_params,
visible: mapped_params,
required: mapped_params, required: mapped_params,
recipient: mapped_params, recipient: mapped_params,
categories: mapped_params, categories: mapped_params,

Datei anzeigen

@ -36,12 +36,9 @@ class CustomWizard::Action
end end
def create_topic def create_topic
params = basic_topic_params params = basic_topic_params.merge(public_topic_params)
if params[:title].present? && params[:raw].present? if params[:title].present? && params[:raw].present?
params[:category] = action_category
params[:tags] = action_tags
creator = PostCreator.new(user, params) creator = PostCreator.new(user, params)
post = creator.create post = creator.create
@ -437,6 +434,32 @@ class CustomWizard::Action
add_custom_fields(params) add_custom_fields(params)
end end
def public_topic_params
params = {}
if (category = action_category)
params[:category] = category
end
if (tags = action_tags)
params[:tags] = tags
end
if public_topic_fields.any?
public_topic_fields.each do |field|
unless action[field].nil? || action[field] == ""
params[field.to_sym] = CustomWizard::Mapper.new(
inputs: action[field],
data: data,
user: user
).perform
end
end
end
params
end
def new_group_params def new_group_params
params = {} params = {}
@ -532,6 +555,10 @@ class CustomWizard::Action
[:create_topic, :send_message].include?(action['type'].to_sym) [:create_topic, :send_message].include?(action['type'].to_sym)
end end
def public_topic_fields
['visible']
end
def profile_url_fields def profile_url_fields
['profile_background', 'card_background'] ['profile_background', 'card_background']
end end