diff --git a/.gitignore b/.gitignore index aab6533..8c1afc1 100644 --- a/.gitignore +++ b/.gitignore @@ -62,4 +62,5 @@ VersionInfo.cs .builds .svn .hg -.hgignore \ No newline at end of file +.hgignore +app/Umbraco/.vs/config/applicationhost.config \ No newline at end of file diff --git a/app/controllers/config.controller.js b/app/controllers/config.controller.js index b8437a2..715b3e1 100644 --- a/app/controllers/config.controller.js +++ b/app/controllers/config.controller.js @@ -47,6 +47,12 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio } }; + // added to track loaded fieldsets + $scope.loadedFieldsets = []; + $scope.isLoaded = function (fieldset) { + return $scope.loadedFieldsets.indexOf(fieldset) >= 0; + } + //function that determines how to manage expanding/collapsing fieldsets $scope.focusFieldset = function(fieldset){ var iniState; @@ -60,6 +66,7 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio if($scope.archetypeConfigRenderModel.fieldsets.length == 1 && fieldset.remove == false) { fieldset.collapse = false; + $scope.loadedFieldsets.push(fieldset); return; } @@ -70,12 +77,14 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio else { fieldset.collapse = false; + $scope.loadedFieldsets.push(fieldset); } }); if(iniState) { fieldset.collapse = !iniState; + $scope.loadedFieldsets.push(fieldset); } } @@ -123,27 +132,20 @@ angular.module("umbraco").controller("Imulus.ArchetypeConfigController", functio //watch for changes $scope.$watch('archetypeConfigRenderModel', function (v) { - //console.log(v); if (typeof v === 'string') { $scope.archetypeConfigRenderModel = JSON.parse(v); $scope.archetypeConfigRenderModel.toString = stringify; } }); - $scope.autoPopulateAlias = function(s) { - var modelType = s.hasOwnProperty('fieldset') ? 'fieldset' : 'property'; - var modelProperty = s[modelType]; - - if (!modelProperty.aliasIsDirty) { + $scope.autoPopulateAlias = function (modelProperty) { + if (modelProperty && !modelProperty.aliasIsDirty) { modelProperty.alias = modelProperty.label.toUmbracoAlias(); } } - $scope.markAliasDirty = function(s) { - var modelType = s.hasOwnProperty('fieldset') ? 'fieldset' : 'property'; - var modelProperty = s[modelType]; - - if (!modelProperty.aliasIsDirty) { + $scope.markAliasDirty = function (modelProperty) { + if (modelProperty && !modelProperty.aliasIsDirty) { modelProperty.aliasIsDirty = true;; } } diff --git a/app/services/archetypeCacheService.js b/app/services/archetypeCacheService.js index 81b6a15..7508c78 100644 --- a/app/services/archetypeCacheService.js +++ b/app/services/archetypeCacheService.js @@ -73,6 +73,34 @@ angular.module('umbraco.services').factory('archetypeCacheService', function (ar } return null; - } + }, + + getEntityByUmbracoId: function(scope, udi, type) { + var cachedEntity = _.find(entityCache, function (e){ + return e.udi == udi; + }); + + if(cachedEntity) { + return cachedEntity; + } + + //go get it from server + if (!isEntityLookupLoading) { + isEntityLookupLoading = true; + + 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: "" }; + + entityCache.push(entity); + + isEntityLookupLoading = false; + + return entity; + }); + } + + return null; + } } }); \ No newline at end of file diff --git a/app/services/archetypeLabelService.js b/app/services/archetypeLabelService.js index f33760c..6a2ef99 100644 --- a/app/services/archetypeLabelService.js +++ b/app/services/archetypeLabelService.js @@ -19,7 +19,6 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar } function getNativeLabel(datatype, value, scope) { - switch (datatype.selectedEditor) { case "Imulus.UrlPicker": return imulusUrlPicker(value, scope, {}); @@ -27,13 +26,22 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar 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, {}); - default: + case "Umbraco.ContentPickerAlias": + return coreContentPicker(value, scope, datatype); + case "Umbraco.ContentPicker2": + return coreContentPickerV2(value, scope, datatype); + default: return ""; } } @@ -87,6 +95,39 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar return entityArray.join(', '); } + function coreMntpV2(value, scope, args) { + var ids = value.split(','); + if (ids.length == 0) { + return ""; + } + var type = "document"; + + switch(args.preValues[0].value.type) { + case 'content': + type = 'document'; + break; + case 'media': + type = 'media'; + break; + case 'member': + type = 'member'; + break; + + default: + break; + } + + var entity; + + _.each(ids, function (id) { + if(id && !entity) { + entity = archetypeCacheService.getEntityByUmbracoId(scope, id, type); + } + }); + + return (entity != null ? entity.name : "") + (ids.length > 1 ? ", ..." : ""); + } + function coreMediaPicker(value, scope, args) { if(value) { var entity = archetypeCacheService.getEntityById(scope, value, "media"); @@ -99,6 +140,42 @@ angular.module('umbraco.services').factory('archetypeLabelService', function (ar return ""; } + function coreMediaPickerV2(value, scope, args) { + if(value) { + var entity = archetypeCacheService.getEntityByUmbracoId(scope, value, "media"); + + if(entity) { + return entity.name; + } + } + + return ""; + } + + function coreContentPicker(value, scope, args) { + if (value) { + var entity = archetypeCacheService.getEntityById(scope, value, "document"); + + if (entity) { + return entity.name; + } + } + + return ""; + } + + function coreContentPickerV2(value, scope, args) { + if (value) { + var entity = archetypeCacheService.getEntityByUmbracoId(scope, value, "document"); + + if (entity) { + return entity.name; + } + } + + return ""; + } + function imulusUrlPicker(value, scope, args) { if(!args.propertyName) { diff --git a/app/views/archetype.config.html b/app/views/archetype.config.html index 224bb0b..bc5755e 100644 --- a/app/views/archetype.config.html +++ b/app/views/archetype.config.html @@ -12,14 +12,14 @@
{{fieldset.label}}
-
+
- +
- +
@@ -50,11 +50,11 @@
- +
- +