diff --git a/src/Umbraco.Core/Models/IContentBase.cs b/src/Umbraco.Core/Models/IContentBase.cs
index 2cf2d85024..de1b2666d5 100644
--- a/src/Umbraco.Core/Models/IContentBase.cs
+++ b/src/Umbraco.Core/Models/IContentBase.cs
@@ -139,7 +139,7 @@ namespace Umbraco.Core.Models
// fixme validate published cultures?
///
- /// Validates the content item's properties.
+ /// Validates the content item's properties pass variant rules
///
/// If the content type is variant, then culture can be either '*' or an actual culture, but neither 'null' nor
/// 'empty'. If the content type is invariant, then culture can be either '*' or null or empty.
diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js
index 57491fc81e..99cff8a309 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/content/edit.controller.js
@@ -239,7 +239,6 @@
},
function (err) {
- setActiveCulture();
syncTreeNode($scope.content, $scope.content.path);
//error
@@ -349,6 +348,7 @@
if (formHelper.submitForm({ scope: $scope, action: "publish" })) {
var dialog = {
+ parentScope: $scope,
view: "views/content/overlays/publish.html",
variants: $scope.content.variants, //set a model property for the dialog
skipFormValidation: true, //when submitting the overlay form, skip any client side validation
@@ -370,7 +370,8 @@
//re-map the dialog model since we've re-bound the properties
dialog.variants = $scope.content.variants;
- return $q.reject(err);
+ //don't reject, we've handled the error
+ return $q.when(err);
});
},
close: function (oldModel) {
@@ -417,7 +418,8 @@
//re-map the dialog model since we've re-bound the properties
dialog.variants = $scope.content.variants;
- return $q.reject(err);
+ //don't reject, we've handled the error
+ return $q.when(err);
});
},
close: function (oldModel) {
diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/components/overlays/umboverlay.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/components/overlays/umboverlay.directive.js
index 4d90dd9655..6655bef4ca 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/components/overlays/umboverlay.directive.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/components/overlays/umboverlay.directive.js
@@ -412,7 +412,7 @@ Opens an overlay to show a custom YSOD.
(function() {
'use strict';
- function OverlayDirective($timeout, formHelper, overlayHelper, localizationService, $q) {
+ function OverlayDirective($timeout, formHelper, overlayHelper, localizationService, $q, $templateCache, $http, $compile) {
function link(scope, el, attr, ctrl) {
@@ -424,7 +424,8 @@ Opens an overlay to show a custom YSOD.
var numberOfOverlays = 0;
var isRegistered = false;
- var modelCopy = {};
+ var modelCopy = {};
+ var unsubscribe = [];
function activate() {
@@ -459,6 +460,21 @@ Opens an overlay to show a custom YSOD.
scope.view = "views/common/overlays/" + viewAlias + "/" + viewAlias + ".html";
}
+ //if a custom parent scope is defined then we need to manually compile the view
+ if (scope.parentScope) {
+ var element = el.find(".scoped-view");
+ $http.get(scope.view, { cache: $templateCache })
+ .then(function (response) {
+ var templateScope = scope.parentScope.$new();
+ unsubscribe.push(function() {
+ templateScope.$destroy();
+ });
+ templateScope.model = scope.model;
+ element.html(response.data);
+ element.show();
+ $compile(element.contents())(templateScope);
+ });
+ }
}
}
@@ -553,7 +569,7 @@ Opens an overlay to show a custom YSOD.
var newObject = {};
for (var key in object) {
- if (key !== "event") {
+ if (key !== "event" && key !== "parentScope") {
newObject[key] = angular.copy(object[key]);
}
}
@@ -684,8 +700,11 @@ Opens an overlay to show a custom YSOD.
};
- scope.$on('$destroy', function(){
- unregisterOverlay();
+ unsubscribe.push(unregisterOverlay);
+ scope.$on('$destroy', function () {
+ for (var i = 0; i < unsubscribe.length; i++) {
+ unsubscribe[i]();
+ }
});
activate();
@@ -701,7 +720,8 @@ Opens an overlay to show a custom YSOD.
ngShow: "=",
model: "=",
view: "=",
- position: "@"
+ position: "@",
+ parentScope: "=?"
},
link: link
};
diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/validation/showvalidationonsubmit.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/validation/showvalidationonsubmit.directive.js
index c46a3a9f9a..3dc48573c7 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/validation/showvalidationonsubmit.directive.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/validation/showvalidationonsubmit.directive.js
@@ -3,16 +3,20 @@
function showValidationOnSubmit(serverValidationManager) {
return {
- require: "ngMessages",
+ require: ["ngMessages", "^^?valFormManager"],
restrict: "A",
-
+ scope: {
+ form: "=?"
+ },
link: function (scope, element, attr, ctrl) {
- //We can either get the form submitted status by the parent directive valFormManager (if we add a property to it)
- //or we can just check upwards in the DOM for the css class (easier for now).
+ var formMgr = ctrl.length > 1 ? ctrl[1] : null;
+
+ //We can either get the form submitted status by the parent directive valFormManager
+ //or we can check upwards in the DOM for the css class... lets try both :)
//The initial hidden state can't always be hidden because when we switch variants in the content editor we cannot
//reset the status.
- var submitted = element.closest(".show-validation").length > 0;
+ var submitted = element.closest(".show-validation").length > 0 || (formMgr && formMgr.showValidation);
if (!submitted) {
element.hide();
}
diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/validation/valformmanager.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/validation/valformmanager.directive.js
index 948702a4e3..35e9005cc6 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/validation/valformmanager.directive.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/validation/valformmanager.directive.js
@@ -19,7 +19,7 @@ function valFormManager(serverValidationManager, $rootScope, $timeout, $location
var SAVED_EVENT_NAME = "formSubmitted";
return {
- require: "form",
+ require: ["form", "^^?valFormManager"],
restrict: "A",
controller: function($scope) {
//This exposes an API for direct use with this directive
@@ -35,6 +35,8 @@ function valFormManager(serverValidationManager, $rootScope, $timeout, $location
}));
};
+ this.showValidation = $scope.showValidation === true;
+
//Ensure to remove the event handlers when this instance is destroyted
$scope.$on('$destroy', function () {
for (var u in unsubscribe) {
@@ -42,7 +44,10 @@ function valFormManager(serverValidationManager, $rootScope, $timeout, $location
}
});
},
- link: function (scope, element, attr, formCtrl) {
+ link: function (scope, element, attr, ctrls) {
+
+ var formCtrl = ctrls[0];
+ var parentFormMgr = ctrls.length > 0 ? ctrls[1] : null;
var labels = {};
@@ -96,8 +101,9 @@ function valFormManager(serverValidationManager, $rootScope, $timeout, $location
var isSavingNewItem = false;
//we should show validation if there are any msgs in the server validation collection
- if (serverValidationManager.items.length > 0) {
+ if (serverValidationManager.items.length > 0 || (parentFormMgr && parentFormMgr.showValidation)) {
element.addClass(SHOW_VALIDATION_CLASS_NAME);
+ scope.showValidation = true;
}
var unsubscribe = [];
@@ -105,7 +111,7 @@ function valFormManager(serverValidationManager, $rootScope, $timeout, $location
//listen for the forms saving event
unsubscribe.push(scope.$on(SAVING_EVENT_NAME, function(ev, args) {
element.addClass(SHOW_VALIDATION_CLASS_NAME);
-
+ scope.showValidation = true;
//set the flag so we can check to see if we should display the error.
isSavingNewItem = $routeParams.create;
}));
@@ -114,7 +120,7 @@ function valFormManager(serverValidationManager, $rootScope, $timeout, $location
unsubscribe.push(scope.$on(SAVED_EVENT_NAME, function(ev, args) {
//remove validation class
element.removeClass(SHOW_VALIDATION_CLASS_NAME);
-
+ scope.showValidation = false;
//clear form state as at this point we retrieve new data from the server
//and all validation will have cleared at this point
formCtrl.$setPristine();
diff --git a/src/Umbraco.Web.UI.Client/src/views/components/overlays/umb-overlay.html b/src/Umbraco.Web.UI.Client/src/views/components/overlays/umb-overlay.html
index 5aab9c6335..feacf3adf8 100644
--- a/src/Umbraco.Web.UI.Client/src/views/components/overlays/umb-overlay.html
+++ b/src/Umbraco.Web.UI.Client/src/views/components/overlays/umb-overlay.html
@@ -8,7 +8,8 @@
diff --git a/src/Umbraco.Web.UI/Umbraco/Views/Default.cshtml b/src/Umbraco.Web.UI/Umbraco/Views/Default.cshtml
index 1f26d628e4..bf5b3b17e3 100644
--- a/src/Umbraco.Web.UI/Umbraco/Views/Default.cshtml
+++ b/src/Umbraco.Web.UI/Umbraco/Views/Default.cshtml
@@ -100,7 +100,8 @@
+ view="overlay.view"
+ parent-scope="overlay.parentScope">