2 lines
2.7 KiB
JavaScript
2 lines
2.7 KiB
JavaScript
import{E as e,M as t,c as n,ct as r,d as i,i as a,t as o,u as s,w as c}from"./_plugin-vue_export-helper-Conii5fq.js";import{a as l,c as u,r as d}from"./runtime-dom.esm-bundler-CI28bPhn.js";import{r as f}from"./router-Bizgx2Ol.js";var p={name:`UserAdministration`,data(){return{users:[],currentUser:{name:``,email:``,password:``,active:!1},isCreating:!0}},computed:{formTitle(){return this.isCreating?`Benutzer erstellen`:`Benutzer bearbeiten`}},methods:{async fetchUsers(){try{this.users=(await f.get(`/users`)).data}catch(e){console.error(`Fehler beim Abrufen der Benutzer:`,e)}},async saveUser(){this.isCreating?await this.createUser():await this.updateUser(),this.resetForm(),this.fetchUsers()},async createUser(){try{await f.post(`/users`,this.currentUser)}catch(e){console.error(`Fehler beim Erstellen des Benutzers:`,e)}},async updateUser(){try{await f.put(`/users/${this.currentUser.id}`,this.currentUser)}catch(e){console.error(`Fehler beim Aktualisieren des Benutzers:`,e)}},editUser(e){this.currentUser={...e,password:``},this.isCreating=!1},resetForm(){this.currentUser={name:``,email:``,password:``,active:!1},this.isCreating=!0}},mounted(){this.fetchUsers()}},m={class:`user-administration`},h=[`required`],g={type:`submit`},_={key:1},v=[`onClick`];function y(o,f,p,y,b,x){return c(),i(`div`,m,[f[11]||=n(`h1`,null,`Benutzerverwaltung`,-1),n(`h2`,null,r(x.formTitle),1),n(`form`,{onSubmit:f[4]||=u((...e)=>x.saveUser&&x.saveUser(...e),[`prevent`])},[f[7]||=n(`label`,{for:`name`},`Name:`,-1),t(n(`input`,{id:`name`,"onUpdate:modelValue":f[0]||=e=>b.currentUser.name=e,required:``},null,512),[[l,b.currentUser.name]]),f[8]||=n(`label`,{for:`email`},`Email:`,-1),t(n(`input`,{id:`email`,"onUpdate:modelValue":f[1]||=e=>b.currentUser.email=e,type:`email`,required:``},null,512),[[l,b.currentUser.email]]),f[9]||=n(`label`,{for:`password`},`Passwort:`,-1),t(n(`input`,{id:`password`,"onUpdate:modelValue":f[2]||=e=>b.currentUser.password=e,type:`password`,required:b.isCreating},null,8,h),[[l,b.currentUser.password]]),n(`div`,null,[f[6]||=n(`label`,{for:`active`},`Aktiv:`,-1),t(n(`input`,{id:`active`,"onUpdate:modelValue":f[3]||=e=>b.currentUser.active=e,type:`checkbox`},null,512),[[d,b.currentUser.active]])]),n(`button`,g,r(b.isCreating?`Erstellen`:`Aktualisieren`),1)],32),b.isCreating?s(``,!0):(c(),i(`button`,{key:0,onClick:f[5]||=(...e)=>x.resetForm&&x.resetForm(...e)},`Zurück zu Benutzer erstellen`)),b.users.length?(c(),i(`div`,_,[f[10]||=n(`h2`,null,`Vorhandene Benutzer`,-1),n(`ul`,null,[(c(!0),i(a,null,e(b.users,e=>(c(),i(`li`,{key:e.id,onClick:t=>x.editUser(e)},r(e.name)+` (`+r(e.email)+`) `,9,v))),128))])])):s(``,!0)])}var b=o(p,[[`render`,y],[`__scopeId`,`data-v-b4cc64c6`]]);export{b as default};
|
|
//# sourceMappingURL=UserAdministration-qeIVIT38.js.map
|