Item tracking fixes (#12146)

* Cleanup; Fix lang keys

* Documentation

* Typos

* Distinct the results

* Changed GetPagedRelationsForItems to GetPagedRelationsForItem as we would only expect a single id to be passed when calling this + fix more docs

* Changed to the correct reference

* Unused code

* Only load references when info tab is clicked

Co-authored-by: Bjarke Berg <mail@bergmania.dk>
This commit is contained in:
Elitsa Marinovska
2022-03-18 11:21:49 +01:00
committed by GitHub
parent 30a30731ec
commit 3044f8df04
17 changed files with 175 additions and 137 deletions

View File

@@ -1,12 +1,7 @@
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Umbraco.Cms.Core;
using Umbraco.Cms.Core.Models;
using Umbraco.Cms.Core.Models.ContentEditing;
using Umbraco.Cms.Core.Models.Entities;
using Umbraco.Cms.Core.Services;
using Umbraco.Cms.Web.BackOffice.ModelBinders;
using Umbraco.Cms.Web.Common.Attributes;
@@ -19,28 +14,36 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
public class TrackedReferencesController : BackOfficeNotificationsController
{
private readonly ITrackedReferencesService _relationService;
private readonly IEntityService _entityService;
public TrackedReferencesController(ITrackedReferencesService relationService,
IEntityService entityService)
public TrackedReferencesController(ITrackedReferencesService relationService)
{
_relationService = relationService;
_entityService = entityService;
}
// Used by info tabs on content, media etc. So this is basically finding childs of relations.
public ActionResult<PagedResult<RelationItem>> GetPagedReferences(int id, int pageNumber = 1,
int pageSize = 100, bool filterMustBeIsDependency = false)
/// <summary>
/// Gets a page list of tracked references for the current item, so you can see where an item is being used.
/// </summary>
/// <remarks>
/// Used by info tabs on content, media etc. and for the delete and unpublish of single items.
/// This is basically finding parents of relations.
/// </remarks>
public ActionResult<PagedResult<RelationItem>> GetPagedReferences(int id, int pageNumber = 1, int pageSize = 100, bool filterMustBeIsDependency = false)
{
if (pageNumber <= 0 || pageSize <= 0)
{
return BadRequest("Both pageNumber and pageSize must be greater than zero");
}
return _relationService.GetPagedRelationsForItems(new []{id}, pageNumber - 1, pageSize, filterMustBeIsDependency);
return _relationService.GetPagedRelationsForItem(id, pageNumber - 1, pageSize, filterMustBeIsDependency);
}
// Used on delete, finds
/// <summary>
/// Gets a page list of the child nodes of the current item used in any kind of relation.
/// </summary>
/// <remarks>
/// Used when deleting and unpublishing a single item to check if this item has any descending items that are in any kind of relation.
/// This is basically finding the descending items which are children in relations.
/// </remarks>
public ActionResult<PagedResult<RelationItem>> GetPagedDescendantsInReferences(int parentId, int pageNumber = 1, int pageSize = 100, bool filterMustBeIsDependency = true)
{
if (pageNumber <= 0 || pageSize <= 0)
@@ -48,12 +51,16 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
return BadRequest("Both pageNumber and pageSize must be greater than zero");
}
return _relationService.GetPagedDescendantsInReferences(parentId, pageNumber - 1, pageSize, filterMustBeIsDependency);
}
// Used by unpublish content. So this is basically finding parents of relations.
/// <summary>
/// Gets a page list of the items used in any kind of relation from selected integer ids.
/// </summary>
/// <remarks>
/// Used when bulk deleting content/media and bulk unpublishing content (delete and unpublish on List view).
/// This is basically finding children of relations.
/// </remarks>
[HttpGet]
[HttpPost]
public ActionResult<PagedResult<RelationItem>> GetPagedReferencedItems([FromJsonPath] int[] ids, int pageNumber = 1, int pageSize = 100, bool filterMustBeIsDependency = true)
@@ -64,8 +71,6 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
}
return _relationService.GetPagedItemsWithRelations(ids, pageNumber - 1, pageSize, filterMustBeIsDependency);
}
}
}