From e2d4073b3e407cfcae536b538d4276cfc89cfecb Mon Sep 17 00:00:00 2001 From: Dominique Da Silva Date: Sun, 3 Nov 2019 02:14:56 +0000 Subject: [PATCH] Added editor and mode column to template list. --- lib/models/templates.js | 12 +++++++++++- routes/templates.js | 4 +++- views/templates/templates.hbs | 10 ++++++++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/lib/models/templates.js b/lib/models/templates.js index b0f0099e..bc235be1 100644 --- a/lib/models/templates.js +++ b/lib/models/templates.js @@ -7,12 +7,22 @@ let tableHelpers = require('../table-helpers'); let allowedKeys = ['description', 'editor_name', 'editor_data', 'html', 'text']; +module.exports.editorName = (edt) => { + const names = { + grapejs: 'GrapesJS', + summernote: 'Summernote', + codeeditor: 'Code Editor', + mosaico: 'Mosaico', + }; + return names[edt] || edt || 'Unknow'; +} + module.exports.list = (start, limit, callback) => { tableHelpers.list('templates', ['*'], 'name', null, start, limit, callback); }; module.exports.filter = (request, parent, callback) => { - tableHelpers.filter('templates', ['*'], request, ['#', 'name', 'description'], ['name'], 'name ASC', null, callback); + tableHelpers.filter('templates', ['*'], request, ['#', 'name', 'editor_name', 'editor_data', 'description'], ['name'], 'name ASC', null, callback); }; module.exports.quicklist = callback => { diff --git a/routes/templates.js b/routes/templates.js index d91bdb43..eb3066e2 100644 --- a/routes/templates.js +++ b/routes/templates.js @@ -179,8 +179,10 @@ router.post('/ajax', (req, res) => { data: data.map((row, i) => [ (Number(req.body.start) || 0) + 1 + i, ' ' + htmlescape(row.name || ''), + templates.editorName(row.editorName), + row.editorData && row.editorData.indexOf('"mjml":') > -1 ? 'MJML' : 'HTML', htmlescape(striptags(row.description) || ''), - '' + _('Edit') + '' ] + ' ' + _('Edit') + '' ] ) }); }); diff --git a/views/templates/templates.hbs b/views/templates/templates.hbs index e88aac21..d53db1ab 100644 --- a/views/templates/templates.hbs +++ b/views/templates/templates.hbs @@ -12,14 +12,20 @@
- +
- + +
# + {{#translate}}Name{{/translate}} + {{#translate}}Editor{{/translate}} + + {{#translate}}Mode{{/translate}} + {{#translate}}Description{{/translate}}