start tree collection
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
using FluentValidation;
|
||||
using Raven.Client;
|
||||
using Raven.Client.Documents;
|
||||
using Raven.Client.Documents.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using zero.Core.Entities;
|
||||
using zero.Core.Extensions;
|
||||
|
||||
namespace zero.Core.Collections
|
||||
{
|
||||
public abstract class TreeCollectionBase<T> : CollectionBase<T>, ITreeCollectionBase<T>, IDisposable where T : IZeroEntity, ITreeEntity
|
||||
{
|
||||
public TreeCollectionBase(IZeroContext context, ICollectionInterceptorHandler interceptorHandler, IValidator<T> validator = null) : base(context, interceptorHandler, validator) { }
|
||||
|
||||
|
||||
///// <inheritdoc />
|
||||
//public async Task<List<T>> GetHierarchy(string id)
|
||||
//{
|
||||
// Categories_ByHierarchy.Result result = await Session.Query<Categories_ByHierarchy.Result, Categories_ByHierarchy>()
|
||||
// .ProjectInto<Categories_ByHierarchy.Result>()
|
||||
// .Include<Categories_ByHierarchy.Result, ICategory>(x => x.Path.Select(p => p.Id))
|
||||
// .FirstOrDefaultAsync(x => x.Id == id);
|
||||
|
||||
// if (result == null)
|
||||
// {
|
||||
// return new();
|
||||
// }
|
||||
|
||||
// return (await Session.LoadAsync<T>(result.Path.Select(x => x.Id))).Select(x => x.Value).ToList();
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
public interface ITreeCollectionBase<T> : ICollectionBase<T> where T : IZeroEntity, ITreeEntity
|
||||
{
|
||||
///// <summary>
|
||||
///// Get the tree hierarchy path for this entity
|
||||
///// </summary>
|
||||
//Task<List<T>> GetHierarchy(string id);
|
||||
|
||||
///// <summary>
|
||||
///// Update sorting of entities on a specific level
|
||||
///// </summary>
|
||||
//Task<EntityResult<List<T>>> SaveSorting(string[] sortedIds);
|
||||
|
||||
///// <summary>
|
||||
///// Move an entity to a new parent
|
||||
///// </summary>
|
||||
//Task<EntityResult<T>> Move(string id, string parentId);
|
||||
|
||||
///// <summary>
|
||||
///// Copies an entity to a new location
|
||||
///// </summary>
|
||||
//Task<EntityResult<T>> Copy(string id, string destinationId, bool includeDescendants = false);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
//using Raven.Client.Documents.Indexes;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using zero.Core.Entities;
|
||||
|
||||
//namespace zero.Core.Database.Indexes
|
||||
//{
|
||||
// public class TreeEntity_ByPath : AbstractIndexCreationTask<ITreeEntity, TreeEntity_ByPath.Result>
|
||||
// {
|
||||
// public class Result : IZeroIdEntity, IZeroDbConventions
|
||||
// {
|
||||
// public string Id { get; set; }
|
||||
|
||||
// public string Name { get; set; }
|
||||
|
||||
// public List<PathResult> Path { get; set; } = new List<PathResult>();
|
||||
|
||||
// public List<string> PathIds { get; set; } = new List<string>();
|
||||
// }
|
||||
|
||||
|
||||
// public class PathResult
|
||||
// {
|
||||
// public string Id { get; set; }
|
||||
|
||||
// public string Name { get; set; }
|
||||
// }
|
||||
|
||||
|
||||
// public TreeEntity_ByPath()
|
||||
// {
|
||||
// Map = items => items.Select(item => new Result
|
||||
// {
|
||||
// Id = item.Id,
|
||||
// Name = item.Name,
|
||||
// Path = Recurse(item, x => LoadDocument<ITreeEntity>(x.ParentId))
|
||||
// .Where(x => x != null && x.Id != null && x.Id != item.Id)
|
||||
// .Reverse()
|
||||
// .Select(current => new PathResult()
|
||||
// {
|
||||
// Id = current.Id,
|
||||
// Name = current.Name
|
||||
// })
|
||||
// .ToList(),
|
||||
// PathIds = Recurse(item, x => LoadDocument<ITreeEntity>(x.ParentId))
|
||||
// .Where(x => x != null && x.Id != null && x.Id != item.Id)
|
||||
// .Reverse()
|
||||
// .Select(current => current.Id)
|
||||
// .ToList()
|
||||
// });
|
||||
|
||||
// StoreAllFields(FieldStorage.Yes);
|
||||
// Index("PathIds", FieldIndexing.Exact);
|
||||
// //Index(x => x.ChannelId, FieldIndexing.Exact);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace zero.Core.Entities
|
||||
{
|
||||
public interface ITreeEntity : IZeroEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Id of the parent entity
|
||||
/// </summary>
|
||||
string ParentId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -27,18 +27,13 @@ namespace zero.Core.Entities
|
||||
|
||||
|
||||
[Collection("Pages")]
|
||||
public interface IPage : IZeroEntity, IZeroDbConventions
|
||||
public interface IPage : IZeroEntity, IZeroDbConventions, ITreeEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Use this field (when filled out) instead of the alias for URL generation
|
||||
/// </summary>
|
||||
string UrlAlias { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Id of the parent page
|
||||
/// </summary>
|
||||
string ParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Alias of the used page type
|
||||
/// </summary>
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<template>
|
||||
<div class="app-nav theme-dark" :class="{'is-compact': compact }">
|
||||
<div class="app-nav" :class="{'is-compact': compact }">
|
||||
|
||||
<h1 class="app-nav-headline">
|
||||
<img src="/Assets/zero-2.png" v-localize:alt="'@zero.name'" />
|
||||
<img src="/Assets/zero-2-light.png" v-localize:alt="'@zero.name'" />
|
||||
</h1>
|
||||
|
||||
<ui-dropdown v-if="applications.length > 0" class="app-nav-switch">
|
||||
|
||||
Reference in New Issue
Block a user