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> <app-user-table #users [onSelectedRows]="userOnSelectedRows"></app-user-table>
</mat-tab> </mat-tab>
<mat-tab label="Gruppe"> <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>
</mat-tab-group> </mat-tab-group>
</div> </div>

View File

@@ -22,11 +22,11 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
useRepLabel: string = ""; useRepLabel: string = "";
groupColumns: Array<GuiColumn>; groupColumns: Array<GuiColumn>;
groupRepCols: Array<GuiColumn>; groupRepCols: Array<GuiColumn>;
slUserId: null | number = null; slUserId?: number;
slRepUserId: null | number = null; slGroupId?: number;
slRepGroupId: null | number = null; slRepUserId?: number;
slRightGroupId: null | number = null; slRepGroupId?: number;
slUserRepId: null | number = null; slUserRepId?: number;
initWithoutData = () => { } initWithoutData = () => { }
@@ -61,17 +61,19 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
userGroupOnSelectedRows = (rows: GuiSelectedRow[], isUser: boolean = true) => { userGroupOnSelectedRows = (rows: GuiSelectedRow[], isUser: boolean = true) => {
if (rows.length > 0) { if (rows.length > 0) {
this.users.safelyUnselectAll();
if (isUser) { if (isUser) {
this.useRepLabel = `Vertretungen von ${rows[0].source?.username}` this.useRepLabel = `Vertretungen von ${rows[0].source?.username}`
this.users.safelyUnselectAll();
this.userReps.fetchData(rows[0].source?.id) this.userReps.fetchData(rows[0].source?.id)
this.slGroupId = undefined;
this.slUserId = rows[0].source?.id this.slUserId = rows[0].source?.id
} }
else { else {
this.useRepLabel = `Vertretungen von ${rows[0].source?.name}` this.useRepLabel = `Vertretungen von ${rows[0].source?.name}`
this.groups.safelyUnselectAll();
this.userReps.fetchData(undefined, rows[0].source?.id) 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[]) => { repUserOnSelectedRows = (rows: GuiSelectedRow[]) => {
if (rows.length == 0 && this.slRepUserId) { if (rows.length == 0 && this.slRepUserId) {
if (!this.slUserId) { if (!this.slUserId && !this.slGroupId) {
Swal.fire({ Swal.fire({
icon: "error", icon: "error",
title: "Oops...", title: "Oops...",
text: "Bitte wählen Sie den Benutzer!", text: "Bitte wählen Sie den Benutzer oder die Gruppe!",
}); });
} }
else if (!this.slRepUserId) { else if (!this.slRepUserId) {
@@ -103,15 +105,20 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
else { else {
var newUserRep: UserRep = { var newUserRep: UserRep = {
userId: this.slUserId, userId: this.slUserId,
groupId: this.slGroupId,
repUserId: this.slRepUserId, repUserId: this.slRepUserId,
addedWho: 'DEFAULT' addedWho: 'DEFAULT'
} }
this.userRepService.create(newUserRep).subscribe({ this.userRepService.create(newUserRep).subscribe({
next: (response) => { next: (response) => {
this.slRepUserId = null; this.slRepUserId = undefined;
this.repUsers.safelyUnselectAll() this.repUsers.safelyUnselectAll()
if (this.slUserId != null) this.repGroups.safelyUnselectAll()
if (this.slUserId != undefined)
this.userReps.fetchData(this.slUserId) this.userReps.fetchData(this.slUserId)
if (this.slGroupId != undefined)
this.userReps.fetchData(this.slGroupId)
}, },
error: (error) => { error: (error) => {
Swal.fire({ Swal.fire({
@@ -123,7 +130,7 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
}); });
} }
this.slRepUserId = null; this.slRepUserId = undefined;
} }
else if (rows.length > 0) { else if (rows.length > 0) {
this.slRepUserId = rows[0].source?.id; this.slRepUserId = rows[0].source?.id;
@@ -132,11 +139,11 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
repGroupOnSelectedRows = (rows: GuiSelectedRow[]) => { repGroupOnSelectedRows = (rows: GuiSelectedRow[]) => {
if (rows.length == 0 && this.slRepGroupId) { if (rows.length == 0 && this.slRepGroupId) {
if (!this.slUserId) { if (!this.slUserId && !this.slGroupId) {
Swal.fire({ Swal.fire({
icon: "error", icon: "error",
title: "Oops...", title: "Oops...",
text: "Bitte wählen Sie den Benutzer!", text: "Bitte wählen Sie den Benutzer oder die Gruppe!",
}); });
} }
else if (!this.slRepGroupId) { else if (!this.slRepGroupId) {
@@ -149,15 +156,19 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
else { else {
var newUserRep = { var newUserRep = {
userId: this.slUserId, userId: this.slUserId,
groupId: this.slGroupId,
repGroupId: this.slRepGroupId, repGroupId: this.slRepGroupId,
addedWho: 'DEFAULT' addedWho: 'DEFAULT'
} }
this.userRepService.create(newUserRep).subscribe({ this.userRepService.create(newUserRep).subscribe({
next: (res) => { next: (res) => {
this.slRepGroupId = null; this.slRepGroupId = undefined;
this.repUsers.safelyUnselectAll() this.repUsers.safelyUnselectAll()
if (this.slUserId != null) this.groups.safelyUnselectAll()
if (this.slUserId != undefined)
this.userReps.fetchData(this.slUserId) this.userReps.fetchData(this.slUserId)
if (this.slGroupId != undefined)
this.userReps.fetchData(undefined, this.slGroupId)
}, },
error: (error) => { error: (error) => {
Swal.fire({ Swal.fire({
@@ -169,7 +180,7 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
}); });
} }
this.slRepGroupId = null; this.slRepGroupId = undefined;
} }
else if (rows.length > 0) { else if (rows.length > 0) {
this.slRepGroupId = rows[0].source?.id; this.slRepGroupId = rows[0].source?.id;
@@ -180,13 +191,15 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
if (rows.length == 0 && this.slUserRepId) { if (rows.length == 0 && this.slUserRepId) {
this.userRepService.delete(this.slUserRepId).subscribe({ this.userRepService.delete(this.slUserRepId).subscribe({
next: (res) => { next: (res) => {
this.slUserRepId = null; this.slUserRepId = undefined;
this.userReps.safelyUnselectAll(); this.userReps.safelyUnselectAll();
if (this.slUserId != null) if (this.slUserId != undefined)
this.userReps.fetchData(this.slUserId) this.userReps.fetchData(this.slUserId)
if (this.slGroupId != undefined)
this.userReps.fetchData(undefined, this.slGroupId)
}, },
error: (err) => { error: (err) => {
this.slUserRepId = null; this.slUserRepId = undefined;
this.repUsers.safelyUnselectAll() this.repUsers.safelyUnselectAll()
Swal.fire({ Swal.fire({
icon: "error", 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( public record UserRepReadDto(
int Id, int Id,
int? UserId, int? UserId,
int? RepGroupId,
int? GroupId, int? GroupId,
int? RepUserId,
int? RepGroupId,
string AddedWho, string AddedWho,
string ChangedWho, string ChangedWho,
int? RepUserId,
UserReadDto? User, UserReadDto? User,
GroupReadDto? RepGroup, GroupReadDto? RepGroup,
GroupReadDto? Group, GroupReadDto? Group,