Getting NestedContent and ModelsBuilder happy

This commit is contained in:
Stephan
2017-10-25 13:23:14 +02:00
parent 0fe96a58c1
commit cf46a51866
15 changed files with 228 additions and 137 deletions

View File

@@ -17,7 +17,7 @@
<dependencies>
<dependency id="UmbracoCms.Core" version="[$version$]" />
<dependency id="Newtonsoft.Json" version="[10.0.3, 11.0.0)" />
<dependency id="Umbraco.ModelsBuilder" version="[8.0.0-alpha0009, 9.0.0)" />
<dependency id="Umbraco.ModelsBuilder" version="[8.0.0-alpha.10, 9.0.0)" />
<dependency id="Microsoft.AspNet.SignalR.Core" version="[2.2.2, 3.0.0)" />
</dependencies>
</metadata>

76
build/build-bootstrap.ps1 Normal file
View File

@@ -0,0 +1,76 @@
# this script should be dot-sourced into the build.ps1 scripts
# right after the parameters declaration
# ie
# . "$PSScriptRoot\build-bootstrap.ps1"
# THIS FILE IS DISTRIBUTED AS PART OF UMBRACO.BUILD
# DO NOT MODIFY IT - ALWAYS USED THE COMMON VERSION
# ################################################################
# BOOTSTRAP
# ################################################################
# reset errors
$error.Clear()
# ensure we have temp folder for downloads
$scriptRoot = "$PSScriptRoot"
$scriptTemp = "$scriptRoot\temp"
if (-not (test-path $scriptTemp)) { mkdir $scriptTemp > $null }
# get NuGet
$cache = 4
$nuget = "$scriptTemp\nuget.exe"
if (-not $local)
{
$source = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
if ((test-path $nuget) -and ((ls $nuget).CreationTime -lt [DateTime]::Now.AddDays(-$cache)))
{
Remove-Item $nuget -force -errorAction SilentlyContinue > $null
}
if (-not (test-path $nuget))
{
Write-Host "Download NuGet..."
Invoke-WebRequest $source -OutFile $nuget
if (-not $?) { throw "Failed to download NuGet." }
}
}
elseif (-not (test-path $nuget))
{
throw "Failed to locate NuGet.exe."
}
# get the build system
if (-not $local)
{
$solutionRoot = "$scriptRoot\.."
$nugetConfig = @{$true="$solutionRoot\src\NuGet.config.user";$false="$solutionRoot\src\NuGet.config"}[(test-path "$solutionRoot\src\NuGet.config.user")]
&$nuget install Umbraco.Build -OutputDirectory $scriptTemp -Verbosity quiet -PreRelease -ConfigFile $nugetConfig
if (-not $?) { throw "Failed to download Umbraco.Build." }
}
# ensure we have the build system
$ubuildPath = ls "$scriptTemp\Umbraco.Build.*" | sort -property CreationTime -descending | select -first 1
if (-not $ubuildPath)
{
throw "Failed to locate the build system."
}
# boot the build system
# this creates $global:ubuild
return &"$ubuildPath\ps\Boot.ps1"
# at that point the build.ps1 script must boot the build system
# eg
# $ubuild.Boot($ubuildPath.FullName, [System.IO.Path]::GetFullPath("$scriptRoot\.."),
# @{ Local = $local; With7Zip = $false; WithNode = $false },
# @{ continue = $continue })
# if (-not $?) { throw "Failed to boot the build system." }
#
# and it's good practice to report
# eg
# Write-Host "Umbraco.Whatever Build"
# Write-Host "Umbraco.Build v$($ubuild.BuildVersion)"
# eof

View File

@@ -1,11 +1,11 @@
param (
# load but don't execute
# get, don't execute
[Parameter(Mandatory=$false)]
[Alias("n")]
[switch] $nop = $false,
[Alias("g")]
[switch] $get = $false,
# run local - don't download, assume everything is ready
# run local, don't download, assume everything is ready
[Parameter(Mandatory=$false)]
[Alias("l")]
[Alias("loc")]
@@ -13,74 +13,31 @@
# keep the build directories, don't clear them
[Parameter(Mandatory=$false)]
[Alias("k")]
[Alias("keep")]
[switch] $keepBuildDirs = $false
[Alias("c")]
[Alias("cont")]
[switch] $continue = $false
)
Write-Host "Umbraco.Cms Build"
# ################################################################
# BOOTSTRAP
# ################################################################
# ensure we have temp folder for downloads
$scriptRoot = "$PSScriptRoot"
$scriptTemp = "$scriptRoot\temp"
if (-not (test-path $scriptTemp)) { mkdir $scriptTemp > $null }
# get NuGet
$cache = 4
$nuget = "$scriptTemp\nuget.exe"
if (-not $local)
{
$source = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
if ((test-path $nuget) -and ((ls $nuget).CreationTime -lt [DateTime]::Now.AddDays(-$cache)))
{
Remove-Item $nuget -force -errorAction SilentlyContinue > $null
}
if (-not (test-path $nuget))
{
Write-Host "Download NuGet..."
Invoke-WebRequest $source -OutFile $nuget
if (-not $?) { throw "Failed to download NuGet." }
}
}
elseif (-not (test-path $nuget))
{
throw "Failed to locate NuGet.exe."
}
# get the build system
if (-not $local)
{
$solutionRoot = "$scriptRoot\.."
$nugetConfig = @{$true="$solutionRoot\src\NuGet.config.user";$false="$solutionRoot\src\NuGet.config"}[(test-path "$solutionRoot\src\NuGet.config.user")]
&$nuget install Umbraco.Build -OutputDirectory $scriptTemp -Verbosity quiet -PreRelease -ConfigFile $nugetConfig
if (-not $?) { throw "Failed to download Umbraco.Build." }
}
# ensure we have the build system
$ubuildPath = ls "$scriptTemp\Umbraco.Build.*" | sort -property CreationTime -descending | select -first 1
if (-not $ubuildPath)
{
throw "Failed to locate the build system."
}
# boot the build system
# this creates $global:ubuild
&"$ubuildPath\ps\Boot.ps1"
$ubuild.Boot($ubuildPath.FullName, [System.IO.Path]::GetFullPath("$scriptRoot\.."),
# create and boot the buildsystem
$ubuild = &"$PSScriptRoot\build-bootstrap.ps1"
if (-not $?) { return }
$ubuild.Boot($PSScriptRoot,
@{ Local = $local; },
@{ KeepBuildDirs = $keepBuildDirs })
if (-not $?) { throw "Failed to boot the build system." }
@{ Continue = $continue })
if ($ubuild.OnError()) { return }
Write-Host "Zbu.ModelsBuilder Build"
Write-Host "Umbraco.Build v$($ubuild.BuildVersion)"
# ################################################################
# TASKS
# ################################################################
$ubuild | Add-Member -MemberType ScriptMethod SetMoreUmbracoVersion -value `
$ubuild.DefineMethod("SetMoreUmbracoVersion",
{
param ( $semver )
@@ -98,9 +55,9 @@
$updater = New-Object "Umbraco.Build.ExpressPortUpdater"
$csproj = "$($this.SolutionRoot)\src\Umbraco.Web.UI\Umbraco.Web.UI.csproj"
$updater.Update($csproj, $release)
}
})
$ubuild | Add-Member -MemberType ScriptMethod SandboxNode -value `
$ubuild.DefineMethod("SandboxNode",
{
$global:node_path = $env:path
$nodePath = $this.BuildEnv.NodePath
@@ -111,18 +68,18 @@
$global:node_nodepath = $this.ClearEnvVar("NODEPATH")
$global:node_npmcache = $this.ClearEnvVar("NPM_CONFIG_CACHE")
$global:node_npmprefix = $this.ClearEnvVar("NPM_CONFIG_PREFIX")
}
})
$ubuild | Add-Member -MemberType ScriptMethod RestoreNode -value `
$ubuild.DefineMethod("RestoreNode",
{
$env:path = $node_path
$this.SetEnvVar("NODEPATH", $node_nodepath)
$this.SetEnvVar("NPM_CONFIG_CACHE", $node_npmcache)
$this.SetEnvVar("NPM_CONFIG_PREFIX", $node_npmprefix)
}
})
$ubuild | Add-Member -MemberType ScriptMethod CompileBelle -value `
$ubuild.DefineMethod("CompileBelle",
{
$src = "$($this.SolutionRoot)\src"
$log = "$($this.BuildTemp)\belle.log"
@@ -133,24 +90,45 @@
# get a temp clean node env (will restore)
$this.SandboxNode()
Push-Location "$($uenv.SolutionRoot)\src\Umbraco.Web.UI.Client"
# stupid PS is going to gather all "warnings" in $error
# so we have to take care of it else they'll bubble and kill the build
if ($error.Count -gt 0) { return }
Push-Location "$($this.SolutionRoot)\src\Umbraco.Web.UI.Client"
Write-Output "" > $log
Write-Output "node version is:" > $log
Write-Output "### node version is:" > $log
&node -v >> $log 2>&1
Write-Output "npm version is:" >> $log 2>&1
if (-not $?) { throw "Failed to report node version." }
Write-Output "### npm version is:" >> $log 2>&1
&npm -v >> $log 2>&1
Write-Output "clean npm cache" >> $log 2>&1
if (-not $?) { throw "Failed to report npm version." }
Write-Output "### clean npm cache" >> $log 2>&1
&npm cache clean >> $log 2>&1
Write-Output "npm install" >> $log 2>&1
$error.Clear() # that one can fail 'cos security bug - ignore
Write-Output "### npm install" >> $log 2>&1
&npm install >> $log 2>&1
Write-Output "install bower" >> $log 2>&1
Write-Output ">> $? $($error.Count)" >> $log 2>&1
Write-Output "### install bower" >> $log 2>&1
&npm install -g bower >> $log 2>&1
Write-Output "install gulp" >> $log 2>&1
$error.Clear() # that one fails 'cos bower is deprecated - ignore
Write-Output "### install gulp" >> $log 2>&1
&npm install -g gulp >> $log 2>&1
Write-Output "install gulp-cli" >> $log 2>&1
$error.Clear() # that one fails 'cos deprecated stuff - ignore
Write-Output "### nstall gulp-cli" >> $log 2>&1
&npm install -g gulp-cli --quiet >> $log 2>&1
Write-Output "gulp build for version $($this.Version.Release)" >> $log 2>&1
if (-not $?) { throw "Failed to install gulp-cli" } # that one is expected to work
Write-Output "### gulp build for version $($this.Version.Release)" >> $log 2>&1
&gulp build --buildversion=$this.Version.Release >> $log 2>&1
if (-not $?) { throw "Failed to build" } # that one is expected to work
Pop-Location
# fixme - should we filter the log to find errors?
@@ -167,9 +145,9 @@
Write-Host "Set hidden attribute on node_modules"
$dir = Get-Item -force "$src\Umbraco.Web.UI.Client\node_modules"
$dir.Attributes = $dir.Attributes -bor ([System.IO.FileAttributes]::Hidden)
}
})
$ubuild | Add-Member -MemberType ScriptMethod CompileUmbraco -value `
$ubuild.DefineMethod("CompileUmbraco",
{
$buildConfiguration = "Release"
@@ -222,9 +200,9 @@
if (-not $?) { throw "Failed to compile Umbraco.Compat7." }
# /p:UmbracoBuild tells the csproj that we are building from PS, not VS
}
})
$ubuild | Add-Member -MemberType ScriptMethod PrepareTests -value `
$ubuild.DefineMethod("PrepareTests",
{
Write-Host "Prepare Tests"
@@ -248,9 +226,9 @@
Write-Host "Create bin directory"
mkdir "$($this.BuildTemp)\tests\bin" > $null
}
}
})
$ubuild | Add-Member -MemberType ScriptMethod CompileTests -value `
$ubuild.DefineMethod("CompileTests",
{
$buildConfiguration = "Release"
$log = "$($this.BuildTemp)\msbuild.tests.log"
@@ -282,9 +260,9 @@
if (-not $?) { throw "Failed to compile tests." }
# /p:UmbracoBuild tells the csproj that we are building from PS
}
})
$ubuild | Add-Member -MemberType ScriptMethod PreparePackages -value `
$ubuild.DefineMethod("PreparePackages",
{
Write-Host "Prepare Packages"
@@ -359,9 +337,9 @@
mkdir "$tmp\WebPi\umbraco" > $null
$this.CopyFiles("$tmp\WebApp", "*", "$tmp\WebPi\umbraco")
$this.CopyFiles("$src\WebPi", "*", "$tmp\WebPi")
}
})
$ubuild | Add-Member -MemberType ScriptMethod PackageZip -value `
$ubuild.DefineMethod("PackageZip",
{
Write-Host "Create Zip packages"
@@ -394,9 +372,9 @@
Write-Host "Hash WebPI"
$hash = $this.GetFileHash("$out\UmbracoCms.WebPI.$($this.Version.Semver).zip")
Write-Output $hash | out-file "$out\webpihash.txt" -encoding ascii
}
})
$ubuild | Add-Member -MemberType ScriptMethod PrepareBuild -value `
$ubuild.DefineMethod("PrepareBuild",
{
Write-Host "Clear folders and files"
$this.RemoveDirectory("$($this.SolutionRoot)\src\Umbraco.Web.UI.Client\bower_components")
@@ -404,9 +382,9 @@
$this.TempStoreFile("$($this.SolutionRoot)\src\Umbraco.Web.UI\web.config")
Write-Host "Create clean web.config"
$this.CopyFile("$($this.SolutionRoot)\src\Umbraco.Web.UI\web.Template.config", "$($this.SolutionRoot)\src\Umbraco.Web.UI\web.config")
}
})
$ubuild | Add-Member -MemberType ScriptMethod PrepareNuGet -value `
$ubuild.DefineMethod("PrepareNuGet",
{
Write-Host "Prepare NuGet"
@@ -416,17 +394,17 @@
# fixme - that one does not exist in .bat build either?
#mv "$($this.BuildTemp)\WebApp\Xslt\Web.config" "$($this.BuildTemp)\WebApp\Xslt\Web.config.transform"
}
})
$ubuild | Add-Member -MemberType ScriptMethod RestoreNuGet -value `
$ubuild.DefineMethod("RestoreNuGet",
{
Write-Host "Restore NuGet"
Write-Host "Logging to $($this.BuildTemp)\nuget.restore.log"
&$this.BuildEnv.NuGet restore "$($this.SolutionRoot)\src\Umbraco.sln" -ConfigFile $this.BuildEnv.NuGetConfig > "$($this.BuildTemp)\nuget.restore.log"
if (-not $?) { throw "Failed to restore NuGet packages." }
}
})
$ubuild | Add-Member -MemberType ScriptMethod PackageNuGet -value `
$ubuild.DefineMethod("PackageNuGet",
{
$nuspecs = "$($this.SolutionRoot)\build\NuSpecs"
@@ -440,19 +418,19 @@
&$this.BuildEnv.NuGet Pack "$nuspecs\UmbracoCms.Core.nuspec" `
-Properties BuildTmp="$($this.BuildTemp)" `
-Version "$($this.Version.Semver.ToString())" `
-Symbols -Verbosity quiet -outputDirectory "$($this.BuildOutput)"
-Symbols -Verbosity detailed -outputDirectory "$($this.BuildOutput)" > "$($this.BuildTemp)\nupack.cmscore.log"
if (-not $?) { throw "Failed to pack NuGet UmbracoCms.Core." }
&$this.BuildEnv.NuGet Pack "$nuspecs\UmbracoCms.nuspec" `
-Properties BuildTmp="$($this.BuildTemp)" `
-Version $this.Version.Semver.ToString() `
-Verbosity quiet -outputDirectory "$($this.BuildOutput)"
-Verbosity detailed -outputDirectory "$($this.BuildOutput)" > "$($this.BuildTemp)\nupack.cms.log"
if (-not $?) { throw "Failed to pack NuGet UmbracoCms." }
&$this.BuildEnv.NuGet Pack "$nuspecs\UmbracoCms.Compat7.nuspec" `
-Properties BuildTmp="$($this.BuildTemp)" `
-Version $this.Version.Semver.ToString() `
-Verbosity quiet -outputDirectory "$($this.BuildOutput)"
-Verbosity detailed -outputDirectory "$($this.BuildOutput)" > "$($this.BuildTemp)\nupack.compat7.log"
if (-not $?) { throw "Failed to pack NuGet UmbracoCms.Compat7." }
# run hook
@@ -462,25 +440,42 @@
$this.PostPackageNuGet();
if (-not $?) { throw "Failed to run hook." }
}
}
})
$ubuild | Add-Member -MemberType ScriptMethod Build -value `
$ubuild.DefineMethod("VerifyNuGet",
{
$this.VerifyNuGetConsistency(
("UmbracoCms", "UmbracoCms.Core", "UmbracoCms.Compat7"),
("Umbraco.Core", "Umbraco.Web", "Umbraco.Web.UI", "Umbraco.Examine", "Umbraco.Compat7"))
if ($this.OnError()) { return }
})
$ubuild.DefineMethod("Build",
{
$this.PrepareBuild()
if ($this.OnError()) { return }
$this.RestoreNuGet()
if ($this.OnError()) { return }
$this.CompileBelle()
if ($this.OnError()) { return }
$this.CompileUmbraco()
if ($this.OnError()) { return }
$this.PrepareTests()
if ($this.OnError()) { return }
$this.CompileTests()
if ($this.OnError()) { return }
# not running tests
$this.PreparePackages()
if ($this.OnError()) { return }
$this.PackageZip()
$this.VerifyNuGet(
("UmbracoCms", "UmbracoCms.Core", "UmbracoCms.Compat7"),
("Umbraco.Core", "Umbraco.Web", "Umbraco.Web.UI", "Umbraco.Examine", "Umbraco.Compat7"))
if ($this.OnError()) { return }
$this.VerifyNuGet()
if ($this.OnError()) { return }
$this.PrepareNuGet()
if ($this.OnError()) { return }
$this.PackageNuGet()
}
if ($this.OnError()) { return }
})
# ################################################################
# RUN
@@ -490,6 +485,10 @@
$ubuild.ReleaseBranches = @( "master" )
# run
if (-not $nop) { $ubuild.Build() }
if (-not $get)
{
$ubuild.Build()
if ($ubuild.OnError()) { return }
}
Write-Host "Done"
if ($nop) { return $ubuild }
if ($get) { return $ubuild }

View File

@@ -17,4 +17,4 @@ using System.Resources;
// these are FYI and changed automatically
[assembly: AssemblyFileVersion("8.0.0")]
[assembly: AssemblyInformationalVersion("8.0.0-alpha.27")]
[assembly: AssemblyInformationalVersion("8.0.0-alpha.28")]

View File

@@ -10,14 +10,14 @@ namespace Umbraco.Core.Composing
/// <summary>
/// Provides extensions to LightInject.
/// </summary>
internal static class LightInjectExtensions
public static class LightInjectExtensions
{
/// <summary>
/// Configure the container for Umbraco Core usage and assign to Current.
/// </summary>
/// <param name="container">The container.</param>
/// <remarks>The container is now the unique application container and is now accessible via Current.Container.</remarks>
public static void ConfigureUmbracoCore(this ServiceContainer container)
internal static void ConfigureUmbracoCore(this ServiceContainer container)
{
// supports annotated constructor injections
// eg to specify the service name on some services

View File

@@ -21,7 +21,7 @@ namespace Umbraco.Core.Configuration
/// <summary>
/// Gets the version comment of the executing code (eg "beta").
/// </summary>
public static string CurrentComment => "alpha.27";
public static string CurrentComment => "alpha.28";
/// <summary>
/// Gets the assembly version of Umbraco.Code.dll.

View File

@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Reflection;
using Umbraco.Core.Exceptions;
namespace Umbraco.Core.Models.PublishedContent
{
@@ -19,6 +20,7 @@ namespace Umbraco.Core.Models.PublishedContent
{
private ModelType(string contentTypeAlias)
{
if (string.IsNullOrWhiteSpace(contentTypeAlias)) throw new ArgumentNullOrEmptyException(nameof(contentTypeAlias));
ContentTypeAlias = contentTypeAlias;
Name = "{" + ContentTypeAlias + "}";
}
@@ -227,10 +229,12 @@ namespace Umbraco.Core.Models.PublishedContent
public override Guid GUID { get; } = Guid.NewGuid();
/// <inheritdoc />
public override Module Module => throw new NotSupportedException();
//public override Module Module => throw new NotSupportedException();
public override Module Module => GetType().Module;
/// <inheritdoc />
public override Assembly Assembly => throw new NotSupportedException();
//public override Assembly Assembly => throw new NotSupportedException();
public override Assembly Assembly => GetType().Assembly;
/// <inheritdoc />
public override string FullName => Name;

View File

@@ -27,6 +27,11 @@ namespace Umbraco.Core.PropertyEditors.ValueConverters
return (int.TryParse(sourceString, out i)) ? i : 0;
}
// in json an integer comes back as Int64
// ignore overflows ;(
if (source is long)
return Convert.ToInt32(source);
// in the database an integer is an integer
// default value is zero
return (source is int) ? source : 0;

View File

@@ -151,8 +151,8 @@
<HintPath>..\packages\System.Xml.XPath.XDocument.4.3.0\lib\net46\System.Xml.XPath.XDocument.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Umbraco.ModelsBuilder, Version=8.0.0.6, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Umbraco.ModelsBuilder.8.0.0-alpha0009\lib\Umbraco.ModelsBuilder.dll</HintPath>
<Reference Include="Umbraco.ModelsBuilder, Version=8.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Umbraco.ModelsBuilder.8.0.0-alpha.11\lib\Umbraco.ModelsBuilder.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
@@ -1049,7 +1049,7 @@ xcopy "$(ProjectDir)"..\packages\SqlServerCE.4.0.0.1\x86\*.* "$(TargetDir)x86\"
<Copy SourceFiles="$(ProjectDir)Web.$(Configuration).config.transformed" DestinationFiles="$(ProjectDir)Web.config" OverwriteReadOnlyFiles="true" SkipUnchangedFiles="false" Condition="$(BuildingInsideVisualStudio) == true" />
</Target>
<Target Name="BelleBuild" BeforeTargets="Rebuild" Condition=" '$(UmbracoBuild)' == '' ">
<Exec WorkingDirectory="$(ProjectDir)\..\..\" Command="powershell -ExecutionPolicy RemoteSigned -Command &quot;&amp;{ $env:PSModulePath = \&quot;$pwd\build\Modules\;$env:PSModulePath\&quot; ; Import-Module Umbraco.Build -Force -DisableNameChecking ; build-umbraco compile-belle }&quot;" />
<Exec WorkingDirectory="$(ProjectDir)\..\..\" Command="powershell -ExecutionPolicy RemoteSigned -Command &quot;&amp;{ $ubuild = $pwd\build\build.ps1 -get ; $ubuild.CompileBelle() }&quot;" />
<Error Condition="!Exists('..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.Net.Compilers.2.2.0\build\Microsoft.Net.Compilers.props'))" />
<Error Condition="!Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.5\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.5\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props'))" />
</Target>

View File

@@ -81,5 +81,5 @@
<package id="System.Xml.XmlDocument" version="4.3.0" targetFramework="net461" />
<package id="System.Xml.XPath" version="4.3.0" targetFramework="net461" />
<package id="System.Xml.XPath.XDocument" version="4.3.0" targetFramework="net461" />
<package id="Umbraco.ModelsBuilder" version="8.0.0-alpha0009" targetFramework="net461" />
<package id="Umbraco.ModelsBuilder" version="8.0.0-alpha.12" targetFramework="net461" />
</packages>

View File

@@ -92,12 +92,22 @@ namespace Umbraco.Web.PropertyEditors
public class DataTypeConfiguration
{
public string[] ContentTypes { get; set; }
public NestedContentType[] ContentTypes { get; set; }
public int? MinItems { get; set; }
public int? MaxItems { get; set; }
public bool ConfirmDeletes { get; set; }
public bool ShowIcons { get; set; }
public bool HideLabel { get; set; }
public class NestedContentType
{
[JsonProperty("ncAlias")]
public string Alias { get; set; }
[JsonProperty("ncTabAlias")]
public string Tab { get; set; }
[JsonProperty("nameTemplate")]
public string Template { get; set; }
}
}
public override object MapDataTypeConfiguration(PreValueCollection preValues)
@@ -105,7 +115,9 @@ namespace Umbraco.Web.PropertyEditors
var d = preValues.PreValuesAsDictionary;
return new DataTypeConfiguration
{
ContentTypes = d.TryGetValue("contentTypes", out var preValue) ? preValue.Value.Split(',') : Array.Empty<string>(),
ContentTypes = d.TryGetValue("contentTypes", out var preValue)
? JsonConvert.DeserializeObject<DataTypeConfiguration.NestedContentType[]>(preValue.Value)
: Array.Empty<DataTypeConfiguration.NestedContentType>(),
MinItems = d.TryGetValue("minItems", out preValue) && int.TryParse(preValue.Value, out var minItems) ? (int?) minItems : null,
MaxItems = d.TryGetValue("maxItems", out preValue) && int.TryParse(preValue.Value, out var maxItems) ? (int?) maxItems : null,
ConfirmDeletes = d.TryGetValue("confirmDeletes", out preValue) && preValue.Value == "1",

View File

@@ -37,7 +37,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters
var contentTypes = propertyType.DataType.GetConfiguration<NestedContentPropertyEditor.DataTypeConfiguration>().ContentTypes;
return contentTypes.Length > 1
? typeof (IEnumerable<IPublishedElement>)
: typeof (IEnumerable<>).MakeGenericType(ModelType.For(contentTypes[0]));
: typeof (IEnumerable<>).MakeGenericType(ModelType.For(contentTypes[0].Alias));
}
/// <inheritdoc />
@@ -65,7 +65,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters
var contentTypes = propertyType.DataType.GetConfiguration<NestedContentPropertyEditor.DataTypeConfiguration>().ContentTypes;
var elements = contentTypes.Length > 1
? new List<IPublishedElement>()
: PublishedModelFactory.CreateModelList(contentTypes[0]);
: PublishedModelFactory.CreateModelList(contentTypes[0].Alias);
foreach (var sourceObject in objects)
{

View File

@@ -36,7 +36,7 @@ namespace Umbraco.Web.PropertyEditors.ValueConverters
var contentTypes = propertyType.DataType.GetConfiguration<NestedContentPropertyEditor.DataTypeConfiguration>().ContentTypes;
return contentTypes.Length > 1
? typeof(IPublishedElement)
: ModelType.For(contentTypes[0]);
: ModelType.For(contentTypes[0].Alias);
}
/// <inheritdoc />

View File

@@ -132,6 +132,7 @@ namespace Umbraco.Web.PublishedCache.NuCache
public readonly int CreatorId;
// draft and published version (either can be null, but not both)
// are models not direct PublishedContent instances
public IPublishedContent Draft;
public IPublishedContent Published;
@@ -142,13 +143,21 @@ namespace Umbraco.Web.PublishedCache.NuCache
public ContentNodeKit ToKit()
{
var draft = Draft is PublishedContentModel draftModel
? (PublishedContent) draftModel.Unwrap()
: (PublishedContent) Draft;
var published = Published is PublishedContentModel publishedModel
? (PublishedContent) publishedModel.Unwrap()
: (PublishedContent) Published;
return new ContentNodeKit
{
Node = this,
ContentTypeId = ContentType.Id,
DraftData = ((PublishedContent) Draft)?._contentData,
PublishedData = ((PublishedContent) Published)?._contentData
DraftData = draft?._contentData,
PublishedData = published?._contentData
};
}
}

View File

@@ -1,12 +1,11 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2002
VisualStudioVersion = 15.0.27004.2005
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Web.UI", "Umbraco.Web.UI\Umbraco.Web.UI.csproj", "{4C4C194C-B5E4-4991-8F87-4373E24CC19F}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{2849E9D4-3B4E-40A3-A309-F3CB4F0E125F}"
ProjectSection(SolutionItems) = preProject
..\build\build.md = ..\build\build.md
..\build\build.ps1 = ..\build\build.ps1
..\build\BuildDocs.ps1 = ..\build\BuildDocs.ps1
..\build\RevertToCleanInstall.bat = ..\build\RevertToCleanInstall.bat
@@ -17,6 +16,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{2849E9D4
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{FD962632-184C-4005-A5F3-E705D92FC645}"
ProjectSection(SolutionItems) = preProject
..\BUILD.md = ..\BUILD.md
..\apidocs\docfx.filter.yml = ..\apidocs\docfx.filter.yml
..\apidocs\docfx.json = ..\apidocs\docfx.json
..\apidocs\index.md = ..\apidocs\index.md
@@ -88,18 +88,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Tests.Benchmarks",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Umbraco.Compat7", "Umbraco.Compat7\Umbraco.Compat7.csproj", "{185E098F-5706-4B97-B404-EB974F05F633}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Modules", "Modules", "{460C4687-9209-4100-AAB0-82867B592FDC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Umbraco.Build", "Umbraco.Build", "{F80CA2F0-168E-4364-AB75-A27DDD58643D}"
ProjectSection(SolutionItems) = preProject
..\build\Modules\Umbraco.Build\Get-UmbracoBuildEnv.ps1 = ..\build\Modules\Umbraco.Build\Get-UmbracoBuildEnv.ps1
..\build\Modules\Umbraco.Build\Get-UmbracoVersion.ps1 = ..\build\Modules\Umbraco.Build\Get-UmbracoVersion.ps1
..\build\Modules\Umbraco.Build\Get-VisualStudio.ps1 = ..\build\Modules\Umbraco.Build\Get-VisualStudio.ps1
..\build\Modules\Umbraco.Build\Set-UmbracoVersion.ps1 = ..\build\Modules\Umbraco.Build\Set-UmbracoVersion.ps1
..\build\Modules\Umbraco.Build\Umbraco.Build.psm1 = ..\build\Modules\Umbraco.Build\Umbraco.Build.psm1
..\build\Modules\Umbraco.Build\Utilities.ps1 = ..\build\Modules\Umbraco.Build\Utilities.ps1
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -146,8 +134,6 @@ Global
{E3F9F378-AFE1-40A5-90BD-82833375DBFE} = {227C3B55-80E5-4E7E-A802-BE16C5128B9D}
{5B03EF4E-E0AC-4905-861B-8C3EC1A0D458} = {227C3B55-80E5-4E7E-A802-BE16C5128B9D}
{86DEB346-089F-4106-89C8-D852B9CF2A33} = {B5BD12C1-A454-435E-8A46-FF4A364C0382}
{460C4687-9209-4100-AAB0-82867B592FDC} = {2849E9D4-3B4E-40A3-A309-F3CB4F0E125F}
{F80CA2F0-168E-4364-AB75-A27DDD58643D} = {460C4687-9209-4100-AAB0-82867B592FDC}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {7A0F2E34-D2AF-4DAB-86A0-7D7764B3D0EC}