Browse Source

fixes #2538

pull/2553/head
Alper Ebicoglu 7 years ago
parent
commit
fe59b90e5a
  1. 7
      modules/docs/src/Volo.Docs.Application/Volo/Docs/Documents/DocumentAppService.cs
  2. 18
      modules/docs/src/Volo.Docs.Web/Pages/Documents/Project/Index.cshtml.cs

7
modules/docs/src/Volo.Docs.Application/Volo/Docs/Documents/DocumentAppService.cs

@ -23,7 +23,7 @@ namespace Volo.Docs.Documents
IDocumentStoreFactory documentStoreFactory, IDocumentStoreFactory documentStoreFactory,
IDistributedCache<DocumentWithDetailsDto> documentCache, IDistributedCache<DocumentWithDetailsDto> documentCache,
IDistributedCache<LanguageConfig> languageCache, IDistributedCache<LanguageConfig> languageCache,
IDistributedCache<DocumentResourceDto> resourceCache, IDistributedCache<DocumentResourceDto> resourceCache,
IHostEnvironment hostEnvironment) IHostEnvironment hostEnvironment)
{ {
_projectRepository = projectRepository; _projectRepository = projectRepository;
@ -107,6 +107,11 @@ namespace Volo.Docs.Documents
try try
{ {
if (string.IsNullOrWhiteSpace(project.ParametersDocumentName))
{
return await Task.FromResult<DocumentParametersDto>(null);
}
var document = await GetDocumentWithDetailsDtoAsync( var document = await GetDocumentWithDetailsDtoAsync(
project, project,
project.ParametersDocumentName, project.ParametersDocumentName,

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

@ -91,7 +91,7 @@ namespace Volo.Docs.Pages.Documents.Project
try try
{ {
await SetProjectAsync(); await SetProjectAsync();
} }
catch (EntityNotFoundException e) catch (EntityNotFoundException e)
{ {
@ -391,7 +391,8 @@ namespace Volo.Docs.Pages.Documents.Project
private async Task ConvertDocumentContentToHtmlAsync() private async Task ConvertDocumentContentToHtmlAsync()
{ {
await SetDocumentPreferences(); await SetDocumentPreferencesAsync();
SetUserPreferences(); SetUserPreferences();
Document.Content = await _documentSectionRenderer.RenderAsync(Document.Content, UserPreferences); Document.Content = await _documentSectionRenderer.RenderAsync(Document.Content, UserPreferences);
@ -431,12 +432,13 @@ namespace Volo.Docs.Pages.Documents.Project
{ {
continue; continue;
} }
var key = keyValue.Split("=")[0]; var key = keyValue.Split("=")[0];
var value = keyValue.Split("=")[1]; var value = keyValue.Split("=")[1];
UserPreferences.Add(key, value); UserPreferences.Add(key, value);
UserPreferences.Add(key + "_Value", DocumentPreferences.Parameters?.FirstOrDefault(p=>p.Name == key) UserPreferences.Add(key + "_Value", DocumentPreferences.Parameters?.FirstOrDefault(p => p.Name == key)
?.Values.FirstOrDefault(v=>v.Key == value).Value); ?.Values.FirstOrDefault(v => v.Key == value).Value);
} }
} }
@ -449,9 +451,11 @@ namespace Volo.Docs.Pages.Documents.Project
UserPreferences.Remove(keyValue.Key); UserPreferences.Remove(keyValue.Key);
UserPreferences.Remove(keyValue.Key + "_Value"); UserPreferences.Remove(keyValue.Key + "_Value");
} }
UserPreferences.Add(keyValue.Key, keyValue.Value); UserPreferences.Add(keyValue.Key, keyValue.Value);
UserPreferences.Add(keyValue.Key + "_Value", DocumentPreferences.Parameters?.FirstOrDefault(p => p.Name == keyValue.Key) UserPreferences.Add(keyValue.Key + "_Value",
?.Values.FirstOrDefault(v => v.Key == keyValue.Value).Value); DocumentPreferences.Parameters?.FirstOrDefault(p => p.Name == keyValue.Key)?.Values
.FirstOrDefault(v => v.Key == keyValue.Value).Value);
} }
if (DocumentPreferences?.Parameters == null) if (DocumentPreferences?.Parameters == null)
@ -469,7 +473,7 @@ namespace Volo.Docs.Pages.Documents.Project
} }
} }
public async Task SetDocumentPreferences() public async Task SetDocumentPreferencesAsync()
{ {
var projectParameters = await _documentAppService.GetParametersAsync( var projectParameters = await _documentAppService.GetParametersAsync(
new GetParametersDocumentInput new GetParametersDocumentInput

Loading…
Cancel
Save