//>>built
define("mill/dataBrowser/browserGrid","dojo/DeferredList dijit/Menu dojox/grid/EnhancedGrid dojox/grid/enhanced/_Plugin dojox/grid/enhanced/_PluginManager dojox/grid/enhanced/plugins/IndirectSelection mill/mill mill/dataBrowser/browserGridData mill/dataBrowser/parametersView mill/dataBrowser/blobAttachment mill/gridColumnsFilter".split(" "),function(){mill.dataBrowser||(mill.dataBrowser={});dojo.declare("mill.dataBrowser.browserGrid",[dojox.grid.EnhancedGrid,dijit._Contained],{rttiManager:null,viewName:null,
viewID:null,view:null,classInfo:null,columns:null,conditions:null,actions:null,parentView:null,escapeHTMLInData:!1,keyFieldName:"ID",hasChildrenFieldName:"HasChildren",parametersDialogClass:"mill.dataBrowser.parametersView",childViews:null,plugins:{dataBrowserColumnsFilter:{visible:!0},indirectSelection:{headerSelector:!0}},constructor:function(){this.inherited(arguments);this.childViews=[]},preDefinedConditions:function(){return[]},formatCell:function(a,c,d){c=d.grid.getItem(c);if("TBlobDomain"==
d.columnInfo.domainInfo.handle)if("1"==d.grid.store.getValue(c,d.columnInfo.Name))if(d.columnInfo.domainInfo.blobSubtype||(d.columnInfo.domainInfo.blobSubtype=d.grid.rttiManager.get("TEnumerationItem",d.columnInfo.domainInfo.BlobSubtype,null)),"btNamedFile"==d.columnInfo.domainInfo.blobSubtype.Name)a='\x3ca target\x3d"_blank" href\x3d\'/'+d.grid.rttiManager.handle+"/getblob?query\x3d"+mill._itemsToQuery({className:d.grid.classInfo.Name,propName:d.columnInfo.propertyInfo.Name,ID:d.grid.store.getValue(c,
"ID")})+"'\x3e(\u0414\u0430\u043d\u043d\u044b\u0435)\x3c/a\x3e";else return new mill.dataBrowser.blobAttachment({hrefConstructor:["javascript:mill.dataBrowser.browserGrid.__showGridBlob('",[d.grid.id,d.grid.store.getValue(c,"ID"),d.columnInfo.ID],"')"]});else a="(\u041d\u0435\u0442)";if(a)return style=["font-size:110%"],c.indent&&style.push("padding-left:"+10*c.indent+"px"),d.grid.view.boldProperty&&"1"==d.grid.store.getValue(c,d.grid.view.boldProperty.Name)&&style.push("font-weight:800"),"TBooleanDomain"==
d.columnInfo.domainInfo.handle&&("1"==a?a=d.columnInfo.domainInfo.TrueValue:"0"==a&&(a=d.columnInfo.domainInfo.FalseValue)),'\x3cspan style\x3d"'+style.join(";")+'"\x3e'+a+"\x3c/span\x3e"},_performAction:function(a){var c=this.selection.getSelected();if(a.routine)if(("1"==a.routine.SingleObject||"1"==a.routine.IsClassMethod)&&dojo.isArray(c)&&(c=c[0]),"TRoutine"==a.routine.handle)if("Refresh"==a.routine.Name)this.refresh();else throw Error("Routine named "+a.routine.Name+" not handled yet.");else(new dojo.getObject(this.parametersDialogClass))({grid:this,
rttiManager:this.rttiManager,routine:a.Routine,item:c}).show()},_buildMenu:function(a){var c=null;dojo.forEach(this.actions,dojo.hitch(this,function(d){if(d.Parent==a){c||(c=new dijit.Menu({}));var g=new dijit.MenuItem({label:d.Description,popup:this._buildMenu(d.ID),onClick:dojo.hitch(this,this._performAction,d)});d.menuItem=g;c.addChild(g);"1"==d.Separated&&c.addChild(new dijit.MenuSeparator)}}));return c},startup:function(){this.inherited(arguments);var a=this;this.view=this.rttiManager.get("TView",
this.viewID,this.viewName);this.viewName=this.view.Name;this.viewID=this.view.ID;this.view.BoldProperty&&(this.view.boldProperty=this.rttiManager.get("TProperty",this.view.BoldProperty,null));this.columns=dojo.filter(this.rttiManager.byHandle("TViewColumn"),function(b){return b.Master==a.viewID});this.classInfo=this.rttiManager.get("TClass",this.view.ShownClass,null);this.conditions=dojo.filter(this.rttiManager.byHandle("TViewCondition"),function(b){return b.Master==a.viewID});this.conditions.length||
(this.conditions=null);this.actions=[];this.actions=this.actions.concat(dojo.filter(this.rttiManager.byHandle("TAction"),function(b){return b.Master==a.viewID}));this.actions=this.actions.concat(dojo.filter(this.rttiManager.byHandle("TRoutineAction"),function(b){return b.Master==a.viewID}));this.actions.sort(function(b,h){return b.Position-h.Position});dojo.forEach(this.actions,dojo.hitch(this,function(b){b.Routine&&(b.handle="TRoutineAction",b.routine=this.rttiManager.getRoutine(b.Routine))}));(this.menu=
this._buildMenu(null))&&this.menu.bindDomNode(this.viewsNode);var c=[],d=0,g=null;dojo.forEach(this.columns,dojo.hitch(this,function(b){b.propertyInfo=this.rttiManager.get("TProperty",b.Property,null);b.domainInfo=this.rttiManager.getDomain(b.propertyInfo.Domain,null);b.sortDirection=this.rttiManager.get("TEnumerationItem",b.SortDirection,null);b.Width&&(d++,g=c.length);var h=b.propertyInfo.Name;"TClassDomain"==b.domainInfo.handle?(b.domainInfo.showObjectInfoType=this.rttiManager.get("TEnumerationItem",
b.domainInfo.ShowObjectInfoType,null),h="soName"==b.domainInfo.showObjectInfoType.Name?b.propertyInfo.Name+"$N":b.propertyInfo.Name+"$D"):"TEnumerationDomain"==b.domainInfo.handle&&(h="1"==b.domainInfo.ShowNames?b.propertyInfo.Name+"$N":b.propertyInfo.Name+"$D");this.sortInfo||("sdAscending"==b.sortDirection.Name?this.sortInfo=+(c.length+1):"sdDescending"==b.sortDirection.Name&&(this.sortInfo=-(c.length+1)));c.push({hidden:!b.Width,name:b.Description,width:b.Width+"px",field:h,styles:"text-align:left;",
headerStyles:"font-weight:800;font-size:120%;",filter:b.Filter,formatter:this.formatCell,columnInfo:b})}));1==d&&(c[g].width="100%",c[g].headerStyles="display:none;",this.indirectSelection=!1);var f=[],e=[];dojo.forEach(c,function(b){("1"==b.columnInfo.Fixed?f:e).push(b)});c=f.length?[{cells:f,noscroll:!0},{cells:e}]:[e];this.setStructure(c);this.parentView?this.parentView.childViews.push(this):this.setStore(this._createStore())},_createStore:function(){var a=new mill.dataBrowser.browserGridData({_id:this.id,
grid:this,rttiManager:this.rttiManager});dojo.mixin(a,{_gridOnStoreCompleteConnection:this.connect(a,"onComplete","onStoreComplete")});return a},_checkActions:function(){var a=this.selection.getSelected();dojo.isArray(a)&&(a=a[0]);dojo.forEach(this.actions,function(c){c.routine&&"0"==c.routine.IsClassMethod&&c.menuItem.attr("disabled",!a)})},_selectOnComplete:!1,refresh:function(){var a=this.store;!this.parentView||this.parentView.selection.getSelected()[0]?(this.setStore(this._createStore()),this._selectOnComplete=
!0):this.setStore(null);a&&(a._gridOnStoreCompleteConnection&&(this.disconnect(a._gridOnStoreCompleteConnection),a._gridOnStoreCompleteConnection=null),a.close())},_refreshChildViews:function(){dojo.forEach(this.childViews,function(a){a.refresh()})},onSelected:function(a){this.inherited(arguments);this._refreshChildViews();this._checkActions()},onStoreComplete:function(a){a.length&&!this.selection.getSelectedCount()&&(this.selection.select(0),this.updateRow(0),this.onSelected(0));this._selectOnComplete?
(this._selectOnComplete=!1,this.onSelected()):(this._resize(),this._checkActions())},onGetFilterStore:function(a){var c=null,d=null;c=[];c.push({ID:"",Description:"(\u0412\u0441\u0435)"});"1"!=a.columnInfo.domainInfo.Required&&(c.push({ID:"!*",Description:"(\u041f\u0443\u0441\u0442\u043e)"}),c.push({ID:"*",Description:"(\u041d\u0435 \u043f\u0443\u0441\u0442\u043e)"}));var g=this.preDefinedConditions();context=[];if(this.parentView&&this.store){var f=this.store,e=this.parentView.selection.getSelected();
dojo.isArray(e)&&(e=e[0]);dojo.mixin(context,{className:this.parentView.classInfo.ID,current:f.getIdentity(e)});context.push({name:"Current",domain:this.rttiManager.getDomain(null,"TObject domain").ID,value:context.current});dojo.forEach(this.parentView.columns,function(b){context.push({name:b.propertyInfo.Name,domain:b.domainInfo.ID,value:f.getValue(e,b.propertyInfo.Name)||""})});g.push({part:1,name:this.viewID,special:16,context:context})}"TStringDomain"==a.columnInfo.domainInfo.handle?d=mill.data({className:this.classInfo.Name,
handler:this.rttiManager.handle,clientFiltering:!0,request:g.concat([{part:0,name:"Description",value:'"'+a.columnInfo.propertyInfo.Name+'"'},{part:1,name:a.columnInfo.propertyInfo.Name,value:"*"},{part:3,name:a.columnInfo.propertyInfo.Name}])}):"TEnumerationDomain"==a.columnInfo.domainInfo.handle?d=mill.data({className:"TEnumerationItem",handler:this.rttiManager.handle,clientFiltering:!0,request:[{part:0,name:"Description"},{part:1,name:"Master",value:a.columnInfo.domainInfo.ID},{part:2,name:"Position"}]}):
"TClassDomain"==a.columnInfo.domainInfo.handle&&(d="soName"==a.columnInfo.domainInfo.showObjectInfoType.Name?"$N":"$D",a=g.concat([{part:1,name:a.columnInfo.propertyInfo.Name,value:"*"},{part:0,name:"Description",value:'"'+a.columnInfo.propertyInfo.Name+d+'"'},{part:3,name:a.columnInfo.propertyInfo.Name+d}]),d=mill.data({className:this.classInfo.Name,handler:this.rttiManager.handle,clientFiltering:!0,request:a}));c=new dojo.data.ItemFileReadStore({data:{identifier:"ID",label:"Description",items:c}});
return d?mill.dataUnion({stores:[c,d]}):c},onFilterChanged:function(a,c,d,g){a.columnInfo.Filter=a.filter;this.refresh()}});dojo.mixin(mill.dataBrowser.browserGrid,{__showGridBlob:function(a,c,d,g){var f=dijit.byId(a);if(f){var e=f.rttiManager.get("TViewColumn",d);if(e)if(e.domainInfo.blobSubtype||(e.domainInfo.blobSubtype=f.rttiManager.get("TEnumerationItem",e.domainInfo.BlobSubtype,null)),"btXHTML"==e.domainInfo.blobSubtype.Name||"btHTML"==e.domainInfo.blobSubtype.Name)(new dijit.Dialog({content:dojo.i18n.substitute(dojo.cache("mill",
"showReferenceDialog.html",'\x3cdiv design\x3d"headline" dojoType\x3d"dijit.layout.BorderContainer" gutters\x3d"false" style\x3d"padding:10px;overflow:hidden"\x3e\x3cdiv dojoType\x3d"dijit.layout.ContentPane" extractContent\x3d"true" region\x3d"center" style\x3d"margin:0;padding:0;overflow:auto"\x3e\x3c/div\x3e\x3cdiv dojoType\x3d"dijit.layout.ContentPane" region\x3d"bottom" style\x3d"margin:0;padding:0;padding-top:10px"\x3e\x3cbutton dojoType\x3d"dijit.form.Button" onClick\x3d"dijit.byNode(this.domNode.parentNode.parentNode.parentNode.parentNode).hide()"\x3e\x3cb\x3e ${close} \x3c/b\x3e\x3c/button\x3e\x3c/div\x3e\x3c/div\x3e'),
dojo.i18n.getLocalization("mill","resources")),draggable:!1,parseOnLoad:!0,title:e.Description,style:"width:90%;height:90%",onShow:function(){this.containerNode.children[0].style.height=dojo.contentBox(this.domNode).h-dojo.marginBox(this.titleBar).h-20+"px";dojo.query('[region\x3d"center"]',this.domNode).forEach(function(h){h=dijit.byNode(h);onload&&(h.onLoad=dojo.hitch(h,onload));h.attr("href","/"+f.rttiManager.handle+"/getblob?query\x3d"+mill._itemsToQuery({className:f.classInfo.Name,propName:e.propertyInfo.Name,
ID:c}))})},onHide:function(){setTimeout(dojo.hitch(this,this.destroyRecursive),1)}})).show();else if("btImage"==e.domainInfo.blobSubtype.Name){var b=e.domainInfo.Extension||".bmp";"newTab"==g?mill.downloadBlob({handler:handle,className:f.classInfo.Name,propName:e.propertyInfo.Name,ID:c,extension:b}):"download"==g?mill.downloadBlob({handler:handle,className:f.classInfo.Name,propName:e.propertyInfo.Name,ID:c,extension:b,fileName:"\u0421\u043a\u0430\u043d_\u0441\u043f\u0440\u0430\u0432\u043a\u0438"+
b}):(new dijit.Dialog({content:dojo.i18n.substitute(dojo.cache("mill","showImageDialog.html",'\x3cdiv design\x3d"headline" dojoType\x3d"dijit.layout.BorderContainer" gutters\x3d"false" style\x3d"padding:0px;padding-top:0;overflow:hidden"\x3e\x3cdiv dojoType\x3d"dijit.layout.ContentPane" region\x3d"top" style\x3d"height:30px;padding:0px"\x3e\x3cdiv dojoType\x3d"dijit.Toolbar"\x3e\x3cdiv dojoType\x3d"dijit.form.Button" iconClass\x3d"dijitEditorIcon dijitEditorIconFullScreen" onClick\x3d"mill.inscribeImage(dojo.query(\'img\', this.domNode.parentNode.parentNode.parentNode.parentNode.parentNode)[0])" showLabel\x3d"false"\x3e 100% \x3c/div\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv dojoType\x3d"dijit.layout.ContentPane" region\x3d"center" style\x3d"padding:10px"\x3e\x3cdiv style\x3d"margin:0;overflow:auto;width:100%;height:100%"\x3e\x3cimg/\x3e\x3c/div\x3e\x3c/div\x3e\x3cdiv dojoType\x3d"dijit.layout.ContentPane" region\x3d"bottom" style\x3d"margin:0;padding:10px"\x3e\x3cbutton dojoType\x3d"dijit.form.Button" onClick\x3d"dijit.byNode(this.domNode.parentNode.parentNode.parentNode.parentNode).hide()"\x3e\x3cb\x3e ${close} \x3c/b\x3e\x3c/button\x3e\x3c/div\x3e\x3c/div\x3e'),
dojo.i18n.getLocalization("mill","resources")),draggable:!1,parseOnLoad:!0,title:e.Description,style:"width:90%;height:90%",onShow:function(){this.containerNode.children[0].style.height=dojo.contentBox(this.domNode).h-dojo.marginBox(this.titleBar).h-20+"px";dojo.query('[region\x3d"center"]',this.domNode).forEach(function(h){var k=dijit.byNode(h);onload&&(k.onLoad=dojo.hitch(k,onload));dojo.query("*",h)[0].src="/"+f.rttiManager.handle+"/getblob"+b+"?query\x3d"+mill._itemsToQuery({className:f.classInfo.Name,
propName:e.propertyInfo.Name,ID:c})})},onHide:function(){setTimeout(dojo.hitch(this,this.destroyRecursive),1)}})).show()}}}});dojo.declare("dojox.grid.enhanced.plugins.dataBrowserColumnsFilter",dojox.grid.enhanced.plugins.millColumnsFilter,{name:"dataBrowserColumnsFilter"});dojox.grid.EnhancedGrid.registerPlugin(dojox.grid.enhanced.plugins.dataBrowserColumnsFilter)});