forked from external-repos/pa11y-dashboard
Make the "new task" form functional
This commit is contained in:
1
app.js
1
app.js
@@ -24,6 +24,7 @@ function initApp (config, callback) {
|
|||||||
maxAge: (process.env.NODE_ENV === 'production' ? 604800 : 0)
|
maxAge: (process.env.NODE_ENV === 'production' ? 604800 : 0)
|
||||||
}));
|
}));
|
||||||
app.express.use(express.compress());
|
app.express.use(express.compress());
|
||||||
|
app.express.use(express.bodyParser());
|
||||||
|
|
||||||
// View engine
|
// View engine
|
||||||
app.express.set('views', __dirname + '/view');
|
app.express.set('views', __dirname + '/view');
|
||||||
|
15
route/new.js
15
route/new.js
@@ -4,7 +4,22 @@ module.exports = route;
|
|||||||
|
|
||||||
// Route definition
|
// Route definition
|
||||||
function route (app) {
|
function route (app) {
|
||||||
|
|
||||||
app.express.get('/new', function (req, res) {
|
app.express.get('/new', function (req, res) {
|
||||||
res.render('new');
|
res.render('new');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
app.express.post('/new', function (req, res) {
|
||||||
|
var newTask = {
|
||||||
|
url: req.body.url,
|
||||||
|
standard: req.body.standard
|
||||||
|
};
|
||||||
|
app.webservice.tasks.create(newTask, function (err, task) {
|
||||||
|
if (err) {
|
||||||
|
return res.render('new', {error: err});
|
||||||
|
}
|
||||||
|
res.redirect('/' + task.id + '?added');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -15,7 +15,8 @@ function route (app) {
|
|||||||
}
|
}
|
||||||
res.render('task', {
|
res.render('task', {
|
||||||
task: task,
|
task: task,
|
||||||
results: results
|
results: results,
|
||||||
|
added: (typeof req.query.added !== 'undefined')
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -7,4 +7,33 @@
|
|||||||
|
|
||||||
<h1>Create A Task</h1>
|
<h1>Create A Task</h1>
|
||||||
|
|
||||||
<p><b>TODO: Add form here and create handler for it.</b></p>
|
<form action="/new" method="post">
|
||||||
|
|
||||||
|
{{#error}}
|
||||||
|
<div style="color: #c00;">
|
||||||
|
<p>{{error}}</p>
|
||||||
|
</div>
|
||||||
|
{{/error}}
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="new-task-url">URL</label><br/>
|
||||||
|
<input id="new-task-url" type="text" name="url"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<label for="new-task-standard">Standard</label><br/>
|
||||||
|
<select id="new-task-standard" name="standard">
|
||||||
|
<option>WCAG2A</option>
|
||||||
|
<option>WCAG2AA</option>
|
||||||
|
<option>WCAG2AAA</option>
|
||||||
|
<option>Section508</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p><b>TODO: add ignore rules!</b></p>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<input type="submit" value="Add"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
@@ -7,6 +7,12 @@
|
|||||||
|
|
||||||
<h1>Task: {{task.url}} ({{task.standard}})</h1>
|
<h1>Task: {{task.url}} ({{task.standard}})</h1>
|
||||||
|
|
||||||
|
{{#added}}
|
||||||
|
<div style="color: #090;">
|
||||||
|
<p>Task added!</p>
|
||||||
|
</div>
|
||||||
|
{{/added}}
|
||||||
|
|
||||||
<p>Here are the results:</p>
|
<p>Here are the results:</p>
|
||||||
|
|
||||||
{{> results}}
|
{{> results}}
|
||||||
|
Reference in New Issue
Block a user