wizard-custom-input.js.es6 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. import { default as computed, on } from 'ember-addons/ember-computed-decorators';
  2. import { getOwner } from 'discourse-common/lib/get-owner';
  3. export default Ember.Component.extend({
  4. classNames: 'custom-input',
  5. noneKey: 'admin.wizard.select_field',
  6. noneValue: 'admin.wizard.none',
  7. inputKey: 'admin.wizard.key',
  8. inputValue: 'admin.wizard.value',
  9. customDisabled: Ember.computed.alias('input.user_field'),
  10. @computed('input.value_custom', 'input.user_field')
  11. valueDisabled(custom, user) {
  12. return Boolean(custom || user);
  13. },
  14. @on('init')
  15. setupUserFields() {
  16. const allowUserField = this.get('allowUserField');
  17. if (allowUserField) {
  18. const store = getOwner(this).lookup('store:main');
  19. store.findAll('user-field').then((result) => {
  20. if (result && result.content && result.content.length) {
  21. this.set('userFields', result.content.map((f) => {
  22. return {
  23. id: `user_field_${f.id}`,
  24. name: f.name
  25. };
  26. }));
  27. }
  28. });
  29. }
  30. }
  31. });