Skip to content

Commit

Permalink
Merge branch 'develop' into develop_umb_740
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Edney committed Mar 26, 2019
2 parents 71cb6b1 + 0352878 commit d5d5d68
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ internal class IntegrationTests
[TestCase("MultiNodeTreePicker")]
[TestCase("AllDataTypes")]
[TestCase("UpdateHomePage")]
[TestCase("RemoveAllowedDocType")]
public void CallUpgradeScriptApi(string apiMethodName)
{
GetResponse(apiMethodName);
Expand Down
11 changes: 6 additions & 5 deletions src/DeployCmsData.UmbracoCms/Builders/DocumentTypeBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class DocumentTypeBuilder
internal readonly IList<string> RemoveFieldList = new List<string>();
internal readonly IList<IContentTypeComposition> Compositions = new List<IContentTypeComposition>();
internal IList<ContentTypeSort> AllowedChildNodeTypes = new List<ContentTypeSort>();
internal IList<ContentTypeSort> RemoveAllowedChildNodeTypes = new List<ContentTypeSort>();
internal IList<int> RemoveAllowedChildNodeTypes = new List<int>();
public IList<PropertyBuilder> FieldList { get; } = new List<PropertyBuilder>();

public DocumentTypeBuilder(string alias)
Expand Down Expand Up @@ -204,11 +204,12 @@ private void CopyExistingAllowedTypes(IContentType documentType)

private void RemoveNotAllowedTypes()
{
foreach (var allowedType in RemoveAllowedChildNodeTypes)
foreach (var typeIdToRemove in RemoveAllowedChildNodeTypes)
{
if (AllowedChildNodeTypes.Any(x => x.Id.Value == allowedType.Id.Value))
var typeToRemove = AllowedChildNodeTypes.FirstOrDefault(x => x.Id.Value == typeIdToRemove);
if (typeToRemove != null)
{
AllowedChildNodeTypes.Remove(allowedType);
AllowedChildNodeTypes.Remove(typeToRemove);
}
}
}
Expand Down Expand Up @@ -428,7 +429,7 @@ public DocumentTypeBuilder RemoveAllowedChildNodeType(string alias)
var documentType = _contentTypeService.GetContentType(alias);
if (documentType != null)
{
RemoveAllowedChildNodeTypes.Add(new ContentTypeSort(documentType.Id, RemoveAllowedChildNodeTypes.Count + 1));
RemoveAllowedChildNodeTypes.Add(documentType.Id);
}

return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@
<Compile Include="UpgradeScripts\ClearTheDecks.cs" />
<Compile Include="UpgradeScripts\CreateContent.cs" />
<Compile Include="UpgradeScripts\MultiNodeTreePicker.cs" />
<Compile Include="UpgradeScripts\RemoveAllowedDocType.cs" />
<Compile Include="UpgradeScripts\Templates.cs" />
<Compile Include="UpgradeScripts\UpdateHomePage.cs" />
<Compile Include="UpgradeScripts\Upgrade01.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using DeployCmsData.Core.Attributes;
using DeployCmsData.Core.Interfaces;
using DeployCmsData.UmbracoCms.Builders;
using DeployCmsData.UmbracoCms.Constants;
using DeployCmsData.UpgradeScripts_7.Constants;

namespace DeployCmsData.UpgradeScripts_7.UpgradeScripts
{
[DoNotAutoRun]
public class RemoveAllowedDocType : IUpgradeScript
{
public bool RunScript()
{
new DocumentTypeBuilder("allowedChildNodeType1").BuildInFolder("Pages");
new DocumentTypeBuilder("allowedChildNodeType2").BuildInFolder("Pages");
new DocumentTypeBuilder("allowedChildNodeType3").BuildInFolder("Pages");

var builder = new DocumentTypeBuilder("removeAllowedDocType");

builder
.Icon(Icons.Home)
.AddComposition("pageMetaData")
.AddComposition("contentBase")
.AddComposition("navigationBase")
.AddAllowedChildNodeType("allowedChildNodeType1")
.AddAllowedChildNodeType("allowedChildNodeType2")
.AddAllowedChildNodeType("allowedChildNodeType3");

builder.AddField("mainContent")
.DataType(LocalDataTypes.Grid)
.Tab("Content");

builder.BuildInFolder("Pages");


new DocumentTypeBuilder("removeAllowedDocType")
.RemoveAllowedChildNodeType("allowedChildNodeType2")
.Update();

return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@
<Compile Include="UpgradeScripts\ClearTheDecks.cs" />
<Compile Include="UpgradeScripts\CreateContent.cs" />
<Compile Include="UpgradeScripts\MultiNodeTreePicker.cs" />
<Compile Include="UpgradeScripts\RemoveAllowedDocType.cs" />
<Compile Include="UpgradeScripts\Templates.cs" />
<Compile Include="UpgradeScripts\UpdateHomePage.cs" />
<Compile Include="UpgradeScripts\Upgrade01.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using DeployCmsData.Core.Attributes;
using DeployCmsData.Core.Interfaces;
using DeployCmsData.UmbracoCms.Builders;
using DeployCmsData.UmbracoCms.Constants;
using DeployCmsData.UpgradeScripts_8.Constants;

namespace DeployCmsData.UpgradeScripts_8.UpgradeScripts
{
[DoNotAutoRun]
public class RemoveAllowedDocType : IUpgradeScript
{
public bool RunScript()
{
new DocumentTypeBuilder("allowedChildNodeType1").BuildInFolder("Pages");
new DocumentTypeBuilder("allowedChildNodeType2").BuildInFolder("Pages");
new DocumentTypeBuilder("allowedChildNodeType3").BuildInFolder("Pages");

var builder = new DocumentTypeBuilder("removeAllowedDocType");

builder
.Icon(Icons.Home)
.AddComposition("pageMetaData")
.AddComposition("contentBase")
.AddComposition("navigationBase")
.AddAllowedChildNodeType("allowedChildNodeType1")
.AddAllowedChildNodeType("allowedChildNodeType2")
.AddAllowedChildNodeType("allowedChildNodeType3");

builder.AddField("mainContent")
.DataType(LocalDataTypes.Grid)
.Tab("Content");

builder.BuildInFolder("Pages");


new DocumentTypeBuilder("removeAllowedDocType")
.RemoveAllowedChildNodeType("allowedChildNodeType2")
.Update();

return true;
}
}
}
2 changes: 1 addition & 1 deletion src/Integration.Web.Umb8.0/App_Data/Models/models.hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
97835e505561aea2
574b199fb14ab401

0 comments on commit d5d5d68

Please sign in to comment.