Guest User

Untitled

a guest
Apr 26th, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. import Ember from 'ember';
  2.  
  3. const {
  4. Component,
  5. computed
  6. } = Ember;
  7.  
  8. export default Component.extend({
  9. classNameBindings: ['isActive', ':pill-meta'],
  10.  
  11. isActive: false,
  12. options: [
  13. { displayName: "A", flags: -2147482621, format: "Text", formattedName: "a(A)", metaName: "a" },
  14. { displayName: "B", flags: -2147482621, format: "Text", formattedName: "b(B)", metaName: "a" },
  15. { displayName: "C", flags: -2147482621, format: "Text", formattedName: "c(C)", metaName: "a" },
  16. { displayName: "D", flags: -2147482621, format: "Text", formattedName: "d(D)", metaName: "a" },
  17. ],
  18. selection: null,
  19. sendMessage: () => {},
  20.  
  21. actions: {
  22. onChange(selection /* powerSelectAPI, event */) {
  23. this._broadcast('META_SELECTED', selection);
  24. },
  25. onFocus(powerSelectAPI /* event */) {
  26. if (powerSelectAPI.lastSearchedText) {
  27. powerSelectAPI.actions.search('');
  28. }
  29. powerSelectAPI.actions.open();
  30. }
  31. },
  32.  
  33. _broadcast(type, data) {
  34. this.get('sendMessage')(type, data);
  35. },
  36.  
  37. _isActive: computed('isActive', 'options', function() {
  38. const isActive = this.get('isActive');
  39. const options = this.get('options');
  40. return isActive && options.length > 0;
  41. }),
  42.  
  43. _matcher: (m, input) => {
  44. const _input = input.toLowerCase();
  45. const _metaName = m.metaName.toLowerCase();
  46. const _displayName = m.displayName.toLowerCase();
  47. return _metaName.indexOf(_input) & _displayName.indexOf(_input);
  48. }
  49. });
Add Comment
Please, Sign In to add comment