Compare commits
10 Commits
5df5cc555a
...
968ff8349f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
968ff8349f | ||
|
|
770921011a | ||
|
|
a9bc4f90ac | ||
|
|
6e5ba82869 | ||
|
|
fb3dedadc5 | ||
|
|
8cf2183cd6 | ||
|
|
881d2ccac8 | ||
|
|
deacd1a8c6 | ||
|
|
616862391e | ||
|
|
296f29cf82 |
@@ -31,4 +31,12 @@ export class UserRepTableComponent extends BaseTableComponent<UserRep, UserRepSe
|
||||
error: (error: any) => { }
|
||||
});
|
||||
}
|
||||
|
||||
public fetchByUser(id: number): void {
|
||||
this.fetchData(id, undefined);
|
||||
}
|
||||
|
||||
public fetchByGroup(id: number): void {
|
||||
this.fetchData(undefined, id);
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ export interface UserRep {
|
||||
userId?: number,
|
||||
repGroupId?: number,
|
||||
groupId?: number,
|
||||
addedWho: string,
|
||||
addedWho?: string,
|
||||
repUser?: User
|
||||
user?: User,
|
||||
repGroup?: Group,
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<div class="col-3">
|
||||
<mat-tab-group>
|
||||
<mat-tab label="{{useRepLabel}}">
|
||||
<app-user-rep-table #userReps [initData]="initWithoutData" [onSelectedRows]="userRepOnSelectedRows"></app-user-rep-table>
|
||||
<app-user-rep-table #userReps [initData]="initWithoutData" [onSelectedRows]="repOnSelectedRows"></app-user-rep-table>
|
||||
</mat-tab>
|
||||
</mat-tab-group>
|
||||
</div>
|
||||
|
||||
@@ -26,7 +26,7 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
|
||||
slGroupId?: number;
|
||||
slRepUserId?: number;
|
||||
slRepGroupId?: number;
|
||||
slUserRepId?: number;
|
||||
slRepId?: number;
|
||||
|
||||
initWithoutData = () => { }
|
||||
|
||||
@@ -59,31 +59,24 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
|
||||
@ViewChild("repGroups") repGroups!: GroupTableComponent;
|
||||
@ViewChild("userReps") userReps!: UserRepTableComponent;
|
||||
|
||||
userGroupOnSelectedRows = (rows: GuiSelectedRow[], isUser: boolean = true) => {
|
||||
userOnSelectedRows = (rows: GuiSelectedRow[]) => {
|
||||
if (rows.length > 0) {
|
||||
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 = undefined;
|
||||
this.slGroupId = rows[0].source?.id
|
||||
}
|
||||
this.useRepLabel = `Vertretungen von ${rows[0].source?.username}`
|
||||
this.users.safelyUnselectAll();
|
||||
this.userReps.fetchByUser(rows[0].source?.id);
|
||||
this.slGroupId = undefined;
|
||||
this.slUserId = rows[0].source?.id
|
||||
}
|
||||
}
|
||||
|
||||
userOnSelectedRows = (rows: GuiSelectedRow[]) => {
|
||||
this.userGroupOnSelectedRows(rows, true);
|
||||
}
|
||||
|
||||
groupOnSelectedRows = (rows: GuiSelectedRow[]) => {
|
||||
this.userGroupOnSelectedRows(rows, false);
|
||||
if (rows.length > 0) {
|
||||
this.useRepLabel = `Vertretungen von ${rows[0].source?.name}`
|
||||
this.groups.safelyUnselectAll();
|
||||
this.userReps.fetchByGroup(rows[0].source?.id);
|
||||
this.slUserId = undefined;
|
||||
this.slGroupId = rows[0].source?.id
|
||||
}
|
||||
}
|
||||
|
||||
repUserOnSelectedRows = (rows: GuiSelectedRow[]) => {
|
||||
@@ -107,7 +100,6 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
|
||||
userId: this.slUserId,
|
||||
groupId: this.slGroupId,
|
||||
repUserId: this.slRepUserId,
|
||||
addedWho: 'DEFAULT'
|
||||
}
|
||||
this.userRepService.create(newUserRep).subscribe({
|
||||
next: (response) => {
|
||||
@@ -115,10 +107,10 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
|
||||
|
||||
this.repUsers.safelyUnselectAll()
|
||||
this.repGroups.safelyUnselectAll()
|
||||
if (this.slUserId != undefined)
|
||||
this.userReps.fetchData(this.slUserId)
|
||||
if (this.slGroupId != undefined)
|
||||
this.userReps.fetchData(this.slGroupId)
|
||||
if (this.slUserId)
|
||||
this.userReps.fetchByUser(this.slUserId)
|
||||
if (this.slGroupId)
|
||||
this.userReps.fetchByGroup(this.slGroupId)
|
||||
},
|
||||
error: (error) => {
|
||||
Swal.fire({
|
||||
@@ -158,17 +150,16 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
|
||||
userId: this.slUserId,
|
||||
groupId: this.slGroupId,
|
||||
repGroupId: this.slRepGroupId,
|
||||
addedWho: 'DEFAULT'
|
||||
}
|
||||
this.userRepService.create(newUserRep).subscribe({
|
||||
next: (res) => {
|
||||
this.slRepGroupId = undefined;
|
||||
this.repUsers.safelyUnselectAll()
|
||||
this.groups.safelyUnselectAll()
|
||||
if (this.slUserId != undefined)
|
||||
this.userReps.fetchData(this.slUserId)
|
||||
if (this.slGroupId != undefined)
|
||||
this.userReps.fetchData(undefined, this.slGroupId)
|
||||
if (this.slUserId)
|
||||
this.userReps.fetchByUser(this.slUserId)
|
||||
if (this.slGroupId)
|
||||
this.userReps.fetchByGroup(this.slGroupId)
|
||||
},
|
||||
error: (error) => {
|
||||
Swal.fire({
|
||||
@@ -187,11 +178,11 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
|
||||
}
|
||||
}
|
||||
|
||||
userRepOnSelectedRows = (rows: GuiSelectedRow[]) => {
|
||||
if (rows.length == 0 && this.slUserRepId) {
|
||||
this.userRepService.delete(this.slUserRepId).subscribe({
|
||||
repOnSelectedRows = (rows: GuiSelectedRow[]) => {
|
||||
if (rows.length == 0 && this.slRepId) {
|
||||
this.userRepService.delete(this.slRepId).subscribe({
|
||||
next: (res) => {
|
||||
this.slUserRepId = undefined;
|
||||
this.slRepId = undefined;
|
||||
this.userReps.safelyUnselectAll();
|
||||
if (this.slUserId != undefined)
|
||||
this.userReps.fetchData(this.slUserId)
|
||||
@@ -199,7 +190,7 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
|
||||
this.userReps.fetchData(undefined, this.slGroupId)
|
||||
},
|
||||
error: (err) => {
|
||||
this.slUserRepId = undefined;
|
||||
this.slRepId = undefined;
|
||||
this.repUsers.safelyUnselectAll()
|
||||
Swal.fire({
|
||||
icon: "error",
|
||||
@@ -210,7 +201,7 @@ export class UserRepresentationComponent extends BasePageComponent implements Af
|
||||
})
|
||||
}
|
||||
else if (rows.length > 0) {
|
||||
this.slUserRepId = rows[0].source?.id;
|
||||
this.slRepId = rows[0].source?.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,18 +19,18 @@ namespace DigitalData.UserManager.API.Controllers
|
||||
{
|
||||
return base.GetAll();
|
||||
}
|
||||
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetAll(bool withUser = false, bool withRepGroup = false, bool withGroup = false, bool withRepUser = false, int? userId = null, int? groupId = null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return await _service.ReadAllAsync(withUser, withRepGroup, withGroup, withRepUser, userId, groupId).ThenAsync(Ok, IActionResult (m, n) =>
|
||||
return await _service.ReadAllAsync(withUser: withUser, withRepGroup: withRepGroup, withGroup: withGroup, withRepUser: withRepUser,
|
||||
userId: userId, groupId: groupId).ThenAsync(Ok, IActionResult (m, n) =>
|
||||
{
|
||||
_logger.LogNotice(n);
|
||||
return NotFound();
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -6,6 +6,8 @@ namespace DigitalData.UserManager.Application.DTOs.UserRep
|
||||
int? UserId,
|
||||
int? RepGroupId,
|
||||
int? GroupId,
|
||||
int? RepUserId
|
||||
int? RepUserId,
|
||||
DateTime? ValidFrom,
|
||||
DateTime? ValidTo
|
||||
) : BaseCreateDto();
|
||||
}
|
||||
@@ -9,9 +9,11 @@ namespace DigitalData.UserManager.Application.DTOs.UserRep
|
||||
int? UserId,
|
||||
int? GroupId,
|
||||
int? RepUserId,
|
||||
int? RepGroupId,
|
||||
int? RepGroupId,
|
||||
DateTime ValidFrom,
|
||||
DateTime ValidTo,
|
||||
string AddedWho,
|
||||
string? ChangedWho,
|
||||
string? ChangedWho,
|
||||
UserReadDto? User,
|
||||
GroupReadDto? RepGroup,
|
||||
GroupReadDto? Group,
|
||||
|
||||
@@ -6,6 +6,8 @@ namespace DigitalData.UserManager.Application.DTOs.UserRep
|
||||
int? UserId,
|
||||
int? RepGroupId,
|
||||
int? GroupId,
|
||||
int? RepUserId
|
||||
int? RepUserId,
|
||||
DateTime? ValidFrom,
|
||||
DateTime? ValidTo
|
||||
) : BaseUpdateDto();
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using AutoMapper;
|
||||
using DigitalData.Core.Application;
|
||||
using DigitalData.Core.DTO;
|
||||
using DigitalData.UserManager.Application.Contracts;
|
||||
using DigitalData.UserManager.Application.DTOs.UserRep;
|
||||
@@ -17,7 +16,7 @@ namespace DigitalData.UserManager.Application.Services
|
||||
|
||||
public async Task<DataResult<IEnumerable<UserRepReadDto>>> ReadAllAsync(bool withUser = false, bool withRepGroup = false, bool withGroup = false, bool withRepUser = false, int? userId = null, int? groupId = null)
|
||||
{
|
||||
var urs = await _repository.ReadAllAsync(withUser, withRepGroup, withGroup, withRepUser, userId, groupId);
|
||||
var urs = await _repository.ReadAllAsync(withUser: withUser, withRepGroup: withRepGroup, withGroup: withGroup, withRepUser: withRepUser, userId: userId, groupId: groupId);
|
||||
var urReadDTOs = _mapper.Map<IEnumerable<UserRepReadDto>>(urs);
|
||||
return Result.Success(urReadDTOs);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace DigitalData.UserManager.Domain.Entities
|
||||
{
|
||||
@@ -18,6 +18,14 @@ namespace DigitalData.UserManager.Domain.Entities
|
||||
[Column("REPR_USER")]
|
||||
public int? RepUserId { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("VALID_FROM")]
|
||||
public required DateTime ValidFrom { get; set; }
|
||||
|
||||
[Required]
|
||||
[Column("VALID_TO")]
|
||||
public required DateTime ValidTo { get; set; }
|
||||
|
||||
[ForeignKey("UserId")]
|
||||
public virtual User? User { get; set; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user