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 726103caf9..69af5db001 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
@@ -44,34 +44,34 @@ function valFormManager(serverValidationManager, $rootScope, $log, $timeout, not
},
link: function (scope, element, attr, formCtrl) {
- //watch the list of validation errors to notify the application of any validation changes
- scope.$watch(function () {
- //the validators are in the $error collection: https://docs.angularjs.org/api/ng/type/form.FormController#$error
- //since each key is the validator name (i.e. 'required') we can't just watch the number of keys, we need to watch
- //the sum of the items inside of each key
+ ////watch the list of validation errors to notify the application of any validation changes
+ //scope.$watch(function () {
+ // //the validators are in the $error collection: https://docs.angularjs.org/api/ng/type/form.FormController#$error
+ // //since each key is the validator name (i.e. 'required') we can't just watch the number of keys, we need to watch
+ // //the sum of the items inside of each key
- //get the lengths of each array for each key in the $error collection
- var validatorLengths = _.map(formCtrl.$error, function (val, key) {
- return val.length;
- });
- //sum up all numbers in the resulting array
- var sum = _.reduce(validatorLengths, function (memo, num) {
- return memo + num;
- }, 0);
- //this is the value we watch to notify of any validation changes on the form
- return sum;
- }, function (e) {
- scope.$broadcast("valStatusChanged", { form: formCtrl });
+ // //get the lengths of each array for each key in the $error collection
+ // var validatorLengths = _.map(formCtrl.$error, function (val, key) {
+ // return val.length;
+ // });
+ // //sum up all numbers in the resulting array
+ // var sum = _.reduce(validatorLengths, function (memo, num) {
+ // return memo + num;
+ // }, 0);
+ // //this is the value we watch to notify of any validation changes on the form
+ // return sum;
+ //}, function (e) {
+ // scope.$broadcast("valStatusChanged", { form: formCtrl });
- //find all invalid elements' .control-group's and apply the error class
- var inError = element.find(".control-group .ng-invalid").closest(".control-group");
- inError.addClass("error");
+ // //find all invalid elements' .control-group's and apply the error class
+ // var inError = element.find(".control-group .ng-invalid").closest(".control-group");
+ // inError.addClass("error");
- //find all control group's that have no error and ensure the class is removed
- var noInError = element.find(".control-group .ng-valid").closest(".control-group").not(inError);
- noInError.removeClass("error");
+ // //find all control group's that have no error and ensure the class is removed
+ // var noInError = element.find(".control-group .ng-valid").closest(".control-group").not(inError);
+ // noInError.removeClass("error");
- });
+ //});
//This tracks if the user is currently saving a new item, we use this to determine
// if we should display the warning dialog that they are leaving the page - if a new item
diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/validation/valpropertymsg.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/validation/valpropertymsg.directive.js
index 78af4b9c35..3fdcc4090d 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/validation/valpropertymsg.directive.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/validation/valpropertymsg.directive.js
@@ -16,7 +16,7 @@ function valPropertyMsg(serverValidationManager) {
replace: true,
restrict: "E",
template: "
{{errorMsg}}
",
-
+ scope: {},
link: function (scope, element, attrs, ctrl) {
//the property form controller api
@@ -28,7 +28,7 @@ function valPropertyMsg(serverValidationManager) {
//the tabbed content controller api
var tabbedContent = ctrl[3];
- var currentProperty = umbPropCtrl.property;
+ scope.currentProperty = umbPropCtrl.property;
var currentCulture = tabbedContent.content.language.culture;
var watcher = null;
@@ -36,16 +36,16 @@ function valPropertyMsg(serverValidationManager) {
// Gets the error message to display
function getErrorMsg() {
//this can be null if no property was assigned
- if (currentProperty) {
+ if (scope.currentProperty) {
//first try to get the error msg from the server collection
- var err = serverValidationManager.getPropertyError(currentProperty.alias, null, "");
+ var err = serverValidationManager.getPropertyError(scope.currentProperty.alias, null, "");
//if there's an error message use it
if (err && err.errorMsg) {
return err.errorMsg;
}
else {
//TODO: localize
- return currentProperty.propertyErrorMessage ? currentProperty.propertyErrorMessage : "Property has errors";
+ return scope.currentProperty.propertyErrorMessage ? scope.currentProperty.propertyErrorMessage : "Property has errors";
}
}
@@ -61,33 +61,31 @@ function valPropertyMsg(serverValidationManager) {
// the form. Of course normal client-side validators will continue to execute.
function startWatch() {
//if there's not already a watch
- if (!watcher) {
- watcher = scope.$watch(function () {
- return currentProperty.value;
- }, function (newValue, oldValue) {
+ //if (!watcher) {
+ // watcher = scope.$watch("currentProperty.value", function (newValue, oldValue) {
- if (!newValue || angular.equals(newValue, oldValue)) {
- return;
- }
+ // if (!newValue || angular.equals(newValue, oldValue)) {
+ // return;
+ // }
- var errCount = 0;
- for (var e in formCtrl.$error) {
- if (angular.isArray(formCtrl.$error[e])) {
- errCount++;
- }
- }
+ // var errCount = 0;
+ // for (var e in formCtrl.$error) {
+ // if (angular.isArray(formCtrl.$error[e])) {
+ // errCount++;
+ // }
+ // }
- //we are explicitly checking for valServer errors here, since we shouldn't auto clear
- // based on other errors. We'll also check if there's no other validation errors apart from valPropertyMsg, if valPropertyMsg
- // is the only one, then we'll clear.
+ // //we are explicitly checking for valServer errors here, since we shouldn't auto clear
+ // // based on other errors. We'll also check if there's no other validation errors apart from valPropertyMsg, if valPropertyMsg
+ // // is the only one, then we'll clear.
- if ((errCount === 1 && angular.isArray(formCtrl.$error.valPropertyMsg)) || (formCtrl.$invalid && angular.isArray(formCtrl.$error.valServer))) {
- scope.errorMsg = "";
- formCtrl.$setValidity('valPropertyMsg', true);
- stopWatch();
- }
- }, true);
- }
+ // if ((errCount === 1 && angular.isArray(formCtrl.$error.valPropertyMsg)) || (formCtrl.$invalid && angular.isArray(formCtrl.$error.valServer))) {
+ // scope.errorMsg = "";
+ // formCtrl.$setValidity('valPropertyMsg', true);
+ // stopWatch();
+ // }
+ // }, true);
+ //}
}
//clear the watch when the property validator is valid again
@@ -178,8 +176,8 @@ function valPropertyMsg(serverValidationManager) {
// indicate that a content property is invalid at the property level since developers may not actually implement
// the correct field validation in their property editors.
- if (currentProperty) { //this can be null if no property was assigned
- serverValidationManager.subscribe(currentProperty.alias, currentCulture, "", function (isValid, propertyErrors, allErrors) {
+ if (scope.currentProperty) { //this can be null if no property was assigned
+ serverValidationManager.subscribe(scope.currentProperty.alias, currentCulture, "", function (isValid, propertyErrors, allErrors) {
hasError = !isValid;
if (hasError) {
//set the error message to the server message
@@ -201,7 +199,7 @@ function valPropertyMsg(serverValidationManager) {
// but they are a different callback instance than the above.
element.bind('$destroy', function () {
stopWatch();
- serverValidationManager.unsubscribe(currentProperty.alias, currentCulture, "");
+ serverValidationManager.unsubscribe(scope.currentProperty.alias, currentCulture, "");
});
//checkValidationStatus();
diff --git a/src/Umbraco.Web.UI.Client/src/common/directives/validation/valserver.directive.js b/src/Umbraco.Web.UI.Client/src/common/directives/validation/valserver.directive.js
index cb68e7e89c..c7bee7f4e5 100644
--- a/src/Umbraco.Web.UI.Client/src/common/directives/validation/valserver.directive.js
+++ b/src/Umbraco.Web.UI.Client/src/common/directives/validation/valserver.directive.js
@@ -43,21 +43,21 @@ function valServer(serverValidationManager) {
function startWatch() {
//if there's not already a watch
if (!watcher) {
- watcher = scope.$watch(function () {
- return modelCtrl.$modelValue;
- }, function (newValue, oldValue) {
+ //watcher = scope.$watch(function () {
+ // return modelCtrl.$modelValue;
+ //}, function (newValue, oldValue) {
- if (!newValue || angular.equals(newValue, oldValue)) {
- return;
- }
+ // if (!newValue || angular.equals(newValue, oldValue)) {
+ // return;
+ // }
- if (modelCtrl.$invalid) {
- modelCtrl.$setValidity('valServer', true);
- //clear the server validation entry
- serverValidationManager.removePropertyError(currentProperty.alias, currentCulture, fieldName);
- stopWatch();
- }
- }, true);
+ // if (modelCtrl.$invalid) {
+ // modelCtrl.$setValidity('valServer', true);
+ // //clear the server validation entry
+ // serverValidationManager.removePropertyError(currentProperty.alias, currentCulture, fieldName);
+ // stopWatch();
+ // }
+ //}, true);
}
}