Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 09:20:29 +01:00
Merge branch 'master' into add_date_time_inputs
Dieser Commit ist enthalten in:
Commit
888072f196
18 geänderte Dateien mit 771 neuen und 33 gelöschten Zeilen
|
@ -1 +1 @@
|
||||||
2.6.0.beta1: bb85b3a0d2c0ab6b59bcb405731c39089ec6731c
|
2.5.0: bb85b3a0d2c0ab6b59bcb405731c39089ec6731c
|
|
@ -20,11 +20,13 @@ export default Component.extend(UndoChanges, {
|
||||||
sendToApi: equal('action.type', 'send_to_api'),
|
sendToApi: equal('action.type', 'send_to_api'),
|
||||||
addToGroup: equal('action.type', 'add_to_group'),
|
addToGroup: equal('action.type', 'add_to_group'),
|
||||||
routeTo: equal('action.type', 'route_to'),
|
routeTo: equal('action.type', 'route_to'),
|
||||||
|
createCategory: equal('action.type', 'create_category'),
|
||||||
|
createGroup: equal('action.type', 'create_group'),
|
||||||
apiEmpty: empty('action.api'),
|
apiEmpty: empty('action.api'),
|
||||||
groupPropertyTypes: selectKitContent(['id', 'name']),
|
groupPropertyTypes: selectKitContent(['id', 'name']),
|
||||||
hasAdvanced: or('hasCustomFields', 'routeTo'),
|
hasAdvanced: or('hasCustomFields', 'routeTo'),
|
||||||
showAdvanced: and('hasAdvanced', 'action.type'),
|
showAdvanced: and('hasAdvanced', 'action.type'),
|
||||||
hasCustomFields: or('basicTopicFields', 'updateProfile'),
|
hasCustomFields: or('basicTopicFields', 'updateProfile', 'createGroup', 'createCategory'),
|
||||||
basicTopicFields: or('createTopic', 'sendMessage', 'openComposer'),
|
basicTopicFields: or('createTopic', 'sendMessage', 'openComposer'),
|
||||||
publicTopicFields: or('createTopic', 'openComposer'),
|
publicTopicFields: or('createTopic', 'openComposer'),
|
||||||
showSkipRedirect: or('createTopic', 'sendMessage'),
|
showSkipRedirect: or('createTopic', 'sendMessage'),
|
||||||
|
|
|
@ -17,7 +17,7 @@ export default Component.extend(UndoChanges, {
|
||||||
isText: equal('field.type', 'text'),
|
isText: equal('field.type', 'text'),
|
||||||
isTextarea: equal('field.type', 'textarea'),
|
isTextarea: equal('field.type', 'textarea'),
|
||||||
isUrl: equal('field.type', 'url'),
|
isUrl: equal('field.type', 'url'),
|
||||||
showPrefill: or('isCategory', 'isTag', 'isGroup', 'isDropdown'),
|
showPrefill: or('isText', 'isCategory', 'isTag', 'isGroup', 'isDropdown'),
|
||||||
showContent: or('isCategory', 'isTag', 'isGroup', 'isDropdown'),
|
showContent: or('isCategory', 'isTag', 'isGroup', 'isDropdown'),
|
||||||
showLimit: or('isCategory', 'isTag'),
|
showLimit: or('isCategory', 'isTag'),
|
||||||
showMinLength: or('isText', 'isTextarea', 'isUrl', 'isComposer'),
|
showMinLength: or('isText', 'isTextarea', 'isUrl', 'isComposer'),
|
||||||
|
|
|
@ -13,6 +13,7 @@ export default Component.extend({
|
||||||
|
|
||||||
showText: computed('activeType', function() { return this.showInput('text') }),
|
showText: computed('activeType', function() { return this.showInput('text') }),
|
||||||
showWizardField: computed('activeType', function() { return this.showInput('wizardField') }),
|
showWizardField: computed('activeType', function() { return this.showInput('wizardField') }),
|
||||||
|
showWizardAction: computed('activeType', function() { return this.showInput('wizardAction') }),
|
||||||
showUserField: computed('activeType', function() { return this.showInput('userField') }),
|
showUserField: computed('activeType', function() { return this.showInput('userField') }),
|
||||||
showUserFieldOptions: computed('activeType', function() { return this.showInput('userFieldOptions') }),
|
showUserFieldOptions: computed('activeType', function() { return this.showInput('userFieldOptions') }),
|
||||||
showCategory: computed('activeType', function() { return this.showInput('category') }),
|
showCategory: computed('activeType', function() { return this.showInput('category') }),
|
||||||
|
@ -22,6 +23,7 @@ export default Component.extend({
|
||||||
showList: computed('activeType', function() { return this.showInput('list') }),
|
showList: computed('activeType', function() { return this.showInput('list') }),
|
||||||
textEnabled: computed('options.textSelection', 'inputType', function() { return this.optionEnabled('textSelection') }),
|
textEnabled: computed('options.textSelection', 'inputType', function() { return this.optionEnabled('textSelection') }),
|
||||||
wizardFieldEnabled: computed('options.wizardFieldSelection', 'inputType', function() { return this.optionEnabled('wizardFieldSelection') }),
|
wizardFieldEnabled: computed('options.wizardFieldSelection', 'inputType', function() { return this.optionEnabled('wizardFieldSelection') }),
|
||||||
|
wizardActionEnabled: computed('options.wizardActionSelection', 'inputType', function() { return this.optionEnabled('wizardActionSelection') }),
|
||||||
userFieldEnabled: computed('options.userFieldSelection', 'inputType', function() { return this.optionEnabled('userFieldSelection') }),
|
userFieldEnabled: computed('options.userFieldSelection', 'inputType', function() { return this.optionEnabled('userFieldSelection') }),
|
||||||
userFieldOptionsEnabled: computed('options.userFieldOptionsSelection', 'inputType', function() { return this.optionEnabled('userFieldOptionsSelection') }),
|
userFieldOptionsEnabled: computed('options.userFieldOptionsSelection', 'inputType', function() { return this.optionEnabled('userFieldOptionsSelection') }),
|
||||||
categoryEnabled: computed('options.categorySelection', 'inputType', function() { return this.optionEnabled('categorySelection') }),
|
categoryEnabled: computed('options.categorySelection', 'inputType', function() { return this.optionEnabled('categorySelection') }),
|
||||||
|
@ -32,7 +34,7 @@ export default Component.extend({
|
||||||
|
|
||||||
groups: alias('site.groups'),
|
groups: alias('site.groups'),
|
||||||
categories: alias('site.categories'),
|
categories: alias('site.categories'),
|
||||||
showComboBox: or('showWizardField', 'showUserField', 'showUserFieldOptions'),
|
showComboBox: or('showWizardField', 'showWizardAction', 'showUserField', 'showUserFieldOptions'),
|
||||||
showMultiSelect: or('showCategory', 'showGroup'),
|
showMultiSelect: or('showCategory', 'showGroup'),
|
||||||
hasTypes: gt('selectorTypes.length', 1),
|
hasTypes: gt('selectorTypes.length', 1),
|
||||||
showTypes: false,
|
showTypes: false,
|
||||||
|
@ -73,20 +75,48 @@ export default Component.extend({
|
||||||
return type ? I18n.t(`admin.wizard.selector.label.${snakeCase(type)}`) : null;
|
return type ? I18n.t(`admin.wizard.selector.label.${snakeCase(type)}`) : null;
|
||||||
},
|
},
|
||||||
|
|
||||||
comboBoxAllowAny: alias('showWizardField'),
|
comboBoxAllowAny: or('showWizardField', 'showWizardAction'),
|
||||||
|
|
||||||
@discourseComputed('activeType')
|
@discourseComputed
|
||||||
comboBoxContent(activeType) {
|
showController() {
|
||||||
const controller = getOwner(this).lookup('controller:admin-wizards-wizard-show');
|
return getOwner(this).lookup('controller:admin-wizards-wizard-show');
|
||||||
const wizardFields = controller.wizardFields;
|
},
|
||||||
const userFields = controller.userFields;
|
|
||||||
|
@discourseComputed(
|
||||||
|
'activeType',
|
||||||
|
'showController.wizardFields.[]',
|
||||||
|
'showController.wizard.actions.[]',
|
||||||
|
'showController.userFields.[]',
|
||||||
|
'showController.currentField.id',
|
||||||
|
'showController.currentAction.id'
|
||||||
|
)
|
||||||
|
comboBoxContent(
|
||||||
|
activeType,
|
||||||
|
wizardFields,
|
||||||
|
wizardActions,
|
||||||
|
userFields,
|
||||||
|
currentFieldId,
|
||||||
|
currentActionId
|
||||||
|
) {
|
||||||
let content;
|
let content;
|
||||||
|
|
||||||
if (activeType === 'wizardField') {
|
if (activeType === 'wizardField') {
|
||||||
content = wizardFields;
|
content = wizardFields;
|
||||||
|
|
||||||
if (this.options.context === 'field') {
|
if (this.options.context === 'field') {
|
||||||
content = content.filter(field => field.id !== controller.currentField.id);
|
content = content.filter(field => field.id !== currentFieldId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (activeType === 'wizardAction') {
|
||||||
|
content = wizardActions.map(a => ({
|
||||||
|
id: a.id,
|
||||||
|
label: `${generateName(a.type)} (${a.id})`,
|
||||||
|
type: a.type
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (this.options.context === 'action') {
|
||||||
|
content = content.filter(a => a.id !== currentActionId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ export default Component.extend({
|
||||||
previewEnabled: true,
|
previewEnabled: true,
|
||||||
fieldsEnabled: true,
|
fieldsEnabled: true,
|
||||||
hasWizardFields: notEmpty('wizardFieldList'),
|
hasWizardFields: notEmpty('wizardFieldList'),
|
||||||
|
hasWizardActions: notEmpty('wizardActionList'),
|
||||||
|
|
||||||
didReceiveAttrs() {
|
didReceiveAttrs() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
@ -46,6 +47,11 @@ export default Component.extend({
|
||||||
return wizardFields.map((f) => ` w{${f.id}}`);
|
return wizardFields.map((f) => ` w{${f.id}}`);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@discourseComputed('wizardActions')
|
||||||
|
wizardActionList(wizardActions) {
|
||||||
|
return wizardActions.map((a) => ` w{${a.id}}`);
|
||||||
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
togglePreview() {
|
togglePreview() {
|
||||||
this.toggleProperty('forcePreview');
|
this.toggleProperty('forcePreview');
|
||||||
|
|
|
@ -46,7 +46,7 @@ export default Controller.extend({
|
||||||
I18n.t('admin.wizard.after_time_time_label');
|
I18n.t('admin.wizard.after_time_time_label');
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed('currentStep.id', 'wizard.save_submissions', 'wizard.steps.@each.fields[]')
|
@discourseComputed('currentStep.id', 'wizard.save_submissions', 'currentStep.fields.@each.label')
|
||||||
wizardFields(currentStepId, saveSubmissions) {
|
wizardFields(currentStepId, saveSubmissions) {
|
||||||
let steps = this.wizard.steps;
|
let steps = this.wizard.steps;
|
||||||
if (!saveSubmissions) {
|
if (!saveSubmissions) {
|
||||||
|
|
|
@ -80,6 +80,7 @@ const selectionTypes = [
|
||||||
'text',
|
'text',
|
||||||
'list',
|
'list',
|
||||||
'wizardField',
|
'wizardField',
|
||||||
|
'wizardAction',
|
||||||
'userField',
|
'userField',
|
||||||
'userFieldOptions',
|
'userFieldOptions',
|
||||||
'group',
|
'group',
|
||||||
|
|
|
@ -115,6 +115,7 @@ const action = {
|
||||||
post_template: null,
|
post_template: null,
|
||||||
category: null,
|
category: null,
|
||||||
tags: null,
|
tags: null,
|
||||||
|
visible: null,
|
||||||
custom_fields: null,
|
custom_fields: null,
|
||||||
skip_redirect: null
|
skip_redirect: null
|
||||||
},
|
},
|
||||||
|
@ -144,7 +145,9 @@ const action = {
|
||||||
watch_categories: {
|
watch_categories: {
|
||||||
categories: null,
|
categories: null,
|
||||||
notification_level: null,
|
notification_level: null,
|
||||||
mute_remainder: null
|
mute_remainder: null,
|
||||||
|
wizard_user: true,
|
||||||
|
usernames: null
|
||||||
},
|
},
|
||||||
send_to_api: {
|
send_to_api: {
|
||||||
api: null,
|
api: null,
|
||||||
|
@ -157,12 +160,36 @@ const action = {
|
||||||
route_to: {
|
route_to: {
|
||||||
url: null,
|
url: null,
|
||||||
code: null
|
code: null
|
||||||
|
},
|
||||||
|
create_category: {
|
||||||
|
name: null,
|
||||||
|
slug: null,
|
||||||
|
color: null,
|
||||||
|
text_color: "FFFFFF",
|
||||||
|
parent_category_id: null,
|
||||||
|
permissions: null,
|
||||||
|
custom_fields: null
|
||||||
|
},
|
||||||
|
create_group: {
|
||||||
|
name: null,
|
||||||
|
full_name: null,
|
||||||
|
title: null,
|
||||||
|
bio_raw: null,
|
||||||
|
owner_usernames: null,
|
||||||
|
usernames: null,
|
||||||
|
grant_trust_level: null,
|
||||||
|
mentionable_level: null,
|
||||||
|
messageable_level: null,
|
||||||
|
visibility_level: null,
|
||||||
|
members_visibility_level: null,
|
||||||
|
custom_fields: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mapped: [
|
mapped: [
|
||||||
'title',
|
'title',
|
||||||
'category',
|
'category',
|
||||||
'tags',
|
'tags',
|
||||||
|
'visible',
|
||||||
'custom_fields',
|
'custom_fields',
|
||||||
'required',
|
'required',
|
||||||
'recipient',
|
'recipient',
|
||||||
|
@ -170,7 +197,22 @@ const action = {
|
||||||
'group',
|
'group',
|
||||||
'url',
|
'url',
|
||||||
'categories',
|
'categories',
|
||||||
'mute_remainder'
|
'mute_remainder',
|
||||||
|
'name',
|
||||||
|
'slug',
|
||||||
|
'color',
|
||||||
|
'text_color',
|
||||||
|
'parent_category_id',
|
||||||
|
'permissions',
|
||||||
|
'full_name',
|
||||||
|
'bio_raw',
|
||||||
|
'owner_usernames',
|
||||||
|
'usernames',
|
||||||
|
'grant_trust_level',
|
||||||
|
'mentionable_level',
|
||||||
|
'messageable_level',
|
||||||
|
'visibility_level',
|
||||||
|
'members_visibility_level'
|
||||||
],
|
],
|
||||||
advanced: [
|
advanced: [
|
||||||
'code',
|
'code',
|
||||||
|
|
|
@ -139,6 +139,24 @@
|
||||||
)}}
|
)}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="setting full field-mapper-setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.create_topic.visible"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{wizard-mapper
|
||||||
|
inputs=action.visible
|
||||||
|
property='visible'
|
||||||
|
onUpdate=(action 'mappedFieldUpdated')
|
||||||
|
options=(hash
|
||||||
|
wizardFieldSelection=true
|
||||||
|
userFieldSelection=true
|
||||||
|
context='action'
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if sendMessage}}
|
{{#if sendMessage}}
|
||||||
|
@ -297,6 +315,7 @@
|
||||||
options=(hash
|
options=(hash
|
||||||
textSelection='key,value'
|
textSelection='key,value'
|
||||||
wizardFieldSelection=true
|
wizardFieldSelection=true
|
||||||
|
wizardActionSelection=true
|
||||||
userFieldSelection='key,value'
|
userFieldSelection='key,value'
|
||||||
categorySelection='output'
|
categorySelection='output'
|
||||||
context='action'
|
context='action'
|
||||||
|
@ -338,6 +357,358 @@
|
||||||
)}}
|
)}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="setting full">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.watch_categories.wizard_user"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{input type="checkbox" checked=action.wizard_user}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting full field-mapper-setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.watch_categories.usernames"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{wizard-mapper
|
||||||
|
inputs=action.usernames
|
||||||
|
property='usernames'
|
||||||
|
onUpdate=(action 'mappedFieldUpdated')
|
||||||
|
options=(hash
|
||||||
|
context='action'
|
||||||
|
wizardFieldSelection=true
|
||||||
|
userFieldSelection='key,value'
|
||||||
|
userSelection='output'
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if createGroup}}
|
||||||
|
<div class="setting full field-mapper-setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.create_group.name"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{wizard-mapper
|
||||||
|
inputs=action.name
|
||||||
|
property='name'
|
||||||
|
onUpdate=(action 'mappedFieldUpdated')
|
||||||
|
options=(hash
|
||||||
|
textSelection=true
|
||||||
|
wizardFieldSelection=true
|
||||||
|
userFieldSelection=true
|
||||||
|
context='action'
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="setting full field-mapper-setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.create_group.full_name"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{wizard-mapper
|
||||||
|
inputs=action.full_name
|
||||||
|
property='full_name'
|
||||||
|
onUpdate=(action 'mappedFieldUpdated')
|
||||||
|
options=(hash
|
||||||
|
textSelection=true
|
||||||
|
wizardFieldSelection=true
|
||||||
|
userFieldSelection=true
|
||||||
|
context='action'
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="setting full field-mapper-setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.create_group.title"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{wizard-mapper
|
||||||
|
inputs=action.title
|
||||||
|
property='title'
|
||||||
|
onUpdate=(action 'mappedFieldUpdated')
|
||||||
|
options=(hash
|
||||||
|
textSelection=true
|
||||||
|
wizardFieldSelection=true
|
||||||
|
userFieldSelection=true
|
||||||
|
context='action'
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="setting full field-mapper-setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.create_group.bio_raw"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{wizard-mapper
|
||||||
|
inputs=action.bio_raw
|
||||||
|
property='bio_raw'
|
||||||
|
onUpdate=(action 'mappedFieldUpdated')
|
||||||
|
options=(hash
|
||||||
|
textSelection=true
|
||||||
|
wizardFieldSelection=true
|
||||||
|
userFieldSelection=true
|
||||||
|
context='action'
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="setting full field-mapper-setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.create_group.owner_usernames"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{wizard-mapper
|
||||||
|
inputs=action.owner_usernames
|
||||||
|
property='owner_usernames'
|
||||||
|
onUpdate=(action 'mappedFieldUpdated')
|
||||||
|
options=(hash
|
||||||
|
textSelection=true
|
||||||
|
wizardFieldSelection=true
|
||||||
|
userFieldSelection=true
|
||||||
|
userSelection='output'
|
||||||
|
context='action'
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="setting full field-mapper-setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.create_group.usernames"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{wizard-mapper
|
||||||
|
inputs=action.usernames
|
||||||
|
property='usernames'
|
||||||
|
onUpdate=(action 'mappedFieldUpdated')
|
||||||
|
options=(hash
|
||||||
|
textSelection=true
|
||||||
|
wizardFieldSelection=true
|
||||||
|
userFieldSelection=true
|
||||||
|
userSelection='output'
|
||||||
|
context='action'
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="setting full field-mapper-setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.create_group.grant_trust_level"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{wizard-mapper
|
||||||
|
inputs=action.grant_trust_level
|
||||||
|
property='grant_trust_level'
|
||||||
|
onUpdate=(action 'mappedFieldUpdated')
|
||||||
|
options=(hash
|
||||||
|
textSelection=true
|
||||||
|
wizardFieldSelection=true
|
||||||
|
userFieldSelection=true
|
||||||
|
context='action'
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="setting full field-mapper-setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.create_group.mentionable_level"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{wizard-mapper
|
||||||
|
inputs=action.mentionable_level
|
||||||
|
property='mentionable_level'
|
||||||
|
onUpdate=(action 'mappedFieldUpdated')
|
||||||
|
options=(hash
|
||||||
|
textSelection=true
|
||||||
|
wizardFieldSelection=true
|
||||||
|
userFieldSelection=true
|
||||||
|
context='action'
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="setting full field-mapper-setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.create_group.messageable_level"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{wizard-mapper
|
||||||
|
inputs=action.messageable_level
|
||||||
|
property='messageable_level'
|
||||||
|
onUpdate=(action 'mappedFieldUpdated')
|
||||||
|
options=(hash
|
||||||
|
textSelection=true
|
||||||
|
wizardFieldSelection=true
|
||||||
|
userFieldSelection=true
|
||||||
|
context='action'
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="setting full field-mapper-setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.create_group.visibility_level"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{wizard-mapper
|
||||||
|
inputs=action.visibility_level
|
||||||
|
property='visibility_level'
|
||||||
|
onUpdate=(action 'mappedFieldUpdated')
|
||||||
|
options=(hash
|
||||||
|
textSelection=true
|
||||||
|
wizardFieldSelection=true
|
||||||
|
userFieldSelection=true
|
||||||
|
context='action'
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="setting full field-mapper-setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.create_group.members_visibility_level"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{wizard-mapper
|
||||||
|
inputs=action.members_visibility_level
|
||||||
|
property='members_visibility_level'
|
||||||
|
onUpdate=(action 'mappedFieldUpdated')
|
||||||
|
options=(hash
|
||||||
|
textSelection=true
|
||||||
|
wizardFieldSelection=true
|
||||||
|
userFieldSelection=true
|
||||||
|
context='action'
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if createCategory}}
|
||||||
|
<div class="setting full field-mapper-setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.create_category.name"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{wizard-mapper
|
||||||
|
inputs=action.name
|
||||||
|
property='name'
|
||||||
|
onUpdate=(action 'mappedFieldUpdated')
|
||||||
|
options=(hash
|
||||||
|
textSelection='key,value'
|
||||||
|
wizardFieldSelection=true
|
||||||
|
userFieldSelection='key,value'
|
||||||
|
context='action'
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting full field-mapper-setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.create_category.slug"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{wizard-mapper
|
||||||
|
inputs=action.slug
|
||||||
|
property='slug'
|
||||||
|
onUpdate=(action 'mappedFieldUpdated')
|
||||||
|
options=(hash
|
||||||
|
textSelection=true
|
||||||
|
wizardFieldSelection=true
|
||||||
|
userFieldSelection='key,value'
|
||||||
|
context='action'
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting full field-mapper-setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.create_category.color"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{wizard-mapper
|
||||||
|
inputs=action.color
|
||||||
|
property='color'
|
||||||
|
onUpdate=(action 'mappedFieldUpdated')
|
||||||
|
options=(hash
|
||||||
|
textSelection=true
|
||||||
|
wizardFieldSelection=true
|
||||||
|
userFieldSelection='key,value'
|
||||||
|
context='action'
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting full field-mapper-setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.create_category.text_color"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{wizard-mapper
|
||||||
|
inputs=action.text_color
|
||||||
|
property='text_color'
|
||||||
|
onUpdate=(action 'mappedFieldUpdated')
|
||||||
|
options=(hash
|
||||||
|
textSelection=true
|
||||||
|
wizardFieldSelection=true
|
||||||
|
userFieldSelection='key,value'
|
||||||
|
context='action'
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting full field-mapper-setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.create_category.parent_category"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{wizard-mapper
|
||||||
|
inputs=action.parent_category_id
|
||||||
|
property='parent_category_id'
|
||||||
|
onUpdate=(action 'mappedFieldUpdated')
|
||||||
|
options=(hash
|
||||||
|
textSelection='key,value'
|
||||||
|
wizardFieldSelection=true
|
||||||
|
userFieldSelection='key,value'
|
||||||
|
categorySelection='output'
|
||||||
|
context='action'
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting full field-mapper-setting">
|
||||||
|
<div class="setting-label">
|
||||||
|
<label>{{i18n "admin.wizard.action.create_category.permissions"}}</label>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-value">
|
||||||
|
{{wizard-mapper
|
||||||
|
inputs=action.permissions
|
||||||
|
property='permissions'
|
||||||
|
onUpdate=(action 'mappedFieldUpdated')
|
||||||
|
options=(hash
|
||||||
|
inputTypes='association'
|
||||||
|
textSelection=true
|
||||||
|
wizardFieldSelection=true
|
||||||
|
wizardActionSelection='key'
|
||||||
|
userFieldSelection=true
|
||||||
|
groupSelection='key'
|
||||||
|
context='action'
|
||||||
|
)}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if showAdvanced}}
|
{{#if showAdvanced}}
|
||||||
|
|
|
@ -28,6 +28,13 @@
|
||||||
{{wizardFieldList}}
|
{{wizardFieldList}}
|
||||||
</label>
|
</label>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
{{#if hasWizardActions}}
|
||||||
|
<label>
|
||||||
|
{{i18n 'admin.wizard.action.post_builder.wizard_actions'}}
|
||||||
|
{{wizardActionList}}
|
||||||
|
</label>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -35,10 +35,6 @@
|
||||||
|
|
||||||
& + div {
|
& + div {
|
||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
|
|
||||||
&+ div.setting {
|
|
||||||
margin-top: 30px;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,6 +94,7 @@ en:
|
||||||
label:
|
label:
|
||||||
text: "text"
|
text: "text"
|
||||||
wizard_field: "wizard field"
|
wizard_field: "wizard field"
|
||||||
|
wizard_action: "wizard action"
|
||||||
user_field: "user field"
|
user_field: "user field"
|
||||||
user_field_options: "user field options"
|
user_field_options: "user field options"
|
||||||
user: "user"
|
user: "user"
|
||||||
|
@ -106,6 +107,7 @@ en:
|
||||||
text: "Enter text"
|
text: "Enter text"
|
||||||
property: "Select property"
|
property: "Select property"
|
||||||
wizard_field: "Select field"
|
wizard_field: "Select field"
|
||||||
|
wizard_action: "Select action"
|
||||||
user_field: "Select field"
|
user_field: "Select field"
|
||||||
user_field_options: "Select field"
|
user_field_options: "Select field"
|
||||||
user: "Select user"
|
user: "Select user"
|
||||||
|
@ -208,6 +210,7 @@ en:
|
||||||
label: "Create Topic"
|
label: "Create Topic"
|
||||||
category: "Category"
|
category: "Category"
|
||||||
tags: "Tags"
|
tags: "Tags"
|
||||||
|
visible: "Visible"
|
||||||
open_composer:
|
open_composer:
|
||||||
label: "Open Composer"
|
label: "Open Composer"
|
||||||
update_profile:
|
update_profile:
|
||||||
|
@ -226,11 +229,14 @@ en:
|
||||||
watching_first_post: "Watching First Post"
|
watching_first_post: "Watching First Post"
|
||||||
muted: "Muted"
|
muted: "Muted"
|
||||||
select_a_notification_level: "Select level"
|
select_a_notification_level: "Select level"
|
||||||
|
wizard_user: "Wizard User"
|
||||||
|
usernames: "Users"
|
||||||
post_builder:
|
post_builder:
|
||||||
checkbox: "Post Builder"
|
checkbox: "Post Builder"
|
||||||
label: "Builder"
|
label: "Builder"
|
||||||
user_properties: "User Properties"
|
user_properties: "User Properties"
|
||||||
wizard_fields: "Wizard Fields"
|
wizard_fields: "Wizard Fields"
|
||||||
|
wizard_actions: "Wizard Actions"
|
||||||
placeholder: "Insert wizard fields using the field_id in w{}. Insert user properties using property in u{}."
|
placeholder: "Insert wizard fields using the field_id in w{}. Insert user properties using property in u{}."
|
||||||
add_to_group:
|
add_to_group:
|
||||||
label: "Add to Group"
|
label: "Add to Group"
|
||||||
|
@ -246,6 +252,27 @@ en:
|
||||||
select_an_endpoint: "Select an endpoint"
|
select_an_endpoint: "Select an endpoint"
|
||||||
body: "Body"
|
body: "Body"
|
||||||
body_placeholder: "JSON"
|
body_placeholder: "JSON"
|
||||||
|
create_category:
|
||||||
|
label: "Create Category"
|
||||||
|
name: Name
|
||||||
|
slug: Slug
|
||||||
|
color: Color
|
||||||
|
text_color: Text color
|
||||||
|
parent_category: Parent Category
|
||||||
|
permissions: Permissions
|
||||||
|
create_group:
|
||||||
|
label: Create Group
|
||||||
|
name: Name
|
||||||
|
full_name: Full Name
|
||||||
|
title: Title
|
||||||
|
bio_raw: About
|
||||||
|
owner_usernames: Owners
|
||||||
|
usernames: Members
|
||||||
|
grant_trust_level: Automatic Trust Level
|
||||||
|
mentionable_level: Mentionable Level
|
||||||
|
messageable_level: Messageable Level
|
||||||
|
visibility_level: Visibility Level
|
||||||
|
members_visibility_level: Members Visibility Level
|
||||||
|
|
||||||
submissions:
|
submissions:
|
||||||
nav_label: "Submissions"
|
nav_label: "Submissions"
|
||||||
|
|
|
@ -121,17 +121,35 @@ class CustomWizard::AdminWizardController < CustomWizard::AdminController
|
||||||
:api,
|
:api,
|
||||||
:api_endpoint,
|
:api_endpoint,
|
||||||
:api_body,
|
:api_body,
|
||||||
|
:wizard_user,
|
||||||
title: mapped_params,
|
title: mapped_params,
|
||||||
category: mapped_params,
|
category: mapped_params,
|
||||||
tags: mapped_params,
|
tags: mapped_params,
|
||||||
custom_fields: mapped_params,
|
custom_fields: mapped_params,
|
||||||
|
visible: mapped_params,
|
||||||
required: mapped_params,
|
required: mapped_params,
|
||||||
recipient: mapped_params,
|
recipient: mapped_params,
|
||||||
categories: mapped_params,
|
categories: mapped_params,
|
||||||
mute_remainder: mapped_params,
|
mute_remainder: mapped_params,
|
||||||
profile_updates: mapped_params,
|
profile_updates: mapped_params,
|
||||||
group: mapped_params,
|
group: mapped_params,
|
||||||
url: mapped_params
|
url: mapped_params,
|
||||||
|
name: mapped_params,
|
||||||
|
slug: mapped_params,
|
||||||
|
color: mapped_params,
|
||||||
|
text_color: mapped_params,
|
||||||
|
parent_category_id: mapped_params,
|
||||||
|
permissions: mapped_params,
|
||||||
|
full_name: mapped_params,
|
||||||
|
title: mapped_params,
|
||||||
|
bio_raw: mapped_params,
|
||||||
|
usernames: mapped_params,
|
||||||
|
owner_usernames: mapped_params,
|
||||||
|
grant_trust_level: mapped_params,
|
||||||
|
mentionable_level: mapped_params,
|
||||||
|
messageable_level: mapped_params,
|
||||||
|
visibility_level: mapped_params,
|
||||||
|
members_visibility_level: mapped_params
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
27
db/migrate/20200718014105_update_watch_categories_action.rb
Normale Datei
27
db/migrate/20200718014105_update_watch_categories_action.rb
Normale Datei
|
@ -0,0 +1,27 @@
|
||||||
|
class UpdateWatchCategoriesAction < ActiveRecord::Migration[6.0]
|
||||||
|
def change
|
||||||
|
watch_category_wizards = PluginStoreRow.where("
|
||||||
|
plugin_name = 'custom_wizard' AND
|
||||||
|
value::jsonb -> 'actions' @> '[{ \"type\" : \"watch_categories\" }]'::jsonb
|
||||||
|
")
|
||||||
|
|
||||||
|
if watch_category_wizards.exists?
|
||||||
|
watch_category_wizards.each do |row|
|
||||||
|
begin
|
||||||
|
wizard_json = JSON.parse(row.value)
|
||||||
|
rescue TypeError, JSON::ParserError
|
||||||
|
next
|
||||||
|
end
|
||||||
|
|
||||||
|
wizard_json['actions'].each do |a|
|
||||||
|
if a['type'] === "watch_categories" && a['wizard_user'] == nil
|
||||||
|
a['wizard_user'] = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
row.value = wizard_json.to_json
|
||||||
|
row.save
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -2,12 +2,14 @@ class CustomWizard::Action
|
||||||
attr_accessor :data,
|
attr_accessor :data,
|
||||||
:action,
|
:action,
|
||||||
:user,
|
:user,
|
||||||
|
:guardian,
|
||||||
:result
|
:result
|
||||||
|
|
||||||
def initialize(params)
|
def initialize(params)
|
||||||
@wizard = params[:wizard]
|
@wizard = params[:wizard]
|
||||||
@action = params[:action]
|
@action = params[:action]
|
||||||
@user = params[:user]
|
@user = params[:user]
|
||||||
|
@guardian = Guardian.new(@user)
|
||||||
@data = params[:data]
|
@data = params[:data]
|
||||||
@log = []
|
@log = []
|
||||||
@result = CustomWizard::ActionResult.new
|
@result = CustomWizard::ActionResult.new
|
||||||
|
@ -22,6 +24,10 @@ class CustomWizard::Action
|
||||||
@result.handler.enqueue_jobs
|
@result.handler.enqueue_jobs
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if @result.success? && @result.output.present?
|
||||||
|
data[action['id']] = @result.output
|
||||||
|
end
|
||||||
|
|
||||||
save_log
|
save_log
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -30,12 +36,9 @@ class CustomWizard::Action
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_topic
|
def create_topic
|
||||||
params = basic_topic_params
|
params = basic_topic_params.merge(public_topic_params)
|
||||||
|
|
||||||
if params[:title].present? && params[:raw].present?
|
if params[:title].present? && params[:raw].present?
|
||||||
params[:category] = action_category
|
|
||||||
params[:tags] = action_tags
|
|
||||||
|
|
||||||
creator = PostCreator.new(user, params)
|
creator = PostCreator.new(user, params)
|
||||||
post = creator.create
|
post = creator.create
|
||||||
|
|
||||||
|
@ -49,6 +52,7 @@ class CustomWizard::Action
|
||||||
if creator.errors.blank?
|
if creator.errors.blank?
|
||||||
log_success("created topic", "id: #{post.topic.id}")
|
log_success("created topic", "id: #{post.topic.id}")
|
||||||
result.handler = creator
|
result.handler = creator
|
||||||
|
result.output = post.topic.id
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
log_error("invalid topic params", "title: #{params[:title]}; post: #{params[:raw]}")
|
log_error("invalid topic params", "title: #{params[:title]}; post: #{params[:raw]}")
|
||||||
|
@ -87,6 +91,7 @@ class CustomWizard::Action
|
||||||
if creator.errors.blank?
|
if creator.errors.blank?
|
||||||
log_success("created message", "id: #{post.topic.id}")
|
log_success("created message", "id: #{post.topic.id}")
|
||||||
result.handler = creator
|
result.handler = creator
|
||||||
|
result.output = post.topic.id
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
log_error(
|
log_error(
|
||||||
|
@ -135,17 +140,18 @@ class CustomWizard::Action
|
||||||
end
|
end
|
||||||
|
|
||||||
def watch_categories
|
def watch_categories
|
||||||
|
|
||||||
watched_categories = CustomWizard::Mapper.new(
|
watched_categories = CustomWizard::Mapper.new(
|
||||||
inputs: action['categories'],
|
inputs: action['categories'],
|
||||||
data: data,
|
data: data,
|
||||||
user: user
|
user: user
|
||||||
).perform
|
).perform
|
||||||
|
|
||||||
|
watched_categories = [*watched_categories].map(&:to_i)
|
||||||
|
|
||||||
notification_level = action['notification_level']
|
notification_level = action['notification_level']
|
||||||
|
|
||||||
if notification_level.blank?
|
if notification_level.blank?
|
||||||
log_error("Notifcation Level was not set! Exiting wizard action")
|
log_error("Notifcation Level was not set. Exiting wizard action")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -154,12 +160,52 @@ class CustomWizard::Action
|
||||||
data: data,
|
data: data,
|
||||||
user: user
|
user: user
|
||||||
).perform
|
).perform
|
||||||
|
|
||||||
|
users = []
|
||||||
|
|
||||||
|
if action['usernames']
|
||||||
|
mapped_users = CustomWizard::Mapper.new(
|
||||||
|
inputs: action['usernames'],
|
||||||
|
data: data,
|
||||||
|
user: user
|
||||||
|
).perform
|
||||||
|
|
||||||
|
if mapped_users.present?
|
||||||
|
mapped_users = mapped_users.split(',')
|
||||||
|
.map { |username| User.find_by(username: username) }
|
||||||
|
users.push(*mapped_users)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if ActiveRecord::Type::Boolean.new.cast(action['wizard_user'])
|
||||||
|
users.push(user)
|
||||||
|
end
|
||||||
|
|
||||||
Category.all.each do |category|
|
category_ids = Category.all.pluck(:id)
|
||||||
if watched_categories.present? && watched_categories.include?(category.id.to_s)
|
set_level = CategoryUser.notification_levels[notification_level.to_sym]
|
||||||
CategoryUser.set_notification_level_for_category(user, CategoryUser.notification_levels[notification_level.to_sym], category.id)
|
mute_level = CategoryUser.notification_levels[:muted]
|
||||||
elsif mute_remainder
|
|
||||||
CategoryUser.set_notification_level_for_category(user, CategoryUser.notification_levels[:muted], category.id)
|
users.each do |user|
|
||||||
|
category_ids.each do |category_id|
|
||||||
|
new_level = nil
|
||||||
|
|
||||||
|
if watched_categories.include?(category_id) && set_level != nil
|
||||||
|
new_level = set_level
|
||||||
|
elsif mute_remainder
|
||||||
|
new_level = mute_level
|
||||||
|
end
|
||||||
|
|
||||||
|
if new_level
|
||||||
|
CategoryUser.set_notification_level_for_category(user, new_level, category_id)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if watched_categories.any?
|
||||||
|
log_success("#{user.username} notifications for #{watched_categories} set to #{set_level}")
|
||||||
|
end
|
||||||
|
|
||||||
|
if mute_remainder
|
||||||
|
log_success("#{user.username} notifications for all other categories muted")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -274,6 +320,44 @@ class CustomWizard::Action
|
||||||
log_info("route: #{route_to}")
|
log_info("route: #{route_to}")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def create_group
|
||||||
|
guardian.ensure_can_create!(Group)
|
||||||
|
|
||||||
|
group =
|
||||||
|
begin
|
||||||
|
Group.new(new_group_params)
|
||||||
|
rescue ArgumentError => e
|
||||||
|
raise Discourse::InvalidParameters, "Invalid group params"
|
||||||
|
end
|
||||||
|
|
||||||
|
if group.save
|
||||||
|
GroupActionLogger.new(user, group).log_change_group_settings
|
||||||
|
log_success("Group created", group.name)
|
||||||
|
result.output = group.name
|
||||||
|
else
|
||||||
|
log_error("Group creation failed")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def create_category
|
||||||
|
guardian.ensure_can_create!(Category)
|
||||||
|
|
||||||
|
category =
|
||||||
|
begin
|
||||||
|
Category.new(new_category_params.merge(user: user))
|
||||||
|
rescue ArgumentError => e
|
||||||
|
raise Discourse::InvalidParameters, "Invalid category params"
|
||||||
|
end
|
||||||
|
|
||||||
|
if category.save
|
||||||
|
StaffActionLogger.new(user).log_category_creation(category)
|
||||||
|
log_success("Category created", category.name)
|
||||||
|
result.output = category.id
|
||||||
|
else
|
||||||
|
log_error("Category creation failed")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def action_category
|
def action_category
|
||||||
|
@ -350,10 +434,131 @@ class CustomWizard::Action
|
||||||
add_custom_fields(params)
|
add_custom_fields(params)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def public_topic_params
|
||||||
|
params = {}
|
||||||
|
|
||||||
|
if (category = action_category)
|
||||||
|
params[:category] = category
|
||||||
|
end
|
||||||
|
|
||||||
|
if (tags = action_tags)
|
||||||
|
params[:tags] = tags
|
||||||
|
end
|
||||||
|
|
||||||
|
if public_topic_fields.any?
|
||||||
|
public_topic_fields.each do |field|
|
||||||
|
unless action[field].nil? || action[field] == ""
|
||||||
|
params[field.to_sym] = CustomWizard::Mapper.new(
|
||||||
|
inputs: action[field],
|
||||||
|
data: data,
|
||||||
|
user: user
|
||||||
|
).perform
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
params
|
||||||
|
end
|
||||||
|
|
||||||
|
def new_group_params
|
||||||
|
params = {}
|
||||||
|
|
||||||
|
%w(
|
||||||
|
name
|
||||||
|
full_name
|
||||||
|
title
|
||||||
|
bio_raw
|
||||||
|
owner_usernames
|
||||||
|
usernames
|
||||||
|
mentionable_level
|
||||||
|
messageable_level
|
||||||
|
visibility_level
|
||||||
|
members_visibility_level
|
||||||
|
grant_trust_level
|
||||||
|
).each do |attr|
|
||||||
|
input = action[attr]
|
||||||
|
|
||||||
|
if attr === "name" && input.blank?
|
||||||
|
raise ArgumentError.new
|
||||||
|
end
|
||||||
|
|
||||||
|
if attr === "full_name" && input.blank?
|
||||||
|
input = action["name"]
|
||||||
|
end
|
||||||
|
|
||||||
|
if input.present?
|
||||||
|
value = CustomWizard::Mapper.new(
|
||||||
|
inputs: input,
|
||||||
|
data: data,
|
||||||
|
user: user
|
||||||
|
).perform
|
||||||
|
|
||||||
|
value = value.parameterize(separator: '_') if attr === "name"
|
||||||
|
value = value.to_i if attr.include?("_level")
|
||||||
|
|
||||||
|
params[attr.to_sym] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
add_custom_fields(params)
|
||||||
|
end
|
||||||
|
|
||||||
|
def new_category_params
|
||||||
|
params = {}
|
||||||
|
|
||||||
|
%w(
|
||||||
|
name
|
||||||
|
slug
|
||||||
|
color
|
||||||
|
text_color
|
||||||
|
parent_category_id
|
||||||
|
permissions
|
||||||
|
).each do |attr|
|
||||||
|
if action[attr].present?
|
||||||
|
value = CustomWizard::Mapper.new(
|
||||||
|
inputs: action[attr],
|
||||||
|
data: data,
|
||||||
|
user: user
|
||||||
|
).perform
|
||||||
|
|
||||||
|
if attr === "parent_category_id" && value.is_a?(Array)
|
||||||
|
value = value[0]
|
||||||
|
end
|
||||||
|
|
||||||
|
if attr === "permissions" && value.is_a?(Array)
|
||||||
|
permissions = value
|
||||||
|
value = {}
|
||||||
|
|
||||||
|
permissions.each do |p|
|
||||||
|
k = p[:key]
|
||||||
|
v = p[:value].to_i
|
||||||
|
|
||||||
|
if k.is_a?(Array)
|
||||||
|
group = Group.find_by(id: k[0])
|
||||||
|
k = group.name
|
||||||
|
else
|
||||||
|
k = k.parameterize(separator: '_')
|
||||||
|
end
|
||||||
|
|
||||||
|
value[k] = v
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
params[attr.to_sym] = value
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
add_custom_fields(params)
|
||||||
|
end
|
||||||
|
|
||||||
def creates_post?
|
def creates_post?
|
||||||
[:create_topic, :send_message].include?(action['type'].to_sym)
|
[:create_topic, :send_message].include?(action['type'].to_sym)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def public_topic_fields
|
||||||
|
['visible']
|
||||||
|
end
|
||||||
|
|
||||||
def profile_url_fields
|
def profile_url_fields
|
||||||
['profile_background', 'card_background']
|
['profile_background', 'card_background']
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
class CustomWizard::ActionResult
|
class CustomWizard::ActionResult
|
||||||
attr_accessor :success, :handler
|
attr_accessor :success, :handler, :output
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@success = false
|
@success = false
|
||||||
|
|
|
@ -2,10 +2,12 @@ class CustomWizard::Field
|
||||||
def self.types
|
def self.types
|
||||||
@types ||= {
|
@types ||= {
|
||||||
text: {
|
text: {
|
||||||
min_length: nil
|
min_length: nil,
|
||||||
|
prefill: nil
|
||||||
},
|
},
|
||||||
textarea: {
|
textarea: {
|
||||||
min_length: nil
|
min_length: nil,
|
||||||
|
prefill: nil
|
||||||
},
|
},
|
||||||
composer: {
|
composer: {
|
||||||
min_length: nil
|
min_length: nil
|
||||||
|
|
|
@ -187,6 +187,10 @@ class CustomWizard::Mapper
|
||||||
def map_wizard_field(value)
|
def map_wizard_field(value)
|
||||||
data && !data.key?("submitted_at") && data[value]
|
data && !data.key?("submitted_at") && data[value]
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def map_wizard_action(value)
|
||||||
|
data && !data.key?("submitted_at") && data[value]
|
||||||
|
end
|
||||||
|
|
||||||
def map_user_field(value)
|
def map_user_field(value)
|
||||||
if value.include?(User::USER_FIELD_PREFIX)
|
if value.include?(User::USER_FIELD_PREFIX)
|
||||||
|
|
Laden …
In neuem Issue referenzieren