dojo.provide("parus.gridActions");dojo.require("parus.parus8");if(!parus){parus={}}if(!parus.gridActions){dojo.mixin(parus,{gridActions:{}})}dojo.mixin(parus.gridActions,{checkPopupMenuDefaultAction:function(b){var a=false;if(b){dojo.forEach(b.getChildren(),function(c){if(c["default"]){a=true;if(c.declaredClass!="dijit.MenuSeparator"){if(!c.attr("disabled")){c.onClick()}}}})}return a},checkPopupMenuItemAction:function(c,b){if(c){var a=b.selection.getSelectedCount()==0;dojo.forEach(c.getChildren(),function(d){if(d.itemAction){d.attr("disabled",a)}else{if(d.detailAction){d.attr("disabled",b.store.parentRN==null)}}if(d.toolBarButton){d.toolBarButton.attr("disabled",d.disabled)}})}},autoSelectRow:function(a){a.selection.select(0);a.updateRow(0);a.scrollToRow(0);a.autoSelected=true},deleteSelected:function(a,b){(new parus.confirmationDialog({message:"Удалить запись (записи)?",onApply:dojo.hitch(this,function(){var d=a.store;var c=a.selection.getFirstSelected();for(var e=0;e<a.selection.getSelectedCount();e++){if(b){b(d,c)}c=a.selection.getNextSelected(c)}a.selection.deselectAll();parus.balance.refreshGrid(a);return true})})).show()},moveDocumentToCatalog:function(b,a,g,f){var e=b.store;var d=b.selection.getFirstSelected();var c=[];dojo.forEach(a.path,function(h){c.push(a.model.getIdentity(h))});(new parus.treeDialog({model:new (dojo.getObject(a.model.declaredClass,false))({queryid:a.model.queryid,onGetConditions:a.model.onGetConditions}),restoreSelected:false,value:c.join(";"),key:g+"-moveDocument",onDefaultNeeded:function(){var h=parus.database.execute("findAvailableCatalog",{UNITCODE:g});return h?parus.parus8.nodeField(parus.parus8.rowNodes(h)[0],"PATH"):null},onPerform:function(j){for(var h=0;h<b.selection.getSelectedCount();h++){parus.database.execute(f,{RN:e.getValue(d,"RN"),CRN:j});d=b.selection.getNextSelected(d)}b.selection.deselectAll();parus.balance.refreshGrid(b);return true}})).show()}});