Lists and Templates overviews refactored to use ajax. Before the refactoring, they behaved and looked a bit different to the other (Ajax) tables. The main difference in the behavior was in the row numbers (1st column) when sort order was switched. The non-ajax tables rearranged the numbers in the 1st column while the ajax-tables didn't.
Some small tweaks in table-helpers to allow selecting which fields are pulled from DB (and how they are renamed).
This commit is contained in:
parent
e5190c9b20
commit
9fdf52674e
12 changed files with 246 additions and 192 deletions
|
@ -8,23 +8,15 @@ let tableHelpers = require('../table-helpers');
|
|||
let allowedKeys = ['description', 'editor_name', 'editor_data', 'html', 'text'];
|
||||
|
||||
module.exports.list = (start, limit, callback) => {
|
||||
tableHelpers.list('templates', 'name', start, limit, callback);
|
||||
tableHelpers.list('templates', ['*'], 'name', start, limit, callback);
|
||||
};
|
||||
|
||||
module.exports.filter = (request, parent, callback) => {
|
||||
tableHelpers.filter('templates', ['*'], request, ['#', 'name', 'description'], ['name'], 'name ASC', null, callback);
|
||||
};
|
||||
|
||||
module.exports.quicklist = callback => {
|
||||
db.getConnection((err, connection) => {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
connection.query('SELECT id, name FROM templates ORDER BY name LIMIT 1000', (err, rows) => {
|
||||
connection.release();
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
return callback(null, (rows || []).map(tools.convertKeys));
|
||||
});
|
||||
});
|
||||
tableHelpers.quicklist('templates', ['id', 'name'], 'name', callback);
|
||||
};
|
||||
|
||||
module.exports.get = (id, callback) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue