mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-15 19:54:57 +08:00
Fixed that Default recipe was no longer selected by default on setup screen.
This commit is contained in:
@@ -16,7 +16,7 @@
|
||||
(function($) {
|
||||
$(document).ready(function() {
|
||||
$("select.recipe").change(function() { // class="recipe" on the select element
|
||||
var description = $(this).find(":selected").attr("recipedescription"); // reads the html attribute of the selected option
|
||||
var description = $(this).find(":selected").data("recipe-description"); // reads the html attribute of the selected option
|
||||
$("#recipedescription").text(description); // make the contents of <div id="recipe-description"></div> be the escaped description string
|
||||
});
|
||||
$(".data").find('input[name=DatabaseProvider]:checked').click();
|
||||
|
@@ -1,4 +1,5 @@
|
||||
@model Orchard.Setup.ViewModels.SetupViewModel
|
||||
@using Orchard.Recipes.Models;
|
||||
@{
|
||||
Script.Require("jQuery");
|
||||
Script.Require("ShapesBase");
|
||||
@@ -8,6 +9,18 @@
|
||||
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();
|
||||
}
|
||||
@helper RenderRecipeOptions(IEnumerable<Recipe> recipes) {
|
||||
foreach (var recipe in recipes) {
|
||||
var optionAttributes = new RouteValueDictionary {
|
||||
{ "data-recipe-description", recipe.Description }
|
||||
};
|
||||
if (Model.Recipe == null && recipe.Name == "Default") {
|
||||
optionAttributes["selected"] = "selected";
|
||||
}
|
||||
@Html.SelectOption(Model.Recipe, recipe.Name, recipe.Name, optionAttributes)
|
||||
}
|
||||
}
|
||||
}
|
||||
<h1>@Html.TitleForPage(T("Get Started").ToString())</h1>
|
||||
|
||||
@using (Html.BeginFormAntiForgeryPost()) {
|
||||
@@ -83,17 +96,13 @@ if (!Model.DatabaseIsPreconfigured) {
|
||||
if (groupedRecipes.Count() > 1) {
|
||||
<optgroup label="@recipeGroup.Key"></optgroup>
|
||||
}
|
||||
foreach (var recipe in recipeGroup.OrderBy(x => x.Name)) {
|
||||
@Html.SelectOption(Model.Recipe, recipe.Name, recipe.Name, new { recipedescription = recipe.Description })
|
||||
}
|
||||
@RenderRecipeOptions(recipeGroup.OrderBy(x => x.Name))
|
||||
}
|
||||
@if (unspecifiedCategoryRecipes.Any()) {
|
||||
if (groupedRecipes.Any()) {
|
||||
<optgroup label="@T("Unspecified")"></optgroup>
|
||||
}
|
||||
foreach (var recipe in unspecifiedCategoryRecipes.OrderBy(x => x.Name)) {
|
||||
@Html.SelectOption(Model.Recipe, recipe.Name, recipe.Name, new { recipedescription = recipe.Description })
|
||||
}
|
||||
@RenderRecipeOptions(unspecifiedCategoryRecipes.OrderBy(x => x.Name))
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
|
@@ -52,6 +52,10 @@ namespace Orchard.Mvc.Html {
|
||||
}
|
||||
|
||||
public static MvcHtmlString SelectOption<T>(this HtmlHelper html, T currentValue, T optionValue, string text, object htmlAttributes) {
|
||||
return SelectOption(html, optionValue, object.Equals(optionValue, currentValue), text, new RouteValueDictionary(htmlAttributes));
|
||||
}
|
||||
|
||||
public static MvcHtmlString SelectOption<T>(this HtmlHelper html, T currentValue, T optionValue, string text, RouteValueDictionary htmlAttributes) {
|
||||
return SelectOption(html, optionValue, object.Equals(optionValue, currentValue), text, htmlAttributes);
|
||||
}
|
||||
|
||||
@@ -60,6 +64,10 @@ namespace Orchard.Mvc.Html {
|
||||
}
|
||||
|
||||
public static MvcHtmlString SelectOption(this HtmlHelper html, object optionValue, bool selected, string text, object htmlAttributes) {
|
||||
return SelectOption(html, optionValue, selected, text, new RouteValueDictionary(htmlAttributes));
|
||||
}
|
||||
|
||||
public static MvcHtmlString SelectOption(this HtmlHelper html, object optionValue, bool selected, string text, RouteValueDictionary htmlAttributes) {
|
||||
var builder = new TagBuilder("option");
|
||||
|
||||
if (optionValue != null)
|
||||
@@ -71,7 +79,7 @@ namespace Orchard.Mvc.Html {
|
||||
builder.SetInnerText(text);
|
||||
|
||||
if (htmlAttributes != null) {
|
||||
builder.MergeAttributes(new RouteValueDictionary(htmlAttributes));
|
||||
builder.MergeAttributes(htmlAttributes);
|
||||
}
|
||||
|
||||
return MvcHtmlString.Create(builder.ToString(TagRenderMode.Normal));
|
||||
|
Reference in New Issue
Block a user