gui: Reset warnings about nested folder roots (fixes #3433)

GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4173
This commit is contained in:
Simon Frei 2017-05-23 19:54:56 +00:00 committed by Audrius Butkevicius
parent 91d37f35bc
commit dd6bb6d5fd
3 changed files with 34 additions and 30 deletions

View File

@ -20,22 +20,22 @@ angular.module('syncthing.core')
}).every(function(e) { return e }); }).every(function(e) { return e });
} }
scope.pathIsSubFolder = false; scope.folderPathErrors.isSub = false;
scope.pathIsParentFolder = false; scope.folderPathErrors.isParent = false;
scope.otherFolder = ""; scope.folderPathErrors.otherID = "";
scope.otherFolderLabel = ""; scope.folderPathErrors.otherLabel = "";
for (var folderID in scope.folders) { for (var folderID in scope.folders) {
if (isSubDir(scope.folders[folderID].path, viewValue)) { if (isSubDir(scope.folders[folderID].path, viewValue)) {
scope.otherFolder = folderID; scope.folderPathErrors.otherID = folderID;
scope.otherFolderLabel = scope.folders[folderID].label; scope.folderPathErrors.otherLabel = scope.folders[folderID].label;
scope.pathIsSubFolder = true; scope.folderPathErrors.isSub = true;
break; break;
} }
if (viewValue !== "" && if (viewValue !== "" &&
isSubDir(viewValue, scope.folders[folderID].path)) { isSubDir(viewValue, scope.folders[folderID].path)) {
scope.otherFolder = folderID; scope.folderPathErrors.otherID = folderID;
scope.otherFolderLabel = scope.folders[folderID].label; scope.folderPathErrors.otherLabel = scope.folders[folderID].label;
scope.pathIsParentFolder = true; scope.folderPathErrors.isParent = true;
break; break;
} }
} }

View File

@ -53,27 +53,28 @@ angular.module('syncthing.core')
$scope.themes = []; $scope.themes = [];
$scope.globalChangeEvents = {}; $scope.globalChangeEvents = {};
$scope.metricRates = false; $scope.metricRates = false;
$scope.folderPathErrors = {};
try { try {
$scope.metricRates = (window.localStorage["metricRates"] == "true"); $scope.metricRates = (window.localStorage["metricRates"] == "true");
} catch (exception) { } } catch (exception) { }
$scope.folderDefaults = { $scope.folderDefaults = {
selectedDevices: {}, selectedDevices: {},
type: "readwrite", type: "readwrite",
rescanIntervalS: 60, rescanIntervalS: 60,
minDiskFree: {value: 1, unit: "%"}, minDiskFree: {value: 1, unit: "%"},
maxConflicts: 10, maxConflicts: 10,
fsync: true, fsync: true,
order: "random", order: "random",
fileVersioningSelector: "none", fileVersioningSelector: "none",
trashcanClean: 0, trashcanClean: 0,
simpleKeep: 5, simpleKeep: 5,
staggeredMaxAge: 365, staggeredMaxAge: 365,
staggeredCleanInterval: 3600, staggeredCleanInterval: 3600,
staggeredVersionsPath: "", staggeredVersionsPath: "",
externalCommand: "", externalCommand: "",
autoNormalize: true autoNormalize: true
}; };
$scope.localStateTotal = { $scope.localStateTotal = {
@ -1409,6 +1410,7 @@ angular.module('syncthing.core')
$scope.currentFolder.externalCommand = $scope.currentFolder.externalCommand || ""; $scope.currentFolder.externalCommand = $scope.currentFolder.externalCommand || "";
$scope.editingExisting = true; $scope.editingExisting = true;
$scope.folderPathErrors = {};
$scope.folderEditor.$setPristine(); $scope.folderEditor.$setPristine();
$('#editFolder').modal(); $('#editFolder').modal();
}; };
@ -1417,6 +1419,7 @@ angular.module('syncthing.core')
$scope.currentFolder = angular.copy($scope.folderDefaults); $scope.currentFolder = angular.copy($scope.folderDefaults);
$scope.editingExisting = false; $scope.editingExisting = false;
$('#editIgnores textarea').val(""); $('#editIgnores textarea').val("");
$scope.folderPathErrors = {};
$scope.folderEditor.$setPristine(); $scope.folderEditor.$setPristine();
$http.get(urlbase + '/svc/random/string?length=10').success(function (data) { $http.get(urlbase + '/svc/random/string?length=10').success(function (data) {
$scope.currentFolder.id = (data.random.substr(0, 5) + '-' + data.random.substr(5, 5)).toLowerCase(); $scope.currentFolder.id = (data.random.substr(0, 5) + '-' + data.random.substr(5, 5)).toLowerCase();
@ -1435,6 +1438,7 @@ angular.module('syncthing.core')
$scope.currentFolder.selectedDevices[device] = true; $scope.currentFolder.selectedDevices[device] = true;
$scope.editingExisting = false; $scope.editingExisting = false;
$scope.folderPathErrors = {};
$scope.folderEditor.$setPristine(); $scope.folderEditor.$setPristine();
$('#editFolder').modal(); $('#editFolder').modal();
}; };

View File

@ -26,12 +26,12 @@
<option ng-repeat="directory in directoryList" value="{{ directory }}" /> <option ng-repeat="directory in directoryList" value="{{ directory }}" />
</datalist> </datalist>
<p class="help-block"> <p class="help-block">
<span translate ng-if="folderEditor.folderPath.$valid || folderEditor.folderPath.$pristine">Path to the folder on the local computer. Will be created if it does not exist. The tilde character (~) can be used as a shortcut for</span> <code>{{system.tilde}}</code>. <span ng-if="folderEditor.folderPath.$valid || folderEditor.folderPath.$pristine"><span translate>Path to the folder on the local computer. Will be created if it does not exist. The tilde character (~) can be used as a shortcut for</span> <code>{{system.tilde}}</code>.</br></span>
<span translate ng-if="folderEditor.folderPath.$error.required && folderEditor.folderPath.$dirty">The folder path cannot be blank.</span> <span translate ng-if="folderEditor.folderPath.$error.required && folderEditor.folderPath.$dirty">The folder path cannot be blank.</span>
<span class="text-danger" translate translate-value-other-folder="{{otherFolder}}" ng-if="pathIsSubFolder && otherFolderLabel.length == 0">Warning, this path is a subdirectory of an existing folder "{%otherFolder%}".</span> <span class="text-danger" translate translate-value-other-folder="{{folderPathErrors.otherID}}" ng-if="folderPathErrors.isSub && folderPathErrors.otherLabel.length == 0">Warning, this path is a subdirectory of an existing folder "{%otherFolder%}".</span>
<span class="text-danger" translate translate-value-other-folder="{{otherFolder}}" translate-value-other-folder-label="{{otherFolderLabel}}" ng-if="pathIsSubFolder && otherFolderLabel.length != 0">Warning, this path is a subdirectory of an existing folder "{%otherFolderLabel%}" ({%otherFolder%}).</span> <span class="text-danger" translate translate-value-other-folder="{{folderPathErrors.otherID}}" translate-value-other-folder-label="{{folderPathErrors.otherLabel}}" ng-if="folderPathErrors.isSub && folderPathErrors.otherLabel.length != 0">Warning, this path is a subdirectory of an existing folder "{%otherFolderLabel%}" ({%otherFolder%}).</span>
<span class="text-danger" translate translate-value-other-folder="{{otherFolder}}" ng-if="pathIsParentFolder && otherFolderLabel.length == 0">Warning, this path is a parent directory of an existing folder "{%otherFolder%}".</span> <span class="text-danger" translate translate-value-other-folder="{{folderPathErrors.otherID}}" ng-if="folderPathErrors.isParent && folderPathErrors.otherLabel.length == 0">Warning, this path is a parent directory of an existing folder "{%otherFolder%}".</span>
<span class="text-danger" translate translate-value-other-folder="{{otherFolder}}" translate-value-other-folder-label="{{otherFolderLabel}}" ng-if="pathIsParentFolder && otherFolderLabel.length != 0">Warning, this path is a parent directory of an existing folder "{%otherFolderLabel%}" ({%otherFolder%}).</span> <span class="text-danger" translate translate-value-other-folder="{{folderPathErrors.otherID}}" translate-value-other-folder-label="{{folderPathErrors.otherLabel}}" ng-if="folderPathErrors.isParent && folderPathErrors.otherLabel.length != 0">Warning, this path is a parent directory of an existing folder "{%otherFolderLabel%}" ({%otherFolder%}).</span>
</p> </p>
</div> </div>
</div> </div>