dojo.provide("parus.designerReportTablesDictionaryDialog");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.designerReportTableDialog");dojo.require("parus.designerReportTableIndexDialog");dojo.require("parus.designerReportTableNotIncludedIndexesDictionaryDialog");dojo.require("parus.designerReportTableTotalDialog");dojo.require("parus.designerReportTableConstraintDialog");dojo.require("parus.designerReportTableConstraintAttributeDialog");dojo.declare("parus.designerReportTablesDictionaryDialog",[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,this.showConstraints)}));a.startup();this.menu=a;this.inherited(arguments);return a},createDetailMenu:function(){this.detailMenu=this.createIndexPopupMenu(this,this.detailGrid,true,this.getTableRN);this.inherited(arguments);return this.detailMenu},getTableRN:function(){var c=this.grid;var b=c.store;var a=c.selection.getFirstSelected();return b.getValue(a,"RN")},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(){var f=b.call(e);parus.designerReportTablesDictionaryDialog.prototype.showNonIncludedIndexes(e,d,f)})}));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.designerReportTableIndexDialog.prototype.executeChangePriority(f,h.priorityEdit.attr("value"));if(g){parus.balance.refreshGrid(d)}return g})})).show()})}));a.addChild(new dijit.MenuSeparator());a.startup();return a},showNonIncludedIndexes:function(a,d,c){var b=parus.dictionaries.DesignerBalanceTablesNotIncludedIndexes;dojo.mixin(b,{multiselect:true,gridConditions:{PRN:c},onApply:dojo.hitch(a,function(f){var e=f.getValue();if(e&&e.length>0){if(parus.designerReportTableIndexDialog.prototype.executeInsertList(c,e)){parus.balance.refreshGrid(d)}}return true})});a.showDictionaryAction(b,parus.designerReportTableNotIncludedIndexesDictionaryDialog,parus.designerTableModelIndexDialog,null)},showTotals:function(){var f=this.grid;var e=f.store;var d=f.selection.getFirstSelected();var c=parus.dictionaries.DesignerBalanceTableTotals;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)})}));dojo.mixin(c,{multiselect:true,hideCancel:true,editByDoubleClick:true,gridConditions:{PRN:e.getValue(d,"RN")},menu:a});b=this.showDictionaryAction(c,null,parus.designerReportTableTotalDialog,null)},totalsChangePriority:function(a,e){var d=a.grid;var c=d.store;var b=d.selection.getFirstSelected();if(c.getValue(b,"KIND")!="1"){if(parus.designerReportTableTotalDialog.prototype.executeChangePriority(c,b,e)){parus.balance.refreshGrid(d,"RN",c.getValue(b,"RN"))}}},showConstraints:function(){var d=this.grid;var b=d.store;var c=d.selection.getFirstSelected();var a=parus.dictionaries.DesignerBalanceTableConstraintsWithDetails;dojo.mixin(a,{multiselect:true,hideCancel:true,editByDoubleClick:true,gridConditions:{PRN:b.getValue(c,"RN")},checkDetailGridPopupMenu:function(j,i,h){var h=j.grid;var g=h.store;var f=h.selection.getFirstSelected();if(!f){return}var e=g.getValue(f,"CONSTR_TYPE")=="1";dojo.forEach(i.getChildren(),function(k){if(!k.disabled&&(k.itemAction||k.detailAction)){k.attr("disabled",e);if(k.toolBarButton){k.toolBarButton.attr("disabled",k.disabled)}}})}});this.showDictionaryAction(a,null,parus.designerReportTableConstraintDialog,parus.designerReportTableConstraintAttributeDialog)}});