mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Renamed ExportStep to BuilderStep and removed BatchSize from ContentBuilderStep.
This commit is contained in:
@@ -159,7 +159,7 @@
|
|||||||
<Content Include="Views\EditorTemplates\ImportActions\UploadRecipe.cshtml" />
|
<Content Include="Views\EditorTemplates\ImportActions\UploadRecipe.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Views\EditorTemplates\ExportSteps\CustomSteps.cshtml" />
|
<Content Include="Views\EditorTemplates\BuilderSteps\CustomSteps.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Views\EditorTemplates\ExportActions\BuildRecipe.cshtml" />
|
<Content Include="Views\EditorTemplates\ExportActions\BuildRecipe.cshtml" />
|
||||||
|
|||||||
@@ -65,39 +65,41 @@ namespace Orchard.ImportExport.Providers.ImportActions {
|
|||||||
// Validate and read uploaded recipe file.
|
// Validate and read uploaded recipe file.
|
||||||
var request = _orchardServices.WorkContext.HttpContext.Request;
|
var request = _orchardServices.WorkContext.HttpContext.Request;
|
||||||
var file = request.Files["RecipeFile"];
|
var file = request.Files["RecipeFile"];
|
||||||
var isInValid = false;
|
var isValid = true;
|
||||||
|
|
||||||
ResetSite = viewModel.ResetSite;
|
ResetSite = viewModel.ResetSite;
|
||||||
SuperUserPassword = viewModel.SuperUserPassword;
|
SuperUserPassword = viewModel.SuperUserPassword;
|
||||||
|
|
||||||
if (file == null || file.ContentLength == 0) {
|
if (file == null || file.ContentLength == 0) {
|
||||||
updater.AddModelError("RecipeFile", T("No recipe file selected."));
|
updater.AddModelError("RecipeFile", T("No recipe file selected."));
|
||||||
isInValid = true;
|
isValid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ResetSite) {
|
if (ResetSite) {
|
||||||
if (String.IsNullOrWhiteSpace(viewModel.SuperUserPassword)) {
|
if (String.IsNullOrWhiteSpace(viewModel.SuperUserPassword)) {
|
||||||
updater.AddModelError("SuperUserPassword", T("Please specify a new password for the super user."));
|
updater.AddModelError("SuperUserPassword", T("Please specify a new password for the super user."));
|
||||||
isInValid = true;
|
isValid = false;
|
||||||
}
|
}
|
||||||
else if (!String.Equals(viewModel.SuperUserPassword, viewModel.SuperUserPasswordConfirmation)) {
|
else if (!String.Equals(viewModel.SuperUserPassword, viewModel.SuperUserPasswordConfirmation)) {
|
||||||
updater.AddModelError("SuperUserPassword", T("The passwords do not match."));
|
updater.AddModelError("SuperUserPassword", T("The passwords do not match."));
|
||||||
isInValid = true;
|
isValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var stepUpdater = new Updater(updater, secondHalf => String.Format("{0}.{1}", Prefix, secondHalf));
|
var stepUpdater = new Updater(updater, secondHalf => String.Format("{0}.{1}", Prefix, secondHalf));
|
||||||
|
|
||||||
// Update the view model with non-submitted values.
|
// Update the view model with non-roundtripped values.
|
||||||
viewModel.SuperUserName = _orchardServices.WorkContext.CurrentSite.SuperUser;
|
viewModel.SuperUserName = _orchardServices.WorkContext.CurrentSite.SuperUser;
|
||||||
foreach (var stepViewModel in viewModel.RecipeExecutionSteps) {
|
foreach (var stepViewModel in viewModel.RecipeExecutionSteps) {
|
||||||
var step = _recipeExecutionSteps.Single(x => x.Name == stepViewModel.Name);
|
var step = _recipeExecutionSteps.Single(x => x.Name == stepViewModel.Name);
|
||||||
stepViewModel.DisplayName = step.DisplayName;
|
stepViewModel.DisplayName = step.DisplayName;
|
||||||
stepViewModel.Description = step.Description;
|
stepViewModel.Description = step.Description;
|
||||||
|
|
||||||
|
// Update the step with posted values.
|
||||||
stepViewModel.Editor = step.UpdateEditor(shapeFactory, stepUpdater);
|
stepViewModel.Editor = step.UpdateEditor(shapeFactory, stepUpdater);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isInValid) {
|
if (isValid) {
|
||||||
// Read recipe file.
|
// Read recipe file.
|
||||||
RecipeDocument = XDocument.Parse(new StreamReader(file.InputStream).ReadToEnd());
|
RecipeDocument = XDocument.Parse(new StreamReader(file.InputStream).ReadToEnd());
|
||||||
var orchardElement = RecipeDocument.Element("Orchard");
|
var orchardElement = RecipeDocument.Element("Orchard");
|
||||||
@@ -116,6 +118,8 @@ namespace Orchard.ImportExport.Providers.ImportActions {
|
|||||||
RecipeDocument = RecipeDocument,
|
RecipeDocument = RecipeDocument,
|
||||||
Step = orchardElement.Element(executionStep.Name)
|
Step = orchardElement.Element(executionStep.Name)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Give the execution step a chance to augment the recipe step before it will be scheduled.
|
||||||
executionStep.UpdateStep(context);
|
executionStep.UpdateStep(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ namespace Orchard.ImportExport.Recipes.Builders {
|
|||||||
CustomSteps = viewModel.CustomSteps.Where(x => x.IsChecked).Select(x => x.CustomStep).ToList();
|
CustomSteps = viewModel.CustomSteps.Where(x => x.IsChecked).Select(x => x.CustomStep).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
return shapeFactory.EditorTemplate(TemplateName: "ExportSteps/CustomSteps", Model: viewModel, Prefix: Prefix);
|
return shapeFactory.EditorTemplate(TemplateName: "BuilderSteps/CustomSteps", Model: viewModel, Prefix: Prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Build(BuildContext context) {
|
public override void Build(BuildContext context) {
|
||||||
|
|||||||
@@ -103,7 +103,7 @@
|
|||||||
<Compile Include="Services\RecipeStepQueue.cs" />
|
<Compile Include="Services\RecipeStepQueue.cs" />
|
||||||
<Compile Include="ViewModels\ContentTypeEntry.cs" />
|
<Compile Include="ViewModels\ContentTypeEntry.cs" />
|
||||||
<Compile Include="ViewModels\CustomStepEntry.cs" />
|
<Compile Include="ViewModels\CustomStepEntry.cs" />
|
||||||
<Compile Include="ViewModels\DataExportStepViewModel.cs" />
|
<Compile Include="ViewModels\ContentBuilderStepViewModel.cs" />
|
||||||
<Compile Include="ViewModels\ImportResultViewModel.cs" />
|
<Compile Include="ViewModels\ImportResultViewModel.cs" />
|
||||||
<Compile Include="ViewModels\ImportViewModel.cs" />
|
<Compile Include="ViewModels\ImportViewModel.cs" />
|
||||||
<Compile Include="ViewModels\SetupRecipeStepViewModel.cs" />
|
<Compile Include="ViewModels\SetupRecipeStepViewModel.cs" />
|
||||||
@@ -135,13 +135,13 @@
|
|||||||
</Content>
|
</Content>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Views\EditorTemplates\ExportSteps\Content.cshtml" />
|
<Content Include="Views\EditorTemplates\BuilderSteps\Content.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Views\EditorTemplates\ExportSteps\RecipeMetadata.cshtml" />
|
<Content Include="Views\EditorTemplates\BuilderSteps\RecipeMetadata.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Views\EditorTemplates\ExportSteps\Settings.cshtml" />
|
<Content Include="Views\EditorTemplates\BuilderSteps\Settings.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Content Include="Views\EditorTemplates\ExecutionSteps\Content.cshtml" />
|
<Content Include="Views\EditorTemplates\ExecutionSteps\Content.cshtml" />
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ namespace Orchard.Recipes.Providers.Builders {
|
|||||||
|
|
||||||
public IList<string> SchemaContentTypes { get; set; }
|
public IList<string> SchemaContentTypes { get; set; }
|
||||||
public IList<string> DataContentTypes { get; set; }
|
public IList<string> DataContentTypes { get; set; }
|
||||||
public int? ImportBatchSize { get; set; }
|
|
||||||
public VersionHistoryOptions VersionHistoryOptions { get; set; }
|
public VersionHistoryOptions VersionHistoryOptions { get; set; }
|
||||||
|
|
||||||
public override dynamic BuildEditor(dynamic shapeFactory) {
|
public override dynamic BuildEditor(dynamic shapeFactory) {
|
||||||
@@ -54,7 +53,7 @@ namespace Orchard.Recipes.Providers.Builders {
|
|||||||
.Select(x => new ContentTypeEntry { Name = x.Name, DisplayName = x.DisplayName })
|
.Select(x => new ContentTypeEntry { Name = x.Name, DisplayName = x.DisplayName })
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
var viewModel = new DataExportStepViewModel {
|
var viewModel = new ContentBuilderStepViewModel {
|
||||||
ContentTypes = contentTypeViewModels
|
ContentTypes = contentTypeViewModels
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -64,7 +63,7 @@ namespace Orchard.Recipes.Providers.Builders {
|
|||||||
VersionHistoryOptions = viewModel.VersionHistoryOptions;
|
VersionHistoryOptions = viewModel.VersionHistoryOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
return shapeFactory.EditorTemplate(TemplateName: "ExportSteps/Content", Model: viewModel, Prefix: Prefix);
|
return shapeFactory.EditorTemplate(TemplateName: "BuilderSteps/Content", Model: viewModel, Prefix: Prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Build(BuildContext context) {
|
public override void Build(BuildContext context) {
|
||||||
@@ -79,7 +78,7 @@ namespace Orchard.Recipes.Providers.Builders {
|
|||||||
context.RecipeDocument.Element("Orchard").Add(ExportMetadata(schemaContentTypes));
|
context.RecipeDocument.Element("Orchard").Add(ExportMetadata(schemaContentTypes));
|
||||||
|
|
||||||
if(contentItems.Any())
|
if(contentItems.Any())
|
||||||
context.RecipeDocument.Element("Orchard").Add(ExportData(dataContentTypes, contentItems, ImportBatchSize));
|
context.RecipeDocument.Element("Orchard").Add(ExportData(dataContentTypes, contentItems));
|
||||||
}
|
}
|
||||||
|
|
||||||
private XElement ExportMetadata(IEnumerable<string> contentTypes) {
|
private XElement ExportMetadata(IEnumerable<string> contentTypes) {
|
||||||
@@ -107,12 +106,9 @@ namespace Orchard.Recipes.Providers.Builders {
|
|||||||
return new XElement("ContentSchema", typesElement, partsElement);
|
return new XElement("ContentSchema", typesElement, partsElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
private XElement ExportData(IEnumerable<string> contentTypes, IEnumerable<ContentItem> contentItems, int? batchSize) {
|
private XElement ExportData(IEnumerable<string> contentTypes, IEnumerable<ContentItem> contentItems) {
|
||||||
var data = new XElement("Content");
|
var data = new XElement("Content");
|
||||||
|
|
||||||
if (batchSize.HasValue && batchSize.Value > 0)
|
|
||||||
data.SetAttributeValue("BatchSize", batchSize);
|
|
||||||
|
|
||||||
var orderedContentItemsQuery =
|
var orderedContentItemsQuery =
|
||||||
from contentItem in contentItems
|
from contentItem in contentItems
|
||||||
let identity = _orchardServices.ContentManager.GetItemMetadata(contentItem).Identity.ToString()
|
let identity = _orchardServices.ContentManager.GetItemMetadata(contentItem).Identity.ToString()
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ namespace Orchard.Recipes.Providers.Builders {
|
|||||||
IsSetupRecipe = viewModel.IsSetupRecipe;
|
IsSetupRecipe = viewModel.IsSetupRecipe;
|
||||||
}
|
}
|
||||||
|
|
||||||
return shapeFactory.EditorTemplate(TemplateName: "ExportSteps/RecipeMetadata", Model: viewModel, Prefix: Prefix);
|
return shapeFactory.EditorTemplate(TemplateName: "BuilderSteps/RecipeMetadata", Model: viewModel, Prefix: Prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Build(BuildContext context) {
|
public override void Build(BuildContext context) {
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ namespace Orchard.Recipes.Providers.Builders {
|
|||||||
|
|
||||||
public override dynamic UpdateEditor(dynamic shapeFactory, IUpdateModel updater) {
|
public override dynamic UpdateEditor(dynamic shapeFactory, IUpdateModel updater) {
|
||||||
var viewModel = new SiteSettingsStepViewModel();
|
var viewModel = new SiteSettingsStepViewModel();
|
||||||
return shapeFactory.EditorTemplate(TemplateName: "ExportSteps/Settings", Model: viewModel, Prefix: Prefix);
|
return shapeFactory.EditorTemplate(TemplateName: "BuilderSteps/Settings", Model: viewModel, Prefix: Prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Build(BuildContext context) {
|
public override void Build(BuildContext context) {
|
||||||
|
|||||||
@@ -2,13 +2,12 @@ using System.Collections.Generic;
|
|||||||
using Orchard.Recipes.Models;
|
using Orchard.Recipes.Models;
|
||||||
|
|
||||||
namespace Orchard.Recipes.ViewModels {
|
namespace Orchard.Recipes.ViewModels {
|
||||||
public class DataExportStepViewModel {
|
public class ContentBuilderStepViewModel {
|
||||||
public DataExportStepViewModel() {
|
public ContentBuilderStepViewModel() {
|
||||||
ContentTypes = new List<ContentTypeEntry>();
|
ContentTypes = new List<ContentTypeEntry>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public IList<ContentTypeEntry> ContentTypes { get; set; }
|
public IList<ContentTypeEntry> ContentTypes { get; set; }
|
||||||
public VersionHistoryOptions VersionHistoryOptions { get; set; }
|
public VersionHistoryOptions VersionHistoryOptions { get; set; }
|
||||||
public int? ImportBatchSize { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
@model Orchard.Recipes.ViewModels.DataExportStepViewModel
|
@model Orchard.Recipes.ViewModels.ContentBuilderStepViewModel
|
||||||
@{
|
@{
|
||||||
Style.Include("recipebuilderstep-content.css");
|
Style.Include("recipebuilderstep-content.css");
|
||||||
Script.Require("jQuery");
|
Script.Require("jQuery");
|
||||||
@@ -40,12 +40,6 @@
|
|||||||
</table>
|
</table>
|
||||||
@Html.Hint(T("Choose the types to include in the export file"))
|
@Html.Hint(T("Choose the types to include in the export file"))
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
|
||||||
@Html.LabelFor(m => m.ImportBatchSize, T("Batch Size"))
|
|
||||||
@Html.TextBoxFor(m => m.ImportBatchSize, new { @class = "text small" })
|
|
||||||
@Html.Hint(T("The batch size to use when importing the data. Leave empty to disable batched imports."))
|
|
||||||
</div>
|
|
||||||
<div>
|
<div>
|
||||||
<p>@T("Version History")</p>
|
<p>@T("Version History")</p>
|
||||||
@Html.RadioButtonFor(m => m.VersionHistoryOptions, "Published", new { id = "Published", Checked = "Checked" })
|
@Html.RadioButtonFor(m => m.VersionHistoryOptions, "Published", new { id = "Published", Checked = "Checked" })
|
||||||
Reference in New Issue
Block a user