2018-05-24 07:34:58 +02:00
|
|
|
import { default as computed, on, observes } from 'ember-addons/ember-computed-decorators';
|
|
|
|
import { getOwner } from 'discourse-common/lib/get-owner';
|
|
|
|
|
|
|
|
const fieldNotPresent = (f) => { return f == null || f === undefined };
|
|
|
|
|
2017-10-17 15:17:53 +02:00
|
|
|
export default Ember.Component.extend({
|
2018-05-24 07:34:58 +02:00
|
|
|
classNames: 'custom-input',
|
2017-10-30 07:24:51 +01:00
|
|
|
noneKey: 'admin.wizard.select_field',
|
2017-10-17 15:17:53 +02:00
|
|
|
noneValue: 'admin.wizard.none',
|
2017-10-30 07:24:51 +01:00
|
|
|
inputKey: 'admin.wizard.key',
|
|
|
|
inputValue: 'admin.wizard.value',
|
2018-05-24 07:34:58 +02:00
|
|
|
customDisabled: Ember.computed.alias('input.user_field'),
|
2017-10-17 15:17:53 +02:00
|
|
|
|
2018-05-24 07:34:58 +02:00
|
|
|
@computed('input.value_custom', 'input.user_field')
|
|
|
|
valueDisabled(custom, user) {
|
|
|
|
return Boolean(custom || user);
|
|
|
|
},
|
2017-10-17 15:17:53 +02:00
|
|
|
|
2018-05-24 07:34:58 +02:00
|
|
|
@on('init')
|
|
|
|
setupUserFields() {
|
|
|
|
const allowUserField = this.get('allowUserField');
|
|
|
|
if (allowUserField) {
|
|
|
|
const store = getOwner(this).lookup('store:main');
|
|
|
|
store.findAll('user-field').then((result) => {
|
|
|
|
if (result && result.content && result.content.length) {
|
|
|
|
this.set('userFields', result.content.map((f) => {
|
|
|
|
return {
|
|
|
|
id: `user_field_${f.id}`,
|
|
|
|
name: f.name
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
});
|
2017-10-17 15:17:53 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|