Add IncludeDocAndDocRes option to envelope queries

Introduced a new boolean property `IncludeDocAndDocRes` in the `ReadEnvelopeQuery` class to control the inclusion of document and document result details in query results. Updated `ReadEnvelopeQueryHandler` to handle this property, returning a simplified `EnvelopeDto` when set to `false`.

Modified `SenderPage.razor` to exclude document details by passing `includeDocAndDocRes: false` to `EnvelopeService.GetAsync()`. Enhanced `EnvelopeService` to accept and process the `includeDocAndDocRes` parameter, ensuring API requests respect this preference.
This commit is contained in:
2026-10-26 15:24:18 +01:00
parent c746612d80
commit 8d27718062
3 changed files with 94 additions and 1 deletions

View File

@@ -2,6 +2,9 @@
using EnvelopeGenerator.Domain.Constants;
using EnvelopeGenerator.Application.Common.Query;
using EnvelopeGenerator.Application.Common.Dto;
using EnvelopeGenerator.Application.Common.Dto.EnvelopeReceiver;
using EnvelopeGenerator.Application.Common.Dto.History;
using EnvelopeGenerator.Application.Common.Dto.Receiver;
using AutoMapper;
using DigitalData.Core.Abstraction.Application.Repository;
using EnvelopeGenerator.Domain.Entities;
@@ -14,6 +17,11 @@ namespace EnvelopeGenerator.Application.Envelopes.Queries;
/// </summary>
public record ReadEnvelopeQuery : EnvelopeQueryBase, IRequest<IEnumerable<EnvelopeDto>>
{
/// <summary>
///
/// </summary>
public bool IncludeDocAndDocRes { get; init; } = true;
/// <summary>
///
/// </summary>
@@ -148,6 +156,86 @@ public class ReadEnvelopeQueryHandler : IRequestHandler<ReadEnvelopeQuery, IEnum
if (request is { OnlyCompleted: true })
query = query.Where(e => Status.Completed.Contains(e.Status));
if (!request.IncludeDocAndDocRes)
{
return await query
.Select(e => new EnvelopeDto
{
Id = e.Id,
UserId = e.UserId,
Status = e.Status,
StatusName = string.Empty,
Uuid = e.Uuid,
Message = e.Message,
AddedWhen = e.AddedWhen,
ChangedWhen = e.ChangedWhen,
Title = e.Title ?? string.Empty,
ContractType = e.ContractType,
Language = e.Language,
EnvelopeTypeId = e.EnvelopeTypeId,
CertificationType = e.CertificationType,
FinalEmailToCreator = e.FinalEmailToCreator,
FinalEmailToReceivers = e.FinalEmailToReceivers,
SendReminderEmails = e.SendReminderEmails,
FirstReminderDays = e.FirstReminderDays,
ReminderIntervalDays = e.ReminderIntervalDays,
ExpiresWhenDays = e.ExpiresWhenDays,
ExpiresWarningWhenDays = e.ExpiresWarningWhenDays,
UseAccessCode = e.UseAccessCode ?? true,
TFAEnabled = e.TfaEnabled ?? false,
EnvelopeTypeTitle = e.Type != null ? e.Type.Title : null,
IsAlreadySent = false,
DocResult = null,
Documents = null,
EnvelopeReceivers = e.EnvelopeReceivers.Select(er => new EnvelopeReceiverDto
{
EnvelopeId = er.EnvelopeId,
ReceiverId = er.ReceiverId,
Sequence = er.Sequence,
Name = er.Name,
JobTitle = er.JobTitle,
CompanyName = er.CompanyName,
PrivateMessage = er.PrivateMessage,
AccessCode = er.AccessCode,
AddedWhen = er.AddedWhen,
ChangedWhen = er.ChangedWhen,
HasPhoneNumber = er.HasPhoneNumber,
Receiver = er.Receiver == null
? null
: new ReceiverDto
{
Id = er.Receiver.Id,
EmailAddress = er.Receiver.EmailAddress,
Signature = er.Receiver.Signature,
AddedWhen = er.Receiver.AddedWhen,
TfaRegDeadline = er.Receiver.TfaRegDeadline
}
}),
Histories = e.Histories.Select(h => new HistoryDto
{
Id = h.Id,
EnvelopeId = h.EnvelopeId,
UserReference = h.UserReference,
Status = h.Status,
StatusName = null,
AddedWhen = h.AddedWhen,
ActionDate = h.ActionDate,
Comment = h.Comment,
Receiver = h.Receiver == null
? null
: new ReceiverDto
{
Id = h.Receiver.Id,
EmailAddress = h.Receiver.EmailAddress,
Signature = h.Receiver.Signature,
AddedWhen = h.Receiver.AddedWhen,
TfaRegDeadline = h.Receiver.TfaRegDeadline
}
})
})
.ToListAsync(cancel);
}
var envelopes = await query
.Include(e => e.Type)
.Include(e => e.EnvelopeReceivers).ThenInclude(er => er.Receiver)

View File

@@ -629,7 +629,7 @@
try
{
_allEnvelopes = await EnvelopeService.GetAsync() ?? [];
_allEnvelopes = await EnvelopeService.GetAsync(includeDocAndDocRes: false) ?? [];
// Split into active and completed based on effective status
// (history-aware: rejected envelopes should not stay in active tab).

View File

@@ -25,6 +25,7 @@ public class EnvelopeService(IHttpClientFactory clientFactory)
string? uuid = null,
bool? onlyActive = null,
bool? onlyCompleted = null,
bool? includeDocAndDocRes = null,
CancellationToken cancel = default)
{
var baseUrl = $"/api/Envelope";
@@ -46,6 +47,10 @@ public class EnvelopeService(IHttpClientFactory clientFactory)
{
queryParams["OnlyCompleted"] = onlyCompleted.Value.ToString();
}
if (includeDocAndDocRes.HasValue)
{
queryParams["IncludeDocAndDocRes"] = includeDocAndDocRes.Value.ToString();
}
var url = QueryHelpers.AddQueryString(baseUrl, queryParams);