(function(){"use strict";u8.Crm.Widgets.ConfigurationPickerComboBox=function(o,e){this.Widget(o,$.extend({},u8.Crm.Widgets.ConfigurationPickerComboBox.defaults,e));this._create()};u8.Crm.Widgets.ConfigurationPickerComboBox.defaults={};$.extend(u8.Crm.Widgets.ConfigurationPickerComboBox.prototype,{_create:function(){u8.services.configuration.getConfigurationsByApplicationType(this.applicationType,this._populateComboBoxItems.bind(this))},setValue:function(o){this.value=o;if(this._comboBox){this._comboBox.setValue(o)}},getValue:function(){if(!this._comboBox){return this.value}return this._comboBox.getValue()},dispose:function(){if(this._isDisposed){return}if(this._comboBox){this._comboBox=null}this.Widget_dispose()},_onComboBoxValueChanged:function(o,e){var i=e[o.keyProperty];this.setValue(i);this.raise("ValueChange",e)},_populateComboBoxItems:function(o){var e=[];var i=this.getValue();if(this.allowNull){e.push({key:"",text:""})}o.forEach(function(o){e.push({key:o.id,text:o.name})});var t=0;var s=this.allowNull?1:0;if(i){o.forEach(function(o){if(o.id===i){t=s}s++})}else{t=this.allowNull?0:-1}var n=this.$("<div/>").appendTo(this.element)[0];this._comboBox=u8.widget("ComboBox",n,{items:e,selectedIndex:t,parent:this,onDropDownSelectionChange:this._onComboBoxValueChanged.bind(this)});this._isCreated=true}});u8.Crm.Widgets.ConfigurationPickerComboBox.makeClass({name:"ConfigurationPickerComboBox",deriveFrom:u8.Base.Widgets.Widget,events:["ValueChange"]})})();