UNPKG

wejsv2old-plugin-cdp-profile

Version:
36 lines (29 loc) 995 B
App.inject( 'component:we-term-simple-select', 'store', 'store:main' ); App.WeTermSimpleSelectComponent = Ember.Component.extend({ promptText: 'Select an option', init: function () { // body... var self = this; self._super.apply(self, arguments); if (!self.get('vocabulary')) return console.warn('No vocabulary was passed, the view won`t know which one to load'); self.loadTerms().then(function (terms){ var termsArr = terms.filter(function (t){ return t.get('text') !== 'Outras' }).map(function (term){ return term.get('text'); }); var last = terms.findBy('text', 'Outras'); if (last.get('text')) termsArr.push(last.get('text')); self.set('options', termsArr); }, function (error){ console.error('Error:', error); }); }, loadTerms: function(){ return this.get('store').find('term', { vocabulary: this.get('vocabulary'), limit: 500, sort: 'text DESC' }); } });