* Add sort order to IDomain, UmbracoDomain and DomainDto * Add migration to create domain sort order column * Add Sort method to domain service * Set sort order when persisting new domain and order results * Add multiple and block style support to umb-button-group * Allow sorting domains in back-office, improve UI and rewrite PostSaveLanguageAndDomains for correctly sorting domains * Ensure routing and cache keeps the domain sort order * Update test to assert correct domain order * Move migration to target 11.3 and cleanup plan * Fix formatting/styling and make SelectDomains private Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com> --------- Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
56 lines
1.7 KiB
C#
56 lines
1.7 KiB
C#
using Umbraco.Cms.Core.PublishedCache;
|
|
using Umbraco.Cms.Core.Routing;
|
|
|
|
namespace Umbraco.Cms.Infrastructure.PublishedCache;
|
|
|
|
/// <summary>
|
|
/// Implements <see cref="IDomainCache" /> for NuCache.
|
|
/// </summary>
|
|
public class DomainCache : IDomainCache
|
|
{
|
|
private readonly SnapDictionary<int, Domain>.Snapshot _snapshot;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="DomainCache" /> class.
|
|
/// </summary>
|
|
public DomainCache(SnapDictionary<int, Domain>.Snapshot snapshot, string defaultCulture)
|
|
{
|
|
_snapshot = snapshot;
|
|
DefaultCulture = defaultCulture;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public string DefaultCulture { get; }
|
|
|
|
/// <inheritdoc />
|
|
public IEnumerable<Domain> GetAll(bool includeWildcards)
|
|
{
|
|
IEnumerable<Domain> list = _snapshot.GetAll();
|
|
if (includeWildcards == false)
|
|
{
|
|
list = list.Where(x => x.IsWildcard == false);
|
|
}
|
|
|
|
return list.OrderBy(x => x.SortOrder);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public IEnumerable<Domain> GetAssigned(int documentId, bool includeWildcards = false)
|
|
{
|
|
// probably this could be optimized with an index
|
|
// but then we'd need a custom DomainStore of some sort
|
|
IEnumerable<Domain> list = _snapshot.GetAll();
|
|
list = list.Where(x => x.ContentId == documentId);
|
|
if (includeWildcards == false)
|
|
{
|
|
list = list.Where(x => x.IsWildcard == false);
|
|
}
|
|
|
|
return list.OrderBy(x => x.SortOrder);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public bool HasAssigned(int documentId, bool includeWildcards = false)
|
|
=> documentId > 0 && GetAssigned(documentId, includeWildcards).Any();
|
|
}
|