fix(user-rep.component): geordnete Assgiment-Ereignisse und -Anfragen

This commit is contained in:
Developer 02 2024-10-31 15:54:53 +01:00
parent be07f16d63
commit 01bc5a4425
4 changed files with 57 additions and 25 deletions

View File

@ -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>

View File

@ -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",

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<WebPublishMethod>Package</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>true</LaunchSiteAfterPublish>
<ExcludeApp_Data>false</ExcludeApp_Data>
<ProjectGuid>07ccd651-647c-49f7-9715-30cebc13710d</ProjectGuid>
<DesktopBuildPackageLocation>P:\Install .Net\0 DD - Smart UP\DD-UserManager\Web\${Version}\$(Version).zip</DesktopBuildPackageLocation>
<PackageAsSingleFile>true</PackageAsSingleFile>
<DeployIisAppPath>UserManager.API</DeployIisAppPath>
<_TargetId>IISWebDeployPackage</_TargetId>
</PropertyGroup>
</Project>

View File

@ -7,11 +7,11 @@ namespace DigitalData.UserManager.Application.DTOs.UserRep
public record UserRepReadDto(
int Id,
int? UserId,
int? RepGroupId,
int? GroupId,
string AddedWho,
string ChangedWho,
int? RepUserId,
int? RepGroupId,
string AddedWho,
string ChangedWho,
UserReadDto? User,
GroupReadDto? RepGroup,
GroupReadDto? Group,