mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-24 23:48:13 -05:00
Added email subject to preview modal header
This commit is contained in:
parent
df8968f13d
commit
904114d844
2 changed files with 6 additions and 3 deletions
|
@ -8,8 +8,8 @@ export default ModalComponent.extend({
|
||||||
ajax: service(),
|
ajax: service(),
|
||||||
type: 'desktop',
|
type: 'desktop',
|
||||||
previewHtml: '',
|
previewHtml: '',
|
||||||
|
previewEmailSubject: null,
|
||||||
post: alias('model'),
|
post: alias('model'),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
changeType(type) {
|
changeType(type) {
|
||||||
this.set('type', type);
|
this.set('type', type);
|
||||||
|
@ -21,10 +21,12 @@ export default ModalComponent.extend({
|
||||||
const resourceId = this.post.id;
|
const resourceId = this.post.id;
|
||||||
const url = this.get('ghostPaths.url').api('/email_preview/posts', resourceId);
|
const url = this.get('ghostPaths.url').api('/email_preview/posts', resourceId);
|
||||||
let htmlData = this.get('previewHtml');
|
let htmlData = this.get('previewHtml');
|
||||||
|
let emailSubject = this.get('previewEmailSubject');
|
||||||
if (!htmlData) {
|
if (!htmlData) {
|
||||||
const response = await this.ajax.request(`${url}?status=all`);
|
const response = await this.ajax.request(url);
|
||||||
let [emailPreview] = response.email_previews;
|
let [emailPreview] = response.email_previews;
|
||||||
htmlData = emailPreview.html;
|
htmlData = emailPreview.html;
|
||||||
|
emailSubject = emailPreview.subject;
|
||||||
}
|
}
|
||||||
|
|
||||||
let iframe = this.element.querySelector('iframe');
|
let iframe = this.element.querySelector('iframe');
|
||||||
|
@ -34,6 +36,7 @@ export default ModalComponent.extend({
|
||||||
iframe.contentWindow.document.close();
|
iframe.contentWindow.document.close();
|
||||||
}
|
}
|
||||||
this.set('previewHtml', htmlData);
|
this.set('previewHtml', htmlData);
|
||||||
|
this.set('previewEmailSubject', emailSubject);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// re-throw if we don't have a validation error
|
// re-throw if we don't have a validation error
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<header class="modal-header gh-pe-header {{if (eq type "desktop") "gh-pe-header-border"}}" data-test-modal="preview-email" style="display:flex">
|
<header class="modal-header gh-pe-header {{if (eq type "desktop") "gh-pe-header-border"}}" data-test-modal="preview-email" style="display:flex">
|
||||||
<h2 class="f5 fw6">Email preview</h2>
|
<h2 class="f5 fw6">{{previewEmailSubject}}</h2>
|
||||||
<div class="gh-contentfilter gh-btn-group gh-pe-btn-group" style="display:flex;flex-grow:1;justify-content:center">
|
<div class="gh-contentfilter gh-btn-group gh-pe-btn-group" style="display:flex;flex-grow:1;justify-content:center">
|
||||||
<button class="gh-btn {{if (eq type "desktop") "gh-btn-group-selected"}}" {{action "changeType" "desktop"}}><span>Desktop</span></button>
|
<button class="gh-btn {{if (eq type "desktop") "gh-btn-group-selected"}}" {{action "changeType" "desktop"}}><span>Desktop</span></button>
|
||||||
<button class="gh-btn {{if (eq type "mobile") "gh-btn-group-selected"}}" {{action "changeType" "mobile"}}><span>Mobile</span></button>
|
<button class="gh-btn {{if (eq type "mobile") "gh-btn-group-selected"}}" {{action "changeType" "mobile"}}><span>Mobile</span></button>
|
||||||
|
|
Loading…
Add table
Reference in a new issue