allow setting empty value in new task page and task detail page
This commit is contained in:
parent
e7c958b5fa
commit
9055c7549e
|
@ -10,7 +10,9 @@
|
|||
availableOptions: (function () {
|
||||
var keys = aria2SettingService.getNewTaskOptionKeys();
|
||||
|
||||
return aria2SettingService.getSpecifiedOptions(keys);
|
||||
return aria2SettingService.getSpecifiedOptions(keys, {
|
||||
disableRequired: true
|
||||
});
|
||||
})(),
|
||||
globalOptions: null,
|
||||
options: {},
|
||||
|
|
|
@ -9,11 +9,9 @@
|
|||
var getAvailableOptions = function (status, isBittorrent) {
|
||||
var keys = aria2SettingService.getAvailableTaskOptionKeys(status, isBittorrent);
|
||||
|
||||
if (!keys) {
|
||||
return;
|
||||
}
|
||||
|
||||
return aria2SettingService.getSpecifiedOptions(keys);
|
||||
return aria2SettingService.getSpecifiedOptions(keys, {
|
||||
disableRequired: true
|
||||
});
|
||||
};
|
||||
|
||||
var processTask = function (task) {
|
||||
|
|
|
@ -170,17 +170,17 @@
|
|||
return;
|
||||
}
|
||||
|
||||
if (scope.option.type === 'integer' && !/^-?\d+$/.test(optionValue)) {
|
||||
if (optionValue !== '' && scope.option.type === 'integer' && !/^-?\d+$/.test(optionValue)) {
|
||||
scope.optionStatus.setError('Input number is invalid!');
|
||||
return;
|
||||
}
|
||||
|
||||
if (scope.option.type === 'float' && !/^-?(\d*\.)?\d+$/.test(optionValue)) {
|
||||
if (optionValue !== '' && scope.option.type === 'float' && !/^-?(\d*\.)?\d+$/.test(optionValue)) {
|
||||
scope.optionStatus.setError('Input number is invalid!');
|
||||
return;
|
||||
}
|
||||
|
||||
if ((scope.option.type === 'integer' || scope.option.type === 'float') && (angular.isDefined(scope.option.min) || angular.isDefined(scope.option.max))) {
|
||||
if (optionValue !== '' && (scope.option.type === 'integer' || scope.option.type === 'float') && (angular.isDefined(scope.option.min) || angular.isDefined(scope.option.max))) {
|
||||
var number = optionValue;
|
||||
|
||||
if (scope.option.type === 'integer') {
|
||||
|
@ -200,7 +200,7 @@
|
|||
}
|
||||
}
|
||||
|
||||
if (angular.isDefined(scope.option.pattern) && !(new RegExp(scope.option.pattern).test(optionValue))) {
|
||||
if (optionValue !== '' && angular.isDefined(scope.option.pattern) && !(new RegExp(scope.option.pattern).test(optionValue))) {
|
||||
scope.optionStatus.setError('Input value is invalid!');
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
|
||||
return availableOptions;
|
||||
},
|
||||
getNewTaskOptionKeys: function (isBittorrent) {
|
||||
getNewTaskOptionKeys: function () {
|
||||
var allOptions = aria2TaskAvailableOptions.taskOptions;
|
||||
var availableOptions = [];
|
||||
|
||||
|
@ -92,9 +92,13 @@
|
|||
|
||||
return availableOptions;
|
||||
},
|
||||
getSpecifiedOptions: function (keys) {
|
||||
getSpecifiedOptions: function (keys, extendSettings) {
|
||||
var options = [];
|
||||
|
||||
if (!keys) {
|
||||
return options;
|
||||
}
|
||||
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
var key = keys[i];
|
||||
var readonly = false;
|
||||
|
@ -132,6 +136,10 @@
|
|||
option.readonly = true;
|
||||
}
|
||||
|
||||
if (extendSettings && extendSettings.disableRequired) {
|
||||
option.required = false;
|
||||
}
|
||||
|
||||
if (option.options) {
|
||||
var availableOptions = [];
|
||||
|
||||
|
|
Reference in a new issue