feat(envelope): ReceiverStatusTable-Komponente unter Envelope-Tabelle hinzugefügt und Backend-Unterstützung integriert

- ReceiverStatusTableComponent als Unterkomponente der EnvelopeTable erstellt, um Empfängerstatus anzuzeigen.
- ReceiverStatusTable in EnvelopeTable mit Tabs und dynamischem Datenladen integriert.
- EnvelopeTable angepasst, um Empfängerdaten über den EnvelopeReceiverService abzurufen und in ReceiverStatusTable anzuzeigen.
- Backend aktualisiert, um das Abrufen von Umschlägen nach Benutzer zu unterstützen:
  - `ReadByUserAsync`-Methode im Envelope-Repository hinzugefügt, um Umschläge für einen bestimmten Benutzer abzufragen.
  - Servicemethode implementiert, um die abgefragten Umschläge in DTOs zu konvertieren und das Ergebnis zurückzugeben.
This commit is contained in:
Developer 02 2024-09-06 11:32:39 +02:00
parent 8753875d93
commit 97f07bc72d
8 changed files with 37 additions and 27 deletions

View File

@ -2,7 +2,6 @@
using DigitalData.Core.DTO;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
namespace EnvelopeGenerator.Application.Contracts
{
@ -11,5 +10,7 @@ namespace EnvelopeGenerator.Application.Contracts
Task<DataResult<IEnumerable<EnvelopeDto>>> ReadAllWithAsync(bool documents = false, bool history = false, bool documentReceiverElement = false);
Task<DataResult<EnvelopeDto>> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withUser = false, bool withAll = false);
Task<DataResult<IEnumerable<EnvelopeDto>>> ReadByUserAsync(int userId);
}
}

View File

@ -3,16 +3,14 @@ using DigitalData.Core.Application;
using DigitalData.Core.DTO;
using EnvelopeGenerator.Application.Contracts;
using EnvelopeGenerator.Application.DTOs;
using EnvelopeGenerator.Application.Resources;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
using Microsoft.Extensions.Logging;
namespace EnvelopeGenerator.Application.Services
{
public class EnvelopeService : BasicCRUDService<IEnvelopeRepository, EnvelopeDto, Envelope, int>, IEnvelopeService
{
public EnvelopeService(IEnvelopeRepository repository, IMapper mapper, ILogger<EnvelopeService> logger)
public EnvelopeService(IEnvelopeRepository repository, IMapper mapper)
: base(repository, mapper)
{
}
@ -34,5 +32,12 @@ namespace EnvelopeGenerator.Application.Services
var readDto = _mapper.MapOrThrow<EnvelopeDto>(envelope);
return Result.Success(readDto);
}
public async Task<DataResult<IEnumerable<EnvelopeDto>>> ReadByUserAsync(int userId)
{
var users = await _repository.ReadByUserAsync(userId: userId);
var readDto = _mapper.MapOrThrow<IEnumerable<EnvelopeDto>>(users);
return Result.Success(readDto);
}
}
}

View File

@ -1,5 +1,4 @@
import { AfterViewInit, Component, Input, ViewChild, inject, viewChild } from '@angular/core';
import { EnvelopeReceiverService } from '../../../services/envelope-receiver.service';
import { EnvelopeService } from '../../../services/envelope.service';
import { animate, state, style, transition, trigger } from '@angular/animations';
import { ConfigurationService } from '../../../services/configuration.service';
@ -7,6 +6,7 @@ import { DDTable } from "../dd-table/dd-table.component";
import { ClearableInputComponent } from '../../clearable-input/clearable-input.component'
import { MatTabsModule } from '@angular/material/tabs';
import { ReceiverStatusTableComponent } from "../receiver-status-table/receiver-status-table.component";
import { EnvelopeReceiverService } from '../../../services/envelope-receiver.service';
@Component({
selector: 'envelope-table',
@ -26,24 +26,20 @@ export class EnvelopeTableComponent implements AfterViewInit {
@Input() options?: { min_status?: number; max_status?: number; ignore_status?: number[] }
displayedColumns: string[] = ['title', 'status', 'type', 'privateMessage', 'addedWhen'];
displayedColumns: string[] = ['title', 'status', 'type', 'addedWhen'];
schema: Record<string, { header: string; field: (element: any) => any; }> = {
'title': {
header: 'Title',
field: (element: any) => element.envelope.title
field: (element: any) => element.title
},
'status': {
header: 'Status',
field: (element: any) => element.envelope.statusName
field: (element: any) => element.statusName
},
'type': {
header: 'Type',
field: (element: any) => this.config.envelopeTypeTitles[element.envelope.contractType - 1]
},
'privateMessage': {
header: 'Private Message',
field: (element: any) => element.privateMessage
field: (element: any) => this.config.envelopeTypeTitles[element.contractType - 1]
},
'addedWhen': {
header: 'Added When',
@ -53,20 +49,19 @@ export class EnvelopeTableComponent implements AfterViewInit {
data: any[] = [];
@ViewChild(ClearableInputComponent) input!: ClearableInputComponent
@ViewChild(ReceiverStatusTableComponent) rsTable!: ReceiverStatusTableComponent
onToggleExpandedRow(element: any, event: Event) {
console.log(element)
}
private erService: EnvelopeReceiverService = inject(EnvelopeReceiverService);
private envService: EnvelopeService = inject(EnvelopeService);
private eService: EnvelopeService = inject(EnvelopeService);
private config: ConfigurationService = inject(ConfigurationService);
private readonly erService: EnvelopeReceiverService = inject(EnvelopeReceiverService);
async ngAfterViewInit() {
this.data = await this.erService.getEnvelopeReceiverAsync(this.options);
await this.envService.getEnvelopeAsync().then(console.log)
this.data = await this.eService.getEnvelopeAsync();
this.rsTable.data = await this.erService.getEnvelopeReceiverAsync();
}
}

View File

@ -1 +1 @@
<p>receiver-status-table works!</p>
<dd-table [data]="data" [columnsToDisplay]="columnsToDisplay" [schema]="schema" [isSortable]="true"></dd-table>

View File

@ -1,12 +1,17 @@
import { Component } from '@angular/core';
import { Component, inject } from '@angular/core';
import { DDTable } from '../dd-table/dd-table.component'
@Component({
selector: 'receiver-status-table',
standalone: true,
imports: [],
imports: [DDTable],
templateUrl: './receiver-status-table.component.html',
styleUrl: './receiver-status-table.component.scss'
})
export class ReceiverStatusTableComponent {
data: any[] = [];
schema = {};
columnsToDisplay: string[] = [];
}

View File

@ -26,7 +26,7 @@ namespace EnvelopeGenerator.GeneratorAPI.Controllers
try
{
if (User.GetId() is int intId)
return await _envelopeService.ReadByIdAsync(intId).ThenAsync(
return await _envelopeService.ReadByUserAsync(intId).ThenAsync(
Success: Ok,
Fail: IActionResult (msg, ntc) =>
{

View File

@ -8,5 +8,7 @@ namespace EnvelopeGenerator.Infrastructure.Contracts
Task<IEnumerable<Envelope>> ReadAllWithAsync(bool documents = false, bool history = false, bool documentReceiverElement = false);
Task<Envelope?> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withUser = false, bool withAll = false);
Task<IEnumerable<Envelope>> ReadByUserAsync(int userId);
}
}

View File

@ -1,5 +1,4 @@
using DigitalData.Core.Infrastructure;
using DigitalData.UserManager.Infrastructure.Repositories;
using EnvelopeGenerator.Domain.Entities;
using EnvelopeGenerator.Infrastructure.Contracts;
using Microsoft.EntityFrameworkCore;
@ -14,7 +13,7 @@ namespace EnvelopeGenerator.Infrastructure.Repositories
public async Task<IEnumerable<Envelope>> ReadAllWithAsync(bool documents = false, bool history = false, bool documentReceiverElement = false)
{
var query = _dbSet.AsQueryable();
var query = _dbSet.AsNoTracking();
if (documents)
if (documentReceiverElement)
@ -30,7 +29,7 @@ namespace EnvelopeGenerator.Infrastructure.Repositories
public async Task<Envelope?> ReadByUuidAsync(string uuid, bool withDocuments = false, bool withHistory = false, bool withDocumentReceiverElement = false, bool withUser = false, bool withAll = false)
{
var query = _dbSet.Where(e => e.Uuid == uuid);
var query = _dbSet.AsNoTracking().Where(e => e.Uuid == uuid);
if (withAll || withDocuments)
if (withAll || withDocumentReceiverElement)
@ -46,5 +45,8 @@ namespace EnvelopeGenerator.Infrastructure.Repositories
return await query.FirstOrDefaultAsync();
}
public async Task<IEnumerable<Envelope>> ReadByUserAsync(int userId) => await _dbSet.AsNoTracking()
.Where(e => e.UserId == userId).ToListAsync();
}
}