fix(user-rep.component): geordnete Assgiment-Ereignisse und -Anfragen
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<app-user-table #users [onSelectedRows]="userOnSelectedRows"></app-user-table>
|
||||
</mat-tab>
|
||||
<mat-tab label="Gruppe">
|
||||
<app-group-table #rightGroups [columns]="groupColumns" [onSelectedRows]="groupOnSelectedRows"></app-group-table>
|
||||
<app-group-table #groups [columns]="groupColumns" [onSelectedRows]="groupOnSelectedRows"></app-group-table>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
</div>
|
||||
|
||||
@@ -22,11 +22,11 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
|
||||
useRepLabel: string = "";
|
||||
groupColumns: Array<GuiColumn>;
|
||||
groupRepCols: Array<GuiColumn>;
|
||||
slUserId: null | number = null;
|
||||
slRepUserId: null | number = null;
|
||||
slRepGroupId: null | number = null;
|
||||
slRightGroupId: null | number = null;
|
||||
slUserRepId: null | number = null;
|
||||
slUserId?: number;
|
||||
slGroupId?: number;
|
||||
slRepUserId?: number;
|
||||
slRepGroupId?: number;
|
||||
slUserRepId?: number;
|
||||
|
||||
initWithoutData = () => { }
|
||||
|
||||
@@ -61,17 +61,19 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
|
||||
|
||||
userGroupOnSelectedRows = (rows: GuiSelectedRow[], isUser: boolean = true) => {
|
||||
if (rows.length > 0) {
|
||||
this.users.safelyUnselectAll();
|
||||
|
||||
if (isUser) {
|
||||
this.useRepLabel = `Vertretungen von ${rows[0].source?.username}`
|
||||
this.users.safelyUnselectAll();
|
||||
this.userReps.fetchData(rows[0].source?.id)
|
||||
this.slGroupId = undefined;
|
||||
this.slUserId = rows[0].source?.id
|
||||
}
|
||||
else {
|
||||
this.useRepLabel = `Vertretungen von ${rows[0].source?.name}`
|
||||
this.groups.safelyUnselectAll();
|
||||
this.userReps.fetchData(undefined, rows[0].source?.id)
|
||||
this.slUserId = rows[0].source?.id
|
||||
this.slUserId = undefined;
|
||||
this.slGroupId = rows[0].source?.id
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,11 +88,11 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
|
||||
|
||||
repUserOnSelectedRows = (rows: GuiSelectedRow[]) => {
|
||||
if (rows.length == 0 && this.slRepUserId) {
|
||||
if (!this.slUserId) {
|
||||
if (!this.slUserId && !this.slGroupId) {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Oops...",
|
||||
text: "Bitte wählen Sie den Benutzer!",
|
||||
text: "Bitte wählen Sie den Benutzer oder die Gruppe!",
|
||||
});
|
||||
}
|
||||
else if (!this.slRepUserId) {
|
||||
@@ -103,15 +105,20 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
|
||||
else {
|
||||
var newUserRep: UserRep = {
|
||||
userId: this.slUserId,
|
||||
groupId: this.slGroupId,
|
||||
repUserId: this.slRepUserId,
|
||||
addedWho: 'DEFAULT'
|
||||
}
|
||||
this.userRepService.create(newUserRep).subscribe({
|
||||
next: (response) => {
|
||||
this.slRepUserId = null;
|
||||
this.slRepUserId = undefined;
|
||||
|
||||
this.repUsers.safelyUnselectAll()
|
||||
if (this.slUserId != null)
|
||||
this.repGroups.safelyUnselectAll()
|
||||
if (this.slUserId != undefined)
|
||||
this.userReps.fetchData(this.slUserId)
|
||||
if (this.slGroupId != undefined)
|
||||
this.userReps.fetchData(this.slGroupId)
|
||||
},
|
||||
error: (error) => {
|
||||
Swal.fire({
|
||||
@@ -123,7 +130,7 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
|
||||
});
|
||||
}
|
||||
|
||||
this.slRepUserId = null;
|
||||
this.slRepUserId = undefined;
|
||||
}
|
||||
else if (rows.length > 0) {
|
||||
this.slRepUserId = rows[0].source?.id;
|
||||
@@ -132,11 +139,11 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
|
||||
|
||||
repGroupOnSelectedRows = (rows: GuiSelectedRow[]) => {
|
||||
if (rows.length == 0 && this.slRepGroupId) {
|
||||
if (!this.slUserId) {
|
||||
if (!this.slUserId && !this.slGroupId) {
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
title: "Oops...",
|
||||
text: "Bitte wählen Sie den Benutzer!",
|
||||
text: "Bitte wählen Sie den Benutzer oder die Gruppe!",
|
||||
});
|
||||
}
|
||||
else if (!this.slRepGroupId) {
|
||||
@@ -149,15 +156,19 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
|
||||
else {
|
||||
var newUserRep = {
|
||||
userId: this.slUserId,
|
||||
groupId: this.slGroupId,
|
||||
repGroupId: this.slRepGroupId,
|
||||
addedWho: 'DEFAULT'
|
||||
}
|
||||
this.userRepService.create(newUserRep).subscribe({
|
||||
next: (res) => {
|
||||
this.slRepGroupId = null;
|
||||
this.slRepGroupId = undefined;
|
||||
this.repUsers.safelyUnselectAll()
|
||||
if (this.slUserId != null)
|
||||
this.groups.safelyUnselectAll()
|
||||
if (this.slUserId != undefined)
|
||||
this.userReps.fetchData(this.slUserId)
|
||||
if (this.slGroupId != undefined)
|
||||
this.userReps.fetchData(undefined, this.slGroupId)
|
||||
},
|
||||
error: (error) => {
|
||||
Swal.fire({
|
||||
@@ -169,7 +180,7 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
|
||||
});
|
||||
}
|
||||
|
||||
this.slRepGroupId = null;
|
||||
this.slRepGroupId = undefined;
|
||||
}
|
||||
else if (rows.length > 0) {
|
||||
this.slRepGroupId = rows[0].source?.id;
|
||||
@@ -180,13 +191,15 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
|
||||
if (rows.length == 0 && this.slUserRepId) {
|
||||
this.userRepService.delete(this.slUserRepId).subscribe({
|
||||
next: (res) => {
|
||||
this.slUserRepId = null;
|
||||
this.slUserRepId = undefined;
|
||||
this.userReps.safelyUnselectAll();
|
||||
if (this.slUserId != null)
|
||||
if (this.slUserId != undefined)
|
||||
this.userReps.fetchData(this.slUserId)
|
||||
if (this.slGroupId != undefined)
|
||||
this.userReps.fetchData(undefined, this.slGroupId)
|
||||
},
|
||||
error: (err) => {
|
||||
this.slUserRepId = null;
|
||||
this.slUserRepId = undefined;
|
||||
this.repUsers.safelyUnselectAll()
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
|
||||
Reference in New Issue
Block a user