Add open composer action
Dieser Commit ist enthalten in:
Ursprung
9006126e04
Commit
f317032bca
5 geänderte Dateien mit 118 neuen und 89 gelöschten Zeilen
|
@ -6,7 +6,8 @@ const ACTION_TYPES = [
|
||||||
{ id: 'send_message', name: 'Send Message' },
|
{ id: 'send_message', name: 'Send Message' },
|
||||||
{ id: 'send_to_api', name: 'Send to API' },
|
{ id: 'send_to_api', name: 'Send to API' },
|
||||||
{ id: 'add_to_group', name: 'Add to Group' },
|
{ id: 'add_to_group', name: 'Add to Group' },
|
||||||
{ id: 'route_to', name: 'Route To' }
|
{ id: 'route_to', name: 'Route To' },
|
||||||
|
{ id: 'open_composer', name: 'Open Composer' }
|
||||||
];
|
];
|
||||||
|
|
||||||
const PROFILE_FIELDS = [
|
const PROFILE_FIELDS = [
|
||||||
|
@ -35,6 +36,21 @@ export default Ember.Component.extend({
|
||||||
routeTo: Ember.computed.equal('action.type', 'route_to'),
|
routeTo: Ember.computed.equal('action.type', 'route_to'),
|
||||||
disableId: Ember.computed.not('action.isNew'),
|
disableId: Ember.computed.not('action.isNew'),
|
||||||
|
|
||||||
|
@computed('action.type')
|
||||||
|
basicTopicFields(actionType) {
|
||||||
|
return ['create_topic', 'send_message', 'open_composer'].indexOf(actionType) > -1;
|
||||||
|
},
|
||||||
|
|
||||||
|
@computed('action.type')
|
||||||
|
publicTopicFields(actionType) {
|
||||||
|
return ['create_topic', 'open_composer'].indexOf(actionType) > -1;
|
||||||
|
},
|
||||||
|
|
||||||
|
@computed('action.type')
|
||||||
|
newTopicFields(actionType) {
|
||||||
|
return ['create_topic', 'send_message'].indexOf(actionType) > -1;
|
||||||
|
},
|
||||||
|
|
||||||
@computed('availableFields')
|
@computed('availableFields')
|
||||||
builderWizardFields(fields) {
|
builderWizardFields(fields) {
|
||||||
return fields.map((f) => ` w{${f.id}}`);
|
return fields.map((f) => ` w{${f.id}}`);
|
||||||
|
|
|
@ -16,41 +16,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#if createTopic}}
|
{{#if basicTopicFields}}
|
||||||
<div class="setting">
|
|
||||||
<div class="setting-label">
|
|
||||||
<h3>{{i18n "admin.wizard.action.create_topic.category"}}</h3>
|
|
||||||
</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.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 class="setting">
|
<div class="setting">
|
||||||
<div class="setting-label">
|
<div class="setting-label">
|
||||||
<h3>{{i18n "admin.wizard.action.title"}}</h3>
|
<h3>{{i18n "admin.wizard.action.title"}}</h3>
|
||||||
|
@ -92,16 +58,68 @@
|
||||||
<div class="setting-label">
|
<div class="setting-label">
|
||||||
<h3>{{i18n 'admin.wizard.action.post_builder.label'}}</h3>
|
<h3>{{i18n 'admin.wizard.action.post_builder.label'}}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="setting-value">
|
<div class="setting-value editor">
|
||||||
<label>{{i18n 'admin.wizard.action.post_builder.user_fields'}}{{builderUserFields}}</label>
|
|
||||||
<label>{{i18n 'admin.wizard.action.post_builder.wizard_fields'}}{{builderWizardFields}}</label>
|
|
||||||
{{d-editor value=action.post_template
|
{{d-editor value=action.post_template
|
||||||
placeholder='admin.wizard.action.interpolate_fields'
|
placeholder='admin.wizard.action.interpolate_fields'
|
||||||
classNames='post-builder-editor'}}
|
classNames='post-builder-editor'}}
|
||||||
|
<div>
|
||||||
|
<label>{{i18n 'admin.wizard.action.post_builder.user_fields'}}{{builderUserFields}}</label>
|
||||||
|
<label>{{i18n 'admin.wizard.action.post_builder.wizard_fields'}}{{builderWizardFields}}</label>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if publicTopicFields}}
|
||||||
|
<div class="setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<h3>{{i18n "admin.wizard.action.create_topic.category"}}</h3>
|
||||||
|
</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.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 class="setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<h3>{{i18n "admin.wizard.action.create_topic.tags"}}</h3>
|
||||||
|
</div>
|
||||||
|
<div class="setting-value">
|
||||||
|
{{tag-chooser tags=action.tags
|
||||||
|
filterable=true
|
||||||
|
allowCreate=true
|
||||||
|
isDisabled=action.custom_category_enabled}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if newTopicFields}}
|
||||||
<div class="setting">
|
<div class="setting">
|
||||||
<div class="setting-label">
|
<div class="setting-label">
|
||||||
<h3>{{i18n "admin.wizard.action.skip_redirect.label"}}</h3>
|
<h3>{{i18n "admin.wizard.action.skip_redirect.label"}}</h3>
|
||||||
|
@ -111,7 +129,9 @@
|
||||||
<span>{{i18n 'admin.wizard.action.skip_redirect.description' type='topic'}}</span>
|
<span>{{i18n 'admin.wizard.action.skip_redirect.description' type='topic'}}</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if createTopic}}
|
||||||
<div class="setting full">
|
<div class="setting full">
|
||||||
<label>{{i18n 'admin.wizard.action.add_fields' type='Topic'}}</label>
|
<label>{{i18n 'admin.wizard.action.add_fields' type='Topic'}}</label>
|
||||||
{{wizard-custom-inputs inputs=action.add_fields
|
{{wizard-custom-inputs inputs=action.add_fields
|
||||||
|
@ -123,46 +143,6 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if sendMessage}}
|
{{#if sendMessage}}
|
||||||
<div class="setting">
|
|
||||||
<div class="setting-label">
|
|
||||||
<h3>{{i18n "admin.wizard.action.title"}}</h3>
|
|
||||||
</div>
|
|
||||||
<div class="setting-value">
|
|
||||||
{{combo-box value=action.title content=availableFields nameProperty='label' none='admin.wizard.select_field'}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="setting">
|
|
||||||
<div class="setting-label">
|
|
||||||
<h3>{{i18n "admin.wizard.action.post"}}</h3>
|
|
||||||
</div>
|
|
||||||
<div class="setting-value">
|
|
||||||
{{combo-box value=action.post content=availableFields
|
|
||||||
nameProperty='label'
|
|
||||||
none='admin.wizard.select_field'
|
|
||||||
isDisabled=action.post_builder}}
|
|
||||||
<div>
|
|
||||||
{{input type='checkbox' checked=action.post_builder}}
|
|
||||||
<span>{{i18n 'admin.wizard.action.post_builder.checkbox'}}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{{#if action.post_builder}}
|
|
||||||
<div class="setting full">
|
|
||||||
<div class="setting-label">
|
|
||||||
<h3>{{i18n 'admin.wizard.action.post_builder.label'}}</h3>
|
|
||||||
</div>
|
|
||||||
<div class="setting-value">
|
|
||||||
<label>{{i18n 'admin.wizard.action.post_builder.user_fields'}}{{builderUserFields}}</label>
|
|
||||||
<label>{{i18n 'admin.wizard.action.post_builder.wizard_fields'}}{{builderWizardFields}}</label>
|
|
||||||
{{d-editor value=action.post_template
|
|
||||||
placeholder='admin.wizard.action.interpolate_fields'
|
|
||||||
classNames='post-builder-editor'}}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{{/if}}
|
|
||||||
|
|
||||||
<div class="setting">
|
<div class="setting">
|
||||||
<div class="setting-label">
|
<div class="setting-label">
|
||||||
<h3>{{i18n "admin.wizard.action.send_message.recipient"}}</h3>
|
<h3>{{i18n "admin.wizard.action.send_message.recipient"}}</h3>
|
||||||
|
@ -175,16 +155,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="setting">
|
|
||||||
<div class="setting-label">
|
|
||||||
<h3>{{i18n "admin.wizard.action.skip_redirect.label"}}</h3>
|
|
||||||
</div>
|
|
||||||
<div class="setting-value">
|
|
||||||
{{input type='checkbox' checked=action.skip_redirect}}
|
|
||||||
<span>{{i18n 'admin.wizard.action.skip_redirect.description' type='message'}}</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="setting full">
|
<div class="setting full">
|
||||||
<label>{{i18n "admin.wizard.action.add_fields" type='Message'}}</label>
|
<label>{{i18n "admin.wizard.action.add_fields" type='Message'}}</label>
|
||||||
{{wizard-custom-inputs inputs=action.add_fields
|
{{wizard-custom-inputs inputs=action.add_fields
|
||||||
|
@ -283,3 +253,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if openComposer}}
|
||||||
|
|
||||||
|
{{/if}}
|
||||||
|
|
|
@ -81,6 +81,14 @@
|
||||||
float: none;
|
float: none;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
||||||
|
&.editor {
|
||||||
|
flex-flow: wrap;
|
||||||
|
|
||||||
|
.d-editor {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.custom-input .remove {
|
.custom-input .remove {
|
||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
margin-top: 0;
|
margin-top: 0;
|
||||||
|
|
|
@ -133,6 +133,7 @@ en:
|
||||||
create_topic:
|
create_topic:
|
||||||
label: "Create Topic"
|
label: "Create Topic"
|
||||||
category: "Category"
|
category: "Category"
|
||||||
|
tags: "Tags"
|
||||||
update_profile:
|
update_profile:
|
||||||
label: "Update Profile"
|
label: "Update Profile"
|
||||||
profile_field: "Profile Field"
|
profile_field: "Profile Field"
|
||||||
|
|
|
@ -505,6 +505,36 @@ class CustomWizard::Builder
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def open_composer(user, action, data)
|
||||||
|
if action['custom_title_enabled']
|
||||||
|
title = CustomWizard::Builder.fill_placeholders(action['custom_title'], user, data)
|
||||||
|
else
|
||||||
|
title = data[action['title']]
|
||||||
|
end
|
||||||
|
|
||||||
|
url = "/new-topic?title=#{title}"
|
||||||
|
|
||||||
|
if action['post_builder']
|
||||||
|
post = CustomWizard::Builder.fill_placeholders(action['post_template'], user, data)
|
||||||
|
else
|
||||||
|
post = data[action['post']]
|
||||||
|
end
|
||||||
|
|
||||||
|
url += "&body=#{post}"
|
||||||
|
|
||||||
|
if action['category_id']
|
||||||
|
if category = Category.find(action['category_id'])
|
||||||
|
url += "&category=#{category.full_slug}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if action['tags'].present?
|
||||||
|
url += "&tags=#{action['tags'].join(',')}"
|
||||||
|
end
|
||||||
|
|
||||||
|
data['redirect_on_complete'] = Discourse.base_uri + URI.encode(url)
|
||||||
|
end
|
||||||
|
|
||||||
def add_to_group(user, action, data)
|
def add_to_group(user, action, data)
|
||||||
if group_id = data[action['group_id']]
|
if group_id = data[action['group_id']]
|
||||||
if group = Group.find(group_id)
|
if group = Group.find(group_id)
|
||||||
|
|
Laden …
In neuem Issue referenzieren