Skip to content

Commit 5403063

Browse files
oskogstadMagnusSandgrenelsand
authored
feat(webapi): Option to include deleted dialogs in ServiceOwner dialog search (#1816)
<!--- Provide a general summary of your changes in the Title above --> ## Description <!--- Describe your changes in detail --> ## Related Issue(s) - #1817 ## Verification - [ ] **Your** code builds clean without any errors or warnings - [ ] Manual testing done (required) - [ ] Relevant automated test added (if you find this hard, leave it and we'll help out) ## Documentation - [ ] Documentation is updated (either in `docs`-directory, Altinnpedia or a separate linked PR in [altinn-studio-docs.](https://github.com/Altinn/altinn-studio-docs), if applicable) Co-authored-by: Magnus Sandgren <5285192+MagnusSandgren@users.noreply.github.com> Co-authored-by: Bjørn Dybvik Langfors <bdl@digdir.no>
1 parent 331d492 commit 5403063

File tree

4 files changed

+57
-1
lines changed

4 files changed

+57
-1
lines changed

docs/schema/V1/swagger.verified.json

+33
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,20 @@
327327
},
328328
"type": "object"
329329
},
330+
"V1Common_dFilter": {
331+
"description": "",
332+
"enum": [
333+
"Exclude",
334+
"Include",
335+
"Only"
336+
],
337+
"type": "string",
338+
"x-enumNames": [
339+
"Exclude",
340+
"Include",
341+
"Only"
342+
]
343+
},
330344
"V1CommonContent_ContentValue": {
331345
"additionalProperties": false,
332346
"properties": {
@@ -4073,6 +4087,12 @@
40734087
"format": "date-time",
40744088
"type": "string"
40754089
},
4090+
"deletedAt": {
4091+
"description": "If deleted, the date and time when the deletion was performed.",
4092+
"format": "date-time",
4093+
"nullable": true,
4094+
"type": "string"
4095+
},
40764096
"dueAt": {
40774097
"description": "The due date for the dialog. This is the last date when the dialog is expected to be completed.",
40784098
"example": "2022-12-31T23:59:59Z",
@@ -5688,6 +5708,19 @@
56885708
},
56895709
"style": "form"
56905710
},
5711+
{
5712+
"description": "If set to \u0027include\u0027, the result will include both deleted and non-deleted dialogs\nIf set to \u0027exclude\u0027, the result will only include non-deleted dialogs\nIf set to \u0027only\u0027, the result will only include deleted dialogs",
5713+
"in": "query",
5714+
"name": "deleted",
5715+
"schema": {
5716+
"allOf": [
5717+
{
5718+
"$ref": "#/components/schemas/V1Common_dFilter"
5719+
}
5720+
],
5721+
"nullable": true
5722+
}
5723+
},
56915724
{
56925725
"description": "Only return dialogs created after this date",
56935726
"in": "query",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace Digdir.Domain.Dialogporten.Application.Features.V1.Common;
2+
3+
public enum DeletedFilter
4+
{
5+
Exclude = 1,
6+
Include = 2,
7+
Only = 3
8+
}

src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Queries/Search/DialogDtoBase.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ public class DialogDtoBase
102102
/// <example>2022-12-31T23:59:59Z</example>
103103
public DateTimeOffset? DueAt { get; set; }
104104

105+
/// <summary>
106+
/// If deleted, the date and time when the deletion was performed.
107+
/// </summary>
108+
public DateTimeOffset? DeletedAt { get; set; }
109+
105110
/// <summary>
106111
/// The timestamp when the dialog will be made visible for authorized end users.
107112
/// </summary>
@@ -198,4 +203,3 @@ public sealed class DialogActivityDto
198203
/// </summary>
199204
public List<LocalizationDto> Description { get; set; } = [];
200205
}
201-

src/Digdir.Domain.Dialogporten.Application/Features/V1/ServiceOwner/Dialogs/Queries/Search/SearchDialogQuery.cs

+11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using Digdir.Domain.Dialogporten.Application.Common.ReturnTypes;
99
using Digdir.Domain.Dialogporten.Application.Externals;
1010
using Digdir.Domain.Dialogporten.Application.Externals.AltinnAuthorization;
11+
using Digdir.Domain.Dialogporten.Application.Features.V1.Common;
1112
using Digdir.Domain.Dialogporten.Domain.DialogEndUserContexts.Entities;
1213
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities;
1314
using Digdir.Domain.Dialogporten.Domain.Localizations;
@@ -51,6 +52,13 @@ public sealed class SearchDialogQuery : SortablePaginationParameter<SearchDialog
5152
/// </summary>
5253
public List<DialogStatus.Values>? Status { get; init; }
5354

55+
/// <summary>
56+
/// If set to 'include', the result will include both deleted and non-deleted dialogs
57+
/// If set to 'exclude', the result will only include non-deleted dialogs
58+
/// If set to 'only', the result will only include deleted dialogs
59+
/// </summary>
60+
public DeletedFilter? Deleted { get; set; } = DeletedFilter.Exclude;
61+
5462
/// <summary>
5563
/// Only return dialogs created after this date
5664
/// </summary>
@@ -191,7 +199,10 @@ public async Task<SearchDialogResult> Handle(SearchDialogQuery request, Cancella
191199
x.Content.Any(x => x.Value.Localizations.AsQueryable().Any(searchExpression)) ||
192200
x.SearchTags.Any(x => EF.Functions.ILike(x.Value, request.Search!))
193201
)
202+
.WhereIf(request.Deleted == DeletedFilter.Exclude, x => !x.Deleted)
203+
.WhereIf(request.Deleted == DeletedFilter.Only, x => x.Deleted)
194204
.Where(x => resourceIds.Contains(x.ServiceResource))
205+
.IgnoreQueryFilters()
195206
.ProjectTo<IntermediateDialogDto>(_mapper.ConfigurationProvider)
196207
.ToPaginatedListAsync(request, cancellationToken: cancellationToken);
197208

0 commit comments

Comments
 (0)