(function(){"use strict";u8.Crm.Widgets.LyrisCrmFieldListBox=function(e,i){i=$.extend({},u8.Crm.Widgets.LyrisCrmFieldListBox.defaults,i);this.FieldListBox(e,i)};u8.Crm.Widgets.LyrisCrmFieldListBox.defaults={selectionMode:null};u8.Crm.Widgets.LyrisCrmFieldListBox.makeClass({name:"LyrisCrmFieldListBox",deriveFrom:u8.Crm.Widgets.FieldListBox,events:["ValueChange"]});$.extend(u8.Crm.Widgets.LyrisCrmFieldListBox.prototype,{dispose:function(){if(this._isDisposed){return}this.Widget_dispose()},_createColumnsModel:function(){var e=[{dataKey:"fieldSelectionInfo",width:"30",showSort:false,cellRenderer:this._lyrisCrmFieldSelectionRenderer.bind(this)},{dataKey:"id",label:this.texts.columnId,width:"40",visible:this.showIds},{dataKey:"label",label:this.texts.columnName,width:"100%"},{dataKey:"dataType",label:this.texts.columnType,width:"120",visible:this.showTypes}];return this._columns=e},setCandidateCrmFields:function(e){this.model=e;if(!u8.session.environment.isEnterpriseVersion||this._isCreated){this.update({reason:"infoAreaId"})}},_lyrisCrmFieldSelectionRenderer:function(e,i){var t=this;if(!u8.session.environment.isEnterpriseVersion){$$(i.elCell).dispose()}var s=i.elCell;var l=i.cellData;if(!l){return}var d=function(e,i){t._onSelectionChange(i,l.fieldSchema)};var n=null;if(u8.session.environment.isEnterpriseVersion&&(s.children.length!=0&&(n=this.children.get(s.id))!=null)){if(n.fieldSchema.fieldId!=l.fieldSchema.fieldId||n.fieldSchema.infoAreaId!=l.fieldSchema.infoAreaId){n.onValueChange.dispose();n.onValueChange.bind(d);n._highlighted=false;n._updateImage();n.fieldSchema=l.fieldSchema}n.setValue(l.selected)}else{var r=u8.widget("CheckBox",s,{parent:t,value:l.selected?"true":"false",trueValue:"true",falseValue:"false",onValueChange:d});r.fieldSchema=l.fieldSchema}},_onSelectionChange:function(e,i){var t=this.model;t.forEach(function(t){if(t.fieldId==i.fieldId&&t.infoAreaId==i.infoAreaId){t.selected=e.value=="true";return false}})},getFields:function(e){var i=this.model;var t={};i.forEach(function(i){if(i.infoAreaId!=e){return}t[i.fieldId]=u8.services.schema.getField(i.infoAreaId,i.fieldId)});return t},getFieldSelectionInfo:function(e){var i=this.model;var t=false;i.forEach(function(i){if(!i.selected){return true}if(i.fieldId==e.fieldId&&i.infoAreaId==e.infoAreaId){t=i.selected;return false}});return{fieldSchema:e,selected:t}}})})();