0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-25 18:50:27 +01:00

Add open composer action

Dieser Commit ist enthalten in:
Angus McLeod 2019-08-27 16:05:24 +10:00
Ursprung 9006126e04
Commit f317032bca
5 geänderte Dateien mit 118 neuen und 89 gelöschten Zeilen

Datei anzeigen

@ -6,7 +6,8 @@ const ACTION_TYPES = [
{ id: 'send_message', name: 'Send Message' },
{ id: 'send_to_api', name: 'Send to API' },
{ 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 = [
@ -35,6 +36,21 @@ export default Ember.Component.extend({
routeTo: Ember.computed.equal('action.type', 'route_to'),
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')
builderWizardFields(fields) {
return fields.map((f) => ` w{${f.id}}`);

Datei anzeigen

@ -16,41 +16,7 @@
</div>
</div>
{{#if createTopic}}
<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>
{{#if basicTopicFields}}
<div class="setting">
<div class="setting-label">
<h3>{{i18n "admin.wizard.action.title"}}</h3>
@ -92,16 +58,68 @@
<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>
<div class="setting-value editor">
{{d-editor value=action.post_template
placeholder='admin.wizard.action.interpolate_fields'
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>
{{/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-label">
<h3>{{i18n "admin.wizard.action.skip_redirect.label"}}</h3>
@ -111,7 +129,9 @@
<span>{{i18n 'admin.wizard.action.skip_redirect.description' type='topic'}}</span>
</div>
</div>
{{/if}}
{{#if createTopic}}
<div class="setting full">
<label>{{i18n 'admin.wizard.action.add_fields' type='Topic'}}</label>
{{wizard-custom-inputs inputs=action.add_fields
@ -123,46 +143,6 @@
{{/if}}
{{#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-label">
<h3>{{i18n "admin.wizard.action.send_message.recipient"}}</h3>
@ -175,16 +155,6 @@
</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">
<label>{{i18n "admin.wizard.action.add_fields" type='Message'}}</label>
{{wizard-custom-inputs inputs=action.add_fields
@ -283,3 +253,7 @@
</div>
</div>
{{/if}}
{{#if openComposer}}
{{/if}}

Datei anzeigen

@ -80,6 +80,14 @@
width: initial;
float: none;
display: flex;
&.editor {
flex-flow: wrap;
.d-editor {
margin-bottom: 5px;
}
}
.custom-input .remove {
margin-left: 10px;

Datei anzeigen

@ -133,6 +133,7 @@ en:
create_topic:
label: "Create Topic"
category: "Category"
tags: "Tags"
update_profile:
label: "Update Profile"
profile_field: "Profile Field"

Datei anzeigen

@ -504,6 +504,36 @@ class CustomWizard::Builder
## add validation callback
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)
if group_id = data[action['group_id']]