mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-27 18:52:14 +03:00
Display "sent" info in publish menu
This commit is contained in:
parent
6419222f31
commit
56cfbf2cd2
@ -14,6 +14,8 @@ export default Component.extend({
|
||||
postStatus: 'draft',
|
||||
saveTask: null,
|
||||
runningText: null,
|
||||
backgroundTask: null,
|
||||
deliveredAction: null,
|
||||
|
||||
_publishedAtBlogTZ: null,
|
||||
_previousStatus: null,
|
||||
|
@ -3,6 +3,7 @@ import PostModel from 'ghost-admin/models/post';
|
||||
import boundOneWay from 'ghost-admin/utils/bound-one-way';
|
||||
import config from 'ghost-admin/config/environment';
|
||||
import isNumber from 'ghost-admin/utils/isNumber';
|
||||
import moment from 'moment';
|
||||
import {alias, mapBy} from '@ember/object/computed';
|
||||
import {computed} from '@ember/object';
|
||||
import {inject as controller} from '@ember/controller';
|
||||
@ -132,6 +133,10 @@ export default Controller.extend({
|
||||
}
|
||||
}),
|
||||
|
||||
deliveredAction: computed('actionsList', function () {
|
||||
return this.actionsList && this.actionsList.findBy('event', 'delivered');
|
||||
}),
|
||||
|
||||
_autosaveRunning: computed('_autosave.isRunning', '_timedSave.isRunning', function () {
|
||||
let autosave = this.get('_autosave.isRunning');
|
||||
let timedsave = this.get('_timedSave.isRunning');
|
||||
@ -531,6 +536,15 @@ export default Controller.extend({
|
||||
}
|
||||
}).enqueue(),
|
||||
|
||||
// load supplementel data such as the actions list in the background
|
||||
backgroundLoader: task(function* () {
|
||||
let actions = yield this.store.query('action', {
|
||||
filter: `resource_type:post+resource_id:${this.post.id}+event:delivered`,
|
||||
limit: 'all'
|
||||
});
|
||||
this.set('actionsList', actions);
|
||||
}).restartable(),
|
||||
|
||||
/* Public methods --------------------------------------------------------*/
|
||||
|
||||
// called by the new/edit routes to change the post model
|
||||
@ -546,6 +560,7 @@ export default Controller.extend({
|
||||
this.reset();
|
||||
|
||||
this.set('post', post);
|
||||
this.backgroundLoader.perform();
|
||||
|
||||
// autofocus the editor if we have a new post
|
||||
this.set('shouldFocusEditor', post.get('isNew'));
|
||||
|
12
ghost/admin/app/models/action.js
Normal file
12
ghost/admin/app/models/action.js
Normal file
@ -0,0 +1,12 @@
|
||||
import Model from 'ember-data/model';
|
||||
import attr from 'ember-data/attr';
|
||||
|
||||
export default Model.extend({
|
||||
resourceId: attr('string'),
|
||||
resourceType: attr('string'),
|
||||
actorId: attr('string'),
|
||||
actorType: attr('string'),
|
||||
event: attr('string'),
|
||||
context: attr('json-string'),
|
||||
createdAtUTC: attr('moment-utc')
|
||||
});
|
8
ghost/admin/app/serializers/action.js
Normal file
8
ghost/admin/app/serializers/action.js
Normal file
@ -0,0 +1,8 @@
|
||||
/* eslint-disable camelcase */
|
||||
import ApplicationSerializer from 'ghost-admin/serializers/application';
|
||||
|
||||
export default ApplicationSerializer.extend({
|
||||
attrs: {
|
||||
createdAtUTC: {key: 'created_at'}
|
||||
}
|
||||
});
|
@ -25,17 +25,32 @@
|
||||
</div>
|
||||
</div>
|
||||
{{#if this.feature.labs.members}}
|
||||
<div class="flex mb4">
|
||||
<div class="for-switch mr3">
|
||||
<label class="switch" for="email-when-published-checkbox">
|
||||
<Input @checked={{this.post.sendEmailWhenPublished}} @type="checkbox" @id="email-when-published-checkbox" @name="email-when-published" />
|
||||
<span class="input-toggle-component"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex-grow-1">
|
||||
<div class="gh-publishmenu-radio-label">Email to members</div>
|
||||
<div class="gh-publishmenu-radio-desc">Send email when published</div>
|
||||
</div>
|
||||
<div class="flex mb4 justify-center">
|
||||
{{#if this.backgroundLoader.isRunning}}
|
||||
<div class="gh-loading-spinner" style="zoom: 50%"></div>
|
||||
{{else}}
|
||||
{{#if this.deliveredAction}}
|
||||
<div class="mr3">
|
||||
💌
|
||||
</div>
|
||||
<div class="flex-grow-1">
|
||||
<div class="gh-publishmenu-radio-label">Sent</div>
|
||||
<div class="gh-publishmenu-radio-desc">Post was sent {{gh-format-post-time this.deliveredAction.createdAtUTC}}</div>
|
||||
</div>
|
||||
{{else}}
|
||||
<div class="for-switch mr3">
|
||||
<label class="switch" for="email-when-published-checkbox">
|
||||
<Input @checked={{this.post.sendEmailWhenPublished}} @type="checkbox" @id="email-when-published-checkbox" @name="email-when-published" />
|
||||
<span class="input-toggle-component"></span>
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex-grow-1">
|
||||
<div class="gh-publishmenu-radio-label">Email post</div>
|
||||
<div class="gh-publishmenu-radio-desc">Send post to 56 members when published</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/if}}
|
||||
</section>
|
||||
|
||||
|
@ -21,7 +21,9 @@
|
||||
{{gh-publishmenu-draft
|
||||
post=post
|
||||
saveType=saveType
|
||||
setSaveType=(action "setSaveType")}}
|
||||
setSaveType=(action "setSaveType")
|
||||
backgroundTask=this.backgroundTask
|
||||
deliveredAction=this.deliveredAction}}
|
||||
{{/if}}
|
||||
|
||||
{{!--
|
||||
|
@ -55,7 +55,9 @@
|
||||
postStatus=post.status
|
||||
saveTask=save
|
||||
setSaveType=(action "setSaveType")
|
||||
onOpen=(action "cancelAutosave")}}
|
||||
onOpen=(action "cancelAutosave")
|
||||
backgroundTask=this.backgroundLoader
|
||||
deliveredAction=this.deliveredAction}}
|
||||
{{/if}}
|
||||
{{/unless}}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user