Ext.define("MyApp.Application",{name:"MyApp",extend:Ext.app.Application,views:[],controllers:[],stores:[]});Ext.define("MyApp.controller.LanguageSettings",{extend:Ext.app.Controller,refs:[{ref:"myForm",selector:"#myForm"},{ref:"mycheckboxgroup",selector:"#mycheckboxgroup"},{ref:"defaultLanguageCombo",selector:"#defaultLanguageCombo"},{ref:"saveButton",selector:"#saveButton"}],init:function(a){this.control({"#saveButton":{click:function(){this.save()}},"#myForm":{dirtychange:function(b,c){if(c){this.getSaveButton().enable()}else{this.getSaveButton().disable()}},actioncomplete:function(b,d,c){this.load()}},"#mycheckboxgroup":{check:function(f,e,h,g){console.log(f);console.log(e);console.log(h);console.log(g)}}})},onLaunch:function(){this.getDefaultLanguageCombo().getStore().load({callback:function(a){this.load();this.createCheckboxes(a)},scope:this})},createCheckboxes:function(c){var a=this.getMycheckboxgroup();var b=[];Ext.Array.each(c,function(e){var d=new Ext.form.Checkbox({xtype:"checkboxfield",flex:1,name:e.get("code"),fieldLabel:'<img src ="'+e.get("icon")+'" /> ',labelAlign:"right",labelSeparator:" ",labelWidth:30,boxLabel:e.get("title"),inputValue:"true",uncheckedValue:"false"});a.items.add(d);a.doLayout();b.push(d)},this);this.getMyForm().add(a);this.getMyForm().doLayout();this.checkboxArray=b},load:function(){var a=this;Ext.Ajax.request({url:"../../service/settings_language.php",method:"GET",params:Ext.Object.fromQueryString(document.location.search),success:function(c,d){var b=Ext.JSON.decode(c.responseText).result;b=Ext.Object.merge(b,b.acDashboardDocuments);this.getMyForm().getForm().setValues(b);Ext.Array.each(this.checkboxArray,function(e){if(e.boxLabel===b.fallback_language){if(e.getValue()===false){e.setValue(true);a.save()}e.disable(true)}})},failure:function(b,c){var d=b.responseText;Ext.Error.raise({msg:"Failed to get current settings",option:d,object:c})},scope:this})},save:function(){this.getSaveButton().disable();var a=this.getMyForm().getForm().getValues();a.acDashboardDocuments={};Ext.Array.each(this.getMycheckboxgroup().items.items,function(b){a.acDashboardDocuments[b.name]=b.getValue()},this);a.user=Ext.Object.fromQueryString(document.location.search).user;Ext.Ajax.request({url:"../../service/settings_language.php",method:"POST",params:Ext.Object.fromQueryString(document.location.search),jsonData:a,success:function(b,c){this.load()},failure:function(b,c){var d=b.responseText;Ext.Error.raise({msg:"Failed to get current settings",option:d,object:c})},scope:this})}});Ext.define("MyApp.controller.Main",{extend:Ext.app.Controller});Ext.define("MyApp.model.Language",{extend:Ext.data.Model,fields:[{name:"code"},{name:"title"},{name:"icon"}]});Ext.define("MyApp.store.LanguageStore",{extend:Ext.data.Store,constructor:function(a){var b=this;a=a||{};b.callParent([Ext.apply({autoLoad:false,model:"MyApp.model.Language",storeId:"LanguageStore",proxy:{type:"ajax",url:"../../../common/service/languages_get_available.php",reader:{type:"json"}}},a)])}});Ext.define("MyApp.view.Main",{extend:Ext.panel.Panel,border:false,layout:"fit",header:false,title:"My Panel",initComponent:function(){var a=this;Ext.applyIf(a,{items:[{xtype:"fieldset",title:"Language settings",layout:{type:"vbox",align:"stretch"},items:[{xtype:"form",border:false,itemId:"myForm",layout:"auto",pollForChanges:true,pollInterval:25,jsonSubmit:true,trackResetOnLoad:true,items:[{xtype:"container",margin:"0 0 5 0",layout:{type:"hbox",align:"stretch"},items:[{xtype:"textfield",width:150,fieldLabel:"System fallback language",labelAlign:"top",labelSeparator:" ",name:"fallback_language",readOnly:true},{xtype:"container",flex:1,items:[{xtype:"image",src:"../gfx/icon_question-small-white.png",title:"This can only be set system wide in the apm.ini file"}]}]},{xtype:"combobox",itemId:"defaultLanguageCombo",fieldLabel:"Workflow notifications",labelAlign:"top",labelSeparator:" ",name:"workflow_notifications_language",editable:false,displayField:"title",forceSelection:true,store:"LanguageStore",valueField:"code"},{xtype:"checkboxgroup",itemId:"mycheckboxgroup",minHeight:100,padding:0,width:400,layout:"auto",fieldLabel:"Dashboard reports",labelAlign:"top",labelPad:0,labelSeparator:" "}]},{xtype:"container",margins:"20 0 8 20",layout:{type:"hbox",align:"bottom",pack:"end"},items:[{xtype:"button",disabled:true,itemId:"saveButton",padding:"5 10 5 10",icon:"../gfx/save.png",scale:"medium",text:"Save changes"}]}]}]});a.callParent(arguments)}});Ext.define("MyApp.view.Viewport",{extend:Ext.container.Viewport,layout:{type:"fit"},items:[{xtype:"app-main"}]});