mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-21 09:52:06 +03:00
c4ad61ac0f
no issue If you scheduled a post to a specific newsletter it was no longer visible in the scheduled state of the publish menu making it difficult to know the behaviour when coming back to a scheduled post. - duplicated the newsletter dropdown from the draft to the scheduled state components and disabled it the same as the other recipient options - added temporary workaround for missing newsletter embed for the posts endpoint in the API - adds `newsletterId` attribute to the post model - uses `post.newsletterId` to find the matching newsletter model from the available newsletters list
75 lines
1.9 KiB
JavaScript
75 lines
1.9 KiB
JavaScript
import Component from '@glimmer/component';
|
|
import moment from 'moment';
|
|
import {action} from '@ember/object';
|
|
import {inject as service} from '@ember/service';
|
|
import {tracked} from '@glimmer/tracking';
|
|
|
|
export default class GhPublishmenuScheduledComponent extends Component {
|
|
@service clock;
|
|
@service session;
|
|
@service feature;
|
|
@service settings;
|
|
@service config;
|
|
|
|
// used to set minDate in datepicker
|
|
@tracked minDate = null;
|
|
|
|
get timeToPublished() {
|
|
let publishedAtUTC = this.args.post.publishedAtUTC;
|
|
|
|
if (!publishedAtUTC) {
|
|
return null;
|
|
}
|
|
|
|
this.clock.get('second');
|
|
|
|
return publishedAtUTC.toNow(true);
|
|
}
|
|
|
|
get selectedNewsletter() {
|
|
return this.args.availableNewsletters.find(n => n.id === this.args.post.newsletterId);
|
|
}
|
|
|
|
constructor() {
|
|
super(...arguments);
|
|
this.minDate = new Date();
|
|
}
|
|
|
|
@action
|
|
setSaveType(type) {
|
|
if (this.args.saveType !== type) {
|
|
this.minDate = new Date();
|
|
this.args.setSaveType(type);
|
|
|
|
// when draft switch to now to avoid validation errors
|
|
// when schedule switch back to saved date to avoid unnecessary re-scheduling
|
|
if (type === 'draft') {
|
|
this.args.post.set('publishedAtBlogTZ', new Date());
|
|
} else {
|
|
this.args.post.set('publishedAtBlogTZ', this.args.post.publishedAtUTC);
|
|
}
|
|
|
|
this.args.post.validate();
|
|
}
|
|
}
|
|
|
|
@action
|
|
setDate(date) {
|
|
let post = this.args.post;
|
|
let dateString = moment(date).format('YYYY-MM-DD');
|
|
|
|
post.set('publishedAtBlogDate', dateString);
|
|
return post.validate();
|
|
}
|
|
|
|
@action
|
|
setTime(time) {
|
|
let post = this.args.post;
|
|
|
|
if (!this.args.isClosing) {
|
|
post.set('publishedAtBlogTime', time);
|
|
return post.validate();
|
|
}
|
|
}
|
|
}
|