dojo.provide("parus.statusModelCoWorkingDialog");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.declare("parus.statusModelCoWorkingDialog",[parus.Dialog],{documentRN:null,event:null,coWorkingDate:null,readOnly:false,_refreshDetailGridTimeoutID:null,postCreate:function(){this.inherited(arguments);if(this.readOnly){dojo.forEach(this.popupMasterMenu.getChildren(),function(b){if(b.itemAction){b.destroyRecursive()}})}this.masterGrid.attr("store",this.masterGridStore());this.detailGrid.attr("store",this.detailGridStore());parus.balance._createActionsButton(this.popupMasterMenu,this.headerPane);this.popupMasterMenu.bindDomNode(this.masterGrid.viewsNode);this.popupDetailMenu.bindDomNode(this.detailGrid.viewsNode);var a=parus.userdata.get(this.declaredClass+"-masterGrid");if(a){parus.gridSettingsDialog.mergeGridSettings(this.masterGrid,a.gridSettings);parus.gridSettingsDialog.mergeColorConditions(this.masterGrid,a.colorConditions);parus.gridSettingsDialog.mergeFilterBar(this.masterGrid,a.showFilterBar,a.filterValues,a.sortInfo);this.userSize=a.userSize}a=parus.userdata.get(this.declaredClass+"-detailGrid");if(a){parus.gridSettingsDialog.mergeGridSettings(this.detailGrid,a.gridSettings);parus.gridSettingsDialog.mergeColorConditions(this.detailGrid,a.colorConditions);parus.gridSettingsDialog.mergeFilterBar(this.detailGrid,a.showFilterBar,a.filterValues,a.sortInfo)}this.masterGrid.setQuery(this.masterGrid.query)},masterGridStore:function(){return parus.gridData({queryid:"BalanceStatusModelCoWorkingStatus",onGetConditions:dojo.hitch(this,function(a){return{EVENT:this.event.event,EVENT_STAT:this.event.eventStatus,COWORKING_DATE:this.coWorkingDate}}),onComplete:dojo.hitch(this,function(d,c,b){var a=this.masterGrid;if((c.length>0)&&!a.selection.getSelectedCount()&&!b.start){a.selection.select(0);a.updateRow(0);a.autoSelected=true}else{a.onSelected()}this.checkMasterGridMenu()})})},detailGridStore:function(){return parus.gridData({queryid:"BalanceStatusModelCoWorkingStatusHistory",onGetConditions:dojo.hitch(this,function(b){var a=this.masterGrid.store;var d=this.masterGrid.selection.getSelectedIndex();var c=(d>=0)?this.masterGrid.getItem(d):null;b.parentRN=a.getValue(c,"RN");return{EVENT:b.parentRN||parus.parus8.CLASS_EmptyData,COWORKING_DATE:this.coWorkingDate}}),onComplete:dojo.hitch(this,function(c,b,a){var d=this.detailGrid;if((b.length>0)&&!d.selection.getSelectedCount()&&!a.start){d.selection.select(0);d.updateRow(0);d.autoSelected=true}else{d.onSelected()}})})},checkMasterGridMenu:function(){if(this.readOnly){return}var f=this.masterGrid.selection.getSelectedCount()==0;var e=this.masterGrid.store;var d=this.masterGrid.selection.getSelectedIndex();var c=(d>=0)?this.masterGrid.getItem(d):null;var b=e.getValue(c,"PERF_MARK_SIGN")=="1";var a=e.getValue(c,"PERF_MARK")!=null;this.setMarkMenuItem.attr("disabled",f||!b||a);this.removeMarkMenuItem.attr("disabled",f||!b||!a)},masterGridChange:function(){if(this._refreshDetailGridTimeoutID){clearTimeout(this._refreshDetailGridTimeoutID)}this._refreshDetailGridTimeoutID=setTimeout(dojo.hitch(this,function(){if(this._refreshDetailGridTimeoutID){clearTimeout(this._refreshDetailGridTimeoutID)}this._refreshDetailGridTimeoutID=null;parus.balance.refreshGrid(this.detailGrid);this.checkMasterGridMenu()}),300)},setMark:function(){parus.balance.statusModelSetMark(this.documentRN,this.event,dojo.hitch(this,function(){parus.balance.refreshGrid(this.masterGrid)}))},removeMark:function(){parus.balance.statusModelRemoveMark(this.documentRN,this.event,true,dojo.hitch(this,function(){parus.balance.refreshGrid(this.masterGrid)}))}});