refactor: redundante Funktion entfernen und Logik zur Verarbeitung ausgewählter Zeilen in UserRepresentationComponent konsolidieren

This commit is contained in:
Developer 02 2024-11-06 10:52:19 +01:00
parent 5df5cc555a
commit 296f29cf82

View File

@ -59,16 +59,18 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
@ViewChild("repGroups") repGroups!: GroupTableComponent; @ViewChild("repGroups") repGroups!: GroupTableComponent;
@ViewChild("userReps") userReps!: UserRepTableComponent; @ViewChild("userReps") userReps!: UserRepTableComponent;
userGroupOnSelectedRows = (rows: GuiSelectedRow[], isUser: boolean = true) => { userOnSelectedRows = (rows: GuiSelectedRow[]) => {
if (rows.length > 0) { if (rows.length > 0) {
if (isUser) {
this.useRepLabel = `Vertretungen von ${rows[0].source?.username}` this.useRepLabel = `Vertretungen von ${rows[0].source?.username}`
this.users.safelyUnselectAll(); this.users.safelyUnselectAll();
this.userReps.fetchData(rows[0].source?.id) this.userReps.fetchData(rows[0].source?.id)
this.slGroupId = undefined; this.slGroupId = undefined;
this.slUserId = rows[0].source?.id this.slUserId = rows[0].source?.id
} }
else { }
groupOnSelectedRows = (rows: GuiSelectedRow[]) => {
if (rows.length > 0) {
this.useRepLabel = `Vertretungen von ${rows[0].source?.name}` this.useRepLabel = `Vertretungen von ${rows[0].source?.name}`
this.groups.safelyUnselectAll(); this.groups.safelyUnselectAll();
this.userReps.fetchData(undefined, rows[0].source?.id) this.userReps.fetchData(undefined, rows[0].source?.id)
@ -76,15 +78,6 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
this.slGroupId = rows[0].source?.id this.slGroupId = rows[0].source?.id
} }
} }
}
userOnSelectedRows = (rows: GuiSelectedRow[]) => {
this.userGroupOnSelectedRows(rows, true);
}
groupOnSelectedRows = (rows: GuiSelectedRow[]) => {
this.userGroupOnSelectedRows(rows, false);
}
repUserOnSelectedRows = (rows: GuiSelectedRow[]) => { repUserOnSelectedRows = (rows: GuiSelectedRow[]) => {
if (rows.length == 0 && this.slRepUserId) { if (rows.length == 0 && this.slRepUserId) {