2017-08-22 10:53:26 +03:00
|
|
|
import Component from '@ember/component';
|
2017-08-29 14:33:13 +03:00
|
|
|
import Ember from 'ember';
|
2017-08-22 10:53:26 +03:00
|
|
|
import {computed} from '@ember/object';
|
|
|
|
import {reads} from '@ember/object/computed';
|
2017-05-29 21:50:03 +03:00
|
|
|
import {task, timeout} from 'ember-concurrency';
|
2017-04-11 16:39:45 +03:00
|
|
|
|
|
|
|
export default Component.extend({
|
|
|
|
post: null,
|
|
|
|
isSaving: false,
|
|
|
|
|
|
|
|
'data-test-editor-post-status': true,
|
|
|
|
|
|
|
|
_isSaving: false,
|
|
|
|
|
2018-01-11 20:43:23 +03:00
|
|
|
isNew: reads('post.isNew'),
|
|
|
|
isScheduled: reads('post.isScheduled'),
|
|
|
|
|
2017-04-11 16:39:45 +03:00
|
|
|
isPublished: computed('post.{isPublished,pastScheduledTime}', function () {
|
|
|
|
let isPublished = this.get('post.isPublished');
|
|
|
|
let pastScheduledTime = this.get('post.pastScheduledTime');
|
|
|
|
|
|
|
|
return isPublished || pastScheduledTime;
|
|
|
|
}),
|
|
|
|
|
|
|
|
// isSaving will only be true briefly whilst the post is saving,
|
|
|
|
// we want to ensure that the "Saving..." message is shown for at least
|
|
|
|
// a few seconds so that it's noticeable
|
|
|
|
didReceiveAttrs() {
|
|
|
|
if (this.get('isSaving')) {
|
|
|
|
this.get('showSavingMessage').perform();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
showSavingMessage: task(function* () {
|
|
|
|
this.set('_isSaving', true);
|
2018-01-02 13:19:59 +03:00
|
|
|
yield timeout(Ember.testing ? 0 : 3000); // eslint-disable-line
|
2017-04-11 16:39:45 +03:00
|
|
|
this.set('_isSaving', false);
|
|
|
|
}).drop()
|
|
|
|
});
|