1
0
Fork 0

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,
category: null,
tags: null,
visible: null,
custom_fields: null,
skip_redirect: null
},
@ -188,6 +189,7 @@ const action = {
'title',
'category',
'tags',
'visible',
'custom_fields',
'required',
'recipient',

Datei anzeigen

@ -139,6 +139,24 @@
)}}
</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 sendMessage}}

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -36,12 +36,9 @@ class CustomWizard::Action
end
def create_topic
params = basic_topic_params
params = basic_topic_params.merge(public_topic_params)
if params[:title].present? && params[:raw].present?
params[:category] = action_category
params[:tags] = action_tags
creator = PostCreator.new(user, params)
post = creator.create
@ -437,6 +434,32 @@ class CustomWizard::Action
add_custom_fields(params)
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
params = {}
@ -532,6 +555,10 @@ class CustomWizard::Action
[:create_topic, :send_message].include?(action['type'].to_sym)
end
def public_topic_fields
['visible']
end
def profile_url_fields
['profile_background', 'card_background']
end