Ext.define("KSWN.meta.levelIsolation.model.Document",{extend:"KSWN.meta.lockedDay.model.Change",fields:[{name:"baccount",type:"int"},{name:"link",depends:["baccount"],calculate:_ref=>{let{baccount:baccount}=_ref;return baccount}},{name:"mode",defaultValue:"close"}]}),Ext.define("KSWN.meta.settings.levelIsolation.model.Model",{extend:"Ext.data.Model",alternateClassName:"KSWN.meta.settings.LevelIsolationModel",fields:[{name:"docTitle",type:"string"},{name:"objCode",type:"string"},{name:"code",type:"string"},{name:"level",type:"int",convert:v=>Ext.Number.snapInRange(v,1,0,100)},{name:"setLevel",type:"int",convert:(v,rec)=>v||rec.get("level")}],createIdentifier:function(){const{objCode:objCode,level:level,setLevel:setLevel}=this.data;return{ObjectCode:objCode,LevelNew:setLevel,LevelPrev:level,Title:""}},getSaveChangesParams:function(){const{objCode:objCode,setLevel:setLevel}=this.data;return{level:setLevel,objCode:objCode}}}),Ext.define("KSWN.meta.settings.levelIsolation.store.Outcome",{alias:"store.ks-meta-settings-levelisolation-store-outcome",extend:"KSWN.meta.settings.newVariantEdit.store.Outcome",model:"KSWN.meta.levelIsolation.model.Document",loadUrl:"LevelIsolation/LoadOutcome",isMultiTableOutcome:!1,isDataSet:!0,updateDataOnLoadParamsChange:!0,getLockedDayChanges:function(){return this.getRange().map(rec=>rec.getDataForSave())}}),Ext.define("KSWN.meta.settings.levelIsolation.ViewController",{extend:"Ext.app.ViewController",alias:"controller.ks-meta-settings-levelisolation",init:function(){const{levelIsolationModel:levelIsolationModel}=this.getView();this.getViewModel().set({levelIsolationModel:levelIsolationModel})},onOutcomeStoreBeforeLoad:function(){this.getViewModel().set("outcomeloading",!0)},onOutcomeStoreLoad:function(){this.getViewModel().set("outcomeloading",!1)},saveBtnClick:function(){this.save()},cancelBtnClick:function(){this.closePanel()},closePanel:function(){const{objx:objx}=this.getView();objx.destroy()},save:function(){KSWN.meta.editor.lockedDay.Base.beforeSaveAlertMessage(()=>this.doSave())},doSave:async function(){const vm=this.getViewModel(),store=vm.get("outcomeStore"),params=vm.get("levelIsolationModel").getSaveChangesParams();params.changes=store.getLockedDayChanges();await Ajax({url:"LevelIsolation/Save",params:params})&&this.getView().onLevelIsolationSave()}}),Ext.define("KSWN.meta.settings.levelIsolation.ViewModel",{extend:"Ext.app.ViewModel",alias:"viewmodel.ks-meta-settings-levelisolation",data:{loadParams:null,levelIsolationModel:null,outcomeloading:!1,daysCountMessage:""},formulas:{loadParams:{bind:{bindTo:"{levelIsolationModel}",deep:!0},get:model=>({identifier:model.createIdentifier()})},daysCountMessage:{bind:{bindTo:"{outcomeStore.count}",deep:!0},get:count=>`${KSWN.Locale.kolichestvo_dney_trebuyshih_perezakritiya} - ${count}`}},stores:{outcomeStore:{type:"ks-meta-settings-levelisolation-store-outcome",loadParams:"{loadParams}",listeners:{beginoutcomeload:"onOutcomeStoreBeforeLoad",outcomeload:"onOutcomeStoreLoad"}}}}),Ext.define("KSWN.meta.settings.levelIsolation.Panel",{extend:"Ext.panel.Panel",xtype:"ks-meta-settings-levelisolation-panel",viewModel:"ks-meta-settings-levelisolation",controller:"ks-meta-settings-levelisolation",levelIsolationModel:null,layout:{type:"vbox",align:"stretch"},bodyPadding:8,items:[{xtype:"container",margin:"0 0 4 0",items:{xtype:"displayfield",fieldLabel:KSWN.Locale.document,flex:0,bind:"{levelIsolationModel.docTitle}"}},{xtype:"panel",title:KSWN.Locale.urovenizolyatsii,flex:0,margin:"0 0 4 0",bodyPadding:8,border:1,layout:"hbox",defaultType:"",defaults:{labelWidth:150},items:[{xtype:"displayfield",fieldLabel:KSWN.Locale.tekushchii,editable:!1,readOnly:!0,margin:"0 16 0 0",bind:"{levelIsolationModel.level}"},{xtype:"numberfield",fieldLabel:KSWN.Locale.ustanavlivaemiy,mouseWheelEnabled:!1,repeatTriggerClick:!1,min:0,max:100,bind:{value:"{levelIsolationModel.setLevel}",disabled:"{outcomeloading}"}}]},{xtype:"ks-gridbase",title:KSWN.Locale.informaciya_o_dnyah_trebuyshih_perezakrite,showOperations:!1,showLocked:!1,showFilter:!0,showSummary:!1,showDetails:!1,showTotal:!1,flex:1,columns:{defaults:{flex:1},items:[{xtype:"ks-grid-column-rownumberer",flex:0},{dataIndex:"date",xtype:"datecolumn",text:KSWN.Locale.datazakritiya},{dataIndex:"levels",text:KSWN.Locale.urovenzakritiya},{dataIndex:"baccount",text:KSWN.Locale.schetbyudzheta}]},bind:{store:"{outcomeStore}",loading:"{outcomeloading}"}}],dockedItems:[{xtype:"toolbar",dock:"bottom",items:[{xtype:"tbtext",bind:"{daysCountMessage}"}]}],fbar:[{text:KSWN.Locale.ok,handler:"saveBtnClick"},{text:KSWN.Locale.otmena,handler:"cancelBtnClick"}],onLevelIsolationSave:function(){const{setLevel:setLevel}=this.levelIsolationModel.data;this.fireEvent("levelisolationchange",this,setLevel),this.objx.destroy()}});