mirror of https://github.com/abpframework/abp.git
11 changed files with 118 additions and 98 deletions
@ -0,0 +1,53 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using Newtonsoft.Json; |
||||
|
|
||||
|
namespace Volo.Docs.Documents |
||||
|
{ |
||||
|
public class NavigationNode |
||||
|
{ |
||||
|
[JsonProperty("text")] |
||||
|
public string Text { get; set; } |
||||
|
|
||||
|
[JsonProperty("path")] |
||||
|
public string Path { get; set; } |
||||
|
|
||||
|
[JsonProperty("items")] |
||||
|
public List<NavigationNode> Items { get; set; } |
||||
|
|
||||
|
public bool IsLeaf => !HasChildItems; |
||||
|
|
||||
|
public bool HasChildItems => Items != null && Items.Any(); |
||||
|
|
||||
|
public bool IsEmpty => Text == null && Path == null; |
||||
|
|
||||
|
public bool IsSelected(string documentName) |
||||
|
{ |
||||
|
if (documentName == null) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
if (string.Equals(documentName, Path, StringComparison.OrdinalIgnoreCase)) |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
if (Items == null) |
||||
|
{ |
||||
|
return false; |
||||
|
} |
||||
|
|
||||
|
foreach (var childItem in Items) |
||||
|
{ |
||||
|
if (childItem.IsSelected(documentName)) |
||||
|
{ |
||||
|
return true; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return false; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,30 @@ |
|||||
|
using System; |
||||
|
using Newtonsoft.Json; |
||||
|
|
||||
|
namespace Volo.Docs.Documents |
||||
|
{ |
||||
|
public class NavigationWithDetailsDto : DocumentWithDetailsDto |
||||
|
{ |
||||
|
[JsonProperty("items")] |
||||
|
public NavigationNode RootNode { get; set; } |
||||
|
|
||||
|
public void ConvertItems() |
||||
|
{ |
||||
|
if (!SuccessfullyRetrieved || Content.IsNullOrEmpty()) |
||||
|
{ |
||||
|
RootNode = new NavigationNode(); |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
try |
||||
|
{ |
||||
|
RootNode = JsonConvert.DeserializeObject<NavigationNode>(Content); |
||||
|
} |
||||
|
catch (JsonException ex) |
||||
|
{ |
||||
|
//todo: should log the exception?
|
||||
|
RootNode = new NavigationNode(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue