Make optional fields optional (#154)

This fixes an issue that required people to manually specify a timeout
and wait for their tasks when they're created.
This commit is contained in:
Rowan Manning
2016-11-07 14:06:12 +00:00
committed by GitHub
parent 2976d5e391
commit c562bb07f3
3 changed files with 12 additions and 6 deletions

View File

@@ -28,7 +28,7 @@
"express": "~4.14", "express": "~4.14",
"express-hbs": "~1.0", "express-hbs": "~1.0",
"moment": "~2.13", "moment": "~2.13",
"pa11y-webservice": "^2.0.1", "pa11y-webservice": "^2.1.1",
"pa11y-webservice-client-node": "^1.2.1", "pa11y-webservice-client-node": "^1.2.1",
"underscore": "~1.8" "underscore": "~1.8"
}, },
@@ -38,7 +38,7 @@
"jscs": "^2", "jscs": "^2",
"jshint": "^2", "jshint": "^2",
"less": "~2.7", "less": "~2.7",
"mocha": "^3", "mocha": "^2",
"proclaim": "^3", "proclaim": "^3",
"request": "^2.74", "request": "^2.74",
"uglify-js": "~2.6" "uglify-js": "~2.6"

View File

@@ -41,10 +41,10 @@ function route(app) {
url: req.body.url, url: req.body.url,
standard: req.body.standard, standard: req.body.standard,
ignore: req.body.ignore || [], ignore: req.body.ignore || [],
timeout: req.body.timeout, timeout: req.body.timeout || undefined,
wait: req.body.wait, wait: req.body.wait || undefined,
username: req.body.username, username: req.body.username || undefined,
password: req.body.password password: req.body.password || undefined
}; };
app.webservice.tasks.create(newTask, (err, task) => { app.webservice.tasks.create(newTask, (err, task) => {
if (err) { if (err) {

View File

@@ -13,6 +13,8 @@
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>. // along with Pa11y Dashboard. If not, see <http://www.gnu.org/licenses/>.
/*jshint maxcomplexity:8*/
'use strict'; 'use strict';
const presentTask = require('../../view/presenter/task'); const presentTask = require('../../view/presenter/task');
@@ -55,6 +57,10 @@ function route(app) {
return next(); return next();
} }
req.body.ignore = req.body.ignore || []; req.body.ignore = req.body.ignore || [];
req.body.timeout = req.body.timeout || undefined;
req.body.wait = req.body.wait || undefined;
req.body.username = req.body.username || undefined;
req.body.password = req.body.password || undefined;
app.webservice.task(req.params.id).edit(req.body, err => { app.webservice.task(req.params.id).edit(req.body, err => {
if (err) { if (err) {
task.name = req.body.name; task.name = req.body.name;