gui: Make device ID read-only and hide "nearby devices" when adding a new pending device (fixes #8083) (#8091)
* gui: Make ID read-only and hide nearby devices when adding pending devices (fixes #8083) Currently, there is no distinction between adding "new" and "pending" devices. For this reason, the user is always presented with a list of "nearby devices" to choose from. This commit adds such distinction to the code, and in the case of "pending" device, both the device ID is made read-only and the nearby devices list is hidden. As a by-product of the function rename and clean-up, this commit also hides the non-functional "remove" button that is shown when editing device defaults. Signed-off-by: Tomasz Wilczyński <twilczynski@naver.com>
This commit is contained in:
@@ -4,23 +4,18 @@ angular.module('syncthing.core')
|
||||
require: 'ngModel',
|
||||
link: function (scope, elm, attrs, ctrl) {
|
||||
ctrl.$parsers.unshift(function (viewValue) {
|
||||
if (scope.currentDevice._editing != "add") {
|
||||
// we shouldn't validate
|
||||
ctrl.$setValidity('validDeviceid', true);
|
||||
} else {
|
||||
$http.get(urlbase + '/svc/deviceid?id=' + viewValue).success(function (resp) {
|
||||
if (resp.error) {
|
||||
ctrl.$setValidity('validDeviceid', false);
|
||||
} else {
|
||||
ctrl.$setValidity('validDeviceid', true);
|
||||
}
|
||||
});
|
||||
//Prevents user from adding a duplicate ID
|
||||
if (scope.devices.hasOwnProperty(viewValue)) {
|
||||
ctrl.$setValidity('unique', false);
|
||||
$http.get(urlbase + '/svc/deviceid?id=' + viewValue).success(function (resp) {
|
||||
if (resp.error) {
|
||||
ctrl.$setValidity('validDeviceid', false);
|
||||
} else {
|
||||
ctrl.$setValidity('unique', true);
|
||||
ctrl.$setValidity('validDeviceid', true);
|
||||
}
|
||||
});
|
||||
//Prevents user from adding a duplicate ID
|
||||
if (scope.devices.hasOwnProperty(viewValue)) {
|
||||
ctrl.$setValidity('unique', false);
|
||||
} else {
|
||||
ctrl.$setValidity('unique', true);
|
||||
}
|
||||
return viewValue;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user