FIX: email preview
This commit is contained in:
parent
da4c377277
commit
c74a6ab555
|
@ -1,18 +1,17 @@
|
||||||
export default Ember.Controller.extend({
|
export default Ember.Controller.extend({
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
refresh: function() {
|
refresh() {
|
||||||
var model = this.get('model'),
|
const model = this.get('model');
|
||||||
self = this;
|
|
||||||
|
|
||||||
self.set('loading', true);
|
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'));
|
model.setProperties(email.getProperties('html_content', 'text_content'));
|
||||||
self.set('loading', false);
|
this.set('loading', false);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleShowHtml: function() {
|
toggleShowHtml() {
|
||||||
this.toggleProperty('showHtml');
|
this.toggleProperty('showHtml');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
|
@ -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
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
|
@ -4,11 +4,8 @@
|
||||||
<div class='span7 controls'>
|
<div class='span7 controls'>
|
||||||
<label for='last-seen'>{{i18n 'admin.email.last_seen_user'}}</label>
|
<label for='last-seen'>{{i18n 'admin.email.last_seen_user'}}</label>
|
||||||
{{input type="date" value=lastSeen id="last-seen"}}
|
{{input type="date" value=lastSeen id="last-seen"}}
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<button class='btn' {{action "refresh"}}>{{i18n 'admin.email.refresh'}}</button>
|
<button class='btn' {{action "refresh"}}>{{i18n 'admin.email.refresh'}}</button>
|
||||||
</div>
|
<div class="toggle">
|
||||||
<div class="span7 toggle">
|
|
||||||
<label>{{i18n 'admin.email.format'}}</label>
|
<label>{{i18n 'admin.email.format'}}</label>
|
||||||
{{#if showHtml}}
|
{{#if showHtml}}
|
||||||
<span>{{i18n 'admin.email.html'}}</span> | <a href='#' {{action "toggleShowHtml"}}>{{i18n 'admin.email.text'}}</a>
|
<span>{{i18n 'admin.email.html'}}</span> | <a href='#' {{action "toggleShowHtml"}}>{{i18n 'admin.email.text'}}</a>
|
||||||
|
@ -17,11 +14,12 @@
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
{{#conditional-loading-spinner condition=loading}}
|
{{#conditional-loading-spinner condition=loading}}
|
||||||
{{#if showHtml}}
|
{{#if showHtml}}
|
||||||
{{{html_content}}}
|
{{{model.html_content}}}
|
||||||
{{else}}
|
{{else}}
|
||||||
<pre>{{{text_content}}}</pre>
|
<pre>{{{model.text_content}}}</pre>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/conditional-loading-spinner}}
|
{{/conditional-loading-spinner}}
|
||||||
|
|
Loading…
Reference in New Issue