diff --git a/framework/core/js/dist/common/components/EditUserModal.js b/framework/core/js/dist/common/components/EditUserModal.js index 26d168d115..abf6da6e05 100644 --- a/framework/core/js/dist/common/components/EditUserModal.js +++ b/framework/core/js/dist/common/components/EditUserModal.js @@ -1,2 +1,2 @@ -"use strict";(self.webpackChunkflarum_core=self.webpackChunkflarum_core||[]).push([[841],{4292:(s,i,t)=>{t.r(i),t.d(i,{default:()=>p});var e=t(7905),r=t(7465),a=t(899),n=t(8312),o=t(6697),d=t(7645),l=t(1552),u=t(4041),h=t(6458),c=t(6352);class p extends a.Z{constructor(){super(...arguments),(0,e.Z)(this,"username",void 0),(0,e.Z)(this,"email",void 0),(0,e.Z)(this,"isEmailConfirmed",void 0),(0,e.Z)(this,"setPassword",void 0),(0,e.Z)(this,"password",void 0),(0,e.Z)(this,"groups",{})}oninit(s){super.oninit(s);const i=this.attrs.user;this.username=(0,h.Z)(i.username()||""),this.email=(0,h.Z)(i.email()||""),this.isEmailConfirmed=(0,h.Z)(i.isEmailConfirmed()||!1),this.setPassword=(0,h.Z)(!1),this.password=(0,h.Z)(i.password()||"");const t=i.groups()||[];r.Z.store.all("groups").filter((s=>![d.Z.GUEST_ID,d.Z.MEMBER_ID].includes(s.id()))).forEach((s=>this.groups[s.id()]=(0,h.Z)(t.includes(s))))}className(){return"EditUserModal Modal--small"}title(){return r.Z.translator.trans("core.lib.edit_user.title")}content(){const s=this.fields().toArray();return m("div",{className:"Modal-body"},s.length>1?m(c.Z,null,this.fields().toArray()):r.Z.translator.trans("core.lib.edit_user.nothing_available"))}fields(){const s=new u.Z;return this.attrs.user.canEditCredentials()&&(s.add("username",m("div",{className:"Form-group"},m("label",null,r.Z.translator.trans("core.lib.edit_user.username_heading")),m("input",{className:"FormControl",placeholder:(0,l.Z)(r.Z.translator.trans("core.lib.edit_user.username_label")),bidi:this.username,disabled:this.nonAdminEditingAdmin()})),40),r.Z.session.user!==this.attrs.user&&(s.add("email",m("div",{className:"Form-group"},m("label",null,r.Z.translator.trans("core.lib.edit_user.email_heading")),m("div",null,m("input",{className:"FormControl",placeholder:(0,l.Z)(r.Z.translator.trans("core.lib.edit_user.email_label")),bidi:this.email,disabled:this.nonAdminEditingAdmin()})),!this.isEmailConfirmed()&&this.userIsAdmin(r.Z.session.user)&&m("div",null,m(n.Z,{className:"Button Button--block",loading:this.loading,onclick:this.activate.bind(this)},r.Z.translator.trans("core.lib.edit_user.activate_button")))),30),s.add("password",m("div",{className:"Form-group"},m("label",null,r.Z.translator.trans("core.lib.edit_user.password_heading")),m("div",null,m("label",{className:"checkbox"},m("input",{type:"checkbox",onchange:s=>{const i=s.target;this.setPassword(i.checked),m.redraw.sync(),i.checked&&this.$("[name=password]").select(),s.redraw=!1},disabled:this.nonAdminEditingAdmin()}),r.Z.translator.trans("core.lib.edit_user.set_password_label")),this.setPassword()&&m("input",{className:"FormControl",type:"password",name:"password",placeholder:(0,l.Z)(r.Z.translator.trans("core.lib.edit_user.password_label")),bidi:this.password,disabled:this.nonAdminEditingAdmin()}))),20))),this.attrs.user.canEditGroups()&&s.add("groups",m("div",{className:"Form-group EditUserModal-groups"},m("label",null,r.Z.translator.trans("core.lib.edit_user.groups_heading")),m("div",null,Object.keys(this.groups).map((s=>r.Z.store.getById("groups",s))).filter(Boolean).map((s=>s&&m("label",{className:"checkbox"},m("input",{type:"checkbox",bidi:this.groups[s.id()],disabled:s.id()===d.Z.ADMINISTRATOR_ID&&(this.attrs.user===r.Z.session.user||!this.userIsAdmin(r.Z.session.user))}),m(o.Z,{group:s,label:null})," ",s.nameSingular()))))),10),s.add("submit",m("div",{className:"Form-group Form-controls"},m(n.Z,{className:"Button Button--primary",type:"submit",loading:this.loading},r.Z.translator.trans("core.lib.edit_user.submit_button"))),-10),s}activate(){this.loading=!0;const s={username:this.username(),isEmailConfirmed:!0};this.attrs.user.save(s,{errorHandler:this.onerror.bind(this)}).then((()=>{this.isEmailConfirmed(!0),this.loading=!1,m.redraw()})).catch((()=>{this.loading=!1,m.redraw()}))}data(){const s={},i={};return this.attrs.user.canEditCredentials()&&!this.nonAdminEditingAdmin()&&(s.username=this.username(),r.Z.session.user!==this.attrs.user&&(s.email=this.email()),this.setPassword()&&(s.password=this.password())),this.attrs.user.canEditGroups()&&(i.groups=Object.keys(this.groups).filter((s=>this.groups[s]())).map((s=>r.Z.store.getById("groups",s))).filter((s=>s instanceof d.Z))),s.relationships=i,s}onsubmit(s){s.preventDefault(),this.loading=!0,this.attrs.user.save(this.data(),{errorHandler:this.onerror.bind(this)}).then(this.hide.bind(this)).catch((()=>{this.loading=!1,m.redraw()}))}nonAdminEditingAdmin(){return this.userIsAdmin(this.attrs.user)&&!this.userIsAdmin(r.Z.session.user)}userIsAdmin(s){return!!((null==s?void 0:s.groups())||[]).some((s=>(null==s?void 0:s.id())===d.Z.ADMINISTRATOR_ID))}}flarum.reg.add("core","common/components/EditUserModal",p)}}]); +"use strict";(self.webpackChunkflarum_core=self.webpackChunkflarum_core||[]).push([[841],{4292:(s,t,i)=>{i.r(t),i.d(t,{default:()=>p});var e=i(7905),r=i(7465),a=i(899),n=i(8312),o=i(6697),d=i(7645),l=i(1552),u=i(4041),h=i(6458),c=i(6352);class p extends a.Z{constructor(){super(...arguments),(0,e.Z)(this,"username",void 0),(0,e.Z)(this,"email",void 0),(0,e.Z)(this,"isEmailConfirmed",void 0),(0,e.Z)(this,"setPassword",void 0),(0,e.Z)(this,"password",void 0),(0,e.Z)(this,"groups",{})}oninit(s){super.oninit(s);const t=this.attrs.user;this.username=(0,h.Z)(t.username()||""),this.email=(0,h.Z)(t.email()||""),this.isEmailConfirmed=(0,h.Z)(t.isEmailConfirmed()||!1),this.setPassword=(0,h.Z)(!1),this.password=(0,h.Z)(t.password()||"");const i=t.groups()||[];r.Z.store.all("groups").filter((s=>![d.Z.GUEST_ID,d.Z.MEMBER_ID].includes(s.id()))).forEach((s=>this.groups[s.id()]=(0,h.Z)(i.includes(s))))}className(){return"EditUserModal Modal--small"}title(){return r.Z.translator.trans("core.lib.edit_user.title")}content(){const s=this.fields().toArray();return m("div",{className:"Modal-body"},s.length>1?m(c.Z,null,this.fields().toArray()):r.Z.translator.trans("core.lib.edit_user.nothing_available"))}fields(){const s=new u.Z;return this.attrs.user.canEditCredentials()&&(s.add("username",m("div",{className:"Form-group"},m("label",null,r.Z.translator.trans("core.lib.edit_user.username_heading")),m("input",{className:"FormControl",placeholder:(0,l.Z)(r.Z.translator.trans("core.lib.edit_user.username_label")),bidi:this.username,disabled:this.nonAdminEditingAdmin()})),40),r.Z.session.user!==this.attrs.user&&(s.add("email",m("div",{className:"Form-group"},m("label",null,r.Z.translator.trans("core.lib.edit_user.email_heading")),m("input",{className:"FormControl",placeholder:(0,l.Z)(r.Z.translator.trans("core.lib.edit_user.email_label")),bidi:this.email,disabled:this.nonAdminEditingAdmin()}),!this.isEmailConfirmed()&&this.userIsAdmin(r.Z.session.user)&&m(n.Z,{className:"Button Button--block",loading:this.loading,onclick:this.activate.bind(this)},r.Z.translator.trans("core.lib.edit_user.activate_button"))),30),s.add("password",m("div",{className:"Form-group"},m("label",null,r.Z.translator.trans("core.lib.edit_user.password_heading")),m("div",null,m("label",{className:"checkbox"},m("input",{type:"checkbox",onchange:s=>{const t=s.target;this.setPassword(t.checked),m.redraw.sync(),t.checked&&this.$("[name=password]").select(),s.redraw=!1},disabled:this.nonAdminEditingAdmin()}),r.Z.translator.trans("core.lib.edit_user.set_password_label"))),this.setPassword()&&m("input",{className:"FormControl",type:"password",name:"password",placeholder:(0,l.Z)(r.Z.translator.trans("core.lib.edit_user.password_label")),bidi:this.password,disabled:this.nonAdminEditingAdmin()})),20))),this.attrs.user.canEditGroups()&&s.add("groups",m("div",{className:"Form-group EditUserModal-groups"},m("label",null,r.Z.translator.trans("core.lib.edit_user.groups_heading")),m("div",null,Object.keys(this.groups).map((s=>r.Z.store.getById("groups",s))).filter(Boolean).map((s=>s&&m("label",{className:"checkbox"},m("input",{type:"checkbox",bidi:this.groups[s.id()],disabled:s.id()===d.Z.ADMINISTRATOR_ID&&(this.attrs.user===r.Z.session.user||!this.userIsAdmin(r.Z.session.user))}),m(o.Z,{group:s,label:null})," ",s.nameSingular()))))),10),s.add("submit",m("div",{className:"Form-group Form-controls"},m(n.Z,{className:"Button Button--primary",type:"submit",loading:this.loading},r.Z.translator.trans("core.lib.edit_user.submit_button"))),-10),s}activate(){this.loading=!0;const s={username:this.username(),isEmailConfirmed:!0};this.attrs.user.save(s,{errorHandler:this.onerror.bind(this)}).then((()=>{this.isEmailConfirmed(!0),this.loading=!1,m.redraw()})).catch((()=>{this.loading=!1,m.redraw()}))}data(){const s={},t={};return this.attrs.user.canEditCredentials()&&!this.nonAdminEditingAdmin()&&(s.username=this.username(),r.Z.session.user!==this.attrs.user&&(s.email=this.email()),this.setPassword()&&(s.password=this.password())),this.attrs.user.canEditGroups()&&(t.groups=Object.keys(this.groups).filter((s=>this.groups[s]())).map((s=>r.Z.store.getById("groups",s))).filter((s=>s instanceof d.Z))),s.relationships=t,s}onsubmit(s){s.preventDefault(),this.loading=!0,this.attrs.user.save(this.data(),{errorHandler:this.onerror.bind(this)}).then(this.hide.bind(this)).catch((()=>{this.loading=!1,m.redraw()}))}nonAdminEditingAdmin(){return this.userIsAdmin(this.attrs.user)&&!this.userIsAdmin(r.Z.session.user)}userIsAdmin(s){return!!((null==s?void 0:s.groups())||[]).some((s=>(null==s?void 0:s.id())===d.Z.ADMINISTRATOR_ID))}}flarum.reg.add("core","common/components/EditUserModal",p)}}]); //# sourceMappingURL=EditUserModal.js.map \ No newline at end of file diff --git a/framework/core/js/dist/common/components/EditUserModal.js.map b/framework/core/js/dist/common/components/EditUserModal.js.map index 1571a2859d..049690d77a 100644 --- a/framework/core/js/dist/common/components/EditUserModal.js.map +++ b/framework/core/js/dist/common/components/EditUserModal.js.map @@ -1 +1 @@ -{"version":3,"file":"common/components/EditUserModal.js","mappings":"8OAUe,MAAMA,UAAsB,IACzCC,cACEC,SAASC,YACT,OAAgBC,KAAM,gBAAY,IAClC,OAAgBA,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ClC1D,KAAKgC,SAAU,EACfV,EAAEmB,QAAQ,GAEd,CACAX,uBACE,OAAO9B,KAAK+B,YAAY/B,KAAKI,MAAMD,QAAUH,KAAK+B,YAAY,iBAChE,CAKAA,YAAY5B,GACV,UAAmB,MAARA,OAAe,EAASA,EAAKQ,WAAa,IAAIqD,MAAKJ,IAAW,MAALA,OAAY,EAASA,EAAE7C,QAAU,sBACvG,EAEFkD,OAAOC,IAAIxC,IAAI,OAAQ,kCAAmC9B,E","sources":["webpack://@flarum/core/./src/common/components/EditUserModal.tsx"],"sourcesContent":["import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport app from '../../common/app';\nimport FormModal from '../../common/components/FormModal';\nimport Button from './Button';\nimport GroupBadge from './GroupBadge';\nimport Group from '../models/Group';\nimport extractText from '../utils/extractText';\nimport ItemList from '../utils/ItemList';\nimport Stream from '../utils/Stream';\nimport Form from './Form';\nexport default class EditUserModal extends FormModal {\n constructor() {\n super(...arguments);\n _defineProperty(this, \"username\", void 0);\n _defineProperty(this, \"email\", void 0);\n _defineProperty(this, \"isEmailConfirmed\", void 0);\n _defineProperty(this, \"setPassword\", void 0);\n _defineProperty(this, \"password\", void 0);\n _defineProperty(this, \"groups\", {});\n }\n oninit(vnode) {\n super.oninit(vnode);\n const user = this.attrs.user;\n this.username = Stream(user.username() || '');\n this.email = Stream(user.email() || '');\n this.isEmailConfirmed = Stream(user.isEmailConfirmed() || false);\n this.setPassword = Stream(false);\n this.password = Stream(user.password() || '');\n const userGroups = user.groups() || [];\n app.store.all('groups').filter(group => ![Group.GUEST_ID, Group.MEMBER_ID].includes(group.id())).forEach(group => this.groups[group.id()] = Stream(userGroups.includes(group)));\n }\n className() {\n return 'EditUserModal Modal--small';\n }\n title() {\n return app.translator.trans('core.lib.edit_user.title');\n }\n content() {\n const fields = this.fields().toArray();\n return m(\"div\", {\n className: \"Modal-body\"\n }, fields.length > 1 ? m(Form, null, this.fields().toArray()) : app.translator.trans('core.lib.edit_user.nothing_available'));\n }\n fields() {\n const items = new ItemList();\n if (this.attrs.user.canEditCredentials()) {\n items.add('username', m(\"div\", {\n className: \"Form-group\"\n }, m(\"label\", null, app.translator.trans('core.lib.edit_user.username_heading')), m(\"input\", {\n className: \"FormControl\",\n placeholder: extractText(app.translator.trans('core.lib.edit_user.username_label')),\n bidi: this.username,\n disabled: this.nonAdminEditingAdmin()\n })), 40);\n if (app.session.user !== this.attrs.user) {\n items.add('email', m(\"div\", {\n className: \"Form-group\"\n }, m(\"label\", null, app.translator.trans('core.lib.edit_user.email_heading')), m(\"div\", null, m(\"input\", {\n className: \"FormControl\",\n placeholder: extractText(app.translator.trans('core.lib.edit_user.email_label')),\n bidi: this.email,\n disabled: this.nonAdminEditingAdmin()\n })), !this.isEmailConfirmed() && this.userIsAdmin(app.session.user) && m(\"div\", null, m(Button, {\n className: \"Button Button--block\",\n loading: this.loading,\n onclick: this.activate.bind(this)\n }, app.translator.trans('core.lib.edit_user.activate_button')))), 30);\n items.add('password', m(\"div\", {\n className: \"Form-group\"\n }, m(\"label\", null, app.translator.trans('core.lib.edit_user.password_heading')), m(\"div\", null, m(\"label\", {\n className: \"checkbox\"\n }, m(\"input\", {\n type: \"checkbox\",\n onchange: e => {\n const target = e.target;\n this.setPassword(target.checked);\n m.redraw.sync();\n if (target.checked) this.$('[name=password]').select();\n e.redraw = false;\n },\n disabled: this.nonAdminEditingAdmin()\n }), app.translator.trans('core.lib.edit_user.set_password_label')), this.setPassword() && m(\"input\", {\n className: \"FormControl\",\n type: \"password\",\n name: \"password\",\n placeholder: extractText(app.translator.trans('core.lib.edit_user.password_label')),\n bidi: this.password,\n disabled: this.nonAdminEditingAdmin()\n }))), 20);\n }\n }\n if (this.attrs.user.canEditGroups()) {\n items.add('groups', m(\"div\", {\n className: \"Form-group EditUserModal-groups\"\n }, m(\"label\", null, app.translator.trans('core.lib.edit_user.groups_heading')), m(\"div\", null, Object.keys(this.groups).map(id => app.store.getById('groups', id)).filter(Boolean).map(group =>\n // Necessary because filter(Boolean) doesn't narrow out falsy values.\n group && m(\"label\", {\n className: \"checkbox\"\n }, m(\"input\", {\n type: \"checkbox\",\n bidi: this.groups[group.id()],\n disabled: group.id() === Group.ADMINISTRATOR_ID && (this.attrs.user === app.session.user || !this.userIsAdmin(app.session.user))\n }), m(GroupBadge, {\n group: group,\n label: null\n }), \" \", group.nameSingular())))), 10);\n }\n items.add('submit', m(\"div\", {\n className: \"Form-group Form-controls\"\n }, m(Button, {\n className: \"Button Button--primary\",\n type: \"submit\",\n loading: this.loading\n }, app.translator.trans('core.lib.edit_user.submit_button'))), -10);\n return items;\n }\n activate() {\n this.loading = true;\n const data = {\n username: this.username(),\n isEmailConfirmed: true\n };\n this.attrs.user.save(data, {\n errorHandler: this.onerror.bind(this)\n }).then(() => {\n this.isEmailConfirmed(true);\n this.loading = false;\n m.redraw();\n }).catch(() => {\n this.loading = false;\n m.redraw();\n });\n }\n data() {\n const data = {};\n const relationships = {};\n if (this.attrs.user.canEditCredentials() && !this.nonAdminEditingAdmin()) {\n data.username = this.username();\n if (app.session.user !== this.attrs.user) {\n data.email = this.email();\n }\n if (this.setPassword()) {\n data.password = this.password();\n }\n }\n if (this.attrs.user.canEditGroups()) {\n relationships.groups = Object.keys(this.groups).filter(id => this.groups[id]()).map(id => app.store.getById('groups', id)).filter(g => g instanceof Group);\n }\n data.relationships = relationships;\n return data;\n }\n onsubmit(e) {\n e.preventDefault();\n this.loading = true;\n this.attrs.user.save(this.data(), {\n errorHandler: this.onerror.bind(this)\n }).then(this.hide.bind(this)).catch(() => {\n this.loading = false;\n m.redraw();\n });\n }\n nonAdminEditingAdmin() {\n return this.userIsAdmin(this.attrs.user) && !this.userIsAdmin(app.session.user);\n }\n\n /**\n * @internal\n */\n userIsAdmin(user) {\n return !!((user == null ? void 0 : user.groups()) || []).some(g => (g == null ? void 0 : g.id()) === Group.ADMINISTRATOR_ID);\n }\n}\nflarum.reg.add('core', 'common/components/EditUserModal', EditUserModal);"],"names":["EditUserModal","constructor","super","arguments","this","oninit","vnode","user","attrs","username","email","isEmailConfirmed","setPassword","password","userGroups","groups","filter","group","includes","id","forEach","className","title","content","fields","toArray","m","length","items","canEditCredentials","add","placeholder","bidi","disabled","nonAdminEditingAdmin","userIsAdmin","loading","onclick","activate","bind","type","onchange","e","target","checked","redraw","sync","$","select","name","canEditGroups","Object","keys","map","Boolean","label","nameSingular","data","save","errorHandler","onerror","then","catch","relationships","g","onsubmit","preventDefault","hide","some","flarum","reg"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"common/components/EditUserModal.js","mappings":"8OAUe,MAAMA,UAAsB,IACzCC,cACEC,SAASC,YACT,OAAgBC,KAAM,gBAAY,IAClC,OAAgBA,KAAM,aAAS,IAC/B,OAAgBA,KAAM,wBAAoB,IAC1C,OAAgBA,KAAM,mBAAe,IACrC,OAAgBA,KAAM,gBAAY,IAClC,OAAgBA,KAAM,SAAU,CAAC,EACnC,CACAC,OAAOC,GACLJ,MAAMG,OAAOC,GACb,MAAMC,EAAOH,KAAKI,MAAMD,KACxBH,KAAKK,UAAW,OAAOF,EAAKE,YAAc,IAC1CL,KAAKM,OAAQ,OAAOH,EAAKG,SAAW,IACpCN,KAAKO,kBAAmB,OAAOJ,EAAKI,qBAAsB,GAC1DP,KAAKQ,aAAc,QAAO,GAC1BR,KAAKS,UAAW,OAAON,EAAKM,YAAc,IAC1C,MAAMC,EAAaP,EAAKQ,UAAY,GACpC,cAAc,UAAUC,QAAOC,IAAU,CAAC,aAAgB,eAAiBC,SAASD,EAAME,QAAOC,SAAQH,GAASb,KAAKW,OAAOE,EAAME,OAAQ,OAAOL,EAAWI,SAASD,KACzK,CACAI,YACE,MAAO,4BACT,CACAC,QACE,OAAO,qBAAqB,2BAC9B,CACAC,UACE,MAAMC,EAASpB,KAAKoB,SAASC,UAC7B,OAAOC,EAAE,MAAO,CACdL,UAAW,cACVG,EAAOG,OAAS,EAAID,EAAE,IAAM,KAAMtB,KAAKoB,SAASC,WAAa,qBAAq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AAMD,KAAK2C,kBAClBa,EAAchD,OAASoC,OAAOC,KAAKhD,KAAKW,QAAQC,QAAOG,GAAMf,KAAKW,OAAOI,OAAOkC,KAAIlC,GAAM,kBAAkB,SAAUA,KAAKH,QAAOgD,GAAKA,aAAa,OAEtJP,EAAKM,cAAgBA,EACdN,CACT,CACAQ,SAASvB,GACPA,EAAEwB,iBACF9D,KAAKgC,SAAU,EACfhC,KAAKI,MAAMD,KAAKmD,KAAKtD,KAAKqD,OAAQ,CAChCE,aAAcvD,KAAKwD,QAAQrB,KAAKnC,QAC/ByD,KAAKzD,KAAK+D,KAAK5B,KAAKnC,OAAO0D,OAAM,KAClC1D,KAAKgC,SAAU,EACfV,EAAEmB,QAAQ,GAEd,CACAX,uBACE,OAAO9B,KAAK+B,YAAY/B,KAAKI,MAAMD,QAAUH,KAAK+B,YAAY,iBAChE,CAKAA,YAAY5B,GACV,UAAmB,MAARA,OAAe,EAASA,EAAKQ,WAAa,IAAIqD,MAAKJ,IAAW,MAALA,OAAY,EAASA,EAAE7C,QAAU,sBACvG,EAEFkD,OAAOC,IAAIxC,IAAI,OAAQ,kCAAmC9B,E","sources":["webpack://@flarum/core/./src/common/components/EditUserModal.tsx"],"sourcesContent":["import _defineProperty from \"@babel/runtime/helpers/esm/defineProperty\";\nimport app from '../../common/app';\nimport FormModal from '../../common/components/FormModal';\nimport Button from './Button';\nimport GroupBadge from './GroupBadge';\nimport Group from '../models/Group';\nimport extractText from '../utils/extractText';\nimport ItemList from '../utils/ItemList';\nimport Stream from '../utils/Stream';\nimport Form from './Form';\nexport default class EditUserModal extends FormModal {\n constructor() {\n super(...arguments);\n _defineProperty(this, \"username\", void 0);\n _defineProperty(this, \"email\", void 0);\n _defineProperty(this, \"isEmailConfirmed\", void 0);\n _defineProperty(this, \"setPassword\", void 0);\n _defineProperty(this, \"password\", void 0);\n _defineProperty(this, \"groups\", {});\n }\n oninit(vnode) {\n super.oninit(vnode);\n const user = this.attrs.user;\n this.username = Stream(user.username() || '');\n this.email = Stream(user.email() || '');\n this.isEmailConfirmed = Stream(user.isEmailConfirmed() || false);\n this.setPassword = Stream(false);\n this.password = Stream(user.password() || '');\n const userGroups = user.groups() || [];\n app.store.all('groups').filter(group => ![Group.GUEST_ID, Group.MEMBER_ID].includes(group.id())).forEach(group => this.groups[group.id()] = Stream(userGroups.includes(group)));\n }\n className() {\n return 'EditUserModal Modal--small';\n }\n title() {\n return app.translator.trans('core.lib.edit_user.title');\n }\n content() {\n const fields = this.fields().toArray();\n return m(\"div\", {\n className: \"Modal-body\"\n }, fields.length > 1 ? m(Form, null, this.fields().toArray()) : app.translator.trans('core.lib.edit_user.nothing_available'));\n }\n fields() {\n const items = new ItemList();\n if (this.attrs.user.canEditCredentials()) {\n items.add('username', m(\"div\", {\n className: \"Form-group\"\n }, m(\"label\", null, app.translator.trans('core.lib.edit_user.username_heading')), m(\"input\", {\n className: \"FormControl\",\n placeholder: extractText(app.translator.trans('core.lib.edit_user.username_label')),\n bidi: this.username,\n disabled: this.nonAdminEditingAdmin()\n })), 40);\n if (app.session.user !== this.attrs.user) {\n items.add('email', m(\"div\", {\n className: \"Form-group\"\n }, m(\"label\", null, app.translator.trans('core.lib.edit_user.email_heading')), m(\"input\", {\n className: \"FormControl\",\n placeholder: extractText(app.translator.trans('core.lib.edit_user.email_label')),\n bidi: this.email,\n disabled: this.nonAdminEditingAdmin()\n }), !this.isEmailConfirmed() && this.userIsAdmin(app.session.user) && m(Button, {\n className: \"Button Button--block\",\n loading: this.loading,\n onclick: this.activate.bind(this)\n }, app.translator.trans('core.lib.edit_user.activate_button'))), 30);\n items.add('password', m(\"div\", {\n className: \"Form-group\"\n }, m(\"label\", null, app.translator.trans('core.lib.edit_user.password_heading')), m(\"div\", null, m(\"label\", {\n className: \"checkbox\"\n }, m(\"input\", {\n type: \"checkbox\",\n onchange: e => {\n const target = e.target;\n this.setPassword(target.checked);\n m.redraw.sync();\n if (target.checked) this.$('[name=password]').select();\n e.redraw = false;\n },\n disabled: this.nonAdminEditingAdmin()\n }), app.translator.trans('core.lib.edit_user.set_password_label'))), this.setPassword() && m(\"input\", {\n className: \"FormControl\",\n type: \"password\",\n name: \"password\",\n placeholder: extractText(app.translator.trans('core.lib.edit_user.password_label')),\n bidi: this.password,\n disabled: this.nonAdminEditingAdmin()\n })), 20);\n }\n }\n if (this.attrs.user.canEditGroups()) {\n items.add('groups', m(\"div\", {\n className: \"Form-group EditUserModal-groups\"\n }, m(\"label\", null, app.translator.trans('core.lib.edit_user.groups_heading')), m(\"div\", null, Object.keys(this.groups).map(id => app.store.getById('groups', id)).filter(Boolean).map(group =>\n // Necessary because filter(Boolean) doesn't narrow out falsy values.\n group && m(\"label\", {\n className: \"checkbox\"\n }, m(\"input\", {\n type: \"checkbox\",\n bidi: this.groups[group.id()],\n disabled: group.id() === Group.ADMINISTRATOR_ID && (this.attrs.user === app.session.user || !this.userIsAdmin(app.session.user))\n }), m(GroupBadge, {\n group: group,\n label: null\n }), \" \", group.nameSingular())))), 10);\n }\n items.add('submit', m(\"div\", {\n className: \"Form-group Form-controls\"\n }, m(Button, {\n className: \"Button Button--primary\",\n type: \"submit\",\n loading: this.loading\n }, app.translator.trans('core.lib.edit_user.submit_button'))), -10);\n return items;\n }\n activate() {\n this.loading = true;\n const data = {\n username: this.username(),\n isEmailConfirmed: true\n };\n this.attrs.user.save(data, {\n errorHandler: this.onerror.bind(this)\n }).then(() => {\n this.isEmailConfirmed(true);\n this.loading = false;\n m.redraw();\n }).catch(() => {\n this.loading = false;\n m.redraw();\n });\n }\n data() {\n const data = {};\n const relationships = {};\n if (this.attrs.user.canEditCredentials() && !this.nonAdminEditingAdmin()) {\n data.username = this.username();\n if (app.session.user !== this.attrs.user) {\n data.email = this.email();\n }\n if (this.setPassword()) {\n data.password = this.password();\n }\n }\n if (this.attrs.user.canEditGroups()) {\n relationships.groups = Object.keys(this.groups).filter(id => this.groups[id]()).map(id => app.store.getById('groups', id)).filter(g => g instanceof Group);\n }\n data.relationships = relationships;\n return data;\n }\n onsubmit(e) {\n e.preventDefault();\n this.loading = true;\n this.attrs.user.save(this.data(), {\n errorHandler: this.onerror.bind(this)\n }).then(this.hide.bind(this)).catch(() => {\n this.loading = false;\n m.redraw();\n });\n }\n nonAdminEditingAdmin() {\n return this.userIsAdmin(this.attrs.user) && !this.userIsAdmin(app.session.user);\n }\n\n /**\n * @internal\n */\n userIsAdmin(user) {\n return !!((user == null ? void 0 : user.groups()) || []).some(g => (g == null ? void 0 : g.id()) === Group.ADMINISTRATOR_ID);\n }\n}\nflarum.reg.add('core', 'common/components/EditUserModal', EditUserModal);"],"names":["EditUserModal","constructor","super","arguments","this","oninit","vnode","user","attrs","username","email","isEmailConfirmed","setPassword","password","userGroups","groups","filter","group","includes","id","forEach","className","title","content","fields","toArray","m","length","items","canEditCredentials","add","placeholder","bidi","disabled","nonAdminEditingAdmin","userIsAdmin","loading","onclick","activate","bind","type","onchange","e","target","checked","redraw","sync","$","select","name","canEditGroups","Object","keys","map","Boolean","label","nameSingular","data","save","errorHandler","onerror","then","catch","relationships","g","onsubmit","preventDefault","hide","some","flarum","reg"],"sourceRoot":""} \ No newline at end of file