0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-27 03:20:27 +01:00
discourse-custom-wizard/assets/javascripts/discourse/components/wizard-custom-input.js.es6

34 Zeilen
1.012 B
Text

2018-06-29 08:07:34 +02:00
import { default as computed, on } from 'ember-addons/ember-computed-decorators';
2018-05-24 07:34:58 +02:00
import { getOwner } from 'discourse-common/lib/get-owner';
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',
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
2018-06-29 08:07:34 +02:00
};
2018-05-24 07:34:58 +02:00
}));
}
});
2017-10-17 15:17:53 +02:00
}
}
});