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 a3a212a603..1987c897f0 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 @@ -194,7 +194,9 @@ return a.alias === "umbContent"; }); - contentApp.viewModel = _.omit(variant, 'apps'); + //The view model for the content app is simply the index of the variant being edited + var variantIndex = vm.content.variants.indexOf(variant); + contentApp.viewModel = variantIndex; // make sure the same app it set to active in the new variant if(activeAppAlias) { diff --git a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/treepicker/treepicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/treepicker/treepicker.controller.js index 5b5de1b393..002b617f84 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/treepicker/treepicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/treepicker/treepicker.controller.js @@ -376,7 +376,7 @@ angular.module("umbraco").controller("Umbraco.Editors.TreePickerController", var foundIndex = 0; if ($scope.model.selection.length > 0) { - for (i = 0; $scope.model.selection.length > i; i++) { + for (var i = 0; $scope.model.selection.length > i; i++) { var selectedItem = $scope.model.selection[i]; if (selectedItem.id === item.id) { found = true; diff --git a/src/Umbraco.Web.UI.Client/src/views/common/overlays/treepicker/treepicker.controller.js b/src/Umbraco.Web.UI.Client/src/views/common/overlays/treepicker/treepicker.controller.js index fa7a797125..827b2ad4e0 100644 --- a/src/Umbraco.Web.UI.Client/src/views/common/overlays/treepicker/treepicker.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/common/overlays/treepicker/treepicker.controller.js @@ -285,7 +285,7 @@ angular.module("umbraco").controller("Umbraco.Overlays.TreePickerController", var foundIndex = 0; if ($scope.model.selection.length > 0) { - for (i = 0; $scope.model.selection.length > i; i++) { + for (var i = 0; $scope.model.selection.length > i; i++) { var selectedItem = $scope.model.selection[i]; if (selectedItem.id === item.id) { found = true; diff --git a/src/Umbraco.Web.UI.Client/src/views/content/apps/content/content.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/apps/content/content.controller.js index 7d3f10fab4..2bde680bf4 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/apps/content/content.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/content/apps/content/content.controller.js @@ -3,33 +3,39 @@ function ContentAppContentController($scope, $timeout, serverValidationManager) { + //the contentApp's viewModel is actually the index of the variant being edited, not the variant itself. + //if we make the viewModel the variant itself, we end up with a circular reference in the models which isn't ideal + // (i.e. variant.apps[contentApp].viewModel = variant) + //so instead since we already have access to the content, we can just get the variant directly by the index. + var vm = this; vm.loading = true; function onInit() { - vm.content = $scope.model.viewModel; + //get the variant by index (see notes above) + vm.content = $scope.content.variants[$scope.model.viewModel]; serverValidationManager.notify(); vm.loading = false; + + //if this variant has a culture/language assigned, then we need to watch it since it will change + //if the language drop down changes and we need to re-init + if (vm.content.language) { + $scope.$watch(function () { + return vm.content.language.culture; + }, function (newVal, oldVal) { + if (newVal !== oldVal) { + vm.loading = true; + + //TODO: Can we minimize the flicker? + $timeout(function () { + onInit(); + }, 100); + } + }); + } } onInit(); - - //if this variant has a culture/language assigned, then we need to watch it since it will change - //if the language drop down changes and we need to re-init - if ($scope.model.viewModel.language) { - $scope.$watch(function () { - return $scope.model.viewModel.language.culture; - }, function (newVal, oldVal) { - if (newVal !== oldVal) { - vm.loading = true; - - //TODO: Can we minimize the flicker? - $timeout(function () { - onInit(); - }, 100); - } - }); - } } angular.module("umbraco").controller("Umbraco.Editors.Content.Apps.ContentController", ContentAppContentController); diff --git a/src/Umbraco.Web.UI.Client/src/views/content/overlays/save.controller.js b/src/Umbraco.Web.UI.Client/src/views/content/overlays/save.controller.js index 4a9e7d2dca..a99da13811 100644 --- a/src/Umbraco.Web.UI.Client/src/views/content/overlays/save.controller.js +++ b/src/Umbraco.Web.UI.Client/src/views/content/overlays/save.controller.js @@ -22,12 +22,8 @@ //determine a variant is 'dirty' (meaning it will show up as save-able) if it's // * the active one // * it's editor is in a $dirty state - // * it's umbContent app viewModel (if any) is in a $dirty state // * it is in NotCreated state - var contentApp = _.find(variant.apps, function(app) { - return app.alias === "umbContent"; - }); - return (variant.active || variant.isDirty || (contentApp && contentApp.viewModel && contentApp.viewModel.isDirty)); + return (variant.active || variant.isDirty); } function pristineVariantFilter(variant) { diff --git a/src/Umbraco.Web.UI.Client/src/views/media/edit.html b/src/Umbraco.Web.UI.Client/src/views/media/edit.html index a9afde36ac..2dfc8c967e 100644 --- a/src/Umbraco.Web.UI.Client/src/views/media/edit.html +++ b/src/Umbraco.Web.UI.Client/src/views/media/edit.html @@ -19,7 +19,7 @@
- +