0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 18:50:27 +01:00
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>
{{#if basicTopicFields}}
<div class="setting">
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.title"}}</label>
</div>
<div class="setting-value">
{{combo-box
value=action.title
content=wizardFields
nameProperty="label"
onChange=(action (mut action.title))
{{wizard-field-mapper
inputs=action.title
wizardFields=wizardFields
options=(hash
none='admin.wizard.select_field'
isDisabled=action.custom_title_enabled
hasOutput=true
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>
@ -80,85 +71,45 @@
{{/if}}
{{#if publicTopicFields}}
<div class="setting">
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_topic.category"}}</label>
</div>
<div class="setting-value">
{{category-chooser
value=action.category_id
isDisabled=action.custom_category_enabled}}
<div class="setting-gutter">
{{input type='checkbox' checked=action.custom_category_enabled}}
<span>{{i18n 'admin.wizard.action.custom_category.label'}}</span>
{{#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))
{{wizard-field-mapper
inputs=action.category
wizardFields=wizardFields
options=(hash
none='admin.wizard.select_field'
hasOutput=true
categorySelection='output'
wizardFieldSelection=true
userFieldSelection='key,value'
)}}
{{/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 class="setting">
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.create_topic.tags"}}</label>
</div>
<div class="setting-value">
{{tag-chooser
tags=action.tags
filterable=true
allowCreate=true
isDisabled=action.custom_tag_enabled}}
<div class="setting-gutter">
{{input type='checkbox' checked=action.custom_tag_enabled}}
<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))
{{wizard-field-mapper
inputs=action.tags
wizardFields=wizardFields
options=(hash
none='admin.wizard.select_field'
hasOutput=true
tagSelection='output'
wizardFieldSelection=true
userFieldSelection='key,value'
)}}
</div>
{{/if}}
</div>
</div>
</div>
{{/if}}
{{#if newTopicFields}}
<div class="setting">
<div class="setting full">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.skip_redirect.label"}}</label>
</div>
@ -173,75 +124,70 @@
</div>
{{/if}}
{{#if createTopic}}
{{#if basicTopicFields}}
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n 'admin.wizard.action.add_fields'}}</label>
<label>{{i18n 'admin.wizard.action.add_fields.label'}}</label>
</div>
<div class="setting-value">
{{wizard-field-mapper
inputs=action.add_fields
wizardFields=wizardFields
connectorKey='admin.wizard.action.add_fields.connector'
options=(hash
wizardFieldSelection=true
)}}
</div>
</div>
{{/if}}
{{#if sendMessage}}
<div class="setting">
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n 'admin.wizard.required'}}</label>
</div>
<div class="setting-value">
{{combo-box
value=action.required
content=wizardFields
nameProperty='label'
onChange=(action (mut action.required))
{{wizard-field-mapper
inputs=action.required
wizardFields=wizardFields
options=(hash
none='admin.wizard.select_field'
enableConnectors=true
wizardFieldSelection=true
userFieldSelection=true
groupSelection=true
)}}
</div>
</div>
<div class="setting">
<div class="setting-label">
<label>{{i18n "admin.wizard.action.send_message.recipient"}}</label>
</div>
<div class="setting-value">
{{user-selector
single="true"
includeMentionableGroups="true"
usernames=action.username
allowedUsers="true"}}
</div>
</div>
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n 'admin.wizard.action.add_fields'}}</label>
<label>{{i18n "admin.wizard.action.send_message.recipient"}}</label>
</div>
<div class="setting-value">
{{wizard-field-mapper
inputs=action.add_fields
wizardFields=wizardFields}}
inputs=action.recipient
wizardFields=wizardFields
options=(hash
hasOutput=true
wizardFieldSelection=true
userFieldSelection=true
groupSelection='key,value'
)}}
</div>
</div>
{{/if}}
{{#if updateProfile}}
<div class="setting full field-mapper-setting">
<div class="setting-label">
<label>{{i18n 'admin.wizard.action.add_fields'}}</label>
<label>{{i18n 'admin.wizard.action.add_fields.label'}}</label>
</div>
{{wizard-field-mapper
inputs=action.profile_updates
wizardFields=wizardFields
connectorKey='admin.wizard.action.add_fields.connector'
options=(hash
wizardFieldSelection=true
userFieldSelection=true

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

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

Datei anzeigen

@ -131,12 +131,14 @@ en:
include: "Include Fields"
title: "Title"
post: "Post"
add_fields: "Fields"
topic_attr: "Topic Attribute"
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:
label: "No Redirect"
label: "Redirect"
description: "Don't redirect the user to this {{type}} after the wizard completes"
send_message:
label: "Send Message"

Datei anzeigen

@ -43,8 +43,6 @@ class CustomWizard::Action
tags = action_tags(action, data)
params[:tags] = tags
topic_custom_fields = {}
if action['add_fields']
action['add_fields'].each do |field|
value = field['value_custom'].present? ? field['value_custom'] : data[field['value']]
@ -59,14 +57,16 @@ class CustomWizard::Action
type = keyArr.first
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'
params[:custom_fields] ||= {}
params[:custom_fields][custom_key.to_sym] = value
end
end
else
value = [*value] + tags if key === 'tags'
value = [*value] + [*tags] if key === 'tags'
params[key.to_sym] = value
end
end
@ -79,12 +79,6 @@ class CustomWizard::Action
if creator.errors.present?
updater.errors.add(:create_topic, creator.errors.full_messages.join(" "))
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']
data['redirect_on_complete'] = post.topic.url
@ -211,13 +205,13 @@ class CustomWizard::Action
url += "&body=#{post}"
if category_id = action_category_id(action, data)
if category_id = action_category_id
if category = Category.find(category_id)
url += "&category=#{category.full_slug('/')}"
end
end
if tags = action_tags(action, data)
if tags = action_tags
url += "&tags=#{tags.join(',')}"
end