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

35 Zeilen
1 KiB
Text

2018-06-29 16:07:34 +10:00
import { default as computed, on } from 'ember-addons/ember-computed-decorators';
2018-05-24 15:34:58 +10:00
import { getOwner } from 'discourse-common/lib/get-owner';
2017-10-17 21:17:53 +08:00
export default Ember.Component.extend({
2018-05-24 15:34:58 +10:00
classNames: 'custom-input',
2017-10-30 14:24:51 +08:00
noneKey: 'admin.wizard.select_field',
2017-10-17 21:17:53 +08:00
noneValue: 'admin.wizard.none',
connectorNone: 'admin.wizard.none',
2017-10-30 14:24:51 +08:00
inputKey: 'admin.wizard.key',
2018-05-24 15:34:58 +10:00
customDisabled: Ember.computed.alias('input.user_field'),
2017-10-17 21:17:53 +08:00
2018-05-24 15:34:58 +10:00
@computed('input.value_custom', 'input.user_field')
valueDisabled(custom, user) {
return Boolean(custom || user);
},
2017-10-17 21:17:53 +08:00
2018-05-24 15:34:58 +10: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 16:07:34 +10:00
};
2018-05-24 15:34:58 +10:00
}));
}
});
2017-10-17 21:17:53 +08:00
}
}
});