dojo.provide("parus.designerEdit");dojo.require("dijit.form.DateTextBox");dojo.require("dijit.form.NumberTextBox");dojo.require("dijit.form.ValidationTextBox");dojo.require("dijit.form.TimeTextBox");dojo.require("dijit.form.CheckBox");dojo.require("parus.parus8");dojo.require("parus.dictEdit");dojo.declare("parus.designerDictEdit",[parus.dictEdit],{unitCode:null,methodCode:null,inCode:null,outCode:null,dictionaryInfoText:null,dictionaryInfoPending:false,autoComplete:false,postMixInProperties:function(){this._checkInfo();this.inherited(arguments)},_dictionaryInfoLoaded:function(){if(this.autoComplete){var e=dojo.fromJson(this.dictionaryInfoText);this.searchAttr=e.labelField;var d=this.unitCode+"#"+this.methodCode+"#"+this.inCode+"#"+this.outCode;var c=parus.dictionaries._stores?parus.dictionaries._stores[d]:null;if(!c){var b=e.labelAttr;dojo.forEach(e.columns,function(f){if(f.fieldName==e.labelAttr){b=f.sortField||e.labelAttr}});var a={attribute:e.labelAttr,descending:false,field:b};c=new parus.gridData({asJson:true,persistent:true,__lastSort:dojo.clone(a),__lastConditions:{__sort:dojo.clone(a)},_data:parus.database.queryObject(e.queryID,this.onGetGridConditions()||{})});if(!parus.dictionaries._stores){parus.dictionaries._stores={}}parus.dictionaries._stores[d]=c}this.store=c;this.store.fetch({start:0,query:{},queryOptions:{ignoreCase:true,deep:true},onBegin:dojo.hitch(this,function(f){this._itemCount=f;if(parus.dictionaries._autoCompleteLimit!=null){if(this._itemCount>=parus.dictionaries._autoCompleteLimit){this.autoComplete=false;this.searchAttr=""}}})});this._setStoreAttr(this.store)}},_checkInfo:function(){if(this.unitCode&&this.methodCode&&this.inCode&&this.outCode&&!this.dictionaryInfoText&&!this.dictionaryInfoPending){this.dictionaryInfoPending=true;parus.database.execute("designerUnitInfo",{UNITCODE:this.unitCode,METHOD_CODE:this.methodCode,INPARAM_CODE:this.inCode,OUTPARAM_CODE:this.outCode},dojo.hitch(this,function(a){this.dictionaryInfoText=parus.parus8.nodeField(parus.parus8.rowNodes(a)[0],"clobDEFINITION");this.dictionaryInfoPending=false;this._dictionaryInfoLoaded()}),dojo.hitch(this,function(a){dojo.query(".dijitArrowButtonInner",this.domNode).style({display:"none"});this.dictionaryInfoText="{}";this.dictionaryInfoPending=false}))}},onGetGridConditions:function(){var a=this.inherited(arguments)||{};dojo.mixin(a,{UNITCODE:this.unitCode,METHOD_CODE:this.methodCode,INPARAM_CODE:this.inCode,OUTPARAM_CODE:this.outCode});return a},dictButtonClick:function(){this._checkInfo();if(this.showingDictionary){return}if(this.dictionaryInfoPending){setTimeout(dojo.hitch(this,arguments.callee),1000);return}var a=dojo.fromJson(this.dictionaryInfoText);dojo.mixin(a,{multiselect:this.multiselect,label:this.value,dictionary:a,unitCode:this.unitCode||a.unitCode,gridConditions:this.onGetGridConditions(),userDataSection:this.unitCode||a.unitCode,menu:this.menu,catalogConditions:{METHOD_CODE:this.methodCode,INPARAM_CODE:this.inCode,OUTPARAM_CODE:this.outCode},onApply:dojo.hitch(this,function(b){this.setValue(b.getLabel());this.onApplyDictionary(b);return true}),onClose:dojo.hitch(this,function(b){this.showingDictionary=false;dijit.focus(this.focusNode)})});this.showingDictionary=true;dijit.hideTooltip(this.domNode);setTimeout(function(){new parus.dictionaryDialog(a).show()},100)}});