2020-03-21 18:30:11 +01:00
|
|
|
import {
|
|
|
|
default as computed,
|
|
|
|
observes
|
|
|
|
} from 'discourse-common/utils/decorators';
|
|
|
|
import {
|
|
|
|
actionTypes,
|
|
|
|
generateName,
|
2020-03-29 09:49:33 +02:00
|
|
|
generateSelectKitContent,
|
|
|
|
profileFields
|
2020-03-21 18:30:11 +01:00
|
|
|
} from '../lib/custom-wizard';
|
2017-10-13 15:02:34 +02:00
|
|
|
|
2017-09-23 04:34:07 +02:00
|
|
|
export default Ember.Component.extend({
|
2017-10-06 04:59:02 +02:00
|
|
|
classNames: 'wizard-custom-action',
|
2020-03-21 18:30:11 +01:00
|
|
|
types: actionTypes.map(t => ({ id: t, name: generateName(t) })),
|
2017-10-05 02:36:46 +02:00
|
|
|
createTopic: Ember.computed.equal('action.type', 'create_topic'),
|
|
|
|
updateProfile: Ember.computed.equal('action.type', 'update_profile'),
|
2017-10-13 15:02:34 +02:00
|
|
|
sendMessage: Ember.computed.equal('action.type', 'send_message'),
|
2019-06-03 09:09:24 +02:00
|
|
|
sendToApi: Ember.computed.equal('action.type', 'send_to_api'),
|
|
|
|
apiEmpty: Ember.computed.empty('action.api'),
|
2019-07-01 04:31:50 +02:00
|
|
|
addToGroup: Ember.computed.equal('action.type', 'add_to_group'),
|
2019-07-02 06:49:14 +02:00
|
|
|
routeTo: Ember.computed.equal('action.type', 'route_to'),
|
2017-10-17 15:17:53 +02:00
|
|
|
disableId: Ember.computed.not('action.isNew'),
|
2020-03-21 18:30:11 +01:00
|
|
|
groupPropertyTypes: generateSelectKitContent(['id', 'name']),
|
2017-10-17 09:18:53 +02:00
|
|
|
|
2019-08-27 08:05:24 +02:00
|
|
|
@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;
|
|
|
|
},
|
2019-10-15 07:08:49 +02:00
|
|
|
|
2020-03-21 18:30:11 +01:00
|
|
|
@computed('wizardFields')
|
2019-10-15 07:08:49 +02:00
|
|
|
categoryFields(fields) {
|
|
|
|
return fields.filter(f => f.type == 'category');
|
|
|
|
},
|
2019-10-15 07:34:43 +02:00
|
|
|
|
2020-03-21 18:30:11 +01:00
|
|
|
@computed('wizardFields')
|
2019-10-15 07:34:43 +02:00
|
|
|
tagFields(fields) {
|
|
|
|
return fields.filter(f => f.type == 'tag');
|
|
|
|
},
|
2017-11-24 05:32:15 +01:00
|
|
|
|
2017-11-30 03:55:15 +01:00
|
|
|
@observes('action.custom_category_wizard_field')
|
|
|
|
toggleCustomCategoryUserField() {
|
2020-04-01 07:03:26 +02:00
|
|
|
if (this.action.custom_category_wizard_field)
|
|
|
|
this.set('action.custom_category_user_field', false);
|
2017-11-30 03:55:15 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
@observes('action.custom_category_user_field')
|
|
|
|
toggleCustomCategoryWizardField() {
|
2020-04-01 07:03:26 +02:00
|
|
|
if (this.action.custom_category_user_field)
|
|
|
|
this.set('action.custom_category_wizard_field', false);
|
2019-06-03 09:09:24 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
@computed('wizard.apis')
|
|
|
|
availableApis(apis) {
|
|
|
|
return apis.map(a => {
|
|
|
|
return {
|
|
|
|
id: a.name,
|
|
|
|
name: a.title
|
|
|
|
};
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
@computed('wizard.apis', 'action.api')
|
|
|
|
availableEndpoints(apis, api) {
|
|
|
|
if (!api) return [];
|
|
|
|
return apis.find(a => a.name === api).endpoints;
|
2017-10-13 15:02:34 +02:00
|
|
|
}
|
2017-09-23 04:34:07 +02:00
|
|
|
});
|