Skip to content

Commit cbd162b

Browse files
authored
Allow sort of children by name and create date (#17904)
* Added create date to document and media children endpoints. * Sort by name or create date for documents and media. * Fix build issues. * Only render column headers for sorting if all pages of children are loaded. * Add indicator and debounce sorting by column headers.
1 parent e425f0b commit cbd162b

File tree

21 files changed

+224
-16
lines changed

21 files changed

+224
-16
lines changed

src/Umbraco.Cms.Api.Management/Controllers/Document/Tree/DocumentTreeControllerBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.AspNetCore.Authorization;
1+
using Microsoft.AspNetCore.Authorization;
22
using Microsoft.AspNetCore.Mvc;
33
using Umbraco.Cms.Api.Management.Controllers.Tree;
44
using Umbraco.Cms.Api.Management.Factories;
@@ -54,6 +54,7 @@ protected override DocumentTreeItemResponseModel MapTreeItemViewModel(Guid? pare
5454
responseModel.IsProtected = _publicAccessService.IsProtected(entity.Path);
5555
responseModel.IsTrashed = entity.Trashed;
5656
responseModel.Id = entity.Key;
57+
responseModel.CreateDate = entity.CreateDate;
5758

5859
responseModel.Variants = _documentPresentationFactory.CreateVariantsItemResponseModels(documentEntitySlim);
5960
responseModel.DocumentType = _documentPresentationFactory.CreateDocumentTypeReferenceResponseModel(documentEntitySlim);

src/Umbraco.Cms.Api.Management/Controllers/Media/Tree/MediaTreeControllerBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.AspNetCore.Authorization;
1+
using Microsoft.AspNetCore.Authorization;
22
using Microsoft.AspNetCore.Mvc;
33
using Umbraco.Cms.Api.Management.Controllers.Tree;
44
using Umbraco.Cms.Api.Management.Factories;
@@ -50,6 +50,7 @@ protected override MediaTreeItemResponseModel MapTreeItemViewModel(Guid? parentK
5050
{
5151
responseModel.IsTrashed = entity.Trashed;
5252
responseModel.Id = entity.Key;
53+
responseModel.CreateDate = entity.CreateDate;
5354

5455
responseModel.Variants = _mediaPresentationFactory.CreateVariantsItemResponseModels(mediaEntitySlim);
5556
responseModel.MediaType = _mediaPresentationFactory.CreateMediaTypeReferenceResponseModel(mediaEntitySlim);

src/Umbraco.Cms.Api.Management/Controllers/RecycleBin/RecycleBinControllerBase.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Microsoft.AspNetCore.Http;
1+
using Microsoft.AspNetCore.Http;
22
using Microsoft.AspNetCore.Mvc;
33
using Umbraco.Cms.Api.Common.ViewModels.Pagination;
44
using Umbraco.Cms.Api.Management.Controllers.Content;
@@ -54,6 +54,7 @@ protected virtual TItem MapRecycleBinViewModel(Guid? parentKey, IEntitySlim enti
5454
var viewModel = new TItem
5555
{
5656
Id = entity.Key,
57+
CreateDate = entity.CreateDate,
5758
HasChildren = entity.HasChildren,
5859
Parent = parentKey.HasValue
5960
? new ItemReferenceByIdResponseModel

src/Umbraco.Cms.Api.Management/OpenApi.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36901,6 +36901,7 @@
3690136901
},
3690236902
"DocumentRecycleBinItemResponseModel": {
3690336903
"required": [
36904+
"createDate",
3690436905
"documentType",
3690536906
"hasChildren",
3690636907
"id",
@@ -36912,6 +36913,10 @@
3691236913
"type": "string",
3691336914
"format": "uuid"
3691436915
},
36916+
"createDate": {
36917+
"type": "string",
36918+
"format": "date-time"
36919+
},
3691536920
"hasChildren": {
3691636921
"type": "boolean"
3691736922
},
@@ -37040,6 +37045,7 @@
3704037045
},
3704137046
"DocumentTreeItemResponseModel": {
3704237047
"required": [
37048+
"createDate",
3704337049
"documentType",
3704437050
"hasChildren",
3704537051
"id",
@@ -37071,6 +37077,10 @@
3707137077
"type": "string",
3707237078
"format": "uuid"
3707337079
},
37080+
"createDate": {
37081+
"type": "string",
37082+
"format": "date-time"
37083+
},
3707437084
"isProtected": {
3707537085
"type": "boolean"
3707637086
},
@@ -39014,6 +39024,7 @@
3901439024
},
3901539025
"MediaRecycleBinItemResponseModel": {
3901639026
"required": [
39027+
"createDate",
3901739028
"hasChildren",
3901839029
"id",
3901939030
"mediaType",
@@ -39025,6 +39036,10 @@
3902539036
"type": "string",
3902639037
"format": "uuid"
3902739038
},
39039+
"createDate": {
39040+
"type": "string",
39041+
"format": "date-time"
39042+
},
3902839043
"hasChildren": {
3902939044
"type": "boolean"
3903039045
},
@@ -39141,6 +39156,7 @@
3914139156
},
3914239157
"MediaTreeItemResponseModel": {
3914339158
"required": [
39159+
"createDate",
3914439160
"hasChildren",
3914539161
"id",
3914639162
"isTrashed",
@@ -39171,6 +39187,10 @@
3917139187
"type": "string",
3917239188
"format": "uuid"
3917339189
},
39190+
"createDate": {
39191+
"type": "string",
39192+
"format": "date-time"
39193+
},
3917439194
"mediaType": {
3917539195
"oneOf": [
3917639196
{

src/Umbraco.Cms.Api.Management/ViewModels/RecycleBin/RecycleBinItemResponseModelBase.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System.ComponentModel.DataAnnotations;
1+
using System.ComponentModel.DataAnnotations;
22
using Umbraco.Cms.Api.Management.ViewModels.Item;
33

44
namespace Umbraco.Cms.Api.Management.ViewModels.RecycleBin;
@@ -8,6 +8,8 @@ public abstract class RecycleBinItemResponseModelBase
88
[Required]
99
public Guid Id { get; set; }
1010

11+
public DateTimeOffset CreateDate { get; set; }
12+
1113
[Required]
1214
public bool HasChildren { get; set; }
1315

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace Umbraco.Cms.Api.Management.ViewModels.Tree;
1+
namespace Umbraco.Cms.Api.Management.ViewModels.Tree;
22

33
public abstract class ContentTreeItemResponseModel : EntityTreeItemResponseModel
44
{
@@ -7,4 +7,6 @@ public abstract class ContentTreeItemResponseModel : EntityTreeItemResponseModel
77
public bool IsTrashed { get; set; }
88

99
public Guid Id { get; set; }
10+
11+
public DateTimeOffset CreateDate { get; set; }
1012
}

src/Umbraco.Web.UI.Client/src/external/backend-api/src/types.gen.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,7 @@ export type DocumentPermissionPresentationModel = {
673673

674674
export type DocumentRecycleBinItemResponseModel = {
675675
id: string;
676+
createDate: string;
676677
hasChildren: boolean;
677678
parent?: ((ItemReferenceByIdResponseModel) | null);
678679
documentType: (DocumentTypeReferenceResponseModel);
@@ -702,6 +703,7 @@ export type DocumentTreeItemResponseModel = {
702703
noAccess: boolean;
703704
isTrashed: boolean;
704705
id: string;
706+
createDate: string;
705707
isProtected: boolean;
706708
documentType: (DocumentTypeReferenceResponseModel);
707709
variants: Array<(DocumentVariantItemResponseModel)>;
@@ -1196,6 +1198,7 @@ export type MediaItemResponseModel = {
11961198

11971199
export type MediaRecycleBinItemResponseModel = {
11981200
id: string;
1201+
createDate: string;
11991202
hasChildren: boolean;
12001203
parent?: ((ItemReferenceByIdResponseModel) | null);
12011204
mediaType: (MediaTypeReferenceResponseModel);
@@ -1223,6 +1226,7 @@ export type MediaTreeItemResponseModel = {
12231226
noAccess: boolean;
12241227
isTrashed: boolean;
12251228
id: string;
1229+
createDate: string;
12261230
mediaType: (MediaTypeReferenceResponseModel);
12271231
variants: Array<(VariantItemResponseModel)>;
12281232
};

src/Umbraco.Web.UI.Client/src/mocks/data/document-blueprint/document-blueprint.data.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export const data: Array<UmbMockDocumentBlueprintModel> = [
1414
],
1515
template: null,
1616
id: 'the-simplest-document-id',
17+
createDate: '2023-02-06T15:32:05.350038',
1718
parent: null,
1819
documentType: {
1920
id: 'the-simplest-document-type-id',

src/Umbraco.Web.UI.Client/src/mocks/data/document-blueprint/document-blueprint.db.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ const treeItemMapper = (model: UmbMockDocumentBlueprintModel): Omit<DocumentTree
4545
noAccess: model.noAccess,
4646
parent: model.parent,
4747
variants: model.variants,
48+
createDate: model.createDate,
4849
};
4950
};
5051

@@ -62,6 +63,7 @@ const createMockDocumentBlueprintMapper = (request: CreateDocumentRequestModel):
6263
},
6364
hasChildren: false,
6465
id: request.id ? request.id : UmbId.new(),
66+
createDate: now,
6567
isProtected: false,
6668
isTrashed: false,
6769
noAccess: false,

src/Umbraco.Web.UI.Client/src/mocks/data/document/document.data.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export const data: Array<UmbMockDocumentModel> = [
1717
],
1818
template: null,
1919
id: 'the-simplest-document-id',
20+
createDate: '2023-02-06T15:32:05.350038',
2021
parent: null,
2122
documentType: {
2223
id: 'the-simplest-document-type-id',
@@ -56,6 +57,7 @@ export const data: Array<UmbMockDocumentModel> = [
5657
],
5758
template: null,
5859
id: 'all-property-editors-document-id',
60+
createDate: '2023-02-06T15:32:05.350038',
5961
parent: null,
6062
documentType: {
6163
id: 'all-property-editors-document-type-id',
@@ -601,6 +603,7 @@ export const data: Array<UmbMockDocumentModel> = [
601603
],
602604
template: null,
603605
id: 'c05da24d-7740-447b-9cdc-bd8ce2172e38',
606+
createDate: '2023-02-06T15:32:05.350038',
604607
parent: null,
605608
documentType: {
606609
id: '29643452-cff9-47f2-98cd-7de4b6807681',
@@ -734,6 +737,7 @@ export const data: Array<UmbMockDocumentModel> = [
734737
urls: [],
735738
template: null,
736739
id: 'fd56a0b5-01a0-4da2-b428-52773bfa9cc4',
740+
createDate: '2023-02-06T15:32:05.350038',
737741
parent: null,
738742
documentType: {
739743
id: '29643452-cff9-47f2-98cd-7de4b6807681',
@@ -822,6 +826,7 @@ export const data: Array<UmbMockDocumentModel> = [
822826
],
823827
template: null,
824828
id: 'simple-document-id',
829+
createDate: '2023-02-06T15:32:05.350038',
825830
parent: null,
826831
documentType: {
827832
id: 'simple-document-type-id',
@@ -869,6 +874,7 @@ export const data: Array<UmbMockDocumentModel> = [
869874
],
870875
template: null,
871876
id: 'all-rtes-id',
877+
createDate: '2023-02-06T15:32:05.350038',
872878
parent: null,
873879
documentType: {
874880
id: 'all-rtes-document-type-id',
@@ -938,6 +944,7 @@ export const data: Array<UmbMockDocumentModel> = [
938944
],
939945
template: null,
940946
id: 'block-editors-document-id',
947+
createDate: '2023-02-06T15:32:05.350038',
941948
parent: null,
942949
documentType: {
943950
id: 'block-editors-document-type-id',

0 commit comments

Comments
 (0)