button to revert to original email template

v1.18.x
psychobunny 9 years ago
parent 47fb8e8125
commit 70da64b927

@ -33,6 +33,16 @@ define('admin/settings/email', ['admin/settings'], function(settings) {
$('#email-editor-holder').val(emailEditor.getValue());
});
$('button[data-action="email.revert"]').off('click').on('click', function() {
ajaxify.data.emails.forEach(function(email) {
if (email.path === $('#email-editor-selector').val()) {
emailEditor.getSession().setValue(email.original);
$('#email-editor-holder')
.val(email.original);
}
});
});
updateEmailEditor();
}

@ -28,19 +28,16 @@ function renderEmail(req, res, next) {
async.map(emails, function(email, next) {
var path = email.replace(emailsPath, '').substr(1).replace('.tpl', '');
function callback(err, str) {
fs.readFile(email, function(err, original) {
var text = meta.config['email:custom:' + path] ? meta.config['email:custom:' + path] : original.toString();
next(err, {
path: path,
fullpath: email,
text: str.toString()
text: text,
original: original.toString()
});
}
if (meta.config['email:custom:' + path]) {
return callback(null, meta.config['email:custom:' + path]);
}
fs.readFile(email, callback);
});
}, function(err, emails) {
res.render('admin/settings/email', {
emails: emails,

@ -33,9 +33,12 @@
<!-- BEGIN emails -->
<option value="{emails.path}">{emails.path}</option>
<!-- END emails -->
</select><br />
</select>
<br />
<div id="email-editor"></div>
<input type="hidden" id="email-editor-holder" value="" data-field="" />
<br />
<button class="btn btn-warning" type="button" data-action="email.revert">Revert to Original</button>
</div>
</div>

Loading…
Cancel
Save