1
0
Fork 0
Dieser Commit ist enthalten in:
Angus McLeod 2020-03-31 17:29:59 +11:00
Ursprung 9a489f3b9b
Commit 947a42cf0f
6 geänderte Dateien mit 73 neuen und 130 gelöschten Zeilen

Datei anzeigen

@ -15,29 +15,20 @@
</div> </div>
{{#if basicTopicFields}} {{#if basicTopicFields}}
<div class="setting"> <div class="setting full field-mapper-setting">
<div class="setting-label"> <div class="setting-label">
<label>{{i18n "admin.wizard.action.title"}}</label> <label>{{i18n "admin.wizard.action.title"}}</label>
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{combo-box {{wizard-field-mapper
value=action.title inputs=action.title
content=wizardFields wizardFields=wizardFields
nameProperty="label"
onChange=(action (mut action.title))
options=(hash options=(hash
none='admin.wizard.select_field' hasOutput=true
isDisabled=action.custom_title_enabled wizardFieldSelection=true
userFieldSelection='key,value'
)}} )}}
<div class="setting-gutter">
{{input type='checkbox' checked=action.custom_title_enabled}}
<span>{{i18n 'admin.wizard.action.custom_title'}}</span>
{{#if action.custom_title_enabled}}
{{input value=action.custom_title}}
{{/if}}
</div>
</div> </div>
</div> </div>
@ -80,85 +71,45 @@
{{/if}} {{/if}}
{{#if publicTopicFields}} {{#if publicTopicFields}}
<div class="setting"> <div class="setting full field-mapper-setting">
<div class="setting-label"> <div class="setting-label">
<label>{{i18n "admin.wizard.action.create_topic.category"}}</label> <label>{{i18n "admin.wizard.action.create_topic.category"}}</label>
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{category-chooser {{wizard-field-mapper
value=action.category_id inputs=action.category
isDisabled=action.custom_category_enabled}} wizardFields=wizardFields
options=(hash
<div class="setting-gutter"> hasOutput=true
{{input type='checkbox' checked=action.custom_category_enabled}} categorySelection='output'
<span>{{i18n 'admin.wizard.action.custom_category.label'}}</span> wizardFieldSelection=true
userFieldSelection='key,value'
{{#if action.custom_category_enabled}} )}}
<div class="custom-category">
<div>
{{input type='checkbox' checked=action.custom_category_wizard_field}}
<span>{{i18n 'admin.wizard.wizard_field'}}</span>
{{#if action.custom_category_wizard_field}}
{{combo-box
value=action.category_id
content=categoryFields
nameProperty="label"
onChange=(action (mut action.category_id))
options=(hash
none='admin.wizard.select_field'
)}}
{{/if}}
</div>
<div>
{{input type='checkbox' checked=action.custom_category_user_field}}
<span>{{i18n 'admin.wizard.action.custom_category.user_field'}}</span>
{{#if action.custom_category_user_field}}
{{input value=action.custom_category_user_field_key}}
{{/if}}
</div>
</div>
{{/if}}
</div>
</div> </div>
</div> </div>
<div class="setting"> <div class="setting full field-mapper-setting">
<div class="setting-label"> <div class="setting-label">
<label>{{i18n "admin.wizard.action.create_topic.tags"}}</label> <label>{{i18n "admin.wizard.action.create_topic.tags"}}</label>
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{tag-chooser {{wizard-field-mapper
tags=action.tags inputs=action.tags
filterable=true wizardFields=wizardFields
allowCreate=true options=(hash
isDisabled=action.custom_tag_enabled}} hasOutput=true
tagSelection='output'
<div class="setting-gutter"> wizardFieldSelection=true
{{input type='checkbox' checked=action.custom_tag_enabled}} userFieldSelection='key,value'
<span>{{i18n 'admin.wizard.action.custom_tag.label'}}</span> )}}
{{#if action.custom_tag_enabled}}
<div class="custom-tag">
{{combo-box
value=action.custom_tag_field
content=tagFields
nameProperty="label"
onChange=(action (mut action.custom_tag_field))
options=(hash
none='admin.wizard.select_field'
)}}
</div>
{{/if}}
</div>
</div> </div>
</div> </div>
{{/if}} {{/if}}
{{#if newTopicFields}} {{#if newTopicFields}}
<div class="setting"> <div class="setting full">
<div class="setting-label"> <div class="setting-label">
<label>{{i18n "admin.wizard.action.skip_redirect.label"}}</label> <label>{{i18n "admin.wizard.action.skip_redirect.label"}}</label>
</div> </div>
@ -173,75 +124,70 @@
</div> </div>
{{/if}} {{/if}}
{{#if createTopic}} {{#if basicTopicFields}}
<div class="setting full field-mapper-setting"> <div class="setting full field-mapper-setting">
<div class="setting-label"> <div class="setting-label">
<label>{{i18n 'admin.wizard.action.add_fields'}}</label> <label>{{i18n 'admin.wizard.action.add_fields.label'}}</label>
</div> </div>
<div class="setting-value"> {{wizard-field-mapper
{{wizard-field-mapper inputs=action.add_fields
inputs=action.add_fields wizardFields=wizardFields
wizardFields=wizardFields connectorKey='admin.wizard.action.add_fields.connector'
options=(hash options=(hash
wizardFieldSelection=true wizardFieldSelection=true
)}} )}}
</div>
</div> </div>
{{/if}} {{/if}}
{{#if sendMessage}} {{#if sendMessage}}
<div class="setting"> <div class="setting full field-mapper-setting">
<div class="setting-label"> <div class="setting-label">
<label>{{i18n 'admin.wizard.required'}}</label> <label>{{i18n 'admin.wizard.required'}}</label>
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{combo-box {{wizard-field-mapper
value=action.required inputs=action.required
content=wizardFields wizardFields=wizardFields
nameProperty='label'
onChange=(action (mut action.required))
options=(hash options=(hash
none='admin.wizard.select_field' enableConnectors=true
wizardFieldSelection=true
userFieldSelection=true
groupSelection=true
)}} )}}
</div> </div>
</div> </div>
<div class="setting"> <div class="setting full field-mapper-setting">
<div class="setting-label"> <div class="setting-label">
<label>{{i18n "admin.wizard.action.send_message.recipient"}}</label> <label>{{i18n "admin.wizard.action.send_message.recipient"}}</label>
</div> </div>
<div class="setting-value"> <div class="setting-value">
{{user-selector {{wizard-field-mapper
single="true" inputs=action.recipient
includeMentionableGroups="true" wizardFields=wizardFields
usernames=action.username options=(hash
allowedUsers="true"}} hasOutput=true
wizardFieldSelection=true
userFieldSelection=true
groupSelection='key,value'
)}}
</div> </div>
</div> </div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n 'admin.wizard.action.add_fields'}}</label>
</div>
{{wizard-field-mapper
inputs=action.add_fields
wizardFields=wizardFields}}
</div>
{{/if}} {{/if}}
{{#if updateProfile}} {{#if updateProfile}}
<div class="setting full field-mapper-setting"> <div class="setting full field-mapper-setting">
<div class="setting-label"> <div class="setting-label">
<label>{{i18n 'admin.wizard.action.add_fields'}}</label> <label>{{i18n 'admin.wizard.action.add_fields.label'}}</label>
</div> </div>
{{wizard-field-mapper {{wizard-field-mapper
inputs=action.profile_updates inputs=action.profile_updates
wizardFields=wizardFields wizardFields=wizardFields
connectorKey='admin.wizard.action.add_fields.connector'
options=(hash options=(hash
wizardFieldSelection=true wizardFieldSelection=true
userFieldSelection=true userFieldSelection=true

Datei anzeigen

@ -38,7 +38,7 @@
</div> </div>
{{#if showJoin}} {{#if showJoin}}
<div class="join-pair">&</div> <span class="join-pair">&</span>
{{/if}} {{/if}}
{{#if showRemove}} {{#if showRemove}}

Datei anzeigen

@ -16,6 +16,7 @@
inputType=inputType inputType=inputType
keyPlaceholder=keyPlaceholder keyPlaceholder=keyPlaceholder
valuePlaceholder=valuePlaceholder valuePlaceholder=valuePlaceholder
connectorKey=connectorKey
wizardFields=wizardFields wizardFields=wizardFields
options=options options=options
removePair=(action 'removePair')}} removePair=(action 'removePair')}}

Datei anzeigen

@ -361,7 +361,7 @@ $setting-background: dark-light-diff($primary, $secondary, 96%, -65%);
.remove-pair { .remove-pair {
position: absolute; position: absolute;
top: 25px; top: 25px;
right: -30px; right: -25px;
} }
.join-pair { .join-pair {
@ -378,7 +378,7 @@ $setting-background: dark-light-diff($primary, $secondary, 96%, -65%);
position: relative; position: relative;
&:not(:first-of-type) { &:not(:first-of-type) {
margin-top: 10px; margin-top: 20px;
} }
&.no-connector div.input-block:not(:last-of-type) { &.no-connector div.input-block:not(:last-of-type) {

Datei anzeigen

@ -131,12 +131,14 @@ en:
include: "Include Fields" include: "Include Fields"
title: "Title" title: "Title"
post: "Post" post: "Post"
add_fields: "Fields"
topic_attr: "Topic Attribute" topic_attr: "Topic Attribute"
interpolate_fields: "Insert wizard fields using the field_id in w{}. Insert user fields using field key in u{}." interpolate_fields: "Insert wizard fields using the field_id in w{}. Insert user fields using field key in u{}."
add_fields:
label: "Fields"
connector: "set"
skip_redirect: skip_redirect:
label: "No Redirect" label: "Redirect"
description: "Don't redirect the user to this {{type}} after the wizard completes" description: "Don't redirect the user to this {{type}} after the wizard completes"
send_message: send_message:
label: "Send Message" label: "Send Message"

Datei anzeigen

@ -19,7 +19,7 @@ class CustomWizard::Action
@mapper ||= CustomWizard::Mapper.new(user: user, data: data) @mapper ||= CustomWizard::Mapper.new(user: user, data: data)
end end
def create_topic def create_topic
if action['custom_title_enabled'] if action['custom_title_enabled']
title = mapper.interpolate(action['custom_title']) title = mapper.interpolate(action['custom_title'])
else else
@ -43,8 +43,6 @@ class CustomWizard::Action
tags = action_tags(action, data) tags = action_tags(action, data)
params[:tags] = tags params[:tags] = tags
topic_custom_fields = {}
if action['add_fields'] if action['add_fields']
action['add_fields'].each do |field| action['add_fields'].each do |field|
value = field['value_custom'].present? ? field['value_custom'] : data[field['value']] value = field['value_custom'].present? ? field['value_custom'] : data[field['value']]
@ -59,14 +57,16 @@ class CustomWizard::Action
type = keyArr.first type = keyArr.first
if type === 'topic' if type === 'topic'
topic_custom_fields[custom_key] = value params[:topic_opts] ||= {}
params[:topic_opts][:custom_fields] ||= {}
params[:topic_opts][:custom_fields][custom_key] = value
elsif type === 'post' elsif type === 'post'
params[:custom_fields] ||= {} params[:custom_fields] ||= {}
params[:custom_fields][custom_key.to_sym] = value params[:custom_fields][custom_key.to_sym] = value
end end
end end
else else
value = [*value] + tags if key === 'tags' value = [*value] + [*tags] if key === 'tags'
params[key.to_sym] = value params[key.to_sym] = value
end end
end end
@ -79,12 +79,6 @@ class CustomWizard::Action
if creator.errors.present? if creator.errors.present?
updater.errors.add(:create_topic, creator.errors.full_messages.join(" ")) updater.errors.add(:create_topic, creator.errors.full_messages.join(" "))
else else
if topic_custom_fields.present?
topic_custom_fields.each do |k, v|
post.topic.custom_fields[k] = v
end
post.topic.save_custom_fields(true)
end
unless action['skip_redirect'] unless action['skip_redirect']
data['redirect_on_complete'] = post.topic.url data['redirect_on_complete'] = post.topic.url
@ -211,13 +205,13 @@ class CustomWizard::Action
url += "&body=#{post}" url += "&body=#{post}"
if category_id = action_category_id(action, data) if category_id = action_category_id
if category = Category.find(category_id) if category = Category.find(category_id)
url += "&category=#{category.full_slug('/')}" url += "&category=#{category.full_slug('/')}"
end end
end end
if tags = action_tags(action, data) if tags = action_tags
url += "&tags=#{tags.join(',')}" url += "&tags=#{tags.join(',')}"
end end