(function(){"use strict";u8.Crm.Widgets.LiveTileRecordsProvider=function(e){$.extend(this,u8.Crm.Widgets.LiveTileRecordsProvider.defaults,e);this.bind(e);this._isCreated=false;if(this.maxRows&&!isNaN(this.maxRows)&&this.maxRows>0){this.maxRows=Number(this.maxRows)}else{delete this.maxRows}this._create()};u8.Crm.Widgets.LiveTileRecordsProvider.defaults={items:[],moreRowsExist:true,disabled:false};$.extend(u8.Crm.Widgets.LiveTileRecordsProvider.prototype,{createSlider:function(e,t){return u8.create("RecordSlider",e,$.extend(t,{imageDecorator:"",dataProvider:this._dataProvider,reloadOnUpdate:true,action:this.action}))},load:function(){this._dataProvider.load()},executeAction:function(e,t){var i=this;if(this._popup){if(this._presenter){this._presenter.executeQuery()}this._popup.alignTo=t.element;this._popup.autoSizeAndPosition().show();return}function o(){u8.Base.Widgets.Header.loadModel({headerName:"QueryResult",headerGroupName:"Special"},function(e,o){var s=o.model,r="TXT_net_core_texts_338";u8.services.texts.loadText(r,function(){var e=[{name:"createNewTab",value:"true"},{name:"queryName",value:i.queryName},{name:"queryStatement",value:i._query&&i._query.getStatementString()},{name:"queryLookupScope",value:i.queryLookupScope},{name:"maxRows",value:i.maxRows},{name:"skipRows",value:i.skipRows}];if(i.link&&u8.isValidRecordUid(i.link)){e.push({name:"link",value:u8.linkRecordUidToString(i.link)})}s.buttons=s.buttons.concat([{name:"Separator"},{image:"u8-img-tab",label:$t(r),action:{target:"crm/queryrun.aspx",arguments:e}}]);u8.Base.Widgets.Popup.openWidgetPopup({type:"QueryResultPresenter",widgetOptions:{query:i._query,autoExecute:true,element:{attr:{class:"u8-margin"}},grid:{view:{header:{updatePopupTitle:true,model:s},collapseInvisibleRows:true},onCreateView:function(){if(i._popup){i._popup.autoSizeAndPosition().show()}},onUpdateView:function(){if(i._popup){i._popup.autoSizeAndPosition()}}}},popupOptions:{autoShow:false,autoClose:true,disposeOnClose:false,closeOnHotKey:true,showArrow:true,modal:false,sizing:"fit",alignTo:t.element,position:"right-middle",positionFixed:false,maxSize:{width:.6},onPreClose:function(e,t){t.cancel=true;e.hide()}}},function(e,t){i._popup=t.popup;i._presenter=t.widget})})})}function s(){u8.services.actions.execute(e,{arguments:{link:i.link},pageOptions:{filter:i._query&&i._query.getStatementString()?i._query:null}})}var r=e&&typeof e=="string"?s:o;if(this._query){r()}else{this._dataProvider.createQuery().then(function(e){i._query=e;r()})}},canExecuteAction:function(){return this.disabled!==true&&!!this.items.length},canCreateSlider:function(){return true},dispose:function(){this._dataProvider.dispose();this._isDisposed=true;if(this._popup&&this._popup.dispose){this._popup.dispose()}},set:function(e,t){this[e]=t;if(this._dataProvider){this._dataProvider.set(e,t)}},get:function(e){return this[e]},_create:function(){this._createDataProvider();u8.tools.created(this)},_createDataProvider:function(){this._dataProvider=u8.services.tableCaptions.createDataProvider(u8.tools.extendSome({onUpdate:this._onDataProviderUpdate.bind(this),includeValues:true},["infoAreaId","filterName","filterStatement","queryName","queryStatement","queryLookupScope","link","linkName","uids","uid","tableCaptionName","alternativeTableCaptionNames","sortFields","maxRows","skipRows","includeValues","autoRefresh","flags"],this))},_onDataProviderUpdate:function(e,t){if(this._isDisposed){return}this.items=e.data;this.moreRowsExist=e.moreRowsExist;this.raise("Update",t)}});u8.Crm.Widgets.LiveTileRecordsProvider.makeClass({name:"LiveTileRecordsProvider",events:["Update","Create"]})})();