mirror of
https://github.com/flarum/framework.git
synced 2024-11-29 04:33:47 +08:00
e3569d39cc
PhpStorm/WebStorm doesn't like the mixin syntax, and it's clearer to just use Object.assign.
32 lines
1.0 KiB
JavaScript
32 lines
1.0 KiB
JavaScript
import Model from 'flarum/Model';
|
|
import mixin from 'flarum/utils/mixin';
|
|
import computed from 'flarum/utils/computed';
|
|
import { getPlainContent } from 'flarum/utils/string';
|
|
|
|
export default class Post extends Model {}
|
|
|
|
Object.assign(Post.prototype, {
|
|
number: Model.attribute('number'),
|
|
discussion: Model.hasOne('discussion'),
|
|
|
|
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),
|
|
|
|
editTime: Model.attribute('editTime', Model.transformDate),
|
|
editUser: Model.hasOne('editUser'),
|
|
isEdited: computed('editTime', editTime => !!editTime),
|
|
|
|
hideTime: Model.attribute('hideTime', Model.transformDate),
|
|
hideUser: Model.hasOne('hideUser'),
|
|
isHidden: computed('hideTime', hideTime => !!hideTime),
|
|
|
|
canEdit: Model.attribute('canEdit'),
|
|
canDelete: Model.attribute('canDelete')
|
|
});
|
|
|
|
export default Post;
|