diff --git a/src/scripts/controllers/new.js b/src/scripts/controllers/new.js index 66c0f39..7584dfb 100644 --- a/src/scripts/controllers/new.js +++ b/src/scripts/controllers/new.js @@ -10,7 +10,9 @@ availableOptions: (function () { var keys = aria2SettingService.getNewTaskOptionKeys(); - return aria2SettingService.getSpecifiedOptions(keys); + return aria2SettingService.getSpecifiedOptions(keys, { + disableRequired: true + }); })(), globalOptions: null, options: {}, diff --git a/src/scripts/controllers/task-detail.js b/src/scripts/controllers/task-detail.js index 41837be..6f1a0bf 100644 --- a/src/scripts/controllers/task-detail.js +++ b/src/scripts/controllers/task-detail.js @@ -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) { diff --git a/src/scripts/directives/setting.js b/src/scripts/directives/setting.js index 5083379..fe6dd40 100644 --- a/src/scripts/directives/setting.js +++ b/src/scripts/directives/setting.js @@ -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; } diff --git a/src/scripts/services/aria2SettingService.js b/src/scripts/services/aria2SettingService.js index 4510456..be81d62 100644 --- a/src/scripts/services/aria2SettingService.js +++ b/src/scripts/services/aria2SettingService.js @@ -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 = [];