mirror of
https://github.com/flarum/core.git
synced 2025-08-13 03:44:32 +02:00
Implement post editing
This commit is contained in:
@@ -35,6 +35,7 @@ var Discussion = DS.Model.extend({
|
||||
var posts = this.get('posts') || '';
|
||||
return posts.split(',');
|
||||
}.property('posts'),
|
||||
loadedPosts: DS.hasMany('post'),
|
||||
|
||||
readTime: DS.attr('date'),
|
||||
readNumber: DS.attr('number'),
|
||||
|
@@ -42,17 +42,6 @@ export default Ember.ArrayProxy.extend(Ember.Evented, {
|
||||
// stream to a big gap that covers the amount of posts we now have.
|
||||
this.set('ids', ids);
|
||||
this.clear();
|
||||
|
||||
// Look in the store and see if we already have the data for any of
|
||||
// these posts. If we do, we can add them to the stream.
|
||||
var posts = [];
|
||||
var store = this.get('store');
|
||||
ids.forEach(function(id) {
|
||||
if (store.hasRecordForId('post', id)) {
|
||||
posts.pushObject(store.getById('post', id));
|
||||
}
|
||||
});
|
||||
this.addPosts(posts);
|
||||
},
|
||||
|
||||
// Clear the contents of the post stream, resetting it to one big gap.
|
||||
|
@@ -3,22 +3,22 @@ import DS from 'ember-data';
|
||||
|
||||
export default DS.Model.extend({
|
||||
|
||||
discussion: DS.belongsTo('discussion', {inverse: null}),
|
||||
discussion: DS.belongsTo('discussion', {inverse: 'loadedPosts'}),
|
||||
number: DS.attr('number'),
|
||||
|
||||
time: DS.attr('string'),
|
||||
time: DS.attr('date'),
|
||||
user: DS.belongsTo('user'),
|
||||
type: DS.attr('string'),
|
||||
content: DS.attr('string'),
|
||||
contentHtml: DS.attr('string'),
|
||||
|
||||
editTime: DS.attr('string'),
|
||||
editTime: DS.attr('date'),
|
||||
editUser: DS.belongsTo('user'),
|
||||
edited: Ember.computed.notEmpty('editTime'),
|
||||
isEdited: Ember.computed.notEmpty('editTime'),
|
||||
|
||||
deleteTime: DS.attr('string'),
|
||||
deleteTime: DS.attr('date'),
|
||||
deleteUser: DS.belongsTo('user'),
|
||||
deleted: Ember.computed.notEmpty('deleteTime'),
|
||||
isDeleted: Ember.computed.notEmpty('deleteTime'),
|
||||
|
||||
canEdit: DS.attr('boolean'),
|
||||
canDelete: DS.attr('boolean')
|
||||
|
Reference in New Issue
Block a user