2015-06-13 17:34:09 +03:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
const {Component, computed} = Ember;
|
|
|
|
|
|
|
|
export default Component.extend({
|
2015-06-13 17:34:09 +03:00
|
|
|
tagName: 'section',
|
|
|
|
classNames: ['splitbtn', 'js-publish-splitbutton'],
|
|
|
|
classNameBindings: ['isNew:unsaved'],
|
|
|
|
|
|
|
|
isNew: null,
|
|
|
|
isPublished: null,
|
|
|
|
willPublish: null,
|
|
|
|
postOrPage: null,
|
2015-08-10 18:43:49 +03:00
|
|
|
submitting: false,
|
2015-06-13 17:34:09 +03:00
|
|
|
|
|
|
|
// Tracks whether we're going to change the state of the post on save
|
2015-10-28 14:36:45 +03:00
|
|
|
isDangerous: computed('isPublished', 'willPublish', function () {
|
2015-06-13 17:34:09 +03:00
|
|
|
return this.get('isPublished') !== this.get('willPublish');
|
|
|
|
}),
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
publishText: computed('isPublished', 'postOrPage', function () {
|
|
|
|
return this.get('isPublished') ? `Update ${this.get('postOrPage')}` : 'Publish Now';
|
2015-06-13 17:34:09 +03:00
|
|
|
}),
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
draftText: computed('isPublished', function () {
|
2015-06-13 17:34:09 +03:00
|
|
|
return this.get('isPublished') ? 'Unpublish' : 'Save Draft';
|
|
|
|
}),
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
deleteText: computed('postOrPage', function () {
|
|
|
|
return `Delete ${this.get('postOrPage')}`;
|
2015-06-13 17:34:09 +03:00
|
|
|
}),
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
saveText: computed('willPublish', 'publishText', 'draftText', function () {
|
2015-06-13 17:34:09 +03:00
|
|
|
return this.get('willPublish') ? this.get('publishText') : this.get('draftText');
|
|
|
|
}),
|
|
|
|
|
|
|
|
actions: {
|
2015-10-28 14:36:45 +03:00
|
|
|
save() {
|
2015-06-13 17:34:09 +03:00
|
|
|
this.sendAction('save');
|
|
|
|
},
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
setSaveType(saveType) {
|
2015-06-13 17:34:09 +03:00
|
|
|
this.sendAction('setSaveType', saveType);
|
|
|
|
},
|
|
|
|
|
2015-10-28 14:36:45 +03:00
|
|
|
delete() {
|
2015-06-13 17:34:09 +03:00
|
|
|
this.sendAction('delete');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|