diff --git a/Gruntfile.js b/Gruntfile.js index 14db49a..f3d2691 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -322,4 +322,5 @@ module.exports = function(grunt) { grunt.registerTask('nuget', ['copy:nuget', 'template:nuspec', 'template:nuspec_binaries', 'template:nuspec_courier', 'nugetpack']); grunt.registerTask('umbraco', ['copy:umbraco', 'umbracoPackage']); grunt.registerTask('package', ['clean:tmp', 'default', 'nuget', 'copy:umbraco', 'umbracoPackage', 'clean:tmp']); + grunt.registerTask('assets', ['clean', 'string-replace', 'less', 'concat', 'assemblyinfo', 'copy:assets', 'copy:html', 'copy:config', 'clean:html', 'clean:js', 'clean:less']); }; \ No newline at end of file diff --git a/app/Umbraco/Umbraco.Archetype/Api/ArchetypeDataTypeController.cs b/app/Umbraco/Umbraco.Archetype/Api/ArchetypeDataTypeController.cs index 015f3b5..a82b980 100644 --- a/app/Umbraco/Umbraco.Archetype/Api/ArchetypeDataTypeController.cs +++ b/app/Umbraco/Umbraco.Archetype/Api/ArchetypeDataTypeController.cs @@ -37,6 +37,26 @@ public object GetAll() return dataTypes.Select(t => new { guid = t.Key, name = t.Name }); } + /// + /// Gets all details. + /// + /// System.Object. + public object GetAllDetails() + { + var dataTypes = Services.DataTypeService.GetAllDataTypeDefinitions(); + + var list = new List(); + + foreach (var dataType in dataTypes) + { + var dataTypeDisplay = Mapper.Map(dataType); + + list.Add(new { selectedEditor = dataTypeDisplay.SelectedEditor, preValues = dataTypeDisplay.PreValues, dataTypeGuid = dataType.Key }); + } + + return list; + } + /// /// Gets the datatype by GUID. /// diff --git a/app/Umbraco/Umbraco.Archetype/Properties/VersionInfo.cs b/app/Umbraco/Umbraco.Archetype/Properties/VersionInfo.cs index 6b51d14..f6a30fa 100644 --- a/app/Umbraco/Umbraco.Archetype/Properties/VersionInfo.cs +++ b/app/Umbraco/Umbraco.Archetype/Properties/VersionInfo.cs @@ -1,4 +1,4 @@ using System.Reflection; -[assembly: AssemblyVersion("1.16.0")] -[assembly: AssemblyFileVersion("1.16.0")] +[assembly: AssemblyVersion("1.17.0")] +[assembly: AssemblyFileVersion("1.17.0")] diff --git a/app/controllers/controller.js b/app/controllers/controller.js index e3ea816..51b6c6f 100644 --- a/app/controllers/controller.js +++ b/app/controllers/controller.js @@ -3,6 +3,8 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc // Variables. var draggedParent; + + var isCacheInitialized = false; //$scope.model.value = ""; $scope.model.hideLabel = $scope.model.config.hideLabel == 1; @@ -27,24 +29,15 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc }; init(); - - //hold references to helper resources - $scope.resources = { - entityResource: entityResource, - archetypePropertyEditorResource: archetypePropertyEditorResource - } - - //hold references to helper services - $scope.services = { - archetypeService: archetypeService, - archetypeLabelService: archetypeLabelService, - archetypeCacheService: archetypeCacheService - } - + //helper to get $eval the labelTemplate $scope.fieldsetTitles = []; $scope.getFieldsetTitle = function (fieldsetConfigModel, fieldsetIndex) { - + + if(!isCacheInitialized) { + return ""; + } + // Ensure the collection of titles is large enough. ensureEnoughTitles(fieldsetIndex + 1); var title = $scope.fieldsetTitles[fieldsetIndex]; @@ -63,18 +56,13 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc title.loading = true; title.loaded = false; title.value = null; - archetypeLabelService.getFieldsetTitle($scope, fieldsetConfigModel, fieldsetIndex) - .then(function(value) { - - // Finished loading the title. - title.loaded = true; - title.loading = false; - title.value = value; - - }); - - // Still loading a title, so do not return a title. + archetypeLabelService.getFieldsetTitle($scope, fieldsetConfigModel, fieldsetIndex).then(function(value) { + // Finished loading the title. + title.loaded = true; + title.loading = false; + title.value = value; + }); }; /** @@ -582,6 +570,10 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc function init() { $scope.model.value = removeNulls($scope.model.value); addDefaultProperties($scope.model.value.fieldsets); + + archetypeCacheService.initialize().then(function() { + isCacheInitialized = true; + }); $timeout(function () { $scope.handleMandatoryValidation(); @@ -998,5 +990,4 @@ angular.module("umbraco").controller("Imulus.ArchetypeController", function ($sc } return null; } - }); diff --git a/app/directives/archetypeproperty.js b/app/directives/archetypeproperty.js index 5ede206..6c90fc9 100644 --- a/app/directives/archetypeproperty.js +++ b/app/directives/archetypeproperty.js @@ -1,4 +1,4 @@ -angular.module("umbraco.directives").directive('archetypeProperty', function ($compile, $http, archetypePropertyEditorResource, umbPropEditorHelper, $timeout, $rootScope, $q, fileManager, editorState, archetypeService, archetypeCacheService) { +angular.module("umbraco.directives").directive('archetypeProperty', function ($compile, $http, archetypePropertyEditorResource, umbPropEditorHelper, $timeout, $rootScope, $q, fileManager, editorState, archetypeService) { var linker = function (scope, element, attrs, ngModelCtrl) { var configFieldsetModel = archetypeService.getFieldsetByAlias(scope.archetypeConfig.fieldsets, scope.fieldset.alias); @@ -25,9 +25,6 @@ angular.module("umbraco.directives").directive('archetypeProperty', function ($c config = configObj; - //caching for use by label templates later - archetypeCacheService.addDatatypeToCache(data, dataTypeGuid); - //determine the view to use [...] and load it archetypePropertyEditorResource.getPropertyEditorMapping(data.selectedEditor).then(function(propertyEditor) { var pathToView = umbPropEditorHelper.getViewPath(propertyEditor.view); diff --git a/app/helpers/sampleLabelHelpers.js b/app/helpers/sampleLabelHelpers.js index 400f2b6..e9082c8 100644 --- a/app/helpers/sampleLabelHelpers.js +++ b/app/helpers/sampleLabelHelpers.js @@ -1,70 +1,51 @@ -var ArchetypeSampleLabelTemplates = (function() { - - //public functions - return { - Entity: function (value, scope, args) { - - if(!args.entityType) { - args = {entityType: "Document", propertyName: "name"} - } - - if (value) { - //if handed a csv list, take the first only - var id = value.split(",")[0]; - - if (id) { - var entity = scope.services.archetypeCacheService.getEntityById(scope, id, args.entityType); - - if(entity) { - return entity[args.propertyName]; - } - } - } - - return ""; - }, - UrlPicker: function(value, scope, args) { - - if(!args.propertyName) { - args = {propertyName: "name"} - } - - var entity; - - switch (value.type) { - case "content": - if(value.typeData.contentId) { - entity = scope.services.archetypeCacheService.getEntityById(scope, value.typeData.contentId, "Document"); - } - break; - - case "media": - if(value.typeData.mediaId) { - entity = scope.services.archetypeCacheService.getEntityById(scope, value.typeData.mediaId, "Media"); - } - break; - - case "url": - return value.typeData.url; - - default: - break; - - } - - if(entity) { - return entity[args.propertyName]; - } - - return ""; - }, - Rte: function (value, scope, args) { - - if(!args.contentLength) { - args = {contentLength: 50} - } - - return $(value).text().substring(0, args.contentLength); - } +//create a namespace (optional) +var ArchetypeSampleLabelHelpers = {}; + +//create a function +//you will add it to your label template field as `{{ArchetypeSampleLabelHelpers.testPromise(someArchetypePropertyAlias)}}` +ArchetypeSampleLabelHelpers.testPromise = function(value) { + //you can inject services + return function ($timeout, archetypeCacheService) { + //best to return a promise + //NOTE: $timeout returns a promise + return $timeout(function () { + return "As Promised: " + value; + }, 1000); + } +} + +ArchetypeSampleLabelHelpers.testEntityPromise = function(value, scope, args) { + //hey look, args! + //{{ArchetypeSampleLabelHelpers.testEntityPromise(someArchetypePropertyAlias, {foo: 1})}} + console.log(args); + + return function ($q, entityResource) { + var deferred = $q.defer(); + + entityResource.getById(args.foo, 'document').then(function(entity) { + console.log("Hello from testEntityPromise"); + console.log(entity); + deferred.resolve(entity.name); + }); + + return deferred.promise; + } +} + +ArchetypeSampleLabelHelpers.testEntityPromise2 = function(value, scope, args) { + //hey look, args but we're also using the built-in archetypeCacheService + //{{ArchetypeSampleLabelHelpers.testEntityPromise(someArchetypePropertyAlias, {foo: 1234})}} + console.log(args); + + return function ($q, archetypeCacheService) { + var deferred = $q.defer(); + + archetypeCacheService.getEntityById(args.foo, 'document').then(function(entity) { + console.log("Hello from testEntityPromise2"); + console.log(entity); + deferred.resolve(entity.name); + }); + + return deferred.promise; } -})(); \ No newline at end of file +} \ No newline at end of file diff --git a/app/resources/archetypePropertyEditorResource.js b/app/resources/archetypePropertyEditorResource.js index 463a028..defd84e 100644 --- a/app/resources/archetypePropertyEditorResource.js +++ b/app/resources/archetypePropertyEditorResource.js @@ -6,6 +6,11 @@ angular.module('umbraco.resources').factory('archetypePropertyEditorResource', f $http.get("backoffice/ArchetypeApi/ArchetypeDataType/GetAll"), 'Failed to retrieve datatypes from tree service' ); }, + getAllDataTypesForCache: function() { + return umbRequestHelper.resourcePromise( + $http.get("backoffice/ArchetypeApi/ArchetypeDataType/GetAllDetails"), 'Failed to retrieve datatypes from tree service' + ); + }, getDataType: function (guid, useDeepDatatypeLookup, contentTypeAlias, propertyTypeAlias, archetypeAlias, nodeId) { if(useDeepDatatypeLookup) { return umbRequestHelper.resourcePromise( diff --git a/app/services/archetypeCacheService.js b/app/services/archetypeCacheService.js index 7508c78..b3a3a8c 100644 --- a/app/services/archetypeCacheService.js +++ b/app/services/archetypeCacheService.js @@ -1,106 +1,87 @@ -angular.module('umbraco.services').factory('archetypeCacheService', function (archetypePropertyEditorResource) { +angular.module('umbraco.services').factory('archetypeCacheService', function (archetypePropertyEditorResource, $q, entityResource) { //private - - var isEntityLookupLoading = false; var entityCache = []; - - var isDatatypeLookupLoading = false; var datatypeCache = []; - + return { - getDataTypeFromCache: function(guid) { - return _.find(datatypeCache, function (dt){ - return dt.dataTypeGuid == guid; - }); - }, - - addDatatypeToCache: function(datatype, dataTypeGuid) { - var cachedDatatype = this.getDataTypeFromCache(dataTypeGuid); - - if(!cachedDatatype) { - datatype.dataTypeGuid = dataTypeGuid; - datatypeCache.push(datatype); - } - }, + initialize: function() { + return archetypePropertyEditorResource.getAllDataTypesForCache().then(function(data) { + _.each(data, function(datatype) { + datatypeCache[datatype.dataTypeGuid] = datatype; + }); + }); + }, + + getDataTypeFromCache: function(guid) { + return datatypeCache[guid]; + }, - getDatatypeByGuid: function(guid) { - var cachedDatatype = this.getDataTypeFromCache(guid); - - if(cachedDatatype) { - return cachedDatatype; - } - - //go get it from server, but this should already be pre-populated from the directive, but I suppose I'll leave this in in case used ad-hoc - if (!isDatatypeLookupLoading) { - isDatatypeLookupLoading = true; - - archetypePropertyEditorResource.getDataType(guid).then(function(datatype) { - - datatype.dataTypeGuid = guid; - - datatypeCache.push(datatype); - - isDatatypeLookupLoading = false; - - return datatype; - }); - } + getDatatypeByGuid: function(guid) { + var cachedDatatype = this.getDataTypeFromCache(guid); + + if(cachedDatatype) { + return cachedDatatype; + } - return null; + return null; }, - getEntityById: function(scope, id, type) { - var cachedEntity = _.find(entityCache, function (e){ - return e.id == id; - }); - - if(cachedEntity) { - return cachedEntity; - } - - //go get it from server - if (!isEntityLookupLoading) { - isEntityLookupLoading = true; - - scope.resources.entityResource.getById(id, type).then(function(entity) { - - entityCache.push(entity); - - isEntityLookupLoading = false; - - return entity; - }); - } - - return null; - }, - - getEntityByUmbracoId: function(scope, udi, type) { - var cachedEntity = _.find(entityCache, function (e){ - return e.udi == udi; - }); - - if(cachedEntity) { - return cachedEntity; - } + getEntityById: function(id, type) { + var deferred = $q.defer(); + + //console.log(entityCache); + + var cachedEntity = entityCache[id]; + + if(cachedEntity) { + //console.log("Found ID " + id); + + deferred.resolve(cachedEntity); + + return deferred.promise; + } - //go get it from server - if (!isEntityLookupLoading) { - isEntityLookupLoading = true; + //go get it from server + entityResource.getById(id, type).then(function(entity) { + entityCache[id] = entity; + + //console.log("entity ID is now resolved into cache..."); + //console.log(entityCache); + + deferred.resolve(entity); + }); + + return deferred.promise; + }, - scope.resources.entityResource.getByIds([udi], type).then(function (entities) { - // prevent infinite lookups with a default entity - var entity = entities.length > 0 ? entities[0] : { udi: udi, name: "" }; + //perhaps this should return a promise? + getEntityByUmbracoId: function(udi, type) { + var deferred = $q.defer(); + + var cachedEntity = entityCache[udi]; + + if(cachedEntity) { + //console.log("Found UDI " + udi); + + deferred.resolve(cachedEntity); + + return deferred.promise; + } - entityCache.push(entity); + //go get it from server + entityResource.getByIds([udi], type).then(function (entities) { + // prevent infinite lookups with a default entity + var entity = entities.length > 0 ? entities[0] : { udi: udi, name: "" }; - isEntityLookupLoading = false; + entityCache[udi] = entity; + + //console.log("entity UDI is now resolved into cache..."); + //console.log(entityCache); - return entity; - }); - } + deferred.resolve(entity); + }); - return null; - } + return deferred.promise; + } } }); \ No newline at end of file diff --git a/app/services/archetypeLabelService.js b/app/services/archetypeLabelService.js index f8463e1..30a404c 100644 --- a/app/services/archetypeLabelService.js +++ b/app/services/archetypeLabelService.js @@ -1,4 +1,4 @@ -angular.module('umbraco.services').factory('archetypeLabelService', function (archetypeCacheService, $q, $injector) { +angular.module('umbraco.services').factory('archetypeLabelService', function (archetypeCacheService, $q, $injector, $timeout) { //private /** @@ -12,6 +12,7 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar // Remember the original number of promises being resolved. var originalLength = promises.length; + return $q.all(promises).then(function () { // If there are new promises, resolve those too. @@ -19,9 +20,7 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar promises = promises.slice(originalLength); return repeatedlyWaitForPromises(promises); } - }); - } /** @@ -47,21 +46,18 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar } // Set a new value now that it has been processed. + //console.log("Processing string..." + labelValue); match.value = labelValue; - } else if (isPromise(labelValue)) { - // Remember the promise so we can wait for it to be completed before constructing the // fieldset label. promises.push(labelValue); labelValue.then(function (value) { - + //console.log("Processing final value..." + value); // The value will probably be a string, but recursively process it in case it's // something else. processLabelValue(value, promises, match); - }); - } else if (_.isFunction(labelValue)) { // Allow for the function to accept injected parameters, and invoke it. @@ -70,14 +66,10 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar // Recursively check result (may be a string, promise, or another function (another // function would be pretty strange, though I see no reason to disallow it). processLabelValue(labelValue, promises, match); - } else { - // Some other data type (e.g., number, date, object). match.value = labelValue; - } - } /** @@ -115,7 +107,6 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar * indicating whether or not that substring was matched the regular expression. */ function splitByRegex(rgx, value) { - // Validate input. if (!rgx || !value) { return []; @@ -158,7 +149,6 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar // Get next match. match = rgx.exec(value); - } // The text after the last match. @@ -175,7 +165,6 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar // Return information about the matches. return splitParts; - } function executeFunctionByName(functionName, context) { @@ -196,31 +185,31 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar } function getNativeLabel(datatype, value, scope) { - switch (datatype.selectedEditor) { - case "Imulus.UrlPicker": - return imulusUrlPicker(value, scope, {}); - case "Umbraco.TinyMCEv3": - return coreTinyMce(value, scope, {}); - case "Umbraco.MultiNodeTreePicker": - return coreMntp(value, scope, datatype); - case "Umbraco.MultiNodeTreePicker2": - return coreMntpV2(value, scope, datatype); - case "Umbraco.MultipleMediaPicker": - case "Umbraco.MediaPicker": - return coreMediaPicker(value, scope, datatype); - case "Umbraco.MediaPicker2": - return coreMediaPickerV2(value, scope, datatype); - case "Umbraco.DropDown": - return coreDropdown(value, scope, datatype); - case "RJP.MultiUrlPicker": - return rjpMultiUrlPicker(value, scope, {}); - case "Umbraco.ContentPickerAlias": - return coreContentPicker(value, scope, datatype); - case "Umbraco.ContentPicker2": - return coreContentPickerV2(value, scope, datatype); - default: - return ""; - } + switch (datatype.selectedEditor) { + case "Imulus.UrlPicker": + return imulusUrlPicker(value, scope, {}); + case "Umbraco.TinyMCEv3": + return coreTinyMce(value, scope, {}); + case "Umbraco.MultiNodeTreePicker": + return coreMntp(value, scope, datatype); + case "Umbraco.MultiNodeTreePicker2": + return coreMntpV2(value, scope, datatype); + case "Umbraco.MultipleMediaPicker": + case "Umbraco.MediaPicker": + return coreMediaPicker(value, scope, datatype); + case "Umbraco.MediaPicker2": + return coreMediaPickerV2(value, scope, datatype); + case "Umbraco.DropDown": + return coreDropdown(value, scope, datatype); + case "RJP.MultiUrlPicker": + return rjpMultiUrlPicker(value, scope, {}); + case "Umbraco.ContentPickerAlias": + return coreContentPicker(value, scope, datatype); + case "Umbraco.ContentPicker2": + return coreContentPickerV2(value, scope, datatype); + default: + return null; + } } function coreDropdown(value, scope, args) { @@ -240,6 +229,7 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar function coreMntp(value, scope, args) { var ids = value.split(','); var type = "Document"; + var deferred = $q.defer(); switch(args.preValues[0].value.type) { case 'content': @@ -251,32 +241,39 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar case 'member': type = 'member'; break; - default: break; } var entityArray = []; + var promises = []; _.each(ids, function(id){ if(id) { - - var entity = archetypeCacheService.getEntityById(scope, id, type); - - if(entity) { - entityArray.push(entity.name); - } + promises.push(archetypeCacheService.getEntityById(id, type).then(function(entity){ + if(entity) { + entityArray.push(entity.name); + } + }).promise); } }); - return entityArray.join(', '); + $q.all(promises).then(function() { + deferred.resolve(entityArray.join(', ')); + }); + + return deferred.promise; } - function coreMntpV2(value, scope, args) { + function coreMntpV2(value, scope, args) { + var deferred = $q.defer(); + var ids = value.split(','); + if (ids.length == 0) { return ""; } + var type = "document"; switch(args.preValues[0].value.type) { @@ -293,104 +290,158 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar default: break; } - - var entity; + + var entityArray = []; + var promises = []; _.each(ids, function (id) { - if(id && !entity) { - entity = archetypeCacheService.getEntityByUmbracoId(scope, id, type); + if(id) { + promises.push(archetypeCacheService.getEntityByUmbracoId(id, type).then(function(entity) { + if(entity) { + entityArray.push(entity.name); + } + }).promise); } }); - - return (entity != null ? entity.name : "") + (ids.length > 1 ? ", ..." : ""); + + $q.all(promises).then(function() { + if(entityArray.length == 0) { + deferred.resolve(""); + } + + var firstEntityName = entityArray[0]; + + var value = firstEntityName + (ids.length > 1 ? ", ..." : ""); + + deferred.resolve(value); + }); + + return deferred.promise; } function coreMediaPicker(value, scope, args) { + var deferred = $q.defer(); + if(value) { - var entity = archetypeCacheService.getEntityById(scope, value, "media"); - - if(entity) { - return entity.name; - } + archetypeCacheService.getEntityById(value, "media").then(function(entity) { + deferred.resolve(entity.name); + }); + } + else + { + deferred.resolve(""); } - return ""; + return deferred.promise; } function coreMediaPickerV2(value, scope, args) { + var deferred = $q.defer(); + + //console.log("value="); + //console.log(value); + if(value) { - var entity = archetypeCacheService.getEntityByUmbracoId(scope, value, "media"); - - if(entity) { - return entity.name; - } + archetypeCacheService.getEntityByUmbracoId(value, "media").then(function(entity) { + deferred.resolve(entity.name); + }); + } + else + { + deferred.resolve(""); } - return ""; + return deferred.promise; } function coreContentPicker(value, scope, args) { - if (value) { - var entity = archetypeCacheService.getEntityById(scope, value, "document"); - - if (entity) { - return entity.name; + var deferred = $q.defer(); + + if(value) { + archetypeCacheService.getEntityById(value, "document").then(function(entity) { + deferred.resolve(entity.name); + }); } - } - - return ""; + else + { + deferred.resolve(""); + } + + return deferred.promise; } function coreContentPickerV2(value, scope, args) { - if (value) { - var entity = archetypeCacheService.getEntityByUmbracoId(scope, value, "document"); - - if (entity) { - return entity.name; + var deferred = $q.defer(); + + if (value) { + archetypeCacheService.getEntityByUmbracoId(value, "document").then(function(entity) { + deferred.resolve(entity.name); + }); + } + else + { + deferred.resolve(""); } - } - return ""; + return deferred.promise; } function imulusUrlPicker(value, scope, args) { - + var deferred = $q.defer(); + + if(!value) { + deferred.resolve(""); + + return deferred.promise; + } + if(!args.propertyName) { args = {propertyName: "name"} } + + if(typeof(value) != "object") { + value = JSON.parse(value); + } - var entity; - + //console.log("urlpicker value..."); + //console.log(value); + + if(value.length) { + value = value[0]; + } + switch (value.type) { case "content": if(value.typeData.contentId) { - entity = archetypeCacheService.getEntityById(scope, value.typeData.contentId, "Document"); + archetypeCacheService.getEntityById(value.typeData.contentId, "Document").then(function(entity) { + //console.log("Retrived entity from cache!"); + //console.log("Resolving the entity name with " + entity[args.propertyName]); + deferred.resolve(entity[args.propertyName]); + }); } break; case "media": if(value.typeData.mediaId) { - entity = archetypeCacheService.getEntityById(scope, value.typeData.mediaId, "Media"); + archetypeCacheService.getEntityById(value.typeData.mediaId, "Media").then(function(entity) { + deferred.resolve(entity[args.propertyName]); + }); } break; case "url": - return value.typeData.url; + deferred.resolve(value.typeData.url); + + return deferred.promise; default: break; - - } - - if(entity) { - return entity[args.propertyName]; } - - return ""; + + return deferred.promise; } function coreTinyMce(value, scope, args) { - if(!args.contentLength) { args = {contentLength: 50} } @@ -399,13 +450,13 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar var strippedText = $("
").html(value).text(); if(strippedText.length > args.contentLength) { - suffix = "…"; + suffix = "…"; } return strippedText.substring(0, args.contentLength) + suffix; } - function rjpMultiUrlPicker(values, scope, args) { + function rjpMultiUrlPicker(values, scope, args) { var names = []; _.each(values, function (value) { @@ -416,9 +467,9 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar return names.join(", "); } - - return { - getFieldsetTitle: function(scope, fieldsetConfigModel, fieldsetIndex) { + + return { + getFieldsetTitle: function(scope, fieldsetConfigModel, fieldsetIndex) { if(!fieldsetConfigModel) return $q.when(""); @@ -475,12 +526,13 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar args = JSON.parse(normalizedJsonString); } - + templateLabelValue = executeFunctionByName(functionName, window, scope.getPropertyValueByAlias(fieldset, propertyAlias), scope, args); } //normal {{foo}} syntax else { propertyAlias = template; + var rawValue = scope.getPropertyValueByAlias(fieldset, propertyAlias); templateLabelValue = rawValue; @@ -491,41 +543,39 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar }); if(propertyConfig) { - var datatype = archetypeCacheService.getDatatypeByGuid(propertyConfig.dataTypeGuid); - - if(datatype) { - - //try to get built-in label - var label = getNativeLabel(datatype, templateLabelValue, scope); - - if(label) { - templateLabelValue = label; - } - } + var datatype = archetypeCacheService.getDatatypeByGuid(propertyConfig.dataTypeGuid); + + if(datatype) { + //try to get built-in label + var templateLabelValue = getNativeLabel(datatype, rawValue, scope); + + //console.log("Native label..."); + //console.log(templateLabelValue); + } } - } } // Process the value (i.e., reduce any functions or promises down to strings). processLabelValue(templateLabelValue, promises, match); - }); // Wait for all of the promises to resolve before constructing the full fieldset label. return repeatedlyWaitForPromises(promises).then(function () { + //console.log("done waiting...") // Extract string values and combine them into a single string. var substrings = _.map(matches, function (value) { return value.value; }); - var combinedSubstrigs = substrings.join(''); + + var combinedSubstrings = substrings.join(''); + //console.log(combinedSubstrings); + // Return the title. - return combinedSubstrigs; - + return combinedSubstrings; }); - } - } + } }); \ No newline at end of file diff --git a/config/meta.json b/config/meta.json index b13e405..4c240e0 100644 --- a/config/meta.json +++ b/config/meta.json @@ -1,6 +1,6 @@ { "name": "Archetype", - "version": "1.16.0", + "version": "1.17.0", "url": "http://github.com/kgiszewski/archetype/", "author": "Kevin Giszewski - Tom Fulton - Lee Kelleher - Matt Brailsford - Kenn Jacobsen - Nicholas Westby - Et. Al.", "authorUrl": "http://github.com/kgiszewski/archetype/",