dojo.provide("parus.designerTableModelsDictionaryDialog");dojo.require("dijit.Dialog");dojo.require("dijit.form.Button");dojo.require("dojox.grid.DataGrid");dojo.require("dojo.data.ItemFileReadStore");dojo.require("parus.parus8");dojo.require("parus.dialog");dojo.require("parus.gridData");dojo.require("parus.gridActions");dojo.require("parus.catalogActions");dojo.require("parus.dictionaryDialog");dojo.require("parus.editDictionaryDialog");dojo.require("parus.designerTableModelDialog");dojo.require("parus.designerTableModelIndexDialog");dojo.require("parus.designerTableIndexChangePriorityDialog");dojo.require("parus.designerTableModelTotalDialog");dojo.require("parus.designerTableModelFormulaDialog");dojo.declare("parus.designerTableModelsDictionaryDialog",[parus.editableDictionaryDialog],{createMenu:function(){var a=new dijit.Menu({"class":"balanceMenu"});a.addChild(new dijit.MenuItem({label:"Итоги...",itemAction:true,onClick:dojo.hitch(this,this.showTotals)}));a.addChild(new dijit.MenuItem({label:"Формулы пересчета...",itemAction:true,onClick:dojo.hitch(this,function(){this.showFormulas(false)})}));a.addChild(new dijit.MenuItem({label:"Формулы коррекции итогов...",itemAction:true,onClick:dojo.hitch(this,function(){this.showFormulas(true)})}));a.startup();this.menu=a;this.inherited(arguments);return a},createDetailMenu:function(){this.detailMenu=this.createIndexPopupMenu(this,this.detailGrid,true,this.getTableModelRN);this.inherited(arguments);return this.detailMenu},getTableModelRN:function(){var b=this.detailGrid;var a=b.store;return a.parentRN},createIndexPopupMenu:function(e,d,c,b){var a=new dijit.Menu({"class":"balanceMenu"});a.addChild(new dijit.MenuItem({label:"Добавить списком...",itemAction:false,detailAction:c,onClick:dojo.hitch(e,function(){parus.balance.showIndexes(true,dojo.hitch(e,function(f){var h=f.getValue();if(h&&h.length>0){var g=b.call(e);if(parus.designerTableModelIndexDialog.prototype.executeInsertList(g,h)){parus.balance.refreshGrid(d)}}}))})}));a.addChild(new dijit.MenuItem({label:"Добавить группу...",itemAction:false,detailAction:c,onClick:dojo.hitch(e,function(){parus.balance.showIndexesGroups(false,dojo.hitch(e,function(h){var g=h.getLabel();var f=b.call(e);if(parus.designerTableModelIndexDialog.prototype.executeInsertGroup(f,g)){parus.balance.refreshGrid(d)}}))})}));a.addChild(new dijit.MenuItem({label:"Изменить очередность расчета...",itemAction:false,detailAction:c,onClick:dojo.hitch(e,function(){var f=b.call(e);(new parus.designerTableIndexChangePriorityDialog({prn:f,onApply:dojo.hitch(e,function(h){var g=parus.designerTableModelIndexDialog.prototype.executeChangePriority(f,h.priorityEdit.attr("value"));if(g){parus.balance.refreshGrid(d)}return g})})).show()})}));a.startup();return a},showTotals:function(){var f=this.grid;var e=f.store;var d=f.selection.getFirstSelected();var g=e.getValue(d,"RN");var c=parus.dictionaries.DesignerBalanceTableModelsTotals;var b;var a=new dijit.Menu({"class":"balanceMenu"});a.addChild(new dijit.MenuItem({label:"Повысить уровень",itemAction:true,onClick:dojo.hitch(this,function(){this.totalsChangePriority(b,true)})}));a.addChild(new dijit.MenuItem({label:"Понизить уровень",itemAction:true,onClick:dojo.hitch(this,function(){this.totalsChangePriority(b,false)})}));a.startup();dojo.mixin(c,{dictionary:c,unitCode:c.unitCode,multiselect:true,hideCancel:true,editByDoubleClick:true,editDialogClass:parus.designerTableModelTotalDialog,gridConditions:{PRN:g},menu:a});b=new parus.editableDictionaryDialog(c);b.show()},totalsChangePriority:function(b,a){var e=b.grid;var d=e.store;var c=e.selection.getFirstSelected();if(d.getValue(c,"KIND")!="1"){if(parus.designerTableModelTotalDialog.prototype.executeChangePriority(d,c,a)){parus.balance.refreshGrid(e,"RN",d.getValue(c,"RN"))}}},showFormulas:function(e){var d=this.grid;var b=d.store;var c=d.selection.getFirstSelected();var g=b.getValue(c,"RN");var a=parus.dictionaries[e?"DesignerBalanceTableModelsTotalFormulas":"DesignerBalanceTableModelsFormulas"];var f;dojo.mixin(a,{dictionary:a,unitCode:a.unitCode,multiselect:true,hideCancel:true,editByDoubleClick:true,editDialogClass:parus.designerTableModelFormulaDialog,gridConditions:{PRN:g,KIND:e?"1":"0"}});f=new parus.editableDictionaryDialog(a);f.show()}});