0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2025-02-02 19:37:01 +01:00
discourse-custom-wizard/assets/javascripts/discourse/components/wizard-custom-action.js.es6

78 Zeilen
2,3 KiB
Text

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