2020-03-21 18:30:11 +01:00
|
|
|
import { default as computed, observes, on } from 'discourse-common/utils/decorators';
|
2020-02-02 11:42:05 +01:00
|
|
|
import { generateSelectKitContent } from '../lib/custom-wizard';
|
2017-09-23 04:34:07 +02:00
|
|
|
|
|
|
|
export default Ember.Component.extend({
|
|
|
|
classNames: 'wizard-custom-field',
|
|
|
|
isDropdown: Ember.computed.equal('field.type', 'dropdown'),
|
2019-07-19 05:47:17 +02:00
|
|
|
isUpload: Ember.computed.equal('field.type', 'upload'),
|
2019-07-26 11:12:58 +02:00
|
|
|
isCategory: Ember.computed.equal('field.type', 'category'),
|
2017-10-17 15:17:53 +02:00
|
|
|
disableId: Ember.computed.not('field.isNew'),
|
2020-03-19 08:58:45 +01:00
|
|
|
choicesTypes: generateSelectKitContent(['translation', 'custom']),
|
2017-11-08 09:52:50 +01:00
|
|
|
choicesTranslation: Ember.computed.equal('field.choices_type', 'translation'),
|
|
|
|
choicesCustom: Ember.computed.equal('field.choices_type', 'custom'),
|
2020-02-02 11:42:05 +01:00
|
|
|
categoryPropertyTypes: generateSelectKitContent(['id', 'slug']),
|
2017-09-23 04:34:07 +02:00
|
|
|
|
2017-10-13 15:02:34 +02:00
|
|
|
@computed('field.type')
|
|
|
|
isInput: (type) => type === 'text' || type === 'textarea',
|
|
|
|
|
2019-07-26 10:59:21 +02:00
|
|
|
@computed('field.type')
|
|
|
|
isCategoryOrTag: (type) => type === 'tag' || type === 'category',
|
|
|
|
|
2019-07-19 05:47:17 +02:00
|
|
|
@on('didInsertElement')
|
|
|
|
@observes('isUpload')
|
|
|
|
setupFileType() {
|
|
|
|
if (this.get('isUpload') && !this.get('field.file_types')) {
|
|
|
|
this.set('field.file_types', '.jpg,.png');
|
|
|
|
}
|
|
|
|
}
|
2017-09-23 04:34:07 +02:00
|
|
|
});
|