0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-10 04:12:53 +01:00
discourse-custom-wizard/assets/javascripts/discourse/components/wizard-custom-action.js.es6

78 Zeilen
2,3 KiB
Text

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'),
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;
},
2020-03-21 18:30:11 +01:00
@computed('wizardFields')
categoryFields(fields) {
return fields.filter(f => f.type == 'category');
},
2020-03-21 18:30:11 +01:00
@computed('wizardFields')
tagFields(fields) {
return fields.filter(f => f.type == 'tag');
},
2017-11-24 05:32:15 +01:00
@observes('action.custom_category_wizard_field')
toggleCustomCategoryUserField() {
const wizard = this.get('action.custom_category_wizard_field');
if (wizard) this.set('action.custom_category_user_field', false);
},
@observes('action.custom_category_user_field')
toggleCustomCategoryWizardField() {
const user = this.get('action.custom_category_user_field');
if (user) 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
});