Workplace Widget 5.10

This commit is contained in:
chris
2026-10-27 18:06:55 +00:00
parent 90af5db9ad
commit bf238f0d0a
23 changed files with 212 additions and 76 deletions

View File

@@ -2,7 +2,7 @@
import {ref,onMounted,computed} from 'vue';
import {api} from './api';
interface Role {key:string;description:string}
interface Person {name:string;vorname:string;persId:string}
interface Person {name:string;vorname:string;persId:string;bdeUserId?:string}
interface Assignments {roles:string[];groups:string[];logins:string[]}
const emit=defineEmits<{close:[]}>();
const people=ref<Person[]>([]),search=ref(''), selected=ref<Person|null>(null);
@@ -13,8 +13,8 @@ const error=ref(''),notice=ref(''),busy=ref(false);
const name=computed(()=>selected.value?`${selected.value.vorname} ${selected.value.name} · ${selected.value.persId}`:'Keine Person ausgewählt');
async function reload(){roles.value=await api<Role[]>('/admin/roles');groups.value=await api<Role[]>('/admin/groups');}
async function loadPeople(){try{people.value=await api<Person[]>('/admin/people?q='+encodeURIComponent(search.value));}catch(e){error.value=String(e);}}
async function selectPerson(p:Person){selected.value=p;login.value='';try{const result=await api<Assignments>('/admin/people/'+encodeURIComponent(p.persId)+'/assignments');assignedRoles.value=result.roles;assignedGroups.value=result.groups;logins.value=result.logins;}catch(e){error.value=String(e);}}
async function savePerson(){if(!selected.value)return;busy.value=true;try{await api('/admin/people/'+encodeURIComponent(selected.value.persId)+'/assignments','PUT',{roles:assignedRoles.value,groups:assignedGroups.value});notice.value='Zuweisung gespeichert';error.value='';}catch(e){error.value=String(e);}finally{busy.value=false;}}
async function selectPerson(p:Person){selected.value=p;login.value=p.bdeUserId||'';try{const result=await api<Assignments>('/admin/people/'+encodeURIComponent(p.persId)+'/assignments');assignedRoles.value=result.roles;assignedGroups.value=result.groups;logins.value=result.logins;}catch(e){error.value=String(e);}}
async function savePerson(){if(!selected.value)return;busy.value=true;try{await api('/admin/people/'+encodeURIComponent(selected.value.persId)+'/assignments','PUT',{roles:assignedRoles.value,groups:assignedGroups.value});notice.value='Zuweisung gespeichert; BDE_USERID zugeordnet';error.value='';await selectPerson(selected.value);}catch(e){error.value=String(e);}finally{busy.value=false;}}
async function mapLogin(){if(!selected.value||!login.value.trim())return;try{await api('/admin/logins/'+encodeURIComponent(login.value.trim())+'/person','PUT',{persId:selected.value.persId});notice.value='IMSAPI-Login wurde mit PERS_ID verknüpft';await selectPerson(selected.value);}catch(e){error.value=String(e);}}
async function addRole(){if(!newRole.value.trim())return;try{await api('/admin/roles','POST',{key:newRole.value.trim(),description:newRole.value.trim()});newRole.value='';await reload();}catch(e){error.value=String(e);}}
async function addGroup(){if(!newGroup.value.trim())return;try{await api('/admin/groups','POST',{key:newGroup.value.trim(),description:newGroup.value.trim()});newGroup.value='';await reload();}catch(e){error.value=String(e);}}
@@ -30,9 +30,9 @@ onMounted(async()=>{try{await reload();await loadPeople();}catch(e){error.value=
<div class="role-admin-columns">
<section class="role-pane">
<h3>1. Personalstamm · dsMesMiiNJTA</h3>
<form @submit.prevent="loadPeople" class="role-search"><input v-model="search" placeholder="Name oder Vorname suchen"/><button class="subtle-button">Suchen</button></form>
<div class="person-rows"><button v-for="p in people" :key="p.persId" :class="['person-row',{selected:selected?.persId===p.persId}]" @click="selectPerson(p)"><strong>{{p.name}}, {{p.vorname}}</strong><small>PERS_ID: {{p.persId}}</small></button></div>
<small>Abfrage: SELECT NAME, VORNAME, PERS_ID FROM BDE.PERS_STAMM. Maximal 60 Treffer.</small>
<form @submit.prevent="loadPeople" class="role-search"><input v-model="search" placeholder="Name, Vorname, PERS_ID oder BDE_USERID suchen"/><button class="subtle-button">Suchen</button></form>
<div class="person-rows"><button v-for="p in people" :key="p.persId" :class="['person-row',{selected:selected?.persId===p.persId}]" @click="selectPerson(p)"><strong>{{p.name}}, {{p.vorname}}</strong><small>PERS_ID: {{p.persId}} · BDE_USERID: {{p.bdeUserId||'—'}}</small></button></div>
<small>Abfrage: SELECT NAME, VORNAME, PERS_ID, BDE_USERID FROM BDE.PERS_STAMM. Maximal 60 Treffer.</small>
</section>
<section class="role-pane">
<h3>2. Rollenzuordnung</h3><p class="muted">{{name}}</p>
@@ -40,7 +40,7 @@ onMounted(async()=>{try{await reload();await loadPeople();}catch(e){error.value=
<h4>Direkte Rollen</h4><label class="role-check" v-for="r in roles" :key="r.key"><input type="checkbox" :checked="assignedRoles.includes(r.key)" @change="toggle(assignedRoles,r.key)"/><span>{{r.key}}<small>{{r.description}}</small></span></label>
<h4>Gruppenmitgliedschaft</h4><label class="role-check" v-for="g in groups" :key="g.key"><input type="checkbox" :checked="assignedGroups.includes(g.key)" @change="toggle(assignedGroups,g.key)"/><span>{{g.key}}<small>{{g.description}}</small></span></label>
<button class="primary-button" :disabled="busy" @click="savePerson">Zuweisung speichern</button>
<h4>IMSAPI-Login zuordnen</h4><p class="muted">Bekannte Logins: {{logins.join(', ')||'Keine'}}</p><div class="role-search"><input v-model="login" placeholder="IMSAPI Benutzername"/><button class="subtle-button" @click="mapLogin">Verknüpfen</button></div>
<h4>IMSAPI-Login zuordnen</h4><p class="muted">BDE_USERID aus Personalstamm: {{ selected.bdeUserId||'Nicht hinterlegt' }} (automatische Verknüpfung beim Speichern)</p><p class="muted">Bekannte Logins: {{logins.join(', ')||'Keine'}}</p><div class="role-search"><input v-model="login" placeholder="IMSAPI Benutzername"/><button class="subtle-button" @click="mapLogin">Verknüpfen</button></div>
</template><p v-else>Person auswählen, um Rollen zuzuordnen.</p>
</section>
<section class="role-pane">