diff --git a/assets/javascripts/discourse/components/wizard-custom-field.js.es6 b/assets/javascripts/discourse/components/wizard-custom-field.js.es6 index 7496336a..767258fd 100644 --- a/assets/javascripts/discourse/components/wizard-custom-field.js.es6 +++ b/assets/javascripts/discourse/components/wizard-custom-field.js.es6 @@ -62,7 +62,8 @@ export default Component.extend({ if (this.isDropdown) { options.wizardFieldSelection = 'key,value'; - options.inputTypes = 'association'; + options.userFieldOptionsSelection = 'output'; + options.inputTypes = 'association,assignment'; options.pairConnector = 'association'; options.keyPlaceholder = 'admin.wizard.key'; options.valuePlaceholder = 'admin.wizard.value'; diff --git a/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 b/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 index 4b1daad1..34f6a819 100644 --- a/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 +++ b/assets/javascripts/discourse/components/wizard-mapper-selector.js.es6 @@ -2,33 +2,37 @@ import { alias, or, gt } from "@ember/object/computed"; import { computed } from "@ember/object"; import { default as discourseComputed, observes, on } from "discourse-common/utils/decorators"; import { getOwner } from 'discourse-common/lib/get-owner'; -import { defaultSelectionType, selectionTypes } from '../lib/wizard-mapper'; -import { snakeCase } from '../lib/wizard'; +import { defaultSelectionType, selectionTypes } from '../lib/wizard-mapper'; +import { snakeCase, generateName, userProperties } from '../lib/wizard'; import Component from "@ember/component"; import { bind, later } from "@ember/runloop"; export default Component.extend({ classNameBindings: [':mapper-selector', 'activeType'], - groups: alias('site.groups'), - categories: alias('site.categories'), + showText: computed('activeType', function() { return this.showInput('text') }), showWizardField: computed('activeType', function() { return this.showInput('wizardField') }), showUserField: computed('activeType', function() { return this.showInput('userField') }), + showUserFieldOptions: computed('activeType', function() { return this.showInput('userFieldOptions') }), showCategory: computed('activeType', function() { return this.showInput('category') }), showTag: computed('activeType', function() { return this.showInput('tag') }), showGroup: computed('activeType', function() { return this.showInput('group') }), showUser: computed('activeType', function() { return this.showInput('user') }), showList: computed('activeType', function() { return this.showInput('list') }), - showComboBox: or('showWizardField', 'showUserField'), - showMultiSelect: or('showCategory', 'showGroup'), textEnabled: computed('options.textSelection', 'inputType', function() { return this.optionEnabled('textSelection') }), wizardFieldEnabled: computed('options.wizardFieldSelection', 'inputType', function() { return this.optionEnabled('wizardFieldSelection') }), userFieldEnabled: computed('options.userFieldSelection', 'inputType', function() { return this.optionEnabled('userFieldSelection') }), + userFieldOptionsEnabled: computed('options.userFieldOptionsSelection', 'inputType', function() { return this.optionEnabled('userFieldOptionsSelection') }), categoryEnabled: computed('options.categorySelection', 'inputType', function() { return this.optionEnabled('categorySelection') }), tagEnabled: computed('options.tagSelection', 'inputType', function() { return this.optionEnabled('tagSelection') }), groupEnabled: computed('options.groupSelection', 'inputType', function() { return this.optionEnabled('groupSelection') }), userEnabled: computed('options.userSelection', 'inputType', function() { return this.optionEnabled('userSelection') }), listEnabled: computed('options.listSelection', 'inputType', function() { return this.optionEnabled('listSelection') }), + + groups: alias('site.groups'), + categories: alias('site.categories'), + showComboBox: or('showWizardField', 'showUserField', 'showUserFieldOptions'), + showMultiSelect: or('showCategory', 'showGroup'), hasTypes: gt('selectorTypes.length', 1), showTypes: false, @@ -81,21 +85,35 @@ export default Component.extend({ @discourseComputed('activeType') comboBoxContent(activeType) { const controller = getOwner(this).lookup('controller:admin-wizards-wizard-show'); - let content = controller[`${activeType}s`]; - - // you can't select the current field in the field context - if (activeType === 'wizardField' && this.options.context === 'field') { - content = content.filter(field => field.id !== controller.currentField.id); + const wizardFields = controller.wizardFields; + const userFields = controller.userFields; + let content; + + if (activeType === 'wizardField') { + content = wizardFields; + + if (this.options.context === 'field') { + content = content.filter(field => field.id !== controller.currentField.id); + } } - // updating certain user fields via the profile update action is not supported - if (activeType === 'userField' && - this.options.context === 'action' && - this.inputType === 'association' && - this.selectorType === 'key') { + if (activeType ===' userField') { + content = userProperties.map((f) => ({ + id: f, + name: generateName(f) + })).concat((userFields || [])); - const excludedFields = ['username','email', 'trust_level']; - content = content.filter(userField => excludedFields.indexOf(userField.id) === -1); + if (this.options.context === 'action' && + this.inputType === 'association' && + this.selectorType === 'key') { + + const excludedFields = ['username','email', 'trust_level']; + content = content.filter(userField => excludedFields.indexOf(userField.id) === -1); + } + } + + if (activeType === 'userFieldOptions') { + content = userFields; } return content; @@ -139,7 +157,7 @@ export default Component.extend({ const option = options[type]; if (option === true) return true; if (typeof option !== 'string') return false; - + return option.split(',').filter(option => { return [this.selectorType, this.inputType].indexOf(option) !== -1; }).length; diff --git a/assets/javascripts/discourse/components/wizard-text-editor.js.es6 b/assets/javascripts/discourse/components/wizard-text-editor.js.es6 index 4cbb7efb..2b54b56c 100644 --- a/assets/javascripts/discourse/components/wizard-text-editor.js.es6 +++ b/assets/javascripts/discourse/components/wizard-text-editor.js.es6 @@ -36,7 +36,7 @@ export default Component.extend({ }, @discourseComputed() - userFieldList() { + userPropertyList() { return userProperties.map((f) => ` u{${f}}`); }, diff --git a/assets/javascripts/discourse/lib/wizard-mapper.js.es6 b/assets/javascripts/discourse/lib/wizard-mapper.js.es6 index 514619a4..ceafa5f1 100644 --- a/assets/javascripts/discourse/lib/wizard-mapper.js.es6 +++ b/assets/javascripts/discourse/lib/wizard-mapper.js.es6 @@ -79,6 +79,7 @@ const selectionTypes = [ 'list', 'wizardField', 'userField', + 'userFieldOptions', 'group', 'category', 'tag', diff --git a/assets/javascripts/discourse/routes/admin-wizards-wizard.js.es6 b/assets/javascripts/discourse/routes/admin-wizards-wizard.js.es6 index 5f2ba5af..0ba204f3 100644 --- a/assets/javascripts/discourse/routes/admin-wizards-wizard.js.es6 +++ b/assets/javascripts/discourse/routes/admin-wizards-wizard.js.es6 @@ -1,5 +1,4 @@ import DiscourseRoute from "discourse/routes/discourse"; -import { userProperties, generateName } from '../lib/wizard'; import { buildFieldTypes } from '../lib/wizard-schema'; import { set } from "@ember/object"; import { all } from "rsvp"; @@ -44,12 +43,7 @@ export default DiscourseRoute.extend({ result.content.map((f) => ({ id: `user_field_${f.id}`, name: f.name - })).concat( - userProperties.map((f) => ({ - id: f, - name: generateName(f) - })) - ) + })) ); } }); diff --git a/assets/javascripts/discourse/templates/components/wizard-text-editor.hbs b/assets/javascripts/discourse/templates/components/wizard-text-editor.hbs index 5638ac70..f9f6cc9b 100644 --- a/assets/javascripts/discourse/templates/components/wizard-text-editor.hbs +++ b/assets/javascripts/discourse/templates/components/wizard-text-editor.hbs @@ -18,8 +18,8 @@ {{#if showPopover}}