From 2d2d8df82e6fae91e2c2378a9fced5c66b72f2c5 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Sat, 15 Oct 2022 22:34:47 +0200 Subject: [PATCH] Show published in tracked references --- src/Umbraco.Core/Models/RelationItem.cs | 5 +- .../Implement/RelationRepository.cs | 3 + .../Implement/TrackedReferencesRepository.cs | 94 ++++++++++++++----- .../umbtrackedreferencestable.component.js | 1 + .../umb-tracked-references-table.html | 11 ++- .../references/umb-tracked-references.html | 31 +++--- .../src/views/media/delete.html | 9 +- 7 files changed, 112 insertions(+), 42 deletions(-) diff --git a/src/Umbraco.Core/Models/RelationItem.cs b/src/Umbraco.Core/Models/RelationItem.cs index 111d7e6dfa..a865e7cc2f 100644 --- a/src/Umbraco.Core/Models/RelationItem.cs +++ b/src/Umbraco.Core/Models/RelationItem.cs @@ -1,4 +1,4 @@ -using System.Runtime.Serialization; +using System.Runtime.Serialization; namespace Umbraco.Cms.Core.Models; @@ -20,6 +20,9 @@ public class RelationItem [DataMember(Name = "udi")] public Udi? NodeUdi => NodeType == Constants.UdiEntityType.Unknown ? null : Udi.Create(NodeType, NodeKey); + [DataMember(Name = "published")] + public bool? NodePublished { get; set; } + [DataMember(Name = "icon")] public string? ContentTypeIcon { get; set; } diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/RelationRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/RelationRepository.cs index 88f1a6fee9..9431633993 100644 --- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/RelationRepository.cs +++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/RelationRepository.cs @@ -447,6 +447,9 @@ internal class RelationItemDto [Column(Name = "nodeName")] public string? ChildNodeName { get; set; } + [Column(Name = "nodePublished")] + public bool? ChildNodePublished { get; set; } + [Column(Name = "nodeObjectType")] public Guid ChildNodeObjectType { get; set; } diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/TrackedReferencesRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/TrackedReferencesRepository.cs index fc62ac861b..c7966daec1 100644 --- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/TrackedReferencesRepository.cs +++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/TrackedReferencesRepository.cs @@ -26,11 +26,14 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement bool filterMustBeIsDependency, out long totalRecords) { Sql innerUnionSql = GetInnerUnionSql(); - var sql = _scopeAccessor.AmbientScope?.Database.SqlContext.Sql().SelectDistinct( + + var sql = _scopeAccessor.AmbientScope?.Database.SqlContext.Sql() + .SelectDistinct( "[x].[id] as nodeId", "[n].[uniqueId] as nodeKey", "[n].[text] as nodeName", "[n].[nodeObjectType] as nodeObjectType", + "[d].[published] as nodePublished", "[ct].[icon] as contentTypeIcon", "[ct].[alias] as contentTypeAlias", "[ctn].[text] as contentTypeName", @@ -41,14 +44,27 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement .From("n") .InnerJoinNested(innerUnionSql, "x") .On((n, x) => n.NodeId == x.Id, "n", "x") - .LeftJoin("c").On((left, right) => left.NodeId == right.NodeId, + .LeftJoin("c") + .On( + (left, right) => left.NodeId == right.NodeId, aliasLeft: "n", aliasRight: "c") .LeftJoin("ct") - .On((left, right) => left.ContentTypeId == right.NodeId, aliasLeft: "c", + .On( + (left, right) => left.ContentTypeId == right.NodeId, + aliasLeft: "c", aliasRight: "ct") - .LeftJoin("ctn").On((left, right) => left.NodeId == right.NodeId, - aliasLeft: "ct", aliasRight: "ctn"); + .LeftJoin("ctn") + .On( + (left, right) => left.NodeId == right.NodeId, + aliasLeft: "ct", + aliasRight: "ctn") + .LeftJoin("d") + .On( + (left, right) => left.NodeId == right.NodeId, + aliasLeft: "n", + aliasRight: "d"); + if (ids.Any()) { sql = sql?.Where(x => ids.Contains(x.NodeId), "n"); @@ -78,25 +94,25 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement var innerUnionSqlChild = _scopeAccessor.AmbientScope.Database.SqlContext.Sql().Select( "[cr].childId as id", "[cr].parentId as otherId", "[rt].[alias]", "[rt].[name]", "[rt].[isDependency]", "[rt].[dual]") - .From("cr").InnerJoin("rt") + .From("cr") + .InnerJoin("rt") .On((cr, rt) => rt.Dual == false && rt.Id == cr.RelationType, "cr", "rt"); var innerUnionSqlDualParent = _scopeAccessor.AmbientScope.Database.SqlContext.Sql().Select( "[dpr].parentId as id", "[dpr].childId as otherId", "[dprt].[alias]", "[dprt].[name]", "[dprt].[isDependency]", "[dprt].[dual]") - .From("dpr").InnerJoin("dprt") - .On((dpr, dprt) => dprt.Dual == true && dprt.Id == dpr.RelationType, - "dpr", - "dprt"); + .From("dpr") + .InnerJoin("dprt") + .On( + (dpr, dprt) => dprt.Dual == true && dprt.Id == dpr.RelationType, "dpr", "dprt"); var innerUnionSql3 = _scopeAccessor.AmbientScope.Database.SqlContext.Sql().Select( "[dcr].childId as id", "[dcr].parentId as otherId", "[dcrt].[alias]", "[dcrt].[name]", "[dcrt].[isDependency]", "[dcrt].[dual]") - .From("dcr").InnerJoin("dcrt") - .On((dcr, dcrt) => dcrt.Dual == true && dcrt.Id == dcr.RelationType, - "dcr", - "dcrt"); - + .From("dcr") + .InnerJoin("dcrt") + .On( + (dcr, dcrt) => dcrt.Dual == true && dcrt.Id == dcr.RelationType, "dcr", "dcrt"); var innerUnionSql = innerUnionSqlChild.Union(innerUnionSqlDualParent).Union(innerUnionSql3); @@ -124,11 +140,13 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement .WhereLike(x => x.Path, subsubQuery); Sql innerUnionSql = GetInnerUnionSql(); + var sql = _scopeAccessor.AmbientScope?.Database.SqlContext.Sql().SelectDistinct( "[x].[id] as nodeId", "[n].[uniqueId] as nodeKey", "[n].[text] as nodeName", "[n].[nodeObjectType] as nodeObjectType", + "[d].[published] as nodePublished", "[ct].[icon] as contentTypeIcon", "[ct].[alias] as contentTypeAlias", "[ctn].[text] as contentTypeName", @@ -139,16 +157,28 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement .From("n") .InnerJoinNested(innerUnionSql, "x") .On((n, x) => n.NodeId == x.Id, "n", "x") - .LeftJoin("c").On((left, right) => left.NodeId == right.NodeId, + .LeftJoin("c") + .On( + (left, right) => left.NodeId == right.NodeId, aliasLeft: "n", aliasRight: "c") .LeftJoin("ct") - .On((left, right) => left.ContentTypeId == right.NodeId, aliasLeft: "c", + .On( + (left, right) => left.ContentTypeId == right.NodeId, + aliasLeft: "c", aliasRight: "ct") - .LeftJoin("ctn").On((left, right) => left.NodeId == right.NodeId, - aliasLeft: "ct", aliasRight: "ctn"); - sql = sql?.WhereIn((System.Linq.Expressions.Expression>)(x => x.NodeId), subQuery, - "n"); + .LeftJoin("ctn") + .On( + (left, right) => left.NodeId == right.NodeId, + aliasLeft: "ct", + aliasRight: "ctn") + .LeftJoin("d") + .On( + (left, right) => left.NodeId == right.NodeId, + aliasLeft: "n", + aliasRight: "d"); + + sql = sql?.WhereIn((System.Linq.Expressions.Expression>)(x => x.NodeId), subQuery, "n"); if (filterMustBeIsDependency) { @@ -178,6 +208,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement "[n].[uniqueId] as nodeKey", "[n].[text] as nodeName", "[n].[nodeObjectType] as nodeObjectType", + "[d].[published] as nodePublished", "[ct].[icon] as contentTypeIcon", "[ct].[alias] as contentTypeAlias", "[ctn].[text] as contentTypeName", @@ -188,14 +219,26 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement .From("n") .InnerJoinNested(innerUnionSql, "x") .On((n, x) => n.NodeId == x.OtherId, "n", "x") - .LeftJoin("c").On((left, right) => left.NodeId == right.NodeId, + .LeftJoin("c") + .On( + (left, right) => left.NodeId == right.NodeId, aliasLeft: "n", aliasRight: "c") .LeftJoin("ct") - .On((left, right) => left.ContentTypeId == right.NodeId, aliasLeft: "c", + .On( + (left, right) => left.ContentTypeId == right.NodeId, + aliasLeft: "c", aliasRight: "ct") - .LeftJoin("ctn").On((left, right) => left.NodeId == right.NodeId, - aliasLeft: "ct", aliasRight: "ctn") + .LeftJoin("ctn") + .On( + (left, right) => left.NodeId == right.NodeId, + aliasLeft: "ct", + aliasRight: "ctn") + .LeftJoin("d") + .On( + (left, right) => left.NodeId == right.NodeId, + aliasLeft: "n", + aliasRight: "d") .Where(x => x.Id == id, "x"); if (filterMustBeIsDependency) @@ -400,6 +443,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement NodeKey = dto.ChildNodeKey, NodeType = ObjectTypes.GetUdiType(dto.ChildNodeObjectType), NodeName = dto.ChildNodeName, + NodePublished = dto.ChildNodePublished, RelationTypeName = dto.RelationTypeName, RelationTypeIsBidirectional = dto.RelationTypeIsBidirectional, RelationTypeIsDependency = dto.RelationTypeIsDependency, diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/references/umbtrackedreferencestable.component.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/references/umbtrackedreferencestable.component.js index 4709a9a500..ecd4d07af9 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/references/umbtrackedreferencestable.component.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/references/umbtrackedreferencestable.component.js @@ -92,6 +92,7 @@ totalPages: "<", headline: "<", items: "<", + showPublished: "
Node Name
+
Status
Type Name
Type
Relation
-
+
+
+
+ Published + Unpublished +
+
{{::reference.contentTypeName}}
{{::reference.type}}
{{::reference.relationTypeName}}
diff --git a/src/Umbraco.Web.UI.Client/src/views/components/references/umb-tracked-references.html b/src/Umbraco.Web.UI.Client/src/views/components/references/umb-tracked-references.html index 9e08c5fbae..ec6b7d76fb 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/references/umb-tracked-references.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/references/umb-tracked-references.html @@ -13,24 +13,27 @@
- +
- +
diff --git a/src/Umbraco.Web.UI.Client/src/views/media/delete.html b/src/Umbraco.Web.UI.Client/src/views/media/delete.html index 894cf5ef77..3296b01749 100644 --- a/src/Umbraco.Web.UI.Client/src/views/media/delete.html +++ b/src/Umbraco.Web.UI.Client/src/views/media/delete.html @@ -14,7 +14,14 @@ Are you sure you want to delete {{currentNode.name}}?

- + +
{{warningText}}