mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-10-21 19:34:40 +08:00
Setup UI for recipes
Choose a recipe is shown if there are recipes in the setup module Added jquery to the setup view Recipe description gets shown for selected option via jquery --HG-- branch : recipe
This commit is contained in:
@@ -35,7 +35,7 @@ namespace Orchard.Setup.Controllers {
|
|||||||
|
|
||||||
public ActionResult Index() {
|
public ActionResult Index() {
|
||||||
var initialSettings = _setupService.Prime();
|
var initialSettings = _setupService.Prime();
|
||||||
|
|
||||||
// On the first time installation of Orchard, the user gets to the setup screen, which
|
// On the first time installation of Orchard, the user gets to the setup screen, which
|
||||||
// will take a while to finish (user inputting data and the setup process itself).
|
// will take a while to finish (user inputting data and the setup process itself).
|
||||||
// We use this opportunity to start a background task to "pre-compile" all the known
|
// We use this opportunity to start a background task to "pre-compile" all the known
|
||||||
@@ -46,7 +46,11 @@ namespace Orchard.Setup.Controllers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
return IndexViewResult(new SetupViewModel { AdminUsername = "admin", DatabaseIsPreconfigured = !string.IsNullOrEmpty(initialSettings.DataProvider)});
|
|
||||||
|
return IndexViewResult(new SetupViewModel {
|
||||||
|
AdminUsername = "admin",
|
||||||
|
DatabaseIsPreconfigured = !string.IsNullOrEmpty(initialSettings.DataProvider),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[HttpPost, ActionName("Index")]
|
[HttpPost, ActionName("Index")]
|
||||||
@@ -68,6 +72,8 @@ namespace Orchard.Setup.Controllers {
|
|||||||
|
|
||||||
if (!ModelState.IsValid) {
|
if (!ModelState.IsValid) {
|
||||||
model.DatabaseIsPreconfigured = !string.IsNullOrEmpty(_setupService.Prime().DataProvider);
|
model.DatabaseIsPreconfigured = !string.IsNullOrEmpty(_setupService.Prime().DataProvider);
|
||||||
|
// set HasRecipes flag
|
||||||
|
// set recipedescription
|
||||||
return IndexViewResult(model);
|
return IndexViewResult(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -12,3 +12,12 @@
|
|||||||
document.forms[0].attachEvent("onsubmit", show);
|
document.forms[0].attachEvent("onsubmit", show);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
(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
|
||||||
|
$("#recipedescription").text(description); // make the contents of <div id="recipe-description"></div> be the escaped description string
|
||||||
|
});
|
||||||
|
})(jQuery);
|
||||||
|
|
||||||
|
|
||||||
|
@@ -23,7 +23,6 @@ using Orchard.Environment.Descriptor.Models;
|
|||||||
using Orchard.Indexing;
|
using Orchard.Indexing;
|
||||||
using Orchard.Localization;
|
using Orchard.Localization;
|
||||||
using Orchard.Localization.Services;
|
using Orchard.Localization.Services;
|
||||||
using Orchard.Recipes.Services;
|
|
||||||
using Orchard.Reports.Services;
|
using Orchard.Reports.Services;
|
||||||
using Orchard.Security;
|
using Orchard.Security;
|
||||||
using Orchard.Settings;
|
using Orchard.Settings;
|
||||||
@@ -205,9 +204,6 @@ namespace Orchard.Setup.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void CreateTenantData(SetupContext context, IWorkContextScope environment) {
|
private void CreateTenantData(SetupContext context, IWorkContextScope environment) {
|
||||||
var recipeManager = environment.Resolve<IRecipeManager>();
|
|
||||||
var setupRecipes = recipeManager.DiscoverRecipes("Orchard.Setup");
|
|
||||||
|
|
||||||
// create superuser
|
// create superuser
|
||||||
var membershipService = environment.Resolve<IMembershipService>();
|
var membershipService = environment.Resolve<IMembershipService>();
|
||||||
var user =
|
var user =
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using Orchard.Recipes.Models;
|
||||||
using Orchard.Setup.Annotations;
|
using Orchard.Setup.Annotations;
|
||||||
|
|
||||||
namespace Orchard.Setup.ViewModels {
|
namespace Orchard.Setup.ViewModels {
|
||||||
@@ -19,5 +21,9 @@ namespace Orchard.Setup.ViewModels {
|
|||||||
public string DatabaseConnectionString { get; set; }
|
public string DatabaseConnectionString { get; set; }
|
||||||
public string DatabaseTablePrefix { get; set; }
|
public string DatabaseTablePrefix { get; set; }
|
||||||
public bool DatabaseIsPreconfigured { get; set; }
|
public bool DatabaseIsPreconfigured { get; set; }
|
||||||
|
|
||||||
|
public bool HasRecipes { get; set; }
|
||||||
|
public IEnumerable<Recipe> Recipes { get; set; }
|
||||||
|
public string Recipe { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,5 +1,6 @@
|
|||||||
@model Orchard.Setup.ViewModels.SetupViewModel
|
@model Orchard.Setup.ViewModels.SetupViewModel
|
||||||
@{
|
@{
|
||||||
|
Script.Require("jquery").AtFoot();
|
||||||
Script.Include("setup.js").AtFoot();
|
Script.Include("setup.js").AtFoot();
|
||||||
}
|
}
|
||||||
<h1>@Html.TitleForPage(T("Get Started").ToString())</h1>
|
<h1>@Html.TitleForPage(T("Get Started").ToString())</h1>
|
||||||
@@ -50,6 +51,22 @@ if (!Model.DatabaseIsPreconfigured) {
|
|||||||
</div>
|
</div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
}
|
}
|
||||||
|
if (Model.HasRecipes) {
|
||||||
|
<fieldset>
|
||||||
|
<legend>@T("Use an Orchard Recipe during setup (Optional)")</legend>
|
||||||
|
<div>@T("Orchard Recipes allow you to setup your site with additional pre-configured options, features and settings out of the box")</div>
|
||||||
|
<div>
|
||||||
|
<select id="@Html.FieldIdFor(m => m.Recipe)" name="@Html.FieldNameFor(m => m.Recipe)" class="recipe">
|
||||||
|
@Html.SelectOption("", false, "Choose")
|
||||||
|
@Html.SelectOption("", false, "-------------------")
|
||||||
|
@foreach(var recipe in Model.Recipes) {
|
||||||
|
@Html.SelectOption(Model.Recipe, recipe.Name, recipe.Name, new { recipedescription = recipe.Description })
|
||||||
|
}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div id="recipedescription"></div>
|
||||||
|
</fieldset>
|
||||||
|
}
|
||||||
<div id="throbber">
|
<div id="throbber">
|
||||||
<div class="curtain"></div>
|
<div class="curtain"></div>
|
||||||
<div class="curtain-content">
|
<div class="curtain-content">
|
||||||
|
@@ -128,6 +128,10 @@ input[type="password"] {
|
|||||||
width:98%;
|
width:98%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
select {
|
||||||
|
width:100%;
|
||||||
|
}
|
||||||
|
|
||||||
button.primaryAction, .button.primaryAction, .button.primaryAction:link, .button.primaryAction:visited {
|
button.primaryAction, .button.primaryAction, .button.primaryAction:link, .button.primaryAction:visited {
|
||||||
background:#4687ad;
|
background:#4687ad;
|
||||||
border:1px solid #405f71;
|
border:1px solid #405f71;
|
||||||
|
@@ -52,9 +52,17 @@ namespace Orchard.Mvc.Html {
|
|||||||
return SelectOption(html, optionValue, object.Equals(optionValue, currentValue), text);
|
return SelectOption(html, optionValue, object.Equals(optionValue, currentValue), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MvcHtmlString SelectOption(this HtmlHelper html, object optionValue, bool selected, string text) {
|
public static MvcHtmlString SelectOption<T>(this HtmlHelper html, T currentValue, T optionValue, string text, object htmlAttributes) {
|
||||||
var builder = new TagBuilder("option");
|
return SelectOption(html, optionValue, object.Equals(optionValue, currentValue), text, htmlAttributes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MvcHtmlString SelectOption(this HtmlHelper html, object optionValue, bool selected, string text) {
|
||||||
|
return SelectOption(html, optionValue, selected, text, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MvcHtmlString SelectOption(this HtmlHelper html, object optionValue, bool selected, string text, object htmlAttributes) {
|
||||||
|
var builder = new TagBuilder("option");
|
||||||
|
|
||||||
if (optionValue != null)
|
if (optionValue != null)
|
||||||
builder.MergeAttribute("value", optionValue.ToString());
|
builder.MergeAttribute("value", optionValue.ToString());
|
||||||
|
|
||||||
@@ -63,6 +71,10 @@ namespace Orchard.Mvc.Html {
|
|||||||
|
|
||||||
builder.SetInnerText(text);
|
builder.SetInnerText(text);
|
||||||
|
|
||||||
|
if (htmlAttributes != null) {
|
||||||
|
builder.MergeAttributes(new RouteValueDictionary(htmlAttributes));
|
||||||
|
}
|
||||||
|
|
||||||
return MvcHtmlString.Create(builder.ToString(TagRenderMode.Normal));
|
return MvcHtmlString.Create(builder.ToString(TagRenderMode.Normal));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user