(function(){"use strict";var e,i;page.using={types:["QueryEditor","QueryResults"],texts:["dirty_message","standard_header_texts"]};page.onLoad=function(){var r=document.getElementById("editor");var n=window.query,s=this.url.get(["queryName","query","FormatName","Format"]),u=this.url.getBoolean(["autoExecute","autoRun"]);if(!n){n={name:s}}window.query=null;var l=this.url.get(["virtualInfoAreaReadMode","infoAreaSpecializationMode"],n.virtualInfoAreaReadMode);var d=this.url.getInt("maxRows",u8.services.queries.getMaxRows());var c=this.url.getInt("pageSize",u8.services.queries.getPageSize());var g={selectionMode:this.url.get("selectionMode"),query:$.extend(n,{catalogValueEncoding:"Numeric",link:this.url.getLinkUid(),maxRows:d,queryLookupScope:n.isPrivate?"Private":"Public",onExecute:o,virtualInfoAreaReadMode:l,onSave:t}),autoExecute:u,grid:{view:{autoLayout:{includeContainerPadding:true}},virtualInfoAreaReadMode:l,pageSize:c},parameterFormTemplateName:null,parent:this};var w=this.url.getOptions("listParams",u8.session.webConfigValues["List.ListParams"]);if(w&&!w.isEmpty()){a(g,w)}if(g.selectionMode){g.selectionMode=g.selectionMode.toLowerCase()}else{g.selectionMode="multi"}g.query=new u8.Crm.QueryCommand(g.query);var m=$("#results").hide();i=u8.widget("QueryResultPresenter",m,g);e=u8.widget("QueryEditor",r,{model:{query:g.query},parent:this,isExpanded:!u,isDefault:true,canChangeAssociationMode:!!window.canChangeAssociationMode,results:i,queryParameterForm:{catalogParametersAsText:this.url.getArray("catalogParametersAsText")}});$("#root").layout({name:"dock",includeContainerPadding:true})};page.confirmRequired=function(i){if(!e||!e.model.isModified){return false}if(!e.model.canEditQuery){return false}if(i){i.add($t("TXT_dirty_message_0"))}return true};function o(){$("#results").show()}function t(e){var i=e.uri;if(!i){return}var o=page.url.clear("queryName","FormatName","Format","FormatType").set("query",i);page.setUrl(o)}function a(e,i){i=u8.services.migration.convertListParams(i);if(i.virtualInfoAreaReadMode){e.query.virtualInfoAreaReadMode=i.virtualInfoAreaReadMode}if("associationMode"in i){e.query.associationMode=i.associationMode}e.grid=u8.tools.clean($.extend(true,{defaultAction:i.defaultAction,canEdit:i.canEdit,virtualInfoAreaReadMode:i.virtualInfoAreaReadMode,showLinks:i.showLinks,showMenu:i.showMenu!==false,showMiniDetails:i.showMiniDetails,showQuickViewAction:i.showQuickViewAction,showPaging:i.showPaging,showSumLine:i.showSumLine,autoSelect:i.autoSelect,countRows:i.countRows,view:u8.tools.clean({allowColumnReordering:i.allowColumnReordering,allowColumnResizing:i.allowColumnResizing,allowSorting:i.allowSorting,collapseInvisibleRows:i.collapseInvisibleRows,editable:i.editable,editOnClick:i.allowEditOnClick,singleClickEdit:i.singleClickEdit,header:u8.tools.clean({view:u8.tools.clean({showPaging:i.showPaging})})})},e.grid));if(!e.selectionMode){e.selectionMode=i.selectionMode&&i.selectionMode.toLowerCase()}}})();