syncthing-arm/gui/syncthing/core/uniqueFolderDirective.js
Jakob Borg 9513e91d66 Flatten GUI tree somewhat
The very deep tree structure didn't really aggree with me, sorry. This
makes the core module rather large, but on the other hand that just
highlights that it is rather large.
2015-08-02 09:24:01 +02:00

22 lines
850 B
JavaScript

angular.module('syncthing.core')
.directive('uniqueFolder', function () {
return {
require: 'ngModel',
link: function (scope, elm, attrs, ctrl) {
ctrl.$parsers.unshift(function (viewValue) {
if (scope.editingExisting) {
// we shouldn't validate
ctrl.$setValidity('uniqueFolder', true);
} else if (scope.folders.hasOwnProperty(viewValue)) {
// the folder exists already
ctrl.$setValidity('uniqueFolder', false);
} else {
// the folder is unique
ctrl.$setValidity('uniqueFolder', true);
}
return viewValue;
});
}
};
});