Dynamic Root (Alternative to XPath in MNTP) (#15035)

* Temp commit.. Initial work on XPath alternative for dymamically finding start nodes

* First commit that goes all the way from ui to db for NearestAncestorOrSelf

* Added more filters + return null from controller instead of not found

* Bugfix

* rewrite query to make sqlserver happy?

* Added more tests

* clean up initial step

* Added tests and refactor

* Update endpoint to take model instead of json

* pick origin

* Use model for config instead of string

* append add filter button

* fix

* default filter

* rename json fields

* correct field names

* minor corrections

* Renaming..

* Rename endpoint

* initial work for appending query steps

* query steps ui

* more localization

* query step UI

* Use doc type keys instead of alias

* only for Documents

* change to send keys to anyOfDocTypeKeys

* Fix potential bug

* Fix when level is impossible to get

* correct prop to dynamicRoot

* noValidStartNode dialog

* custom query step

* Renaming

* Rollback unintended file change

* Fixed issue if no doc type is chosen

* Remove unintended file changes

* More unintended changes

* Renaming

* Optimizations

- IDE Recommendation for better source
- Renaming for better clarity
- Improving spacing/formatting
- Typo corrections
- Remove warnings concerning IEnumerable

* Fix failed attempt bug

---------

Co-authored-by: Niels Lyngsø <niels.lyngso@gmail.com>
Co-authored-by: Sven Geusens <sge@umbraco.dk>
This commit is contained in:
Bjarke Berg
2023-10-31 11:38:24 +01:00
committed by GitHub
parent 1b34d33eb7
commit 6658a521b2
49 changed files with 2387 additions and 85 deletions

View File

@@ -0,0 +1,37 @@
using Umbraco.Cms.Core.Extensions;
using Umbraco.Cms.Core.Scoping;
using Umbraco.Extensions;
namespace Umbraco.Cms.Core.DynamicRoot.QuerySteps;
public class NearestAncestorOrSelfDynamicRootQueryStep : IDynamicRootQueryStep
{
private readonly ICoreScopeProvider _scopeProvider;
private readonly IDynamicRootRepository _nodeFilterRepository;
public NearestAncestorOrSelfDynamicRootQueryStep(ICoreScopeProvider scopeProvider, IDynamicRootRepository nodeFilterRepository)
{
_scopeProvider = scopeProvider;
_nodeFilterRepository = nodeFilterRepository;
}
protected virtual string SupportedDirectionAlias { get; set; } = "NearestAncestorOrSelf";
public async Task<Attempt<ICollection<Guid>>> ExecuteAsync(ICollection<Guid> origins, DynamicRootQueryStep filter)
{
if (filter.Alias != SupportedDirectionAlias)
{
return Attempt<ICollection<Guid>>.Fail();
}
if (origins.Count < 1)
{
return Attempt<ICollection<Guid>>.Succeed(Array.Empty<Guid>());
}
using ICoreScope scope = _scopeProvider.CreateCoreScope(autoComplete: true);
var result = (await _nodeFilterRepository.NearestAncestorOrSelfAsync(origins, filter))?.ToSingleItemCollection() ?? Array.Empty<Guid>();
return Attempt<ICollection<Guid>>.Succeed(result);
}
}