Added Recipe Name option to export screen.

This commit is contained in:
Sipke Schoorstra
2015-07-13 18:12:42 +01:00
parent 6d2832ef08
commit 0697042a65
5 changed files with 19 additions and 3 deletions

View File

@@ -10,6 +10,7 @@ using Orchard.Localization;
using Orchard.Recipes.Services;
using Orchard.UI.Notify;
using Orchard.ImportExport.Models;
using Orchard.Utility.Extensions;
namespace Orchard.ImportExport.Controllers {
public class AdminController : Controller {
@@ -104,6 +105,7 @@ namespace Orchard.ImportExport.Controllers {
ExportMetadata = viewModel.Metadata,
ExportSiteSettings = viewModel.SiteSettings,
SetupRecipe = viewModel.SetupRecipe,
RecipeName = viewModel.RecipeName,
RecipeDescription = viewModel.RecipeDescription,
RecipeWebsite = viewModel.RecipeWebsite,
RecipeTags = viewModel.RecipeTags,
@@ -117,8 +119,11 @@ namespace Orchard.ImportExport.Controllers {
exportOptions.ImportBatchSize = viewModel.ImportBatchSize;
}
var exportFilePath = _importExportService.Export(contentTypesToExport, exportOptions);
var exportFileName = exportOptions.SetupRecipe && !String.IsNullOrWhiteSpace(exportOptions.RecipeName)
? String.Format("{0}.recipe.xml", exportOptions.RecipeName.HtmlClassify())
: "export.xml";
return File(exportFilePath, "text/xml", "export.xml");
return File(exportFilePath, "text/xml", exportFileName);
}
}
}

View File

@@ -9,6 +9,7 @@ namespace Orchard.ImportExport.Models {
public bool ExportSiteSettings { get; set; }
public IEnumerable<string> CustomSteps { get; set; }
public bool SetupRecipe { get; set; }
public string RecipeName { get; set; }
public string RecipeDescription { get; set; }
public string RecipeWebsite { get; set; }
public string RecipeTags { get; set; }

View File

@@ -100,12 +100,16 @@ namespace Orchard.ImportExport.Services {
}
private XDocument CreateExportRoot(ExportOptions exportOptions) {
var recipeName = !String.IsNullOrWhiteSpace(exportOptions.RecipeName)
? exportOptions.RecipeName
: T("Generated by Orchard.ImportExport").ToString();
var exportRoot = new XDocument(
new XDeclaration("1.0", "", "yes"),
new XComment("Exported from Orchard"),
new XElement("Orchard",
new XElement("Recipe",
new XElement("Name", "Generated by Orchard.ImportExport"),
new XElement("Name", recipeName),
new XElement("Description", exportOptions.RecipeDescription),
new XElement("Author", _orchardServices.WorkContext.CurrentUser.UserName),
new XElement("WebSite", exportOptions.RecipeWebsite),

View File

@@ -10,6 +10,7 @@ namespace Orchard.ImportExport.ViewModels {
public string DataImportChoice { get; set; }
public bool SiteSettings { get; set; }
public bool SetupRecipe { get; set; }
public string RecipeName { get; set; }
public string RecipeDescription { get; set; }
public string RecipeWebsite { get; set; }
public string RecipeTags { get; set; }

View File

@@ -56,6 +56,11 @@
@Html.Hint(T("Check this option if you want to use the generated recipe as a setup recipe."))
</div>
<div data-controllerid="@Html.FieldIdFor(m => m.SetupRecipe)">
<div>
@Html.LabelFor(m => m.RecipeName, T("Name"))
@Html.TextBoxFor(m => m.RecipeName, new { @class = "text medium" })
@Html.Hint(T("Optionally provide a name for the setup recipe."))
</div>
<div>
@Html.LabelFor(m => m.RecipeDescription, T("Description"))
@Html.TextBoxFor(m => m.RecipeDescription, new {@class = "text large"})
@@ -73,7 +78,7 @@
</div>
<div>
@Html.LabelFor(m => m.RecipeVersion, T("Version"))
@Html.TextBoxFor(m => m.RecipeVersion, new { @class = "text small" })
@Html.TextBoxFor(m => m.RecipeVersion, new {@class = "text small"})
@Html.Hint(T("Optionally provide a version for the setup recipe."))
</div>
</div>