dojo.provide("parus.balanceIndexConsComparationTemplatesDialog");dojo.require("dijit.Dialog");dojo.require("dijit.form.Button");dojo.require("parus.parus8");dojo.require("parus.dialog");dojo.require("parus.balanceIndexConsComparation");dojo.declare("parus.balanceIndexConsComparationTemplatesDialog",[parus.Dialog],{postCreate:function(){this.inherited(arguments);if((dojo.indexOf(parus.balance.availableUnits,"Users")==-1)){this.clearAllTemplatesMenuItem.destroyRecursive();var b=dojo.clone(this.templatesGrid.structure);b[0].cells[0]=dojo.filter(b[0].cells[0],function(c){return(c.field!="user")});this.templatesGrid.attr("structure",b)}this.templatesGrid.attr("store",this._getStore());this.templatesGrid.setQuery({});this.templatesGrid.selection.select(0);this.templatesGridPopupMenu.bindDomNode(this.templatesGrid.viewsNode);parus.balance._createActionsButton(this.templatesGridPopupMenu,this.headerPane);var a=parus.userdata.get(this.declaredClass);if(a){parus.gridSettingsDialog.mergeMenuSettings(this.templatesGridPopupMenu,a.actionSettings,a.userProcsActions,a.userReportsActions,a.userAppsActions);parus.gridSettingsDialog.mergeGridSettings(this.templatesGrid,a.gridSettings);parus.gridSettingsDialog.mergeColorConditions(this.templatesGrid,a.colorConditions);parus.gridSettingsDialog.mergeFilterBar(this.templatesGrid,a.showFilterBar,a.filterValues,a.sortInfo)}setTimeout(dojo.hitch(this,function(){this._selected()}),100)},_getStore:function(){var b=parus.parus8.consComparationData?parus.parus8.consComparationData.dataType:null;var a=parus.parus8.consComparationData?parus.parus8.consComparationData.result:null;return new parus.gridData({persistent:true,_data:parus.balanceIndexConsComparation.getTemplates(b,a)})},_selected:function(){var a=this.templatesGrid.getItem(this.templatesGrid.selection.getSelectedIndex());dojo.forEach(this.templatesGridPopupMenu.getChildren(),dojo.hitch(this,function(c){var b=a?false:true;if(!c.itemAction){b=false}if(c==this.deleteTemplateMenuItem){b=b||!!(this.templatesGrid.store.getValue(a,"user"))}if(c.declaredClass!="dijit.MenuSeparator"){c.attr("disabled",b)}}));parus.parus8.checkMenuSeparators(this.templatesGridPopupMenu)},deleteTemplate:function(){(new parus.confirmationDialog({message:"Удалить запись (записи)?",onApply:dojo.hitch(this,function(){var b=this.templatesGrid.store;var a=this.templatesGrid.selection.getFirstSelected();for(var c=0;c<this.templatesGrid.selection.getSelectedCount();c++){parus.balanceIndexConsComparation.deleteTemplate(b.getValue(a,"name"));a=this.templatesGrid.selection.getNextSelected(a)}parus.parus8.consComparationDataModified();this.templatesGrid.attr("store",this._getStore());this.templatesGrid.setQuery({});this.templatesGrid.selection.select(0);return true})})).show()},clearTemplates:function(){(new parus.confirmationDialog({message:"Удалить все шаблоны?",onApply:dojo.hitch(this,function(){parus.balanceIndexConsComparation.clearTemplates(false);parus.parus8.consComparationDataModified();this.templatesGrid.attr("store",this._getStore());this.templatesGrid.setQuery({});this.templatesGrid.selection.select(0);return true})})).show()},clearAllTemplates:function(){(new parus.confirmationDialog({message:"Удалить все шаблоны всех пользователей?",onApply:dojo.hitch(this,function(){parus.balanceIndexConsComparation.clearTemplates(true);parus.parus8.consComparationDataModified();this.templatesGrid.attr("store",this._getStore());this.templatesGrid.setQuery({});this.templatesGrid.selection.select(0);return true})})).show()},settings:function(){parus.balance.executeSettings(this.templatesGrid,this.templatesGridPopupMenu,this.declaredClass)},destroy:function(){this.store=null;this.inherited(arguments)},gridFilterChanged:function(b,a){parus.balance.gridFilterChanged(this.declaredClass,b,a)}});