1
0
Fork 0
discourse-custom-wizard-unl.../assets/javascripts/discourse/components/wizard-custom-action.js.es6

59 Zeilen
1,5 KiB
Text

2017-10-17 21:17:53 +08:00
import { default as computed } from 'ember-addons/ember-computed-decorators';
2017-10-17 15:18:53 +08:00
2017-10-22 11:37:58 +08:00
const ACTION_TYPES = [
2017-10-30 14:24:51 +08:00
{ id: 'create_topic', name: 'Create Topic' },
{ id: 'update_profile', name: 'Update Profile' },
{ id: 'send_message', name: 'Send Message' }
2017-10-22 11:37:58 +08:00
];
2017-10-17 15:18:53 +08:00
const PROFILE_FIELDS = [
'name',
'email',
'username',
'title',
'date_of_birth',
'muted_usernames',
'theme_key',
'locale',
'bio_raw',
'location',
'website',
'profile_background',
'card_background'
];
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',
2017-10-22 11:37:58 +08:00
types: ACTION_TYPES,
2017-10-17 15:18:53 +08:00
profileFields: PROFILE_FIELDS,
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'),
2017-10-17 21:17:53 +08:00
disableId: Ember.computed.not('action.isNew'),
2017-10-17 15:18:53 +08:00
2017-10-30 14:24:51 +08:00
@computed('currentStepId', 'wizard.save_submissions')
availableFields(currentStepId, saveSubmissions) {
const allSteps = this.get('wizard.steps');
let steps = allSteps;
2017-10-17 15:18:53 +08:00
let fields = [];
2017-10-30 14:24:51 +08:00
if (!saveSubmissions) {
steps = [allSteps.findBy('id', currentStepId)];
}
2017-10-17 15:18:53 +08:00
steps.forEach((s) => {
2017-10-30 14:24:51 +08:00
if (s.fields && s.fields.length > 0) {
let stepFields = s.fields.map((f) => {
return Ember.Object.create({
id: f.id,
label: `${f.id} (${s.id})`
});
2017-10-17 21:17:53 +08:00
});
2017-10-30 14:24:51 +08:00
fields.push(...stepFields);
}
2017-10-17 15:18:53 +08:00
});
2017-10-30 14:24:51 +08:00
2017-10-17 15:18:53 +08:00
return fields;
2017-10-13 21:02:34 +08:00
}
2017-09-23 10:34:07 +08:00
});