text: "use strict";(self.webpackChunkneo_mjs_realworld_example_app=self.webpackChunkneo_mjs_realworld_example_app||[]).push([[930],{7930:(e,t,o)=>{o.r(t),o.d(t,{default:()=>a});var l=o(4683),r=o(5892);class a extends l.Z{static getConfig(){return{className:"RealWorld.view.user.SettingsComponent",bio_:null,cls:["settings-page"],email_:null,errors_:[],image_:null,userName_:null,_vdom:{cn:[{cls:["container","page"],cn:[{cls:["row"],cn:[{cls:["col-md-6","offset-md-3","col-xs-12"],cn:[{tag:"h1",cls:["text-xs-center"],html:"Your Settings"},{tag:"ul",cls:["error-messages"],flag:"errors",removeDom:!0},{tag:"form",cn:[{tag:"fieldset",cn:[{tag:"fieldset",cls:["form-group"],cn:[{tag:"input",cls:["form-control"],flag:"image",placeholder:"URL of profile picture",type:"text"}]},{tag:"fieldset",cls:["form-group"],cn:[{tag:"input",cls:["form-control","form-control-lg"],flag:"userName",placeholder:"Your Name",type:"text"}]},{tag:"fieldset",cls:["form-group"],cn:[{tag:"textarea",cls:["form-control","form-control-lg"],flag:"bio",placeholder:"Short bio about you",rows:8}]},{tag:"fieldset",cls:["form-group"],cn:[{tag:"input",cls:["form-control","form-control-lg"],flag:"email",placeholder:"Email",type:"text"}]},{tag:"fieldset",cls:["form-group"],cn:[{tag:"input",cls:["form-control","form-control-lg"],flag:"password",placeholder:"Password",type:"password"}]},{tag:"button",cls:["btn","btn-lg","btn-primary","pull-xs-right"],html:"Update Settings"}]}]},{tag:"hr"},{tag:"button",cls:["btn","btn-outline-danger"],html:"Or click here to logout."}]}]}]}]}}}construct(e){super.construct(e);let t=this,o=t.domListeners;o.push({click:{fn:t.onLogoutButtonClick,delegate:".btn-outline-danger",scope:t}},{click:{fn:t.onSubmitButtonClick,delegate:".btn-primary",scope:t}}),t.domListeners=o,t.getController().on({afterSetCurrentUser:t.onCurrentUserChange,scope:t})}afterSetBio(e,t){let o=this.vdom;r.Z.getByFlag(o,"bio").value=e,this.vdom=o}afterSetEmail(e,t){let o=this.vdom;r.Z.getByFlag(o,"email").value=e,this.vdom=o}afterSetErrors(e=[],t){let o=this.vdom,l=r.Z.getByFlag(o,"errors");l.cn=[],l.removeDom=0===e.length,Object.entries(e).forEach((([e,t])=>{l.cn.push({tag:"li",html:e+" "+t.join(" and ")})})),this.vdom=o}afterSetImage(e,t){let o=this.vdom;r.Z.getByFlag(o,"image").value=e,this.vdom=o}afterSetUserName(e,t){let o=this.vdom;r.Z.getByFlag(o,"userName").value=e,this.vdom=o}onCurrentUserChange(e){e&&this.set({bio:e.bio,email:e.email,errors:[],image:e.image,userName:e.username})}onLogoutButtonClick(e){this.getController().logout()}onSubmitButtonClick(e){let t=this,o=t.vdom,l=r.Z.getByFlag(o,"bio"),a=r.Z.getByFlag(o,"email"),s=r.Z.getByFlag(o,"image"),n=r.Z.getByFlag(o,"password"),i=r.Z.getByFlag(o,"userName");Neo.main.DomAccess.getAttributes({id:[l.id,a.id,s.id,n.id,i.id],attributes:"value"}).then((e=>{t.getController().updateSettings({data:JSON.stringify({user:{bio:e[0].value,email:e[1].value,image:e[2].value,password:e[3].value,username:e[4].value}})}).then((e=>{const o=e.json.errors;o?t.errors=o:Neo.Main.setRoute({value:"/profile/"+e.json.user.username})}))}))}}Neo.applyClassConfig(a)}}]);