Merge remote-tracking branch 'refs/remotes/umbraco/dev-v7' into dev-v7-U4-6425
This commit is contained in:
@@ -12,22 +12,6 @@
|
||||
function LockedFieldDirective($timeout, localizationService) {
|
||||
|
||||
function link(scope, el, attr, ngModelCtrl) {
|
||||
|
||||
//watch the ngModel so we can manually update the textbox view value when it changes
|
||||
// this ensures that the normal flow (i.e. a user editing the text box) occurs so that
|
||||
// the parsers, validators and viewchangelisteners execute
|
||||
scope.$watch("ngModel", function (newValue, oldValue) {
|
||||
if (newValue !== oldValue) {
|
||||
//Hack: in order for the pipeline to execute for setViewValue, the underlying $modelValue cannot
|
||||
// match the value being set with the newValue, so we'll se it to undefined first.
|
||||
// We could avoid this hack by setting the ngModel of the lockedField input field to a custom
|
||||
// scope object, but that would mean we'd have to watch that value too in order to set the outer
|
||||
// ngModelCtrl.$modelValue. It's seems like less overhead to just do this and not have 2x watches.
|
||||
scope.lockedFieldForm.lockedField.$modelValue = undefined;
|
||||
scope.lockedFieldForm.lockedField.$render();
|
||||
}
|
||||
scope.lockedFieldForm.lockedField.$setViewValue(scope.lockedFieldForm.lockedField.$modelValue);
|
||||
});
|
||||
|
||||
function activate() {
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ function valRegex() {
|
||||
|
||||
var flags = "";
|
||||
var regex;
|
||||
var eventBindings = [];
|
||||
|
||||
attrs.$observe("valRegexFlags", function (newVal) {
|
||||
if (newVal) {
|
||||
@@ -38,6 +39,12 @@ function valRegex() {
|
||||
}
|
||||
});
|
||||
|
||||
eventBindings.push(scope.$watch('ngModel', function(newValue, oldValue){
|
||||
if(newValue && newValue !== oldValue) {
|
||||
patternValidator(newValue);
|
||||
}
|
||||
}));
|
||||
|
||||
var patternValidator = function (viewValue) {
|
||||
if (regex) {
|
||||
//NOTE: we don't validate on empty values, use required validator for that
|
||||
@@ -58,8 +65,14 @@ function valRegex() {
|
||||
}
|
||||
};
|
||||
|
||||
ctrl.$parsers.push(patternValidator);
|
||||
scope.$on('$destroy', function(){
|
||||
// unbind watchers
|
||||
for(var e in eventBindings) {
|
||||
eventBindings[e]();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
angular.module('umbraco.directives.validation').directive("valRegex", valRegex);
|
||||
angular.module('umbraco.directives.validation').directive("valRegex", valRegex);
|
||||
|
||||
Reference in New Issue
Block a user