(function(){"use strict";u8.Crm.Widgets.QuickQueryRunQuery=function(e,t){this.Widget(e,$.extend({},u8.Crm.Widgets.QuickQueryRunQuery.defaults,t));this._create()};u8.Crm.Widgets.QuickQueryRunQuery.makeClass({name:"QuickQueryRunQuery",deriveFrom:u8.Base.Widgets.Widget});u8.Crm.Widgets.QuickQueryRunQuery.defaults={};$.extend(u8.Crm.Widgets.QuickQueryRunQuery.prototype,{execute:function(){if(!this.page.process.statement){this._getArg();return}var e={};var t=$.Deferred();u8.request("QueryChannel.ParseQueryStatement",{queryStatement:this.page.process.statement},function(r,u){var i=u.error;if(i){i.handled=true;var s=[{line:"linePos"in i?i.linePos-1:0,pos:"charPos"in i?i.charPos-1:0,reason:i.message}];return t.resolve(s)}e=u.response.statement;this._getArg(e)}.bind(this))},_create:function(){this._createView()},_getArg:function(e){var t=u8.services.queries.getMaxRowsOptions();var r=t.items!=null&&t.items.length>0?t.items[t.items.length-1].key:u8.services.queries.getMaxRows();var u={selectionMode:"",query:$.extend(e,{catalogValueEncoding:"Numeric",link:"",maxRows:r,queryLookupScope:"Public",onExecute:"",virtualInfoAreaReadMode:"",onSave:""}),autoExecute:true,grid:{view:{autoLayout:{includeContainerPadding:true}},virtualInfoAreaReadMode:"",pageSize:u8.services.queries.getPageSize()},parameterFormTemplateName:null,parent:this};if(u.selectionMode){u.selectionMode=u.selectionMode.toLowerCase()}else{u.selectionMode="multi"}u.query=new u8.Crm.QueryCommand({maxRows:r,statement:e,onExecute:function(){var e=this._results.getResultGrid();e.view.header.headerName="QuickQueryResult";var t=this.parent.$("#results");t.show()}.bind(this)});var i=this.parent.$("#results");this._results=u8.widget("QueryResultPresenter",i,u)},_createView:function(e){var t=this.$(this.element);t.utml({url:"~/crm/QuickQueryRunQuery.utml.htm",itemOptions:{parent:this},data:{display:u8.debug.level?"block":"none"}},function(){this.parent.$("#root").layout({name:"dock",includeContainerPadding:true});this.execute();this._createCodeEditor()}.bind(this));if(e){e()}},_createCodeEditor:function(e,t){if(u8.debug.level){var r=this.parent.$("#query");u8.widget("CodeEditor",r,{autoSize:true,readonly:true,value:this.page.process.statement,editor:{mode:"uql"},parent:this})}}})})();