Fixing Content Picker when Search is the only tab

--HG--
branch : 1.x
This commit is contained in:
Sebastien Ros
2013-02-20 13:01:09 -08:00
parent 9d081860cb
commit 09f8c56377
5 changed files with 20 additions and 5 deletions

View File

@@ -51,11 +51,22 @@ namespace Orchard.ContentPicker.Controllers {
if (contentPickerMenuItem.Items.All(x => x.Text.ToString() != T("Recent Content").Text)) {
// the default tab should not be displayed, redirect to the next one
var root = menuItems.FirstOrDefault();
if (root == null) {
return HttpNotFound();
}
var routeData = new RouteValueDictionary(menuItems.First().RouteValues);
var firstChild = root.Items.First();
if (firstChild == null) {
return HttpNotFound();
}
var routeData = new RouteValueDictionary(firstChild.RouteValues);
var queryString = Request.QueryString;
foreach (var key in queryString.AllKeys) {
routeData[key] = queryString[key];
if (!String.IsNullOrEmpty(key)) {
routeData[key] = queryString[key];
}
}
return RedirectToRoute(routeData);

View File

@@ -61,7 +61,7 @@ namespace Orchard.Search.Controllers {
}
if (!_indexManager.HasIndexProvider()) {
return HttpNotFound();
return View("NoIndex");
}
var builder = _indexManager.GetSearchIndexProvider().CreateSearchBuilder("Search");

View File

@@ -118,6 +118,9 @@
<ItemGroup>
<Content Include="Views\DefinitionTemplates\ContentPickerSearchFieldSettings.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="Views\ContentPicker\NoIndex.cshtml" />
</ItemGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>

View File

@@ -0,0 +1 @@
@T("You need to enable a search index module.")

View File

@@ -9,13 +9,13 @@
<h1>@Html.TitleForPage(T("Search").Text)</h1>
@if (HasText(Model.Query)) {
if (searchResults.Count() == 0) {
if (!searchResults.Any()) {
<p class="search-summary">@T.Plural("There is <em>one</em> result", "<em>zero</em> results", searchResults.Count())</p>
} else {
<p class="search-summary">@T.Plural("There is <em>one</em> result", "<em>{1} - {2}</em> of <em>{0}</em> results", Model.TotalItemCount, Model.StartPosition, Model.EndPosition)</p>
}
}
@if (searchResults != null && searchResults.Count() > 0) {
@if (searchResults != null && searchResults.Any()) {
@Display(searchResults)
@Display(Model.Pager)
}