Skip to content

Commit d9d5dc5

Browse files
elit0451nielslyngsoebergmania
authored
Item tracking improvements (#11919)
* Adding TrackedReferencesController * Adding/changing views * Adding/Editing js files * RelationService changes * RelationRepository changes * Adding missing translations * Adding/Modifying tests * Beginning of #9125 migration * Introducing a new component + refactoring based on that * Abstracting + refactoring * Work on content unpublishing * Work on media.delete * Various small changes * Beginning of #9119 migration * Changes on content.delete * Various fixes * Adding new keys used in the listview bulk actions * Adding methods to get the items used in relations from array of ids * Adding the checkLinkedItems function to the trackedReferencesResource * Passing the selected items from a listview to unpublish and delete * Adding umb-tracked-references-listview * Adding umb-tracked-references-listview-table with language column * Fixes for tracked references * Changes in listview unpublish dialog * Changes in listview delete dialog * Removing Variants logic as it is not currently supported * Visual fixes * Closing dialogs on click * Fix wording * Fix breaking changes * Change to a single title "Items in use" instead of 2 different for Content and Media * No need for obsoleting because we can change new controllers * Return ActionResult from actions * V9: Prevent delete or unpublish of items that have references (#12047) * Introducing config settings that prevent delete or unpublish of items referenced by other items * Disable deletion of content items and show a new warning * Disable deletion of media items and show a new warning * Disable deletion of list view items * Disable unpublish and bulk unpublish * Add a new warning * V9: Displaying descendants in use as part of item tracking (#12039) * Replace HasReferencesInDescendants with GetPagedDescendantsInReferences * Display descendants in use on parent's info tab * Add getPagedDescendantsInReferences to trackedReferencesResource * Add lang keys for Descendants in use * Refactoring controller actions * Don't call check descendants usage when it is a new item * rename busfy to busy * always show references * rearrange for scrollbar to appear at the edge of the dialog * use the word referenced instead of used * change fallback texts * Added "IsDependency" to relation types * refactor of umb-tracked-references * rename checkLinkedItems to getPagedReferencedItems * rename check to load, to be consistent with the rest. * Refactored backend . Needs frontend fixes * Cleanup * Use filters * Front-end refactor to match refactored end-points * Fixed bug + warning * Fixed query (more then 2100 descensdants) and optimized it (using nested select instead of inner join). * remove comment * hideNoneDependencies including varying text for the configuration * Hack for SqlCE :( * some final adjustments for item tracking ui * Unbreak change Co-authored-by: Niels Lyngsø <[email protected]> Co-authored-by: Bjarke Berg <[email protected]>
1 parent 2ff2ae3 commit d9d5dc5

File tree

69 files changed

+1709
-303
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+1709
-303
lines changed

src/Umbraco.Core/Configuration/Models/ContentSettings.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ @keyframes umbraco-preview-badge--effect {{
157157
internal const string StaticLoginBackgroundImage = "assets/img/login.jpg";
158158
internal const string StaticLoginLogoImage = "assets/img/application/umbraco_logo_white.svg";
159159
internal const bool StaticHideBackOfficeLogo = false;
160+
internal const bool StaticDisableDeleteWhenReferenced = false;
161+
internal const bool StaticDisableUnpublishWhenReferenced = false;
160162

161163
/// <summary>
162164
/// Gets or sets a value for the content notification settings.
@@ -226,6 +228,18 @@ @keyframes umbraco-preview-badge--effect {{
226228
[DefaultValue(StaticHideBackOfficeLogo)]
227229
public bool HideBackOfficeLogo { get; set; } = StaticHideBackOfficeLogo;
228230

231+
/// <summary>
232+
/// Gets or sets a value indicating whether to disable the deletion of items referenced by other items.
233+
/// </summary>
234+
[DefaultValue(StaticDisableDeleteWhenReferenced)]
235+
public bool DisableDeleteWhenReferenced { get; set; } = StaticDisableDeleteWhenReferenced;
236+
237+
/// <summary>
238+
/// Gets or sets a value indicating whether to disable the unpublishing of items referenced by other items.
239+
/// </summary>
240+
[DefaultValue(StaticDisableUnpublishWhenReferenced)]
241+
public bool DisableUnpublishWhenReferenced { get; set; } = StaticDisableUnpublishWhenReferenced;
242+
229243
/// <summary>
230244
/// Get or sets the model representing the global content version cleanup policy
231245
/// </summary>

src/Umbraco.Core/Events/RelateOnCopyNotificationHandler.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ public void Handle(ContentCopiedNotification notification)
3333
Constants.Conventions.RelationTypes.RelateDocumentOnCopyName,
3434
true,
3535
Constants.ObjectTypes.Document,
36-
Constants.ObjectTypes.Document);
36+
Constants.ObjectTypes.Document,
37+
false);
3738

3839
_relationService.Save(relationType);
3940
}

src/Umbraco.Core/Models/ContentEditing/RelationTypeDisplay.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,5 +55,11 @@ public RelationTypeDisplay()
5555
/// </summary>
5656
[DataMember(Name = "notifications")]
5757
public List<BackOfficeNotification> Notifications { get; private set; }
58+
59+
/// <summary>
60+
/// Gets or sets a boolean indicating whether the RelationType should be returned in "Used by"-queries.
61+
/// </summary>
62+
[DataMember(Name = "isDependency", IsRequired = true)]
63+
public bool IsDependency { get; set; }
5864
}
5965
}

src/Umbraco.Core/Models/ContentEditing/RelationTypeSave.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,11 @@ public class RelationTypeSave : EntityBasic
2323
/// </summary>
2424
[DataMember(Name = "childObjectType", IsRequired = false)]
2525
public Guid? ChildObjectType { get; set; }
26+
27+
/// <summary>
28+
/// Gets or sets a boolean indicating whether the RelationType should be returned in "Used by"-queries.
29+
/// </summary>
30+
[DataMember(Name = "isDependency", IsRequired = true)]
31+
public bool IsDependency { get; set; }
2632
}
2733
}

src/Umbraco.Core/Models/IRelationType.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,15 @@
44

55
namespace Umbraco.Cms.Core.Models
66
{
7+
public interface IRelationTypeWithIsDependency : IRelationType
8+
{
9+
/// <summary>
10+
/// Gets or sets a boolean indicating whether the RelationType should be returned in "Used by"-queries.
11+
/// </summary>
12+
[DataMember]
13+
bool IsDependency { get; set; }
14+
}
15+
716
public interface IRelationType : IEntity, IRememberBeingDirty
817
{
918
/// <summary>

src/Umbraco.Core/Models/Mapping/RelationMapDefinition.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ private void Map(IRelationType source, RelationTypeDisplay target, MapperContext
3030
target.ChildObjectType = source.ChildObjectType;
3131
target.Id = source.Id;
3232
target.IsBidirectional = source.IsBidirectional;
33+
34+
if (source is IRelationTypeWithIsDependency sourceWithIsDependency)
35+
{
36+
target.IsDependency = sourceWithIsDependency.IsDependency;
37+
}
3338
target.Key = source.Key;
3439
target.Name = source.Name;
3540
target.Alias = source.Alias;
@@ -74,6 +79,11 @@ private static void Map(RelationTypeSave source, IRelationType target, MapperCon
7479
target.ChildObjectType = source.ChildObjectType;
7580
target.Id = source.Id.TryConvertTo<int>().Result;
7681
target.IsBidirectional = source.IsBidirectional;
82+
if (target is IRelationTypeWithIsDependency targetWithIsDependency)
83+
{
84+
targetWithIsDependency.IsDependency = source.IsDependency;
85+
}
86+
7787
target.Key = source.Key;
7888
target.Name = source.Name;
7989
target.ParentObjectType = source.ParentObjectType;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
using System;
2+
using System.Runtime.Serialization;
3+
using Umbraco.Cms.Core.Models.Entities;
4+
5+
namespace Umbraco.Cms.Core.Models
6+
{
7+
[DataContract(Name = "relationItem", Namespace = "")]
8+
public class RelationItem
9+
{
10+
[DataMember(Name = "id")]
11+
public int NodeId { get; set; }
12+
13+
[DataMember(Name = "key")]
14+
public Guid NodeKey { get; set; }
15+
16+
[DataMember(Name = "name")]
17+
public string NodeName { get; set; }
18+
19+
[DataMember(Name = "type")]
20+
public string NodeType { get; set; }
21+
22+
[DataMember(Name = "udi")]
23+
public Udi NodeUdi => Udi.Create(NodeType, NodeKey);
24+
25+
[DataMember(Name = "icon")]
26+
public string ContentTypeIcon { get; set; }
27+
28+
[DataMember(Name = "alias")]
29+
public string ContentTypeAlias { get; set; }
30+
31+
[DataMember(Name = "contentTypeName")]
32+
public string ContentTypeName { get; set; }
33+
34+
[DataMember(Name = "relationTypeName")]
35+
public string RelationTypeName { get; set; }
36+
37+
[DataMember(Name = "relationTypeIsBidirectional")]
38+
public bool RelationTypeIsBidirectional { get; set; }
39+
40+
[DataMember(Name = "relationTypeIsDependency")]
41+
public bool RelationTypeIsDependency { get; set; }
42+
43+
}
44+
}

src/Umbraco.Core/Models/RelationType.cs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,28 @@ namespace Umbraco.Cms.Core.Models
99
/// </summary>
1010
[Serializable]
1111
[DataContract(IsReference = true)]
12-
public class RelationType : EntityBase, IRelationType
12+
public class RelationType : EntityBase, IRelationType, IRelationTypeWithIsDependency
1313
{
1414
private string _name;
1515
private string _alias;
1616
private bool _isBidirectional;
17+
private bool _isDependency;
1718
private Guid? _parentObjectType;
1819
private Guid? _childObjectType;
1920

2021
public RelationType(string alias, string name)
21-
: this(name: name, alias: alias, false, null, null)
22+
: this(name: name, alias: alias, false, null, null, false)
2223
{
2324
}
2425

26+
[Obsolete("Use ctor with isDependency parameter")]
2527
public RelationType(string name, string alias, bool isBidrectional, Guid? parentObjectType, Guid? childObjectType)
28+
:this(name,alias,isBidrectional, parentObjectType, childObjectType, false)
29+
{
30+
31+
}
32+
33+
public RelationType(string name, string alias, bool isBidrectional, Guid? parentObjectType, Guid? childObjectType, bool isDependency)
2634
{
2735
if (name == null) throw new ArgumentNullException(nameof(name));
2836
if (string.IsNullOrWhiteSpace(name)) throw new ArgumentException("Value can't be empty or consist only of white-space characters.", nameof(name));
@@ -32,6 +40,7 @@ public RelationType(string name, string alias, bool isBidrectional, Guid? parent
3240
_name = name;
3341
_alias = alias;
3442
_isBidirectional = isBidrectional;
43+
_isDependency = isDependency;
3544
_parentObjectType = parentObjectType;
3645
_childObjectType = childObjectType;
3746
}
@@ -88,5 +97,11 @@ public Guid? ChildObjectType
8897
set => SetPropertyValueAndDetectChanges(value, ref _childObjectType, nameof(ChildObjectType));
8998
}
9099

100+
101+
public bool IsDependency
102+
{
103+
get => _isDependency;
104+
set => SetPropertyValueAndDetectChanges(value, ref _isDependency, nameof(IsDependency));
105+
}
91106
}
92107
}

src/Umbraco.Core/Persistence/Repositories/IRelationRepository.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using Umbraco.Cms.Core.Models;
44
using Umbraco.Cms.Core.Models.Entities;
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using Umbraco.Cms.Core.Models;
4+
using Umbraco.Cms.Core.Models.Entities;
5+
6+
namespace Umbraco.Cms.Core.Persistence.Repositories
7+
{
8+
public interface ITrackedReferencesRepository
9+
{
10+
IEnumerable<RelationItem> GetPagedRelationsForItems(int[] ids, long pageIndex, int pageSize, bool filterMustBeIsDependency,out long totalRecords);
11+
IEnumerable<RelationItem> GetPagedItemsWithRelations(int[] ids, long pageIndex, int pageSize, bool filterMustBeIsDependency,out long totalRecords);
12+
IEnumerable<RelationItem> GetPagedDescendantsInReferences(int parentId, long pageIndex, int pageSize, bool filterMustBeIsDependency,out long totalRecords);
13+
}
14+
}

0 commit comments

Comments
 (0)