Compare commits
31 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 419180c443 | |||
| e97c976c7f | |||
| 2d05e64e5a | |||
| 6f4d7f9e9b | |||
| 5a24e9b016 | |||
| 4d4e9d7de0 | |||
| 1dde1ed5f0 | |||
| 88051ef61d | |||
| 10d3dd76ed | |||
| b52f153141 | |||
| 062f28f9ca | |||
| cd2bd8c562 | |||
| ed6068230e | |||
| 24bfef64dd | |||
| 1d5e4eda7e | |||
| 346b8c73d4 | |||
| 43ea29cdf2 | |||
| f05a67d9d2 | |||
| 3ac7ef34ec | |||
| 518f95ce01 | |||
| 7831e476e3 | |||
| bfb883c098 | |||
| bbe3506747 | |||
| 42743b1394 | |||
| 9a712acd6a | |||
| 4c8bbd5d8f | |||
| 9296388abe | |||
| 3c5e2013a0 | |||
| aacbc06992 | |||
| 220a034d2a | |||
| 6317b83720 |
@@ -23,6 +23,7 @@ pkg/*.zip
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
[Pp]ackages/
|
||||
VersionInfo.cs
|
||||
|
||||
*.aps
|
||||
*.bak
|
||||
|
||||
+27
-12
@@ -5,6 +5,7 @@ module.exports = function(grunt) {
|
||||
dest: 'dist',
|
||||
package_dir: 'pkg',
|
||||
package_temp_dir: '<%= package_dir %>/tmp/',
|
||||
csProj: 'app/Umbraco/Umbraco.Archetype/Archetype.Umbraco.csproj',
|
||||
|
||||
|
||||
watch: {
|
||||
@@ -25,7 +26,7 @@ module.exports = function(grunt) {
|
||||
},
|
||||
|
||||
dev: {
|
||||
files: ['app/**'],
|
||||
files: ['app/**', '!app/Umbraco/**', 'app/Umbraco/**/*.dll'],
|
||||
tasks: ['deploy'],
|
||||
options: {
|
||||
spawn: false
|
||||
@@ -89,7 +90,7 @@ module.exports = function(grunt) {
|
||||
author: '<%= pkgMeta.author %>',
|
||||
authorUrl: '<%= pkgMeta.authorUrl %>',
|
||||
|
||||
files: [{ path: '..\\..\\..\\<%= dest %>\\**', target: 'content\\App_Plugins\\Archetype'}]
|
||||
files: [{ path: '..\\..\\..\\<%= package_temp_dir %>\\nuget\\**', target: 'content\\App_Plugins\\Archetype'}]
|
||||
}
|
||||
},
|
||||
'files': {
|
||||
@@ -109,25 +110,25 @@ module.exports = function(grunt) {
|
||||
{expand: true, cwd: 'app/views/', src: ['archetype.html', 'archetype.config.html'], dest: '<%= dest %>/views', flatten: true},
|
||||
{expand: true, cwd: 'app/config/', src: ['propertyEditors.views.js'], dest: '<%= dest %>/js', flatten: true},
|
||||
{expand: true, cwd: 'app/langs/', src: ['**'], dest: '<%= dest %>/langs', flatten: true},
|
||||
{expand: true, cwd: 'app/Umbraco/Umbraco.Archetype/bin/Debug/', src: ['Archetype.dll'], dest: '<%= dest %>/bin', flatten: true}
|
||||
{expand: true, cwd: 'app/Umbraco/Umbraco.Archetype/bin/Debug/', src: ['Archetype.dll', 'Archetype.pdb'], dest: '<%= dest %>/bin', flatten: true}
|
||||
]
|
||||
},
|
||||
deploy: {
|
||||
files: [
|
||||
{expand: true, cwd: '<%= dest %>/', src: ['**/*', '!bin/*'], dest: '<%= grunt.option("target") %>\\App_Plugins\\Archetype', flatten: false},
|
||||
{expand: true, cwd: '<%= dest %>/', src: ['bin/*'], dest: '<%= grunt.option("target") %>\\bin', flatten: false},
|
||||
{expand: true, cwd: '<%= dest %>/', src: ['**/*', "!bin", "!bin/**/*"], dest: '<%= grunt.option("target") %>\\App_Plugins\\Archetype', flatten: false},
|
||||
{expand: true, cwd: '<%= dest %>/', src: ['bin/**/*'], dest: '<%= grunt.option("target") %>', flatten: false},
|
||||
]
|
||||
},
|
||||
nuget_prepare: {
|
||||
files: [
|
||||
{expand: true, cwd: '<%= dest %>/', src: ['**/*', '!bin/*'], dest: '<%= package_temp_dir %>/nuget/content/', flatten: false},
|
||||
{expand: true, cwd: '<%= dest %>/', src: ['bin/*'], dest: '<%= package_temp_dir %>/nuget/lib/net40/', flatten: false}
|
||||
{expand: true, cwd: '<%= dest %>/', src: ['**/*', '!bin', '!bin/*'], dest: '<%= package_temp_dir %>/nuget/content/App_Plugins/Archetype', flatten: false},
|
||||
{expand: true, cwd: '<%= dest %>/', src: ['bin/**/*.dll'], dest: '<%= package_temp_dir %>/nuget/lib/net40/', flatten: true}
|
||||
]
|
||||
},
|
||||
umbracopackage: {
|
||||
files: [
|
||||
{expand: true, cwd: '<%= dest %>/', src: ['**/*', "!bin/*"], dest: 'pkg/tmp/umbraco/App_Plugins/Archetype', flatten: false},
|
||||
{expand: true, cwd: '<%= dest %>/', src: ['bin/*'], dest: 'pkg/tmp/umbraco', flatten: false}
|
||||
{expand: true, cwd: '<%= dest %>/', src: ['**/*', '!bin', "!bin/*"], dest: 'pkg/tmp/umbraco/App_Plugins/Archetype', flatten: false},
|
||||
{expand: true, cwd: '<%= dest %>/', src: ['bin/**/*.dll'], dest: 'pkg/tmp/umbraco', flatten: false}
|
||||
]
|
||||
}
|
||||
},
|
||||
@@ -161,16 +162,28 @@ module.exports = function(grunt) {
|
||||
package_artifacts: ['pkg/*.zip', 'pkg/*.nupkg'],
|
||||
},
|
||||
|
||||
assemblyinfo: {
|
||||
options: {
|
||||
files: ['<%= csProj %>'],
|
||||
filename: 'VersionInfo.cs',
|
||||
info: {
|
||||
version: '<%= (pkgMeta.version.indexOf("-") ? pkgMeta.version.substring(0, pkgMeta.version.indexOf("-")) : pkgMeta.version) %>',
|
||||
fileVersion: '<%= pkgMeta.version %>'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
msbuild: {
|
||||
dev: {
|
||||
src: ['app/Umbraco/Umbraco.Archetype/Archetype.Umbraco.csproj'],
|
||||
src: ["<%= csProj %>"],
|
||||
options: {
|
||||
projectConfiguration: 'Debug',
|
||||
targets: ['Clean', 'Rebuild'],
|
||||
stdout: true,
|
||||
maxCpuCount: 4,
|
||||
buildParameters: {
|
||||
WarningLevel: 2
|
||||
WarningLevel: 2,
|
||||
NoWarn: 1607,
|
||||
},
|
||||
verbosity: 'quiet'
|
||||
}
|
||||
@@ -190,6 +203,7 @@ module.exports = function(grunt) {
|
||||
grunt.loadNpmTasks('grunt-template');
|
||||
grunt.loadNpmTasks('grunt-touch');
|
||||
grunt.loadNpmTasks('grunt-msbuild');
|
||||
grunt.loadNpmTasks('grunt-dotnet-assembly-info');
|
||||
grunt.loadTasks('tasks');
|
||||
|
||||
|
||||
@@ -200,6 +214,7 @@ module.exports = function(grunt) {
|
||||
grunt.registerTask('deploy', ['default', 'copy:deploy', 'touchwebconfigifenabled']);
|
||||
grunt.registerTask('css:build', ['less']);
|
||||
grunt.registerTask('js:build', ['concat']);
|
||||
grunt.registerTask('default', ['clean', 'css:build', 'js:build', 'copy:build', 'msbuild:dev']);
|
||||
grunt.registerTask('cs:build', ['assemblyinfo', 'msbuild:dev']);
|
||||
grunt.registerTask('default', ['clean', 'css:build', 'js:build', 'copy:build', 'cs:build']);
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using System.Net;
|
||||
using System.Web.Http;
|
||||
using AutoMapper;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Web.Models.ContentEditing;
|
||||
using Umbraco.Web.Mvc;
|
||||
using Umbraco.Web.Editors;
|
||||
|
||||
namespace Archetype.Umbraco.Api
|
||||
{
|
||||
[PluginController("ArchetypeApi")]
|
||||
public class ArchetypeDataTypeController : UmbracoAuthorizedJsonController
|
||||
{
|
||||
public object GetById(int id)
|
||||
{
|
||||
var dataType = Services.DataTypeService.GetDataTypeDefinitionById(id);
|
||||
if (dataType == null)
|
||||
{
|
||||
throw new HttpResponseException(HttpStatusCode.NotFound);
|
||||
}
|
||||
var dataTypeDisplay = Mapper.Map<IDataTypeDefinition, DataTypeDisplay>(dataType);
|
||||
return new { selectedEditor = dataTypeDisplay.SelectedEditor, preValues = dataTypeDisplay.PreValues };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -34,114 +34,138 @@
|
||||
<ItemGroup>
|
||||
<Reference Include="AutoMapper">
|
||||
<HintPath>..\packages\AutoMapper.3.0.0\lib\net40\AutoMapper.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="AutoMapper.Net4">
|
||||
<HintPath>..\packages\AutoMapper.3.0.0\lib\net40\AutoMapper.Net4.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="businesslogic">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\businesslogic.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="ClientDependency.Core">
|
||||
<HintPath>..\packages\ClientDependency.1.7.0.4\lib\ClientDependency.Core.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="ClientDependency.Core.Mvc">
|
||||
<HintPath>..\packages\ClientDependency-Mvc.1.7.0.4\lib\ClientDependency.Core.Mvc.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="cms">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\cms.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="controls">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\controls.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="CookComputing.XmlRpcV2">
|
||||
<HintPath>..\packages\xmlrpcnet.2.5.0\lib\net20\CookComputing.XmlRpcV2.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Examine">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\Examine.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="HtmlAgilityPack">
|
||||
<HintPath>..\packages\HtmlAgilityPack.1.4.6\lib\Net45\HtmlAgilityPack.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="ICSharpCode.SharpZipLib">
|
||||
<HintPath>..\packages\SharpZipLib.0.86.0\lib\20\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="interfaces">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\interfaces.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="log4net">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\log4net.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Lucene.Net">
|
||||
<HintPath>..\packages\Lucene.Net.2.9.4.1\lib\net40\Lucene.Net.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.ApplicationBlocks.Data">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\Microsoft.ApplicationBlocks.Data.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Helpers">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\Microsoft.Web.Helpers.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<Private>False</Private>
|
||||
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="Microsoft.Web.Mvc.FixedDisplayModes">
|
||||
<HintPath>..\packages\Microsoft.AspNet.Mvc.FixedDisplayModes.1.0.1\lib\net40\Microsoft.Web.Mvc.FixedDisplayModes.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="MiniProfiler">
|
||||
<HintPath>..\packages\MiniProfiler.2.1.0\lib\net40\MiniProfiler.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="MySql.Data">
|
||||
<HintPath>..\packages\MySql.Data.6.6.5\lib\net40\MySql.Data.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Newtonsoft.Json">
|
||||
<HintPath>..\packages\Newtonsoft.Json.4.5.11\lib\net40\Newtonsoft.Json.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="SQLCE4Umbraco">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\SQLCE4Umbraco.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Data.SqlServerCe, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<Private>False</Private>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\System.Data.SqlServerCe.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Data.SqlServerCe.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<Private>False</Private>
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\System.Data.SqlServerCe.Entity.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http" />
|
||||
<Reference Include="System.Net.Http.Formatting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Client.4.0.30506.0\lib\net40\System.Net.Http.Formatting.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Net.Http.WebRequest" />
|
||||
<Reference Include="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<Private>False</Private>
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.Helpers.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebApi.Core.4.0.30506.0\lib\net40\System.Web.Http.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Http.WebHost, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebApi.WebHost.4.0.30506.0\lib\net40\System.Web.Http.WebHost.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<Private>False</Private>
|
||||
<HintPath>..\packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<Private>False</Private>
|
||||
<HintPath>..\packages\Microsoft.AspNet.Razor.2.0.30506.0\lib\net40\System.Web.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<Private>False</Private>
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<Private>False</Private>
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Deployment.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||
<Private>True</Private>
|
||||
<Private>False</Private>
|
||||
<HintPath>..\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Razor.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
@@ -151,39 +175,52 @@
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="TidyNet">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\TidyNet.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="umbraco">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\umbraco.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Umbraco.Core">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\Umbraco.Core.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="umbraco.DataLayer">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\umbraco.DataLayer.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="umbraco.editorControls">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\umbraco.editorControls.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="umbraco.MacroEngines">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\umbraco.MacroEngines.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="umbraco.providers">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\umbraco.providers.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="Umbraco.Web.UI">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\Umbraco.Web.UI.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="umbraco.XmlSerializers">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\umbraco.XmlSerializers.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="UmbracoExamine">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\UmbracoExamine.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
<Reference Include="UrlRewritingNet.UrlRewriter">
|
||||
<HintPath>..\packages\UmbracoCms.Core.7.0.1\lib\UrlRewritingNet.UrlRewriter.dll</HintPath>
|
||||
<Private>False</Private>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Api\ArchetypeDataTypeController.cs" />
|
||||
<Compile Include="Constants.cs" />
|
||||
<Compile Include="Extensions\Extensions.cs" />
|
||||
<Compile Include="Models\Archetype.cs" />
|
||||
<Compile Include="Models\ArchetypePreValue.cs" />
|
||||
@@ -192,6 +229,7 @@
|
||||
<Compile Include="Models\Fieldset.cs" />
|
||||
<Compile Include="Models\Property.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Properties\VersionInfo.cs" />
|
||||
<Compile Include="PropertyConverters\ArchetypeValueConverter.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace Archetype.Umbraco
|
||||
{
|
||||
public static class Constants
|
||||
{
|
||||
public const string PropertyEditorAlias = "Imulus.Archetype";
|
||||
|
||||
public const string PreValueAlias = "archetypeConfig";
|
||||
}
|
||||
}
|
||||
@@ -15,7 +15,7 @@ namespace Archetype.Umbraco.Extensions
|
||||
|
||||
public static bool IsArchetype(this Property prop)
|
||||
{
|
||||
return prop.PropertyEditorAlias.InvariantEquals("Imulus.Archetype");
|
||||
return prop.PropertyEditorAlias.InvariantEquals(Constants.PropertyEditorAlias);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Archetype.Umbraco.Models
|
||||
{
|
||||
public class Archetype
|
||||
{
|
||||
public IEnumerable<Fieldset> Fieldsets { get; set; }
|
||||
[JsonProperty("fieldsets")]
|
||||
public IEnumerable<Fieldset> Fieldsets { get; set; }
|
||||
|
||||
public Archetype()
|
||||
{
|
||||
|
||||
@@ -1,9 +1,44 @@
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Archetype.Umbraco.Models
|
||||
{
|
||||
internal class ArchetypePreValue
|
||||
{
|
||||
internal IEnumerable<ArchetypePreValueFieldset> Fieldsets { get; set; }
|
||||
}
|
||||
public class ArchetypePreValue
|
||||
{
|
||||
[JsonProperty("showAdvancedOptions")]
|
||||
public bool ShowAdvancedOptions { get; set; }
|
||||
|
||||
[JsonProperty("hideFieldsetToolbar")]
|
||||
public bool HideFieldsetToolbar { get; set; }
|
||||
|
||||
[JsonProperty("enableMultipleFieldsets")]
|
||||
public bool EnableMultipleFieldsets { get; set; }
|
||||
|
||||
[JsonProperty("hideFieldsetControls")]
|
||||
public bool HideFieldsetControls { get; set; }
|
||||
|
||||
[JsonProperty("hidePropertyLabel")]
|
||||
public bool HidePropertyLabel { get; set; }
|
||||
|
||||
[JsonProperty("maxFieldsets", NullValueHandling = NullValueHandling.Ignore)]
|
||||
public int MaxFieldsets { get; set; }
|
||||
|
||||
[JsonProperty("fieldsets")]
|
||||
public IEnumerable<ArchetypePreValueFieldset> Fieldsets { get; set; }
|
||||
|
||||
[JsonProperty("hidePropertyLabels")]
|
||||
public bool HidePropertyLabels { get; set; }
|
||||
|
||||
[JsonProperty("customCssClass")]
|
||||
public string CustomCssClass { get; set; }
|
||||
|
||||
[JsonProperty("customCssPath")]
|
||||
public string CustomCssPath { get; set; }
|
||||
|
||||
[JsonProperty("customJsPath")]
|
||||
public string CustomJsPath { get; set; }
|
||||
|
||||
[JsonProperty("developerMode")]
|
||||
public bool DeveloperMode { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Archetype.Umbraco.Models
|
||||
{
|
||||
internal class ArchetypePreValueFieldset
|
||||
{
|
||||
internal string Alias { get; set; }
|
||||
internal IEnumerable<ArchetypePreValueProperty> Properties { get; set; }
|
||||
}
|
||||
}
|
||||
public class ArchetypePreValueFieldset
|
||||
{
|
||||
[JsonProperty("alias")]
|
||||
public string Alias { get; set; }
|
||||
|
||||
[JsonProperty("remove")]
|
||||
public bool Remove { get; set; }
|
||||
|
||||
[JsonProperty("collapse")]
|
||||
public bool Collapse { get; set; }
|
||||
|
||||
[JsonProperty("labelTemplate")]
|
||||
public string LabelTemplate { get; set; }
|
||||
|
||||
[JsonProperty("icon")]
|
||||
public string Icon { get; set; }
|
||||
|
||||
[JsonProperty("label")]
|
||||
public string Label { get; set; }
|
||||
|
||||
[JsonProperty("properties")]
|
||||
public IEnumerable<ArchetypePreValueProperty> Properties { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,37 @@
|
||||
namespace Archetype.Umbraco.Models
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Archetype.Umbraco.Models
|
||||
{
|
||||
internal class ArchetypePreValueProperty
|
||||
{
|
||||
internal string Alias { get; set; }
|
||||
internal int DataTypeId { get; set; }
|
||||
internal string PropertyEditorAlias { get; set; }
|
||||
}
|
||||
public class ArchetypePreValueProperty
|
||||
{
|
||||
[JsonProperty("alias")]
|
||||
public string Alias { get; set; }
|
||||
|
||||
[JsonProperty("remove")]
|
||||
public bool Remove { get; set; }
|
||||
|
||||
[JsonProperty("collapse")]
|
||||
public bool Collapse { get; set; }
|
||||
|
||||
[JsonProperty("label")]
|
||||
public string Label { get; set; }
|
||||
|
||||
[JsonProperty("helpText")]
|
||||
public string HelpText { get; set; }
|
||||
|
||||
[JsonProperty("dataTypeId")]
|
||||
public int DataTypeId { get; set; }
|
||||
|
||||
[JsonProperty("dataTypeGuid")]
|
||||
public string DataTypeGuid { get; set; }
|
||||
|
||||
[JsonProperty("propertyEditorAlias")]
|
||||
public string PropertyEditorAlias { get; set; }
|
||||
|
||||
[JsonProperty("value")]
|
||||
public string Value { get; set; }
|
||||
|
||||
[JsonProperty("required")]
|
||||
public bool Required { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core;
|
||||
|
||||
namespace Archetype.Umbraco.Models
|
||||
{
|
||||
public class Fieldset
|
||||
{
|
||||
[JsonProperty("alias")]
|
||||
public string Alias { get; set; }
|
||||
|
||||
public IEnumerable<Property> Properties;
|
||||
[JsonProperty("properties")]
|
||||
public IEnumerable<Property> Properties;
|
||||
|
||||
public Fieldset()
|
||||
{
|
||||
Properties = new List<Property>();
|
||||
}
|
||||
|
||||
#region Helper Methods
|
||||
#region Helper Methods
|
||||
|
||||
public string GetValue(string propertyAlias)
|
||||
public string GetValue(string propertyAlias)
|
||||
{
|
||||
return GetValue<string>(propertyAlias);
|
||||
}
|
||||
@@ -26,18 +29,18 @@ namespace Archetype.Umbraco.Models
|
||||
{
|
||||
var property = GetProperty(propertyAlias);
|
||||
|
||||
if (property == null || string.IsNullOrEmpty(property.Value.ToString()))
|
||||
return default(T);
|
||||
if (property == null || string.IsNullOrEmpty(property.Value.ToString()))
|
||||
return default(T);
|
||||
|
||||
return property.GetValue<T>();
|
||||
return property.GetValue<T>();
|
||||
}
|
||||
|
||||
private Property GetProperty(string propertyAlias)
|
||||
{
|
||||
return Properties.FirstOrDefault(p => p.Alias.InvariantEquals(propertyAlias));
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.Models;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
@@ -6,66 +7,72 @@ using Umbraco.Core.PropertyEditors;
|
||||
|
||||
namespace Archetype.Umbraco.Models
|
||||
{
|
||||
public class Property
|
||||
public class Property
|
||||
{
|
||||
public string Alias { get; internal set; }
|
||||
public object Value { get; internal set; }
|
||||
[JsonProperty("alias")]
|
||||
public string Alias { get; internal set; }
|
||||
|
||||
[JsonProperty("value")]
|
||||
public object Value { get; set; }
|
||||
|
||||
[JsonProperty("propertyEditorAlias")]
|
||||
public string PropertyEditorAlias { get; internal set; }
|
||||
|
||||
internal int DataTypeId { get; set; }
|
||||
[JsonProperty("dataTypeId")]
|
||||
public int DataTypeId { get; internal set; }
|
||||
|
||||
public T GetValue<T>()
|
||||
{
|
||||
// If the value is of type T, just return it
|
||||
if (Value is T)
|
||||
return (T)Value;
|
||||
public T GetValue<T>()
|
||||
{
|
||||
// If the value is of type T, just return it
|
||||
if (Value is T)
|
||||
return (T)Value;
|
||||
|
||||
// Umbraco has the concept of a IPropertyEditorValueConverter which it
|
||||
// also queries for property resolvers. However I'm not sure what these
|
||||
// are for, nor can I find any implementations in core, so am currently
|
||||
// just ignoring these when looking up converters.
|
||||
// NB: IPropertyEditorValueConverter not to be confused with
|
||||
// IPropertyValueConverter which are the ones most people are creating
|
||||
var properyType = CreateDummyPropertyType(DataTypeId, PropertyEditorAlias);
|
||||
var converters = PropertyValueConvertersResolver.Current.Converters.ToArray();
|
||||
// Umbraco has the concept of a IPropertyEditorValueConverter which it
|
||||
// also queries for property resolvers. However I'm not sure what these
|
||||
// are for, nor can I find any implementations in core, so am currently
|
||||
// just ignoring these when looking up converters.
|
||||
// NB: IPropertyEditorValueConverter not to be confused with
|
||||
// IPropertyValueConverter which are the ones most people are creating
|
||||
var properyType = CreateDummyPropertyType(DataTypeId, PropertyEditorAlias);
|
||||
var converters = PropertyValueConvertersResolver.Current.Converters.ToArray();
|
||||
|
||||
// In umbraco, there are default value converters that try to convert the
|
||||
// value if all else fails. The problem is, they are also in the list of
|
||||
// converters, and the means for filtering these out is internal, so
|
||||
// we currently have to try ALL converters to see if they can convert
|
||||
// rather than just finding the most appropreate. If the ability to filter
|
||||
// out default value converters becomes public, the following logic could
|
||||
// and probably should be changed.
|
||||
foreach (var converter in converters.Where(x => x.IsConverter(properyType)))
|
||||
{
|
||||
// Convert the type using a found value converter
|
||||
var value2 = converter.ConvertDataToSource(properyType, Value, false);
|
||||
// In umbraco, there are default value converters that try to convert the
|
||||
// value if all else fails. The problem is, they are also in the list of
|
||||
// converters, and the means for filtering these out is internal, so
|
||||
// we currently have to try ALL converters to see if they can convert
|
||||
// rather than just finding the most appropreate. If the ability to filter
|
||||
// out default value converters becomes public, the following logic could
|
||||
// and probably should be changed.
|
||||
foreach (var converter in converters.Where(x => x.IsConverter(properyType)))
|
||||
{
|
||||
// Convert the type using a found value converter
|
||||
var value2 = converter.ConvertDataToSource(properyType, Value, false);
|
||||
|
||||
// If the value is of type T, just return it
|
||||
if (value2 is T)
|
||||
return (T)value2;
|
||||
// If the value is of type T, just return it
|
||||
if (value2 is T)
|
||||
return (T)value2;
|
||||
|
||||
// Value is not final value type, so try a regular type conversion aswell
|
||||
var convertAttempt = value2.TryConvertTo<T>();
|
||||
if (convertAttempt.Success)
|
||||
return convertAttempt.Result;
|
||||
}
|
||||
// Value is not final value type, so try a regular type conversion aswell
|
||||
var convertAttempt = value2.TryConvertTo<T>();
|
||||
if (convertAttempt.Success)
|
||||
return convertAttempt.Result;
|
||||
}
|
||||
|
||||
// Value is not final value type, so try a regular type conversion
|
||||
var convertAttempt2 = Value.TryConvertTo<T>();
|
||||
if (convertAttempt2.Success)
|
||||
return convertAttempt2.Result;
|
||||
// Value is not final value type, so try a regular type conversion
|
||||
var convertAttempt2 = Value.TryConvertTo<T>();
|
||||
if (convertAttempt2.Success)
|
||||
return convertAttempt2.Result;
|
||||
|
||||
return default(T);
|
||||
}
|
||||
return default(T);
|
||||
}
|
||||
|
||||
private PublishedPropertyType CreateDummyPropertyType(int dataTypeId, string propertyEditorAlias)
|
||||
{
|
||||
return new PublishedPropertyType(null,
|
||||
new PropertyType(new DataTypeDefinition(-1, propertyEditorAlias)
|
||||
{
|
||||
Id = dataTypeId
|
||||
}));
|
||||
}
|
||||
private PublishedPropertyType CreateDummyPropertyType(int dataTypeId, string propertyEditorAlias)
|
||||
{
|
||||
return new PublishedPropertyType(null,
|
||||
new PropertyType(new DataTypeDefinition(-1, propertyEditorAlias)
|
||||
{
|
||||
Id = dataTypeId
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +1,14 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[assembly: AssemblyTitle("Archetype")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyDescription("Archetype's supporting code library for Umbraco")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyCompany("Imulus")]
|
||||
[assembly: AssemblyProduct("Archetype")]
|
||||
[assembly: AssemblyCopyright("Copyright © 2014")]
|
||||
[assembly: AssemblyCopyright("Copyright \xa9 Imulus 2014")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[assembly: Guid("e37e94f9-c7ba-4b54-b7e1-64419b3dba0b")]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("0.1.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.1.0.0")]
|
||||
[assembly: AssemblyInformationalVersion("0.1.0-alpha")]
|
||||
[assembly: Guid("E37E94F9-C7BA-4B54-B7E1-64419B3DBA0B")]
|
||||
@@ -0,0 +1,4 @@
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyVersion("0.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("0.0.0.0")]
|
||||
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Archetype.Umbraco.Extensions;
|
||||
using Archetype.Umbraco.Models;
|
||||
using Newtonsoft.Json;
|
||||
using Umbraco.Core;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Models.PublishedContent;
|
||||
using Archetype.Umbraco.Models;
|
||||
using Archetype.Umbraco.Extensions;
|
||||
using Umbraco.Core.PropertyEditors;
|
||||
using Umbraco.Core.Services;
|
||||
|
||||
namespace Archetype.Umbraco.PropertyConverters
|
||||
@@ -15,58 +15,65 @@ namespace Archetype.Umbraco.PropertyConverters
|
||||
[PropertyValueCache(PropertyCacheValue.All, PropertyCacheLevel.Content)]
|
||||
public class ArchetypeValueConverter : PropertyValueConverterBase
|
||||
{
|
||||
protected JsonSerializerSettings _jsonSettings;
|
||||
protected JsonSerializerSettings _jsonSettings;
|
||||
|
||||
public ArchetypeValueConverter()
|
||||
{
|
||||
var dcr = new Newtonsoft.Json.Serialization.DefaultContractResolver();
|
||||
dcr.DefaultMembersSearchFlags |= System.Reflection.BindingFlags.NonPublic;
|
||||
public ArchetypeValueConverter()
|
||||
{
|
||||
var dcr = new Newtonsoft.Json.Serialization.DefaultContractResolver();
|
||||
dcr.DefaultMembersSearchFlags |= System.Reflection.BindingFlags.NonPublic;
|
||||
|
||||
_jsonSettings = new JsonSerializerSettings { ContractResolver = dcr };
|
||||
}
|
||||
_jsonSettings = new JsonSerializerSettings { ContractResolver = dcr };
|
||||
}
|
||||
|
||||
public ServiceContext Services
|
||||
{
|
||||
get { return ApplicationContext.Current.Services; }
|
||||
}
|
||||
public ServiceContext Services
|
||||
{
|
||||
get { return ApplicationContext.Current.Services; }
|
||||
}
|
||||
|
||||
public override bool IsConverter(PublishedPropertyType propertyType)
|
||||
{
|
||||
return propertyType.PropertyEditorAlias.Equals("Imulus.Archetype");
|
||||
return propertyType.PropertyEditorAlias.Equals(Constants.PropertyEditorAlias);
|
||||
}
|
||||
|
||||
public override object ConvertDataToSource(PublishedPropertyType propertyType, object source, bool preview)
|
||||
{
|
||||
if (source == null) return null;
|
||||
|
||||
var sourceString = source.ToString();
|
||||
if (source == null)
|
||||
return null;
|
||||
|
||||
var sourceString = source.ToString();
|
||||
|
||||
if (sourceString.DetectIsJson())
|
||||
{
|
||||
try
|
||||
{
|
||||
// Deserialize value to archetype model
|
||||
var archetype = JsonConvert.DeserializeObject<Models.Archetype>(sourceString, _jsonSettings);
|
||||
// Deserialize value to archetype model
|
||||
var archetype = JsonConvert.DeserializeObject<Models.Archetype>(sourceString, _jsonSettings);
|
||||
|
||||
// Get list of configured properties and their types
|
||||
// and map them to the deserialized archetype model
|
||||
var preValue = GetArchetypePreValueFromDataTypeId(propertyType.DataTypeId);
|
||||
foreach (var fieldset in preValue.Fieldsets)
|
||||
{
|
||||
var fieldsetAlias = fieldset.Alias;
|
||||
foreach (var fieldsetInst in archetype.Fieldsets.Where(x => x.Alias == fieldsetAlias))
|
||||
{
|
||||
foreach (var property in fieldset.Properties)
|
||||
{
|
||||
var propertyAlias = property.Alias;
|
||||
foreach (var propertyInst in fieldsetInst.Properties.Where(x => x.Alias == propertyAlias))
|
||||
{
|
||||
propertyInst.DataTypeId = property.DataTypeId;
|
||||
propertyInst.PropertyEditorAlias = property.PropertyEditorAlias;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
// Get list of configured properties and their types
|
||||
// and map them to the deserialized archetype model
|
||||
var preValue = GetArchetypePreValueFromDataTypeId(propertyType.DataTypeId);
|
||||
foreach (var fieldset in preValue.Fieldsets)
|
||||
{
|
||||
var fieldsetAlias = fieldset.Alias;
|
||||
foreach (var fieldsetInst in archetype.Fieldsets.Where(x => x.Alias == fieldsetAlias))
|
||||
{
|
||||
foreach (var property in fieldset.Properties)
|
||||
{
|
||||
var propertyAlias = property.Alias;
|
||||
foreach (var propertyInst in fieldsetInst.Properties.Where(x => x.Alias == propertyAlias))
|
||||
{
|
||||
propertyInst.DataTypeId = property.DataTypeId;
|
||||
propertyInst.PropertyEditorAlias = property.PropertyEditorAlias;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
return archetype;
|
||||
}
|
||||
@@ -79,32 +86,32 @@ namespace Archetype.Umbraco.PropertyConverters
|
||||
return sourceString;
|
||||
}
|
||||
|
||||
internal ArchetypePreValue GetArchetypePreValueFromDataTypeId(int dataTypeId)
|
||||
{
|
||||
var preValues = Services.DataTypeService.GetPreValuesCollectionByDataTypeId(dataTypeId);
|
||||
internal ArchetypePreValue GetArchetypePreValueFromDataTypeId(int dataTypeId)
|
||||
{
|
||||
var preValues = Services.DataTypeService.GetPreValuesCollectionByDataTypeId(dataTypeId);
|
||||
|
||||
var configJson = preValues.IsDictionaryBased
|
||||
? preValues.PreValuesAsDictionary["archetypeConfig"].Value
|
||||
: preValues.PreValuesAsArray.First().Value;
|
||||
var configJson = preValues.IsDictionaryBased
|
||||
? preValues.PreValuesAsDictionary[Constants.PreValueAlias].Value
|
||||
: preValues.PreValuesAsArray.First().Value;
|
||||
|
||||
var config = JsonConvert.DeserializeObject<Models.ArchetypePreValue>(configJson, _jsonSettings);
|
||||
var config = JsonConvert.DeserializeObject<Models.ArchetypePreValue>(configJson, _jsonSettings);
|
||||
|
||||
foreach (var fieldset in config.Fieldsets)
|
||||
{
|
||||
foreach (var property in fieldset.Properties)
|
||||
{
|
||||
// Lookup the properties property editor alias
|
||||
// (See if we've already looked it up first though to save a database hit)
|
||||
var propertyWithSameDataType = config.Fieldsets.SelectMany(x => x.Properties)
|
||||
.FirstOrDefault(x => x.DataTypeId == property.DataTypeId && !string.IsNullOrWhiteSpace(x.PropertyEditorAlias));
|
||||
foreach (var fieldset in config.Fieldsets)
|
||||
{
|
||||
foreach (var property in fieldset.Properties)
|
||||
{
|
||||
// Lookup the properties property editor alias
|
||||
// (See if we've already looked it up first though to save a database hit)
|
||||
var propertyWithSameDataType = config.Fieldsets.SelectMany(x => x.Properties)
|
||||
.FirstOrDefault(x => x.DataTypeId == property.DataTypeId && !string.IsNullOrWhiteSpace(x.PropertyEditorAlias));
|
||||
|
||||
property.PropertyEditorAlias = propertyWithSameDataType != null
|
||||
? propertyWithSameDataType.PropertyEditorAlias
|
||||
: Services.DataTypeService.GetDataTypeDefinitionById(property.DataTypeId).PropertyEditorAlias;
|
||||
}
|
||||
}
|
||||
property.PropertyEditorAlias = propertyWithSameDataType != null
|
||||
? propertyWithSameDataType.PropertyEditorAlias
|
||||
: Services.DataTypeService.GetDataTypeDefinitionById(property.DataTypeId).PropertyEditorAlias;
|
||||
}
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
return config;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -106,7 +106,7 @@
|
||||
|
||||
//helper, ini the render model from the server (model.value)
|
||||
function initArchetypeRenderModel() {
|
||||
$scope.archetypeRenderModel = $scope.model.value;
|
||||
$scope.archetypeRenderModel = removeNulls($scope.model.value);
|
||||
|
||||
_.each($scope.archetypeRenderModel.fieldsets, function (fieldset)
|
||||
{
|
||||
@@ -201,7 +201,7 @@
|
||||
_.each($scope.archetypeRenderModel.fieldsets, function(fieldset){
|
||||
var cleanedFieldset = cleanFieldset(fieldset);
|
||||
|
||||
if(cleanFieldset){
|
||||
if(cleanedFieldset){
|
||||
$scope.model.value.fieldsets.push(cleanedFieldset);
|
||||
}
|
||||
});
|
||||
@@ -248,6 +248,20 @@
|
||||
return JSON.parse('{"alias": "' + fieldsetModel.alias + '", "remove": false, "isValid": true, "properties": []}');
|
||||
}
|
||||
|
||||
//helper to ensure no nulls make it into the model
|
||||
function removeNulls(model){
|
||||
if(model.fieldsets){
|
||||
_.each(model.fieldsets, function(fieldset, index){
|
||||
if(!fieldset){
|
||||
model.fieldsets.splice(index, 1);
|
||||
removeNulls(model);
|
||||
}
|
||||
});
|
||||
|
||||
return model;
|
||||
}
|
||||
}
|
||||
|
||||
//helper to lookup validity when given a fieldsetIndex and property alias
|
||||
$scope.getPropertyValidity = function(fieldsetIndex, alias)
|
||||
{
|
||||
|
||||
@@ -55,6 +55,7 @@ angular.module("umbraco.directives").directive('archetypeProperty', function ($c
|
||||
var config = null;
|
||||
var alias = configFieldsetModel.properties[scope.propertyConfigIndex].alias;
|
||||
var defaultValue = configFieldsetModel.properties[scope.propertyConfigIndex].value;
|
||||
var umbracoPropertyAlias = scope.umbracoPropertyAlias;
|
||||
|
||||
//try to convert the defaultValue to a JS object
|
||||
defaultValue = jsonOrString(defaultValue, scope.archetypeConfig.developerMode, "defaultValue");
|
||||
@@ -81,7 +82,7 @@ angular.module("umbraco.directives").directive('archetypeProperty', function ($c
|
||||
}
|
||||
var mergedConfig = _.extend(defaultConfigObj, config);
|
||||
|
||||
loadView(pathToView, mergedConfig, defaultValue, alias, scope, element, ngModelCtrl);
|
||||
loadView(pathToView, mergedConfig, defaultValue, alias, umbracoPropertyAlias, scope, element, ngModelCtrl);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -111,7 +112,7 @@ angular.module("umbraco.directives").directive('archetypeProperty', function ($c
|
||||
}
|
||||
}
|
||||
|
||||
function loadView(view, config, defaultValue, alias, scope, element, ngModelCtrl) {
|
||||
function loadView(view, config, defaultValue, alias, umbracoPropertyAlias, scope, element, ngModelCtrl) {
|
||||
if (view)
|
||||
{
|
||||
$http.get(view).success(function (data) {
|
||||
@@ -139,7 +140,7 @@ angular.module("umbraco.directives").directive('archetypeProperty', function ($c
|
||||
scope.model.config = config;
|
||||
|
||||
//some items need an alias
|
||||
scope.model.alias = "archetype-property-" + scope.fieldsetIndex + "-" + scope.propertyConfigIndex;
|
||||
scope.model.alias = "archetype-property-" + umbracoPropertyAlias + "-" + scope.fieldsetIndex + "-" + scope.propertyConfigIndex;
|
||||
|
||||
//watch for changes since there is no two-way binding with the local model.value
|
||||
scope.$watch('model.value', function (newValue, oldValue) {
|
||||
@@ -167,7 +168,8 @@ angular.module("umbraco.directives").directive('archetypeProperty', function ($c
|
||||
archetypeConfig: '=',
|
||||
fieldset: '=',
|
||||
fieldsetIndex: '=',
|
||||
archetypeRenderModel: '='
|
||||
archetypeRenderModel: '=',
|
||||
umbracoPropertyAlias: '='
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -1,15 +0,0 @@
|
||||
angular.module('umbraco.filters').filter("archetypeLocale", function(){
|
||||
return function(key, locales){
|
||||
|
||||
if(!locales)
|
||||
return key;
|
||||
|
||||
if(!locales.defaultLocale)
|
||||
return key;
|
||||
|
||||
if(!locales.locale)
|
||||
return key;
|
||||
|
||||
return locales.locale[key] || locales.defaultLocale[key] || key;
|
||||
}
|
||||
})
|
||||
@@ -12,7 +12,7 @@ angular.module('umbraco.resources').factory('archetypePropertyEditorResource', f
|
||||
},
|
||||
getDataType: function(id) {
|
||||
return umbRequestHelper.resourcePromise(
|
||||
$http.get("/umbraco/backoffice/UmbracoApi/DataType/GetById?id=" + id), 'Failed to retrieve datatype'
|
||||
$http.get("/umbraco/backoffice/ArchetypeApi/ArchetypeDataType/GetById?id=" + id), 'Failed to retrieve datatype'
|
||||
);
|
||||
},
|
||||
getPropertyEditorMapping: function(alias) {
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
<div class="archetypeCollapser animate-hide" ng-hide="fieldset.collapse">
|
||||
<form class="form-inline">
|
||||
<div ng-class="{archetypePropertyError: getPropertyValidity($parent.$index, property.alias) === false}" class="archetypeProperty control-group" ng-repeat="property in fieldsetConfigModel.properties">
|
||||
<label ng-hide="archetypeConfig.hidePropertyLabels == '1'" class="control-label" for="archetype-property-{{$parent.$index}}-{{$index}}">
|
||||
<label ng-hide="archetypeConfig.hidePropertyLabels == '1'" class="control-label" for="archetype-property-{{model.alias}}-{{$parent.$index}}-{{$index}}">
|
||||
<span>{{property.label}}</span>
|
||||
<div class="archetypeFieldsetHelpText" ng-show="property.helpText">
|
||||
<em>{{property.helpText}}</em>
|
||||
@@ -38,7 +38,7 @@
|
||||
</label>
|
||||
|
||||
<div class="controls">
|
||||
<archetype-property class="archetypeEditor ng-class:property.alias" property="property" fieldset-index="$parent.$index" fieldset="fieldset" archetype-config="model.config" property-config-index="$index" archetype-render-model="archetypeRenderModel"></archetype-property>
|
||||
<archetype-property class="archetypeEditor ng-class:property.alias" property="property" fieldset-index="$parent.$index" fieldset="fieldset" archetype-config="model.config" property-config-index="$index" archetype-render-model="archetypeRenderModel" umbraco-property-alias="model.alias"></archetype-property>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
+2
-1
@@ -20,7 +20,8 @@
|
||||
"grunt-template": "~0.2.2",
|
||||
"grunt-touch": "~0.1.0",
|
||||
"fs-extra": "~0.8.1",
|
||||
"grunt-msbuild": "~0.1.9"
|
||||
"grunt-msbuild": "~0.1.9",
|
||||
"grunt-dotnet-assembly-info": "~1.0.9"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Archetype",
|
||||
"version": "0.4.0-alpha",
|
||||
"version": "0.5.1-alpha",
|
||||
"url": "http://github.com/imulus/archetype/",
|
||||
"author": "Imulus",
|
||||
"authorUrl": "http://imulus.com/",
|
||||
|
||||
@@ -12,9 +12,4 @@
|
||||
<iconUrl>http://github.com/imulus/archetype/raw/master/assets/logo.png</iconUrl>
|
||||
<licenseUrl><%= licenseUrl %></licenseUrl>
|
||||
</metadata>
|
||||
<files>
|
||||
<% files.forEach(function(file) { %>
|
||||
<file src="<%- file.path %>" target="<%= file.target %>" />
|
||||
<% }); %>
|
||||
</files>
|
||||
</package>
|
||||
Reference in New Issue
Block a user