Ext.define("LockedAccounts.controller.Main",{extend:"Ext.app.Controller",views:["LockedAccounts"],refs:[{selector:"lockedaccounts",ref:"lockedaccounts"},],init:function(){appCnt=this;this.buildFieldData();this.control({"lockedaccounts":{"afterrender":this.afterMainRender},'lockedaccounts trigger[name="gridSearch"]':{"change":this.mainGridSearch},});
},buildFieldData:function(){Ext.Ajax.request({url:"LockedAccounts/data/LockedAccountsJSON.jsp",method:"POST",async:false,success:function(a){if(a.status==200&&!Ext.isEmpty(a.responseText)){var b=a.responseText;publicJSON=Ext.decode(b);}}});},afterMainRender:function(){var a=publicJSON["gridValues"];Ext.getCmp("gridDisplay").show();
Ext.getCmp("gridDisplay").getStore().loadRawData(a);var b=publicJSON["NoExtFound"];if(b=="true"){Ext.getCmp("gridSearch").disable();}else{Ext.getCmp("gridSearch").enable();}},mainGridSearch:function(b){var a=Ext.getCmp("gridSearch").getValue();if(a==""||a.length==0){Ext.get("MyTrigger_0").setStyle("display","none");
Ext.get("MyTrigger_1").setStyle("display","block");}else{Ext.get("MyTrigger_1").setStyle("display","none");Ext.get("MyTrigger_0").setStyle("display","block");}Ext.Ajax.request({url:"LockedAccounts/data/LockedAccountsJSON.jsp?egTitleSearchStr="+a,method:"POST",success:function(c){if(c.status==200&&!Ext.isEmpty(c.responseText)){var e=c.responseText;
publicJSON=Ext.decode(e);}var d=publicJSON["gridValues"];Ext.getCmp("gridDisplay").show();if(d!=null&&d.length>0){Ext.getCmp("gridDisplay").store.loadRawData(publicJSON["gridValues"]);}else{Ext.getCmp("gridDisplay").store.loadData("");Ext.getCmp("gridDisplay").getView().emptyText='<div class="egFlexCenterByColumnWise" style="height:98%"><div class="iconInformation"></div><div class="commonErrorMsgText">'+noSearchFound+".</div></div>";
Ext.getCmp("gridDisplay").getView().refresh();}Ext.getCmp("gridDisplay").getSelectionModel().deselectAll(true);}});},handleDeleteIconClick:function(e,d,b){var a=Ext.getCmp("gridDisplay").getStore().getAt(d);var c=a.get("Username");this.deleteTask(c,d);},deleteTask:function(a,c){var b=this;Ext.Msg.show({title:"Locked Accounts",msg:deleteSingleAckttMsg+" '"+a+"'"+"?",buttons:Ext.Msg.YESNO,icon:"iconConfirmation",width:300,fn:function(d){if(d==="yes"){Ext.Ajax.request({url:"LockedAccounts/data/LockedAccountsJSONp.jsp?deleteGroups="+encodeURIComponent(a)+"&mode=delete",method:"POST",success:function(e){if(e.status==200&&!Ext.isEmpty(e.responseText)){var g=e.responseText;
publicJSON=Ext.decode(g);Ext.getCmp("gridSearch").setRawValue("");b.buildFieldData();var f=publicJSON["gridValues"];if(f==null||f.length==0){Ext.getCmp("gridSearch").disable();Ext.getCmp("gridDisplay").show();Ext.getCmp("gridDisplay").getStore().loadData("");Ext.getCmp("gridDisplay").getView().emptyText='<div class="egFlexCenterByColumnWise" style="height:98%"><div class="iconInformation"></div><div class="commonErrorMsgText">'+noAccMsg+".</div></div>";
Ext.getCmp("gridDisplay").getView().refresh();}else{Ext.getCmp("gridSearch").enable();Ext.getCmp("gridDisplay").show();Ext.getCmp("gridDisplay").getStore().loadRawData(f);}Ext.getCmp("gridDisplay").getSelectionModel().deselectAll(true);}}});}}});},handleDeleteSelected:function(){var f=this;var e=Ext.getCmp("gridDisplay").getSelectionModel().getSelection();
var b="";var g=new Array();var a="";if(e==""){Ext.MessageBox.show({title:"Locked Accounts",msg:publicJSON["screenLabels"]["no accounts selected"]+".",icon:"iconInformation",buttons:Ext.Msg.OK,width:300});return false;}for(var d=0;d<e.length;d++){b=e[d];id=b.get("Username");if(id!=null){g.push(id);}}for(var c=0;
c<g.length;c++){a+=g[c]+",";}Ext.Msg.show({title:mainPageTitle,msg:publicJSON["screenLabels"]["deleteforSelectedMessage"],icon:"iconConfirmation",buttons:Ext.Msg.YESNO,width:300,fn:function(h){if(h=="yes"){var i="LockedAccounts/data/LockedAccountsJSONp.jsp?deleteGroups="+encodeURIComponent(a)+"&mode=delete";
Ext.Ajax.request({url:i,method:"POST",async:false,success:function(j){if(j.status==200&&!Ext.isEmpty(j.responseText)){var l=j.responseText;publicJSON=Ext.decode(l);Ext.getCmp("gridSearch").setRawValue("");f.buildFieldData();var k=publicJSON["gridValues"];if(k==null||k.length==0){Ext.getCmp("gridSearch").disable();
Ext.getCmp("gridDisplay").show();Ext.getCmp("gridDisplay").getStore().loadData("");Ext.getCmp("gridDisplay").getView().emptyText='<div class="egFlexCenterByColumnWise" style="height:98%"><div class="iconInformation"></div><div class="commonErrorMsgText">'+noAccMsg+".</div></div>";Ext.getCmp("gridDisplay").getView().refresh();
}else{Ext.getCmp("gridSearch").enable();Ext.getCmp("gridDisplay").show();Ext.getCmp("gridDisplay").getStore().loadRawData(k);}Ext.getCmp("gridDisplay").getSelectionModel().deselectAll(true);}}});}}});},});