mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-15 11:34:24 +03:00
1d6b1f9667
Closes #3955 - Change titleScratch from being bound to the title to being set when entering the editor so it is not overwritten on a model refresh. - Ensure that the "unsaved content" dialog is shown when there are changes to the "scratch" fields after a post-settings-menu change. - Add tests to prevent regression.
47 lines
1.7 KiB
JavaScript
47 lines
1.7 KiB
JavaScript
import ValidationEngine from 'ghost/mixins/validation-engine';
|
|
import NProgressSaveMixin from 'ghost/mixins/nprogress-save';
|
|
|
|
var Post = DS.Model.extend(NProgressSaveMixin, ValidationEngine, {
|
|
validationType: 'post',
|
|
|
|
uuid: DS.attr('string'),
|
|
title: DS.attr('string', {defaultValue: ''}),
|
|
slug: DS.attr('string'),
|
|
markdown: DS.attr('string', {defaultValue: ''}),
|
|
html: DS.attr('string'),
|
|
image: DS.attr('string'),
|
|
featured: DS.attr('boolean', {defaultValue: false}),
|
|
page: DS.attr('boolean', {defaultValue: false}),
|
|
status: DS.attr('string', {defaultValue: 'draft'}),
|
|
language: DS.attr('string', {defaultValue: 'en_US'}),
|
|
meta_title: DS.attr('string'),
|
|
meta_description: DS.attr('string'),
|
|
author: DS.belongsTo('user', { async: true }),
|
|
author_id: DS.attr('number'),
|
|
updated_at: DS.attr('moment-date'),
|
|
published_at: DS.attr('moment-date'),
|
|
published_by: DS.belongsTo('user', { async: true }),
|
|
tags: DS.hasMany('tag', { embedded: 'always' }),
|
|
//## Computed post properties
|
|
isPublished: Ember.computed.equal('status', 'published'),
|
|
isDraft: Ember.computed.equal('status', 'draft'),
|
|
|
|
// remove client-generated tags, which have `id: null`.
|
|
// Ember Data won't recognize/update them automatically
|
|
// when returned from the server with ids.
|
|
updateTags: function () {
|
|
var tags = this.get('tags'),
|
|
oldTags = tags.filterBy('id', null);
|
|
|
|
tags.removeObjects(oldTags);
|
|
oldTags.invoke('deleteRecord');
|
|
},
|
|
|
|
isAuthoredByUser: function (user) {
|
|
return parseInt(user.get('id'), 10) === parseInt(this.get('author_id'), 10);
|
|
}
|
|
|
|
});
|
|
|
|
export default Post;
|