Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 09:20:29 +01:00
Add custom category and title for create_topic
Dieser Commit ist enthalten in:
Ursprung
f7c1170e07
Commit
aa1c30f1d3
6 geänderte Dateien mit 103 neuen und 10 gelöschten Zeilen
|
@ -1,4 +1,4 @@
|
||||||
import { default as computed } from 'ember-addons/ember-computed-decorators';
|
import { default as computed, observes } from 'ember-addons/ember-computed-decorators';
|
||||||
|
|
||||||
const ACTION_TYPES = [
|
const ACTION_TYPES = [
|
||||||
{ id: 'create_topic', name: 'Create Topic' },
|
{ id: 'create_topic', name: 'Create Topic' },
|
||||||
|
@ -63,5 +63,17 @@ export default Ember.Component.extend({
|
||||||
const noThemeKey = PROFILE_FIELDS.filter((f) => f !== 'theme_key');
|
const noThemeKey = PROFILE_FIELDS.filter((f) => f !== 'theme_key');
|
||||||
const fields = noThemeKey.concat(['email', 'username']);
|
const fields = noThemeKey.concat(['email', 'username']);
|
||||||
return fields.map((f) => ` u{${f}}`);
|
return fields.map((f) => ` u{${f}}`);
|
||||||
|
},
|
||||||
|
|
||||||
|
@observes('action.custom_category_wizard_field')
|
||||||
|
toggleCustomCategoryUserField() {
|
||||||
|
const wizard = this.get('action.custom_category_wizard_field');
|
||||||
|
if (wizard) this.set('action.custom_category_user_field', false);
|
||||||
|
},
|
||||||
|
|
||||||
|
@observes('action.custom_category_user_field')
|
||||||
|
toggleCustomCategoryWizardField() {
|
||||||
|
const user = this.get('action.custom_category_user_field');
|
||||||
|
if (user) this.set('action.custom_category_wizard_field', false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -22,7 +22,32 @@
|
||||||
<h3>{{i18n "admin.wizard.action.create_topic.category"}}</h3>
|
<h3>{{i18n "admin.wizard.action.create_topic.category"}}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-value">
|
<div class="setting-value">
|
||||||
{{category-chooser value=action.category_id}}
|
{{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.action.custom_category.wizard_field'}}</span>
|
||||||
|
{{#if action.custom_category_wizard_field}}
|
||||||
|
{{combo-box value=action.category_id
|
||||||
|
content=availableFields
|
||||||
|
nameProperty="label"
|
||||||
|
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>
|
||||||
|
|
||||||
|
@ -31,7 +56,18 @@
|
||||||
<h3>{{i18n "admin.wizard.action.title"}}</h3>
|
<h3>{{i18n "admin.wizard.action.title"}}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-value">
|
<div class="setting-value">
|
||||||
{{combo-box value=action.title content=availableFields nameProperty="label" none='admin.wizard.select_field'}}
|
{{combo-box value=action.title
|
||||||
|
content=availableFields
|
||||||
|
nameProperty="label"
|
||||||
|
none='admin.wizard.select_field'
|
||||||
|
isDisabled=action.custom_title_enabled}}
|
||||||
|
<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>
|
||||||
|
|
||||||
|
@ -44,7 +80,7 @@
|
||||||
nameProperty='label'
|
nameProperty='label'
|
||||||
none='admin.wizard.select_field'
|
none='admin.wizard.select_field'
|
||||||
isDisabled=action.post_builder}}
|
isDisabled=action.post_builder}}
|
||||||
<div>
|
<div class="setting-gutter">
|
||||||
{{input type='checkbox' checked=action.post_builder}}
|
{{input type='checkbox' checked=action.post_builder}}
|
||||||
<span>{{i18n 'admin.wizard.action.post_builder.checkbox'}}</span>
|
<span>{{i18n 'admin.wizard.action.post_builder.checkbox'}}</span>
|
||||||
</div>
|
</div>
|
||||||
|
@ -71,7 +107,8 @@
|
||||||
{{wizard-custom-input inputs=action.add_fields
|
{{wizard-custom-input inputs=action.add_fields
|
||||||
valueContent=availableFields
|
valueContent=availableFields
|
||||||
inputKey='admin.wizard.action.topic_attr'
|
inputKey='admin.wizard.action.topic_attr'
|
||||||
noneValue='admin.wizard.select_field'}}
|
noneValue='admin.wizard.select_field'
|
||||||
|
optionalCustom=true}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,14 @@
|
||||||
{{input type="text" value=in.key placeholder=(i18n inputKey)}}
|
{{input type="text" value=in.key placeholder=(i18n inputKey)}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if valueContent}}
|
{{#if valueContent}}
|
||||||
{{combo-box value=in.value content=valueContent nameProperty="label" none=noneValue}}
|
{{combo-box value=in.value
|
||||||
|
content=valueContent
|
||||||
|
nameProperty="label"
|
||||||
|
none=noneValue
|
||||||
|
isDisabled=(if in.value_custom true false)}}
|
||||||
|
{{#if optionalCustom}}
|
||||||
|
{{input type="text" value=in.value_custom placeholder=(i18n inputValue)}}
|
||||||
|
{{/if}}
|
||||||
{{else}}
|
{{else}}
|
||||||
{{input type="text" value=in.value placeholder=(i18n inputValue)}}
|
{{input type="text" value=in.value placeholder=(i18n inputValue)}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -87,6 +87,10 @@
|
||||||
label {
|
label {
|
||||||
margin: 5px 0;
|
margin: 5px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.setting-gutter {
|
||||||
|
margin-top: 5px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.select-box-kit-header {
|
.select-box-kit-header {
|
||||||
|
@ -104,6 +108,11 @@
|
||||||
.buttons .remove {
|
.buttons .remove {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.custom-category {
|
||||||
|
margin-top: 5px;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.wizard-links {
|
.wizard-links {
|
||||||
|
|
|
@ -47,7 +47,7 @@ en:
|
||||||
custom_text_placeholder: "Overrides translation"
|
custom_text_placeholder: "Overrides translation"
|
||||||
type: "Type"
|
type: "Type"
|
||||||
none: "Make a selection"
|
none: "Make a selection"
|
||||||
select_field: "Wizard Field"
|
select_field: "Select Field"
|
||||||
error:
|
error:
|
||||||
name_required: "Wizards must have a name."
|
name_required: "Wizards must have a name."
|
||||||
steps_required: "Wizards must have at least one step."
|
steps_required: "Wizards must have at least one step."
|
||||||
|
@ -109,6 +109,11 @@ en:
|
||||||
user_fields: "User Fields: "
|
user_fields: "User Fields: "
|
||||||
wizard_fields: "Wizard Fields: "
|
wizard_fields: "Wizard Fields: "
|
||||||
placeholder: "Insert wizard fields using the field_id in w{}. Insert user fields using field key in u{}."
|
placeholder: "Insert wizard fields using the field_id in w{}. Insert user fields using field key in u{}."
|
||||||
|
custom_title: "Custom Title"
|
||||||
|
custom_category:
|
||||||
|
label: "Custom Category"
|
||||||
|
wizard_field: "Wizard Field"
|
||||||
|
user_field: "User Field"
|
||||||
|
|
||||||
wizard_js:
|
wizard_js:
|
||||||
location:
|
location:
|
||||||
|
|
|
@ -174,7 +174,12 @@ class CustomWizard::Builder
|
||||||
if s['actions'] && s['actions'].length
|
if s['actions'] && s['actions'].length
|
||||||
s['actions'].each do |a|
|
s['actions'].each do |a|
|
||||||
if a['type'] === 'create_topic' && data
|
if a['type'] === 'create_topic' && data
|
||||||
title = data[a['title']]
|
|
||||||
|
if a['custom_title']
|
||||||
|
title = a['custom_title']
|
||||||
|
else
|
||||||
|
title = data[a['title']]
|
||||||
|
end
|
||||||
|
|
||||||
if a['post_builder']
|
if a['post_builder']
|
||||||
post = CustomWizard::Builder.build_post(a['post_template'], user, data)
|
post = CustomWizard::Builder.build_post(a['post_template'], user, data)
|
||||||
|
@ -188,13 +193,31 @@ class CustomWizard::Builder
|
||||||
raw: post,
|
raw: post,
|
||||||
skip_validations: true
|
skip_validations: true
|
||||||
}
|
}
|
||||||
params[:category] = a['category_id'] if a['category_id']
|
|
||||||
|
if a['custom_category_enabled'] &&
|
||||||
|
!a['custom_category_wizard_field'] &&
|
||||||
|
a['custom_category_user_field_key']
|
||||||
|
if a['custom_category_user_field_key'].include?('custom_fields')
|
||||||
|
field = a['custom_category_user_field_key'].split('.').last
|
||||||
|
category_id = user.custom_fields[field]
|
||||||
|
else
|
||||||
|
category_id = user.send(a['custom_category_user_field_key'])
|
||||||
|
end
|
||||||
|
else
|
||||||
|
category_id = a['category_id']
|
||||||
|
end
|
||||||
|
|
||||||
|
params[:category] = category_id
|
||||||
|
|
||||||
topic_custom_fields = {}
|
topic_custom_fields = {}
|
||||||
|
|
||||||
if a['add_fields']
|
if a['add_fields']
|
||||||
a['add_fields'].each do |f|
|
a['add_fields'].each do |f|
|
||||||
value = data[f['value']]
|
if f['value_custom']
|
||||||
|
value = f['value_custom']
|
||||||
|
else
|
||||||
|
value = data[f['value']]
|
||||||
|
end
|
||||||
key = f['key']
|
key = f['key']
|
||||||
|
|
||||||
if key && key.include?('custom_fields')
|
if key && key.include?('custom_fields')
|
||||||
|
|
Laden …
In neuem Issue referenzieren