diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorheader.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorheader.directive.js index 124b834169..2551d30204 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorheader.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/editor/umbeditorheader.directive.js @@ -5,8 +5,21 @@ function link(scope, el, attr, ctrl) { + scope.showVariationsQuickSwitchToggle = false; scope.showVariationsQuickSwitch = false; + function activate() { + showVariationsQuickSwitch(scope.variations); + } + + function showVariationsQuickSwitch(variations) { + if(variations && variations.length > 1 || variations && variations.length === 1 && variations[0].variations && variations[0].variations.length > 0) { + scope.showVariationsQuickSwitchToggle = true; + } else { + scope.showVariationsQuickSwitchToggle = false; + } + } + scope.openIconPicker = function() { scope.dialogModel = { view: "iconpicker", @@ -42,13 +55,37 @@ }; - scope.selectItem = function(variation) { + scope.selectItem = function(item) { if(scope.onSelectItem) { - scope.onSelectItem(variation); + + for(var i = 0; i < scope.variations.length; i++) { + var language = scope.variations[i]; + language.active = false; + + if(language.variations && language.variations.length > 0) { + for(var variationIndex = 0; variationIndex < language.variations.length; variationIndex++) { + var variation = language.variations[variationIndex]; + variation.active = false; + } + + } + } + + // set selected item to active + item.active = true; + + scope.onSelectItem(item); scope.showVariationsQuickSwitch = false; + } }; + scope.$watch('variations', function(newValue, oldValue){ + showVariationsQuickSwitch(newValue); + }, true); + + activate(); + } var directive = { diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbvariations.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbvariations.directive.js index 86cb52eba6..0ea1cfd552 100644 --- a/src/Umbraco.Web.UI.Client/src/common/directives/components/umbvariations.directive.js +++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/umbvariations.directive.js @@ -37,6 +37,7 @@ variation.variationName = newVariation.name; variation.variationDescription = newVariation.description; variation.segments = newVariation.segments; + variation.active = false; language.variations.unshift(variation); diff --git a/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-header.html b/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-header.html index bde9cef69d..4604b4cfc8 100644 --- a/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-header.html +++ b/src/Umbraco.Web.UI.Client/src/views/components/editor/umb-editor-header.html @@ -34,7 +34,7 @@
-
+
{{ language }}
@@ -48,29 +48,35 @@ - - +