parent
e4c995a321
commit
031b91c0ed
|
@ -3,7 +3,7 @@ angular.module('syncthing.core')
|
||||||
return {
|
return {
|
||||||
require: 'ngModel',
|
require: 'ngModel',
|
||||||
link: function (scope, elm, attrs, ctrl) {
|
link: function (scope, elm, attrs, ctrl) {
|
||||||
ctrl.$parsers.unshift(function (viewValue) {
|
ctrl.$validators.folderPathErrors = function (viewValue) {
|
||||||
// This function checks whether ydir is a subdirectory of xdir,
|
// This function checks whether ydir is a subdirectory of xdir,
|
||||||
// e.g. it would return true if xdir = "/home/a", ydir = "/home/a/b".
|
// e.g. it would return true if xdir = "/home/a", ydir = "/home/a/b".
|
||||||
function isSubDir(xdir, ydir) {
|
function isSubDir(xdir, ydir) {
|
||||||
|
@ -25,6 +25,9 @@ angular.module('syncthing.core')
|
||||||
scope.folderPathErrors.otherID = "";
|
scope.folderPathErrors.otherID = "";
|
||||||
scope.folderPathErrors.otherLabel = "";
|
scope.folderPathErrors.otherLabel = "";
|
||||||
for (var folderID in scope.folders) {
|
for (var folderID in scope.folders) {
|
||||||
|
if (folderID === scope.currentFolder.id) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (isSubDir(scope.folders[folderID].path, viewValue)) {
|
if (isSubDir(scope.folders[folderID].path, viewValue)) {
|
||||||
scope.folderPathErrors.otherID = folderID;
|
scope.folderPathErrors.otherID = folderID;
|
||||||
scope.folderPathErrors.otherLabel = scope.folders[folderID].label;
|
scope.folderPathErrors.otherLabel = scope.folders[folderID].label;
|
||||||
|
@ -39,8 +42,8 @@ angular.module('syncthing.core')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return viewValue;
|
return true;
|
||||||
});
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue