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 () {
|
availableOptions: (function () {
|
||||||
var keys = aria2SettingService.getNewTaskOptionKeys();
|
var keys = aria2SettingService.getNewTaskOptionKeys();
|
||||||
|
|
||||||
return aria2SettingService.getSpecifiedOptions(keys);
|
return aria2SettingService.getSpecifiedOptions(keys, {
|
||||||
|
disableRequired: true
|
||||||
|
});
|
||||||
})(),
|
})(),
|
||||||
globalOptions: null,
|
globalOptions: null,
|
||||||
options: {},
|
options: {},
|
||||||
|
|
|
@ -9,11 +9,9 @@
|
||||||
var getAvailableOptions = function (status, isBittorrent) {
|
var getAvailableOptions = function (status, isBittorrent) {
|
||||||
var keys = aria2SettingService.getAvailableTaskOptionKeys(status, isBittorrent);
|
var keys = aria2SettingService.getAvailableTaskOptionKeys(status, isBittorrent);
|
||||||
|
|
||||||
if (!keys) {
|
return aria2SettingService.getSpecifiedOptions(keys, {
|
||||||
return;
|
disableRequired: true
|
||||||
}
|
});
|
||||||
|
|
||||||
return aria2SettingService.getSpecifiedOptions(keys);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var processTask = function (task) {
|
var processTask = function (task) {
|
||||||
|
|
|
@ -170,17 +170,17 @@
|
||||||
return;
|
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!');
|
scope.optionStatus.setError('Input number is invalid!');
|
||||||
return;
|
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!');
|
scope.optionStatus.setError('Input number is invalid!');
|
||||||
return;
|
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;
|
var number = optionValue;
|
||||||
|
|
||||||
if (scope.option.type === 'integer') {
|
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!');
|
scope.optionStatus.setError('Input value is invalid!');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
|
|
||||||
return availableOptions;
|
return availableOptions;
|
||||||
},
|
},
|
||||||
getNewTaskOptionKeys: function (isBittorrent) {
|
getNewTaskOptionKeys: function () {
|
||||||
var allOptions = aria2TaskAvailableOptions.taskOptions;
|
var allOptions = aria2TaskAvailableOptions.taskOptions;
|
||||||
var availableOptions = [];
|
var availableOptions = [];
|
||||||
|
|
||||||
|
@ -92,9 +92,13 @@
|
||||||
|
|
||||||
return availableOptions;
|
return availableOptions;
|
||||||
},
|
},
|
||||||
getSpecifiedOptions: function (keys) {
|
getSpecifiedOptions: function (keys, extendSettings) {
|
||||||
var options = [];
|
var options = [];
|
||||||
|
|
||||||
|
if (!keys) {
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
for (var i = 0; i < keys.length; i++) {
|
for (var i = 0; i < keys.length; i++) {
|
||||||
var key = keys[i];
|
var key = keys[i];
|
||||||
var readonly = false;
|
var readonly = false;
|
||||||
|
@ -132,6 +136,10 @@
|
||||||
option.readonly = true;
|
option.readonly = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (extendSettings && extendSettings.disableRequired) {
|
||||||
|
option.required = false;
|
||||||
|
}
|
||||||
|
|
||||||
if (option.options) {
|
if (option.options) {
|
||||||
var availableOptions = [];
|
var availableOptions = [];
|
||||||
|
|
||||||
|
|
Reference in a new issue