mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Fixed recipe grouping on Setup screen.
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
@{
|
@{
|
||||||
var groupedRecipes = Model.Recipes.Where(x => !String.IsNullOrWhiteSpace(x.Category)).GroupBy(x => x.Category);
|
var groupedRecipes = Model.Recipes.Where(x => !String.IsNullOrWhiteSpace(x.Category)).GroupBy(x => x.Category);
|
||||||
var unspecifiedCategoryRecipes = Model.Recipes.Where(x => String.IsNullOrWhiteSpace(x.Category)).ToList();
|
var unspecifiedCategoryRecipes = Model.Recipes.Where(x => String.IsNullOrWhiteSpace(x.Category)).ToList();
|
||||||
|
var groupCount = groupedRecipes.Count() + unspecifiedCategoryRecipes.Count();
|
||||||
}
|
}
|
||||||
@helper RenderRecipeOptions(IEnumerable<Recipe> recipes) {
|
@helper RenderRecipeOptions(IEnumerable<Recipe> recipes) {
|
||||||
foreach (var recipe in recipes) {
|
foreach (var recipe in recipes) {
|
||||||
@@ -93,13 +94,13 @@ if (!Model.DatabaseIsPreconfigured) {
|
|||||||
<div>
|
<div>
|
||||||
<select id="@Html.FieldIdFor(m => m.Recipe)" name="@Html.FieldNameFor(m => m.Recipe)" class="recipe">
|
<select id="@Html.FieldIdFor(m => m.Recipe)" name="@Html.FieldNameFor(m => m.Recipe)" class="recipe">
|
||||||
@foreach(var recipeGroup in groupedRecipes.OrderBy(x => x.Key)) {
|
@foreach(var recipeGroup in groupedRecipes.OrderBy(x => x.Key)) {
|
||||||
if (groupedRecipes.Count() > 1) {
|
if (groupCount > 1) {
|
||||||
<optgroup label="@recipeGroup.Key"></optgroup>
|
<optgroup label="@recipeGroup.Key"></optgroup>
|
||||||
}
|
}
|
||||||
@RenderRecipeOptions(recipeGroup.OrderBy(x => x.Name))
|
@RenderRecipeOptions(recipeGroup.OrderBy(x => x.Name))
|
||||||
}
|
}
|
||||||
@if (unspecifiedCategoryRecipes.Any()) {
|
@if (unspecifiedCategoryRecipes.Any()) {
|
||||||
if (groupedRecipes.Any()) {
|
if (groupCount > 1) {
|
||||||
<optgroup label="@T("Unspecified")"></optgroup>
|
<optgroup label="@T("Unspecified")"></optgroup>
|
||||||
}
|
}
|
||||||
@RenderRecipeOptions(unspecifiedCategoryRecipes.OrderBy(x => x.Name))
|
@RenderRecipeOptions(unspecifiedCategoryRecipes.OrderBy(x => x.Name))
|
||||||
|
|||||||
Reference in New Issue
Block a user