import{t as e}from"./axios-DHQprbt3.js";import{E as t,M as n,c as r,ct as i,d as a,i as o,t as s,u as c,w as l}from"./_plugin-vue_export-helper-Conii5fq.js";import{a as u,c as d}from"./runtime-dom.esm-bundler-CI28bPhn.js";var f={data(){return{positions:[],newPosition:{caption:``},editMode:!1,editId:null}},methods:{async fetchPositions(){this.positions=(await e.get(`/positions`)).data},async addPosition(){if(this.editMode)await e.put(`/positions/${this.editId}`,this.newPosition);else{let t=await e.post(`/positions`,this.newPosition);this.positions.push(t.data)}this.resetForm(),await this.fetchPositions()},async updatePosition(t){await e.put(`/positions/${t.id}`,t),this.fetchPositions()},async deletePosition(t){await e.delete(`/positions/${t}`),this.fetchPositions()},editPosition(e){this.newPosition={...e},this.editMode=!0,this.editId=e.id},resetForm(){this.newPosition={caption:``},this.editMode=!1,this.editId=null}},created(){this.fetchPositions()}},p={class:`position-management`},m=[`onClick`],h=[`onClick`];function g(e,s,f,g,_,v){return l(),a(`div`,p,[s[6]||=r(`h2`,null,`Verwalten der Rollen`,-1),r(`form`,{onSubmit:s[2]||=d((...e)=>v.addPosition&&v.addPosition(...e),[`prevent`])},[s[3]||=r(`label`,{for:`caption`},`Rollenbezeichnung:`,-1),n(r(`input`,{type:`text`,id:`caption`,"onUpdate:modelValue":s[0]||=e=>_.newPosition.caption=e,placeholder:`Rollenbezeichnung`,required:``},null,512),[[u,_.newPosition.caption]]),s[4]||=r(`button`,{type:`submit`},`Speichern`,-1),_.editMode?(l(),a(`button`,{key:0,type:`button`,onClick:s[1]||=(...e)=>v.resetForm&&v.resetForm(...e)},`Neue Rolle erstellen`)):c(``,!0)],32),r(`table`,null,[s[5]||=r(`thead`,null,[r(`tr`,null,[r(`th`,null,`Rollenbezeichnung`),r(`th`,null,`Bearbeiten`),r(`th`,null,`Löschen`)])],-1),r(`tbody`,null,[(l(!0),a(o,null,t(_.positions,e=>(l(),a(`tr`,{key:e.id},[r(`td`,null,i(e.caption),1),r(`td`,null,[r(`button`,{onClick:t=>v.editPosition(e)},`Bearbeiten`,8,m)]),r(`td`,null,[r(`button`,{onClick:t=>v.deletePosition(e.id)},`Löschen`,8,h)])]))),128))])])])}var _=s(f,[[`render`,g],[`__scopeId`,`data-v-8ae8d402`]]);export{_ as default};
//# sourceMappingURL=PositionManagement-aslFdHNq.js.map