FIX: email preview

This commit is contained in:
Régis Hanol 2015-08-16 11:51:31 +02:00
parent da4c377277
commit c74a6ab555
4 changed files with 31 additions and 43 deletions

View File

@ -1,18 +1,17 @@
export default Ember.Controller.extend({
actions: {
refresh: function() {
var model = this.get('model'),
self = this;
refresh() {
const model = this.get('model');
self.set('loading', true);
Discourse.EmailPreview.findDigest(this.get('lastSeen')).then(function (email) {
Discourse.EmailPreview.findDigest(this.get('lastSeen')).then(email => {
model.setProperties(email.getProperties('html_content', 'text_content'));
self.set('loading', false);
this.set('loading', false);
});
},
toggleShowHtml: function() {
toggleShowHtml() {
this.toggleProperty('showHtml');
}
}

View File

@ -0,0 +1,16 @@
export default Discourse.Route.extend({
model() {
return Discourse.EmailPreview.findDigest();
},
afterModel(model) {
const controller = this.controllerFor('adminEmailPreviewDigest');
controller.setProperties({
model: model,
lastSeen: moment().subtract(7, 'days').format('YYYY-MM-DD'),
showHtml: true
});
}
});

View File

@ -1,25 +0,0 @@
/**
Previews the Email Digests
@class AdminEmailPreviewDigest
@extends Discourse.Route
@namespace Discourse
@module Discourse
**/
Discourse.AdminEmailPreviewDigestRoute = Discourse.Route.extend({
model: function() {
return Discourse.EmailPreview.findDigest();
},
afterModel: function(model) {
var controller = this.controllerFor('adminEmailPreviewDigest');
controller.setProperties({
model: model,
lastSeen: moment().subtract(7, 'days').format('YYYY-MM-DD'),
showHtml: true
});
}
});

View File

@ -4,11 +4,8 @@
<div class='span7 controls'>
<label for='last-seen'>{{i18n 'admin.email.last_seen_user'}}</label>
{{input type="date" value=lastSeen id="last-seen"}}
</div>
<div>
<button class='btn' {{action "refresh"}}>{{i18n 'admin.email.refresh'}}</button>
</div>
<div class="span7 toggle">
<div class="toggle">
<label>{{i18n 'admin.email.format'}}</label>
{{#if showHtml}}
<span>{{i18n 'admin.email.html'}}</span> | <a href='#' {{action "toggleShowHtml"}}>{{i18n 'admin.email.text'}}</a>
@ -17,11 +14,12 @@
{{/if}}
</div>
</div>
</div>
{{#conditional-loading-spinner condition=loading}}
{{#if showHtml}}
{{{html_content}}}
{{{model.html_content}}}
{{else}}
<pre>{{{text_content}}}</pre>
<pre>{{{model.text_content}}}</pre>
{{/if}}
{{/conditional-loading-spinner}}