Fixes: U4-2843 Copying Document Type when Selecting Master Doesn't Work (Master ignored), U4-3552 Copy nested document type is failing

This commit is contained in:
Shannon
2014-03-27 17:26:55 +11:00
parent c309e18f13
commit d8a3e00440

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections;
using System.Globalization;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
@@ -58,10 +59,10 @@ namespace umbraco.dialogs
masterType.Items.Add(new ListItem(ui.Text("none") + "...", "0"));
foreach (var docT in DocumentType.GetAllAsList())
{
masterType.Items.Add(new ListItem(docT.Text, docT.Id.ToString()));
masterType.Items.Add(new ListItem(docT.Text, docT.Id.ToString(CultureInfo.InvariantCulture)));
}
masterType.SelectedValue = documentType.MasterContentType.ToString();
masterType.SelectedValue = documentType.MasterContentType.ToString(CultureInfo.InvariantCulture);
rename.Text = documentType.Text + " (copy)";
pane_settings.Text = "Make a copy of the document type '" + documentType.Text + "' and save it under a new name";
@@ -146,6 +147,9 @@ namespace umbraco.dialogs
private void HandleDocumentTypeCopy()
{
//TODO: This should be a method on the service!!!
var contentTypeService = ApplicationContext.Current.Services.ContentTypeService;
var contentType = contentTypeService.GetContentType(
int.Parse(Request.GetItemAsString("id")));
@@ -153,6 +157,20 @@ namespace umbraco.dialogs
var alias = rename.Text.Trim().Replace("'", "''");
var clone = ((Umbraco.Core.Models.ContentType) contentType).Clone(alias);
clone.Name = rename.Text.Trim();
//set the master
//http://issues.umbraco.org/issue/U4-2843
//http://issues.umbraco.org/issue/U4-3552
var parent = int.Parse(masterType.SelectedValue);
if (parent > 0)
{
clone.ParentId = parent;
}
else
{
clone.ParentId = -1;
}
contentTypeService.Save(clone);
var returnUrl = string.Format("{0}/settings/editNodeTypeNew.aspx?id={1}", SystemDirectories.Umbraco, clone.Id);