From 03b05a05d15a6cf31478261c9b136b54189d9daa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Thu, 23 Jan 2020 19:40:41 +0100 Subject: [PATCH] clean up --- .../umbvariantcontenteditors.directive.js | 8 ++--- .../umbeditorcontentheader.directive.js | 32 +++---------------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontenteditors.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontenteditors.directive.js index 2450e04ac3..7a266163be 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontenteditors.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/umbvariantcontenteditors.directive.js @@ -86,15 +86,13 @@ // set the active variant var activeVariant = null; _.each(vm.content.variants, function (v) { - if ( - (!v.language || v.language.culture === vm.culture) - && - (v.segment === vm.segment) - ) { + if ((!v.language || v.language.culture === vm.culture) && v.segment === vm.segment) { activeVariant = v; } }); if (!activeVariant) { + // Set the first variant to active if we can't find it. + // If the content item is invariant, then only one item exists in the array. activeVariant = vm.content.variants[0]; } diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorcontentheader.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorcontentheader.directive.js index cbc090c821..ec5d04dbb3 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorcontentheader.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorcontentheader.directive.js @@ -4,9 +4,6 @@ function EditorContentHeader(serverValidationManager, localizationService, editorState, variantHelper) { function link(scope) { - - console.log("scope.content", scope.content); - console.log("scope.content.variants", scope.content.variants); var unsubscribe = []; @@ -19,9 +16,11 @@ scope.isNew = scope.editorContent.state == "NotCreated"; - localizationService.localizeMany([ + localizationService.localizeMany( + [ scope.isNew ? "placeholders_a11yCreateItem" : "placeholders_a11yEdit", - "placeholders_a11yName"] + "placeholders_a11yName" + ] ).then(function (data) { scope.a11yMessage = data[0]; scope.a11yName = data[1]; @@ -97,10 +96,6 @@ } - function getCultureFromVariant(variant) { - return variant.language ? variant.language.culture : null; - } - scope.getVariantDisplayName = variantHelper.getDisplayName; scope.goBack = function () { @@ -162,24 +157,7 @@ } onInit(); - /* - //watch for the active culture changing, if it changes, update the current variant - if (scope.content.variants) { - scope.$watch(function () { - for (var i = 0; i < scope.content.variants.length; i++) { - var v = scope.content.variants[i]; - if (v.active) { - return v.language.culture; - } - } - return scope.vm.currentVariant.language.culture; //should never get here - }, function (newValue, oldValue) { - if (newValue !== scope.vm.currentVariant.language.culture) { - setCurrentVariant(); - } - }); - } - */ + scope.$on('$destroy', function () { for (var u in unsubscribe) { unsubscribe[u]();