2015-07-15 12:30:11 +08:00
|
|
|
import Model from 'flarum/Model';
|
|
|
|
import mixin from 'flarum/utils/mixin';
|
2015-04-25 20:58:39 +08:00
|
|
|
import computed from 'flarum/utils/computed';
|
2015-07-15 12:30:11 +08:00
|
|
|
import { getPlainContent } from 'flarum/utils/string';
|
2015-04-25 20:58:39 +08:00
|
|
|
|
2015-10-13 14:27:18 +08:00
|
|
|
export default class Post extends Model {}
|
|
|
|
|
|
|
|
Object.assign(Post.prototype, {
|
2015-07-15 12:30:11 +08:00
|
|
|
number: Model.attribute('number'),
|
|
|
|
discussion: Model.hasOne('discussion'),
|
2015-04-25 20:58:39 +08:00
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
time: Model.attribute('time', Model.transformDate),
|
|
|
|
user: Model.hasOne('user'),
|
|
|
|
contentType: Model.attribute('contentType'),
|
|
|
|
content: Model.attribute('content'),
|
|
|
|
contentHtml: Model.attribute('contentHtml'),
|
|
|
|
contentPlain: computed('contentHtml', getPlainContent),
|
2015-04-25 20:58:39 +08:00
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
editTime: Model.attribute('editTime', Model.transformDate),
|
|
|
|
editUser: Model.hasOne('editUser'),
|
|
|
|
isEdited: computed('editTime', editTime => !!editTime),
|
2015-04-25 20:58:39 +08:00
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
hideTime: Model.attribute('hideTime', Model.transformDate),
|
|
|
|
hideUser: Model.hasOne('hideUser'),
|
|
|
|
isHidden: computed('hideTime', hideTime => !!hideTime),
|
2015-04-25 20:58:39 +08:00
|
|
|
|
2015-07-15 12:30:11 +08:00
|
|
|
canEdit: Model.attribute('canEdit'),
|
|
|
|
canDelete: Model.attribute('canDelete')
|
2015-10-13 14:27:18 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
export default Post;
|