From eda9bab02fbf135ee0cf77727ede38fa85b6f01b Mon Sep 17 00:00:00 2001 From: Nicholas-Westby Date: Sat, 7 May 2016 12:45:34 -0700 Subject: [PATCH] Ensure the property alias is unique when dragging between Archetypes. --- app/services/archetypeService.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/services/archetypeService.js b/app/services/archetypeService.js index b849932..7dba1a6 100644 --- a/app/services/archetypeService.js +++ b/app/services/archetypeService.js @@ -50,7 +50,7 @@ angular.module('umbraco.services').factory('archetypeService', function () { return property.alias == alias; }); }, - getUniquePropertyAlias: function (currentScope, propertyAliasParts) { + getUniquePropertyAlias: function (currentScope, propertyAliasParts, excludeUniqueId) { if (currentScope.hasOwnProperty('fieldsetIndex') && currentScope.hasOwnProperty('property') && currentScope.hasOwnProperty('propertyConfigIndex')) { var currentPropertyAlias = "f" + currentScope.fieldsetIndex + "-" + currentScope.property.alias + "-p" + currentScope.propertyConfigIndex; @@ -63,9 +63,15 @@ angular.module('umbraco.services').factory('archetypeService', function () { } if (currentScope.$parent) - this.getUniquePropertyAlias(currentScope.$parent, propertyAliasParts); + this.getUniquePropertyAlias(currentScope.$parent, propertyAliasParts, true); - return _.unique(propertyAliasParts).reverse().join("-"); + var reversed = _.unique(propertyAliasParts).reverse(); + + if (!excludeUniqueId) { + reversed.push(_.uniqueId("u-")); + } + + return reversed.join("-"); }, getFieldset: function(scope) { return scope.archetypeRenderModel.fieldsets[scope.fieldsetIndex];