Skip to content

Commit 752ce55

Browse files
committed
Merge pull request umbraco#551 from kristianschneider/UmbUkFest-5737
Fix for U4-5737 Create package: ContentType Tab index not saved
2 parents e6d6d3d + 3e66235 commit 752ce55

File tree

2 files changed

+36
-33
lines changed

2 files changed

+36
-33
lines changed

src/Umbraco.Core/Services/EntityXmlSerializer.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,9 @@ public XElement Serialize(IDataTypeService dataTypeService, IMediaType mediaType
248248
{
249249
var tab = new XElement("Tab",
250250
new XElement("Id", propertyGroup.Id.ToString(CultureInfo.InvariantCulture)),
251-
new XElement("Caption", propertyGroup.Name));
251+
new XElement("Caption", propertyGroup.Name),
252+
new XElement("SortOrder", propertyGroup.SortOrder));
253+
252254
tabs.Add(tab);
253255
}
254256

@@ -354,7 +356,8 @@ public XElement Serialize(IDataTypeService dataTypeService, IContentType content
354356
{
355357
var tab = new XElement("Tab",
356358
new XElement("Id", propertyGroup.Id.ToString(CultureInfo.InvariantCulture)),
357-
new XElement("Caption", propertyGroup.Name));
359+
new XElement("Caption", propertyGroup.Name),
360+
new XElement("SortOrder", propertyGroup.SortOrder));
358361
tabs.Add(tab);
359362
}
360363

src/Umbraco.Core/Services/PackagingService.cs

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public PackagingService(IContentService contentService,
7474
public XElement Export(IContent content, bool deep = false, bool raiseEvents = true)
7575
{
7676
var nodeName = UmbracoConfig.For.UmbracoSettings().Content.UseLegacyXmlSchema ? "node" : content.ContentType.Alias.ToSafeAliasWithForcingCheck();
77-
77+
7878
if (raiseEvents)
7979
{
8080
if (ExportingContent.IsRaisedEventCancelled(new ExportEventArgs<IContent>(content, nodeName), this))
@@ -84,13 +84,13 @@ public XElement Export(IContent content, bool deep = false, bool raiseEvents = t
8484
var exporter = new EntityXmlSerializer();
8585
var xml = exporter.Serialize(_contentService, _dataTypeService, content, deep);
8686

87-
if(raiseEvents)
87+
if (raiseEvents)
8888
ExportedContent.RaiseEvent(new ExportEventArgs<IContent>(content, xml, false), this);
8989

9090
return xml;
9191
}
9292

93-
93+
9494

9595
/// <summary>
9696
/// Imports and saves package xml as <see cref="IContent"/>
@@ -107,7 +107,7 @@ public IEnumerable<IContent> ImportContent(XElement element, int parentId = -1,
107107
if (ImportingContent.IsRaisedEventCancelled(new ImportEventArgs<IContent>(element), this))
108108
return Enumerable.Empty<IContent>();
109109
}
110-
110+
111111
var name = element.Name.LocalName;
112112
if (name.Equals("DocumentSet"))
113113
{
@@ -120,7 +120,7 @@ public IEnumerable<IContent> ImportContent(XElement element, int parentId = -1,
120120
if (contents.Any())
121121
_contentService.Save(contents, userId);
122122

123-
if(raiseEvents)
123+
if (raiseEvents)
124124
ImportedContent.RaiseEvent(new ImportEventArgs<IContent>(contents, element, false), this);
125125
return contents;
126126
}
@@ -134,7 +134,7 @@ public IEnumerable<IContent> ImportContent(XElement element, int parentId = -1,
134134
if (contents.Any())
135135
_contentService.Save(contents, userId);
136136

137-
if(raiseEvents)
137+
if (raiseEvents)
138138
ImportedContent.RaiseEvent(new ImportEventArgs<IContent>(contents, element, false), this);
139139
return contents;
140140
}
@@ -248,7 +248,7 @@ where property.Attribute("isDoc") == null
248248

249249
//TODO: We need to refactor this so the packager isn't making direct db calls for an 'edge' case
250250
var database = ApplicationContext.Current.DatabaseContext.Database;
251-
var dtos = database.Fetch<DataTypePreValueDto>("WHERE datatypeNodeId = @Id", new {Id = propertyType.DataTypeDefinitionId});
251+
var dtos = database.Fetch<DataTypePreValueDto>("WHERE datatypeNodeId = @Id", new { Id = propertyType.DataTypeDefinitionId });
252252

253253
var propertyValueList = new List<string>();
254254
foreach (var preValue in propertyValue.Split(','))
@@ -261,7 +261,7 @@ where property.Attribute("isDoc") == null
261261
}
262262

263263
//set property value
264-
content.SetValue(propertyTypeAlias, propertyValue);
264+
content.SetValue(propertyTypeAlias, propertyValue);
265265
}
266266
}
267267
}
@@ -491,13 +491,13 @@ private void UpdateContentTypesTabs(IContentType contentType, XElement tabElemen
491491
{
492492
contentType.AddPropertyGroup(caption);
493493

494-
int sortOrder;
495-
if(tab.Element("SortOrder") != null &&
496-
int.TryParse(tab.Element("SortOrder").Value, out sortOrder))
497-
{
498-
// Override the sort order with the imported value
499-
contentType.PropertyGroups[caption].SortOrder = sortOrder;
500-
}
494+
}
495+
496+
int sortOrder;
497+
if (tab.Element("SortOrder") != null && int.TryParse(tab.Element("SortOrder").Value, out sortOrder))
498+
{
499+
// Override the sort order with the imported value
500+
contentType.PropertyGroups[caption].SortOrder = sortOrder;
501501
}
502502
}
503503
}
@@ -549,7 +549,7 @@ private void UpdateContentTypesProperties(IContentType contentType, XElement gen
549549
dataTypeDefinition = dataTypeDefinitions.First();
550550
}
551551
}
552-
552+
553553
// For backwards compatibility, if no datatype with that ID can be found, we're letting this fail silently.
554554
// This means that the property will not be created.
555555
if (dataTypeDefinition == null)
@@ -786,15 +786,15 @@ private void SavePrevaluesFromXml(List<IDataTypeDefinition> dataTypes, IEnumerab
786786
var dataTypeDefinition = dataTypes.First(x => x.Name == dataTypeDefinitionName);
787787

788788
var valuesWithoutKeys = prevaluesElement.Elements("PreValue")
789-
.Where(x => ((string) x.Attribute("Alias")).IsNullOrWhiteSpace())
789+
.Where(x => ((string)x.Attribute("Alias")).IsNullOrWhiteSpace())
790790
.Select(x => x.Attribute("Value").Value);
791791

792792
var valuesWithKeys = prevaluesElement.Elements("PreValue")
793-
.Where(x => ((string) x.Attribute("Alias")).IsNullOrWhiteSpace() == false)
793+
.Where(x => ((string)x.Attribute("Alias")).IsNullOrWhiteSpace() == false)
794794
.ToDictionary(
795-
key => (string) key.Attribute("Alias"),
796-
val => new PreValue((string) val.Attribute("Value")));
797-
795+
key => (string)key.Attribute("Alias"),
796+
val => new PreValue((string)val.Attribute("Value")));
797+
798798
//save the values with keys
799799
_dataTypeService.SavePreValues(dataTypeDefinition, valuesWithKeys);
800800

@@ -841,7 +841,7 @@ public XElement Export(IDictionaryItem dictionaryItem, bool includeChildren, boo
841841

842842
var exporter = new EntityXmlSerializer();
843843
var xml = exporter.Serialize(dictionaryItem);
844-
844+
845845
if (includeChildren)
846846
{
847847
var children = _localizationService.GetDictionaryItemChildren(dictionaryItem.Key);
@@ -1115,7 +1115,7 @@ private IMacro ParseMacroElement(XElement macroElement)
11151115
dontRender = bool.Parse(dontRenderElement.Value);
11161116
}
11171117

1118-
var existingMacro = _macroService.GetByAlias(macroAlias) as Macro;
1118+
var existingMacro = _macroService.GetByAlias(macroAlias) as Macro;
11191119
var macro = existingMacro ?? new Macro(macroAlias, macroName, controlType, controlAssembly, xsltPath, scriptPath,
11201120
cacheByPage, cacheByMember, dontRender, useInEditor, cacheDuration);
11211121

@@ -1210,7 +1210,7 @@ public XElement Export(IMember member)
12101210
public XElement Export(IMedia media, bool deep = false, bool raiseEvents = true)
12111211
{
12121212
var nodeName = UmbracoConfig.For.UmbracoSettings().Content.UseLegacyXmlSchema ? "node" : media.ContentType.Alias.ToSafeAliasWithForcingCheck();
1213-
1213+
12141214
if (raiseEvents)
12151215
{
12161216
if (ExportingMedia.IsRaisedEventCancelled(new ExportEventArgs<IMedia>(media, nodeName), this))
@@ -1220,7 +1220,7 @@ public XElement Export(IMedia media, bool deep = false, bool raiseEvents = true)
12201220
var exporter = new EntityXmlSerializer();
12211221
var xml = exporter.Serialize(_mediaService, _dataTypeService, media, deep);
12221222

1223-
if(raiseEvents)
1223+
if (raiseEvents)
12241224
ExportedMedia.RaiseEvent(new ExportEventArgs<IMedia>(media, xml, false), this);
12251225

12261226
return xml;
@@ -1334,7 +1334,7 @@ public IEnumerable<ITemplate> ImportTemplates(XElement element, int userId = 0,
13341334
if (templates.Any())
13351335
_fileService.SaveTemplate(templates, userId);
13361336

1337-
if(raiseEvents)
1337+
if (raiseEvents)
13381338
ImportedTemplate.RaiseEvent(new ImportEventArgs<ITemplate>(templates, element, false), this);
13391339

13401340
return templates;
@@ -1352,10 +1352,10 @@ public IEnumerable<IFile> ImportStylesheets(XElement element, int userId = 0, bo
13521352

13531353
IEnumerable<IFile> styleSheets = Enumerable.Empty<IFile>();
13541354

1355-
if(element.Elements().Any())
1355+
if (element.Elements().Any())
13561356
throw new NotImplementedException("This needs to be implimentet");
13571357

1358-
1358+
13591359
if (raiseEvents)
13601360
ImportingStylesheets.RaiseEvent(new ImportEventArgs<IFile>(styleSheets, element, false), this);
13611361

@@ -1480,7 +1480,7 @@ internal MetaData GetPackageMetaData(string packageFilePath)
14801480
/// </summary>
14811481
public static event TypedEventHandler<IPackagingService, ImportEventArgs<IContent>> ImportedContent;
14821482

1483-
1483+
14841484
public static event TypedEventHandler<IPackagingService, ExportEventArgs<IContent>> ExportingContent;
14851485

14861486
/// <summary>
@@ -1607,7 +1607,7 @@ internal MetaData GetPackageMetaData(string packageFilePath)
16071607
/// Occurs before Importing Stylesheets
16081608
/// </summary>
16091609
public static event TypedEventHandler<IPackagingService, ImportEventArgs<IFile>> ImportingStylesheets;
1610-
1610+
16111611
/// <summary>
16121612
/// Occurs after Template is Imported and Saved
16131613
/// </summary>
@@ -1622,7 +1622,7 @@ internal MetaData GetPackageMetaData(string packageFilePath)
16221622
/// Occurs after Template is Exported to Xml
16231623
/// </summary>
16241624
public static event TypedEventHandler<IPackagingService, ExportEventArgs<ITemplate>> ExportedTemplate;
1625-
1625+
16261626
/// <summary>
16271627
/// Occurs before Importing umbraco package
16281628
/// </summary>

0 commit comments

Comments
 (0)