Compare commits
21 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 146a3770a1 | |||
| caf9d1ac15 | |||
| 614595ceb3 | |||
| d1b21a1ca7 | |||
| 54bc507049 | |||
| 037585458c | |||
| f52649eb9e | |||
| 423fedb954 | |||
| b39312ccd2 | |||
| b9c4be0bb6 | |||
| 29285607a9 | |||
| 909b87cea0 | |||
| 3d25f75fb9 | |||
| 6fa713f88e | |||
| d9982fe3a2 | |||
| 588bdfe429 | |||
| 0174f6d78b | |||
| 84144b6206 | |||
| 27910e8d22 | |||
| 9bf413207f | |||
| e5cd3d0cb0 |
+6
-5
@@ -55,6 +55,7 @@ module.exports = function(grunt) {
|
||||
'app/controllers/controller.js',
|
||||
'app/controllers/config.controller.js',
|
||||
'app/directives/archetypeproperty.js',
|
||||
'app/directives/archetypesubmitwatcher.js',
|
||||
'app/directives/archetypecustomview.js',
|
||||
'app/directives/localize.js',
|
||||
'app/services/localization.js',
|
||||
@@ -73,7 +74,7 @@ module.exports = function(grunt) {
|
||||
expand: true
|
||||
},
|
||||
dll: {
|
||||
cwd: 'app/Umbraco/Umbraco.Archetype/bin/Release/',
|
||||
cwd: 'app/Umbraco/Umbraco.Archetype/bin/Debug/',
|
||||
src: 'Archetype.dll',
|
||||
dest: '<%= dest %>/bin/',
|
||||
expand: true
|
||||
@@ -163,10 +164,10 @@ module.exports = function(grunt) {
|
||||
|
||||
assemblyinfo: {
|
||||
options: {
|
||||
files: ['app/Umbraco/Umbraco.Archetype/Archetype.Umbraco.csproj'],
|
||||
files: ['app/Umbraco/Umbraco.Archetype/Archetype.Umbraco.csproj', 'app/Umbraco/Umbraco.Archetype/Archetype.Courier.csproj'],
|
||||
filename: 'VersionInfo.cs',
|
||||
info: {
|
||||
version: '<%= (pkgMeta.version.indexOf("-") ? pkgMeta.version.substring(0, pkgMeta.version.indexOf("-")) : pkgMeta.version) %>',
|
||||
version: '<%= (pkgMeta.version.indexOf("-") > 0 ? pkgMeta.version.substring(0, pkgMeta.version.indexOf("-")) : pkgMeta.version) %>',
|
||||
fileVersion: '<%= pkgMeta.version %>'
|
||||
}
|
||||
}
|
||||
@@ -199,9 +200,9 @@ module.exports = function(grunt) {
|
||||
}
|
||||
},
|
||||
dist: {
|
||||
src: ['app/Umbraco/Umbraco.Archetype/Archetype.Umbraco.csproj'],
|
||||
src: ['app/Umbraco/Umbraco.Archetype/Archetype.Umbraco.csproj','app/Umbraco/Archetype.Courier/Archetype.Courier.csproj'],
|
||||
options: {
|
||||
projectConfiguration: 'Release',
|
||||
projectConfiguration: 'Debug',
|
||||
targets: ['Clean', 'Rebuild'],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ Install the selected <a href='https://github.com/imulus/Archetype/releases'>rele
|
||||
|
||||
|
||||
## Official Docs ##
|
||||
http://imulus.github.io/Archetype
|
||||
https://github.com/kgiszewski/ArchetypeManual
|
||||
|
||||
Follow us on Twitter https://twitter.com/ArchetypeKit
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Archetype.Models
|
||||
|
||||
// Try Umbraco's PropertyValueConverters
|
||||
var converters = UmbracoContext.Current != null ? PropertyValueConvertersResolver.Current.Converters : Enumerable.Empty<IPropertyValueConverter>();
|
||||
if (converters.Any())
|
||||
if (!string.IsNullOrWhiteSpace(this.PropertyEditorAlias) && converters.Any())
|
||||
{
|
||||
var convertedAttempt = TryConvertWithPropertyValueConverters<T>(Value, converters);
|
||||
if (convertedAttempt.Success)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: AssemblyVersion("1.7.1")]
|
||||
[assembly: AssemblyFileVersion("1.7.1")]
|
||||
[assembly: AssemblyVersion("1.7.4")]
|
||||
[assembly: AssemblyFileVersion("1.7.4")]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Archetype.Extensions;
|
||||
using ClientDependency.Core;
|
||||
using Newtonsoft.Json;
|
||||
@@ -56,13 +57,11 @@ namespace Archetype.PropertyEditors
|
||||
if (property.Value == null || property.Value.ToString() == "")
|
||||
return string.Empty;
|
||||
|
||||
//LogHelper.Info<ArchetypeHelper>(property.Value.ToString());
|
||||
|
||||
var archetype = ArchetypeHelper.Instance.DeserializeJsonToArchetype(property.Value.ToString(), propertyType.DataTypeDefinitionId);
|
||||
|
||||
foreach (var fieldset in archetype.Fieldsets)
|
||||
{
|
||||
foreach (var propDef in fieldset.Properties)
|
||||
foreach (var propDef in fieldset.Properties.Where(p => p.DataTypeGuid != null))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -86,15 +85,13 @@ namespace Archetype.PropertyEditors
|
||||
public override object ConvertDbToEditor(Property property, PropertyType propertyType, IDataTypeService dataTypeService)
|
||||
{
|
||||
if (property.Value == null || property.Value.ToString() == "")
|
||||
return string.Empty;
|
||||
|
||||
//LogHelper.Info<ArchetypeHelper>(property.Value.ToString());
|
||||
return string.Empty;;
|
||||
|
||||
var archetype = ArchetypeHelper.Instance.DeserializeJsonToArchetype(property.Value.ToString(), propertyType.DataTypeDefinitionId);
|
||||
|
||||
foreach (var fieldset in archetype.Fieldsets)
|
||||
{
|
||||
foreach (var propDef in fieldset.Properties)
|
||||
foreach (var propDef in fieldset.Properties.Where(p => p.DataTypeGuid != null))
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -118,13 +115,11 @@ namespace Archetype.PropertyEditors
|
||||
if (editorValue.Value == null || editorValue.Value.ToString() == "")
|
||||
return string.Empty;
|
||||
|
||||
//LogHelper.Info<ArchetypeHelper>(editorValue.Value.ToString());
|
||||
|
||||
var archetype = ArchetypeHelper.Instance.DeserializeJsonToArchetype(editorValue.Value.ToString(), editorValue.PreValues);
|
||||
|
||||
foreach (var fieldset in archetype.Fieldsets)
|
||||
{
|
||||
foreach (var propDef in fieldset.Properties)
|
||||
{
|
||||
foreach (var propDef in fieldset.Properties.Where(p => p.DataTypeGuid != null))
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -299,6 +299,8 @@
|
||||
$scope.model.value.toString = stringify;
|
||||
}
|
||||
}
|
||||
// reset submit watcher counter on save
|
||||
$scope.activeSubmitWatcher = 0;
|
||||
});
|
||||
|
||||
//helper to count what is visible
|
||||
@@ -398,4 +400,17 @@
|
||||
{
|
||||
assetsService.loadCss($scope.model.config.customCssPath);
|
||||
}
|
||||
|
||||
// submit watcher handling:
|
||||
// because some property editors use the "formSubmitting" event to set/clean up their model.value,
|
||||
// we need to monitor the "formSubmitting" event from a custom property and broadcast our own event
|
||||
// to forcefully update the appropriate model.value's
|
||||
$scope.activeSubmitWatcher = 0;
|
||||
$scope.submitWatcherOnLoad = function () {
|
||||
$scope.activeSubmitWatcher++;
|
||||
return $scope.activeSubmitWatcher;
|
||||
}
|
||||
$scope.submitWatcherOnSubmit = function () {
|
||||
$scope.$broadcast("archetypeFormSubmitting");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -86,7 +86,7 @@ angular.module("umbraco.directives").directive('archetypeProperty', function ($c
|
||||
});
|
||||
});
|
||||
|
||||
scope.$on("formSubmitting", function (ev, args) {
|
||||
scope.$on("archetypeFormSubmitting", function (ev, args) {
|
||||
// validate all fieldset properties
|
||||
_.each(scope.fieldset.properties, function (property) {
|
||||
validateProperty(scope.fieldset, property);
|
||||
@@ -102,6 +102,7 @@ angular.module("umbraco.directives").directive('archetypeProperty', function ($c
|
||||
ngModelCtrl.$setValidity(validationKey, scope.fieldset.isValid);
|
||||
});
|
||||
|
||||
|
||||
// called when the value of any property in a fieldset changes
|
||||
function propertyValueChanged(fieldset, property) {
|
||||
// it's the Umbraco way to hide the invalid state when altering an invalid property, even if the new value isn't valid either
|
||||
@@ -158,6 +159,14 @@ angular.module("umbraco.directives").directive('archetypeProperty', function ($c
|
||||
return _.unique(propertyAliasParts).reverse().join("-");
|
||||
};
|
||||
|
||||
var getFieldset = function(scope) {
|
||||
return scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex];
|
||||
}
|
||||
|
||||
var getFieldsetProperty = function (scope) {
|
||||
return getFieldset(scope).properties[scope.renderModelPropertyIndex];
|
||||
}
|
||||
|
||||
function loadView(view, config, defaultValue, alias, propertyAlias, scope, element, ngModelCtrl, propertyValueChanged) {
|
||||
if (view)
|
||||
{
|
||||
@@ -174,14 +183,15 @@ angular.module("umbraco.directives").directive('archetypeProperty', function ($c
|
||||
scope.model.config = {};
|
||||
|
||||
//ini the property value after test to make sure a prop exists in the renderModel
|
||||
var renderModelPropertyIndex = getPropertyIndexByAlias(scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties, alias);
|
||||
scope.renderModelPropertyIndex = getPropertyIndexByAlias(getFieldset(scope).properties, alias);
|
||||
|
||||
if (!renderModelPropertyIndex)
|
||||
if (!scope.renderModelPropertyIndex)
|
||||
{
|
||||
scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties.push(JSON.parse('{"alias": "' + alias + '", "value": "' + defaultValue + '"}'));
|
||||
renderModelPropertyIndex = getPropertyIndexByAlias(scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties, alias);
|
||||
getFieldset(scope).properties.push(JSON.parse('{"alias": "' + alias + '", "value": "' + defaultValue + '"}'));
|
||||
scope.renderModelPropertyIndex = getPropertyIndexByAlias(getFieldset(scope).properties, alias);
|
||||
}
|
||||
scope.model.value = scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties[renderModelPropertyIndex].value;
|
||||
scope.renderModel = {};
|
||||
scope.model.value = getFieldsetProperty(scope).value;
|
||||
|
||||
//set the config from the prevalues
|
||||
scope.model.config = config;
|
||||
@@ -208,10 +218,21 @@ angular.module("umbraco.directives").directive('archetypeProperty', function ($c
|
||||
|
||||
//watch for changes since there is no two-way binding with the local model.value
|
||||
scope.$watch('model.value', function (newValue, oldValue) {
|
||||
scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties[renderModelPropertyIndex].value = newValue;
|
||||
getFieldsetProperty(scope).value = newValue;
|
||||
|
||||
// notify the linker that the property value changed
|
||||
propertyValueChanged(scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex], scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex].properties[renderModelPropertyIndex]);
|
||||
propertyValueChanged(getFieldset(scope), getFieldsetProperty(scope));
|
||||
});
|
||||
|
||||
scope.$on('archetypeFormSubmitting', function (ev, args) {
|
||||
// did the value change (if it did, it most likely did so during the "formSubmitting" event)
|
||||
var currentValue = getFieldsetProperty(scope).value;
|
||||
if (currentValue != scope.model.value) {
|
||||
getFieldsetProperty(scope).value = scope.model.value;
|
||||
|
||||
// notify the linker that the property value changed
|
||||
propertyValueChanged(getFieldset(scope), getFieldsetProperty(scope));
|
||||
}
|
||||
});
|
||||
|
||||
element.html(data).show();
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
angular.module("umbraco.directives").directive('archetypeSubmitWatcher', function ($rootScope) {
|
||||
var linker = function (scope, element, attrs, ngModelCtrl) {
|
||||
// call the load callback on scope to obtain the ID of this submit watcher
|
||||
var id = scope.loadCallback();
|
||||
scope.$on("formSubmitting", function (ev, args) {
|
||||
// on the "formSubmitting" event, call the submit callback on scope to notify the Archetype controller to do it's magic
|
||||
if (id == scope.activeSubmitWatcher) {
|
||||
scope.submitCallback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
restrict: "E",
|
||||
replace: true,
|
||||
link: linker,
|
||||
template: "",
|
||||
scope: {
|
||||
loadCallback: '=',
|
||||
submitCallback: '=',
|
||||
activeSubmitWatcher: '='
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -181,6 +181,7 @@
|
||||
|
||||
.archetypeAddButton:hover {
|
||||
text-decoration: none;
|
||||
cursor: pointer;
|
||||
|
||||
.archetypeAddButtonText {
|
||||
text-decoration: underline;
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
|
||||
<div ng-class="[(model.config.hidePropertyLabels == '1' ? 'controls-no-label' : 'controls')]">
|
||||
<archetype-property class="archetypeEditor" property="property" property-editor-alias="model.alias" fieldset-index="$parent.$index" fieldset="fieldset" archetype-config="model.config" property-config-index="$index" archetype-render-model="model.value" umbraco-form="form"></archetype-property>
|
||||
<archetype-submit-watcher active-submit-watcher="activeSubmitWatcher" load-callback="submitWatcherOnLoad" submit-callback="submitWatcherOnSubmit"></archetype-submit-watcher>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -48,7 +49,7 @@
|
||||
</li>
|
||||
</ul>
|
||||
<div ng-show="showAddButton()">
|
||||
<a data-toggle="{{ model.config.fieldsets.length > 1 ? 'dropdown' : ''}}" ng-click="model.config.fieldsets.length == 1 ? addRow(model.config.fieldsets[0].alias, 0) : return" prevent-default>
|
||||
<a class="archetypeAddButton" data-toggle="{{ model.config.fieldsets.length > 1 ? 'dropdown' : ''}}" ng-click="model.config.fieldsets.length == 1 ? addRow(model.config.fieldsets[0].alias, 0) : return" prevent-default>
|
||||
<i class="icon icon-add dropdown-toggle"></i>
|
||||
<localize key="general_add" class="archetypeAddButtonText">Add</localize>
|
||||
</a>
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "Archetype",
|
||||
"version": "1.7.1",
|
||||
"version": "1.7.4",
|
||||
"url": "http://github.com/imulus/archetype/",
|
||||
"author": "Imulus - Kevin Giszewski - Tom Fulton - Lee Kelleher - Matt Brailsford - Kenn Jacobsen - Et. Al.",
|
||||
"authorUrl": "http://imulus.com/",
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@
|
||||
"grunt-msbuild": "~0.1.9",
|
||||
"grunt-dotnet-assembly-info": "~1.0.9",
|
||||
"load-grunt-tasks": "~0.4.0",
|
||||
"grunt-umbraco-package": "0.0.5"
|
||||
"grunt-umbraco-package": "0.0.6"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
Reference in New Issue
Block a user