Browse Source

Resolved #829

pull/839/head
Yunus Emre Kalkan 8 years ago
parent
commit
46c4b19812
  1. 32
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml
  2. 19
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs

32
modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml

@ -45,7 +45,7 @@
<nav class="navbar navbar-logo">
@if (!Model.Project.Name.IsNullOrWhiteSpace())
{
<a class="navbar-brand w-100" href="@Model.CreateLink(Model.LatestVersionInfo, Model.GetSpecificVersionOrLatest())">
<a class="navbar-brand w-100" href="@Model.CreateVersionLink(Model.LatestVersionInfo, Model.GetSpecificVersionOrLatest())">
<span id="ProjectName">@Model.Project.Name</span><br>
<strong class="display-block">
@L["Documents"]
@ -72,12 +72,21 @@
</div>
<div class="docs-tree-list">
<div class="docs-filter">
<input class="form-control" type="search" placeholder="Filter topics" aria-label="Filter">
<span class="my-2 filter-icon my-sm-0">
<i class="fa fa-filter"></i>
</span>
</div>
@if (Model.ProjectSelectItems.Any())
{
<div class="docs-version">
<div class="version-select">
<div class="input-group">
<div class="input-group-prepend">
<label class="input-group-text">@L["Project"]</label>
</div>
<select asp-items="Model.ProjectSelectItems" class="form-control" onchange="window.location.replace(this.value)"></select>
</div>
</div>
</div>
}
@if (Model.VersionSelectItems.Any())
{
@ -88,12 +97,19 @@
<label class="input-group-text">@L["Version"]</label>
</div>
<select asp-items="Model.VersionSelectItems" class="form-control" onchange="window.location.replace(this.value)"></select>
<select asp-items="Model.VersionSelectItems" class="form-control" onchange="if (this.value) { window.location.replace(this.value) }"></select>
</div>
</div>
</div>
}
<div class="docs-filter">
<input class="form-control" type="search" placeholder="Filter topics" aria-label="Filter">
<span class="my-2 filter-icon my-sm-0">
<i class="fa fa-filter"></i>
</span>
</div>
@if (Model.Navigation == null || Model.Navigation.Content.IsNullOrEmpty())
{
<div class="text-muted p-3">

19
modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs

@ -31,6 +31,8 @@ namespace Volo.Docs.Pages.Documents.Project
public List<SelectListItem> VersionSelectItems { get; private set; }
public List<SelectListItem> ProjectSelectItems { get; private set; }
public NavigationWithDetailsDto Navigation { get; private set; }
public VersionInfoViewModel LatestVersionInfo { get; private set; }
@ -52,6 +54,7 @@ namespace Volo.Docs.Pages.Documents.Project
public async Task OnGetAsync()
{
await SetProjectAsync();
await SetProjectsAsync();
await SetVersionAsync();
await SetDocumentAsync();
await SetNavigationAsync();
@ -62,6 +65,18 @@ namespace Volo.Docs.Pages.Documents.Project
Project = await _projectAppService.GetAsync(ProjectName);
}
private async Task SetProjectsAsync()
{
var projects = await _projectAppService.GetListAsync();
ProjectSelectItems = projects.Items.Select(p => new SelectListItem
{
Text = p.Name,
Value = p.Id != Project.Id ? "/documents/" + p.ShortName + "/" + DocsAppConsts.Latest : null,
Selected = p.Id == Project.Id
}).ToList();
}
private async Task SetVersionAsync()
{
//TODO: Needs refactoring
@ -101,7 +116,7 @@ namespace Volo.Docs.Pages.Documents.Project
VersionSelectItems = versions.Select(v => new SelectListItem
{
Text = v.DisplayText,
Value = CreateLink(LatestVersionInfo, v.Version, DocumentName),
Value = CreateVersionLink(LatestVersionInfo, v.Version, DocumentName),
Selected = v.IsSelected
}).ToList();
}
@ -128,7 +143,7 @@ namespace Volo.Docs.Pages.Documents.Project
Navigation.ConvertItems();
}
public string CreateLink(VersionInfoViewModel latestVersion, string version, string documentName = null)
public string CreateVersionLink(VersionInfoViewModel latestVersion, string version, string documentName = null)
{
if (latestVersion == null || latestVersion.Version == version)
{

Loading…
Cancel
Save