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:
Suha Can
2011-02-11 14:36:35 -08:00
parent fbc3bf0a0c
commit 1acd0f0031
7 changed files with 58 additions and 8 deletions

View File

@@ -35,7 +35,7 @@ namespace Orchard.Setup.Controllers {
public ActionResult Index() {
var initialSettings = _setupService.Prime();
// 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).
// 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")]
@@ -68,6 +72,8 @@ namespace Orchard.Setup.Controllers {
if (!ModelState.IsValid) {
model.DatabaseIsPreconfigured = !string.IsNullOrEmpty(_setupService.Prime().DataProvider);
// set HasRecipes flag
// set recipedescription
return IndexViewResult(model);
}

View File

@@ -12,3 +12,12 @@
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);

View File

@@ -23,7 +23,6 @@ using Orchard.Environment.Descriptor.Models;
using Orchard.Indexing;
using Orchard.Localization;
using Orchard.Localization.Services;
using Orchard.Recipes.Services;
using Orchard.Reports.Services;
using Orchard.Security;
using Orchard.Settings;
@@ -205,9 +204,6 @@ namespace Orchard.Setup.Services {
}
private void CreateTenantData(SetupContext context, IWorkContextScope environment) {
var recipeManager = environment.Resolve<IRecipeManager>();
var setupRecipes = recipeManager.DiscoverRecipes("Orchard.Setup");
// create superuser
var membershipService = environment.Resolve<IMembershipService>();
var user =

View File

@@ -1,3 +1,5 @@
using System.Collections.Generic;
using Orchard.Recipes.Models;
using Orchard.Setup.Annotations;
namespace Orchard.Setup.ViewModels {
@@ -19,5 +21,9 @@ namespace Orchard.Setup.ViewModels {
public string DatabaseConnectionString { get; set; }
public string DatabaseTablePrefix { get; set; }
public bool DatabaseIsPreconfigured { get; set; }
public bool HasRecipes { get; set; }
public IEnumerable<Recipe> Recipes { get; set; }
public string Recipe { get; set; }
}
}

View File

@@ -1,5 +1,6 @@
@model Orchard.Setup.ViewModels.SetupViewModel
@{
Script.Require("jquery").AtFoot();
Script.Include("setup.js").AtFoot();
}
<h1>@Html.TitleForPage(T("Get Started").ToString())</h1>
@@ -50,6 +51,22 @@ if (!Model.DatabaseIsPreconfigured) {
</div>
</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 class="curtain"></div>
<div class="curtain-content">

View File

@@ -128,6 +128,10 @@ input[type="password"] {
width:98%;
}
select {
width:100%;
}
button.primaryAction, .button.primaryAction, .button.primaryAction:link, .button.primaryAction:visited {
background:#4687ad;
border:1px solid #405f71;