Compare commits

..

24 Commits

Author SHA1 Message Date
Kevin Giszewski 1dde1ed5f0 Add version to assembly 2014-02-26 10:01:39 -05:00
Kevin Giszewski 88051ef61d Bump Version Number 2014-02-26 09:41:06 -05:00
Kevin Giszewski 10d3dd76ed Fix a situation where null were getting into the model on save. 2014-02-26 09:39:02 -05:00
Kevin Giszewski b52f153141 Merge pull request #57 from imulus/feature/api
Expose the Datatype Service GetById
2014-02-26 08:09:27 -05:00
Tom Fulton 062f28f9ca Tighten up watch/deploy tasks
* Don't trigger watch on changes to the .NET solution (except *.dll)
* Include .pdb file for dev deployments
* Fix DLL copying to wrong paths
2014-02-24 01:00:08 -07:00
Tom Fulton ed6068230e Merge pull request #59 from leekelleher/patch-vs-housekeeping
Some Visual Studio housekeeping
2014-02-21 22:53:16 -07:00
Tom Fulton 24bfef64dd Misc housekeeping 2014-02-21 22:36:27 -07:00
Tom Fulton 1d5e4eda7e Trim down data returned from API 2014-02-21 22:34:30 -07:00
leekelleher 346b8c73d4 Tidied up the AssemblyInfo with your company details, etc. 2014-02-21 18:17:59 +00:00
leekelleher 43ea29cdf2 Set the assembly references not to all "Copy Local",
so that everything isn't copied over to the /bin folders.
2014-02-21 18:14:13 +00:00
Kevin Giszewski f05a67d9d2 Expose the Datatype Service GetById 2014-02-20 11:07:20 -05:00
Kevin Giszewski 3ac7ef34ec Merge pull request #54 from imulus/develop
Develop
2014-02-19 09:17:17 -05:00
Kevin Giszewski 518f95ce01 Merge pull request #52 from imulus/fix-ids
Fix some datatypes not working with multiple Archetypes
2014-02-19 09:16:41 -05:00
Tom Fulton 7831e476e3 Ensure property containers use unique IDs with multiple fieldsets
...by adding the current Archetype's Umbraco Property Alias to the ID string

Old: archetype-property-0-0
New: archetype-property-sliderItems-0-0

Need to DRY this up later ;)
2014-02-17 15:17:57 -07:00
Kevin Giszewski bfb883c098 Merge pull request #49 from leekelleher/feature-patch-courier-dataresolver
Tweaks to support a Courier DataResolver
2014-02-14 09:29:57 -05:00
leekelleher bbe3506747 Housekeeping: Fixed up the whitespace :bowtie:
There was a mix of tabs & spaces...
... normalized to use spaces (which was painful for me as I'm a "tabs kinda guy" 🤘
2014-02-13 17:50:07 +00:00
leekelleher 42743b1394 Fleshed out the ArchetypePreValue models.
(When Courier packages up the DataTypeDefinition - we need to serialize/deserialize the config options/JSON)
2014-02-13 17:43:52 +00:00
leekelleher 9a712acd6a Added constant for the prevalue alias.
(As we reference to this in the Courier DataResolver)
2014-02-13 17:30:28 +00:00
leekelleher 4c8bbd5d8f Added a nested try/catch.
For if the `PublishedPropertyType` value is null, we can still get an `Archetype` model returned)
2014-02-13 16:53:38 +00:00
leekelleher 9296388abe Added a constant for the PropertyEditor alias.
(So that we can reference it from the Courier DataResolver, without fear of typos)
2014-02-13 16:51:31 +00:00
leekelleher 3c5e2013a0 Added JsonProperty attributes to the properties.
(So that we can serialize/deserialize from the Courier DataResolver)
2014-02-13 16:32:03 +00:00
leekelleher aacbc06992 Changed the Property.DataTypeId property to be public, with an internal setter.
(We need to reference it within Courier's DataResolver)
2014-02-13 16:27:29 +00:00
leekelleher 220a034d2a Changed the Property.Value setter to be public. 2014-02-13 14:16:42 +00:00
Kevin Giszewski 6317b83720 Remove legacy filter 2014-02-07 17:31:18 -05:00
19 changed files with 360 additions and 206 deletions
+8 -8
View File
@@ -25,7 +25,7 @@ module.exports = function(grunt) {
},
dev: {
files: ['app/**'],
files: ['app/**', '!app/Umbraco/**', 'app/Umbraco/**/*.dll'],
tasks: ['deploy'],
options: {
spawn: false
@@ -109,25 +109,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/', 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}
]
}
},
@@ -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" />
@@ -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,18 @@
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)]
[assembly: Guid("E37E94F9-C7BA-4B54-B7E1-64419B3DBA0B")]
// 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: AssemblyVersion("0.5.0.0")]
[assembly: AssemblyFileVersion("0.5.0.0")]
[assembly: AssemblyInformationalVersion("0.5.0-alpha")]
@@ -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;
}
}
}
+16 -2
View File
@@ -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)
{
+6 -4
View File
@@ -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: '='
}
}
});
-15
View File
@@ -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;
}
})
+1 -1
View File
@@ -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) {
+2 -2
View File
@@ -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>
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "Archetype",
"version": "0.4.0-alpha",
"version": "0.5.0-alpha",
"url": "http://github.com/imulus/archetype/",
"author": "Imulus",
"authorUrl": "http://imulus.com/",