mirror of
https://github.com/flarum/framework.git
synced 2024-11-23 07:18:31 +08:00
Implement discussion deletion
This commit is contained in:
parent
b97887b612
commit
7001c83fb3
|
@ -55,7 +55,7 @@ export default Ember.Component.extend(FadeIn, HasItemLists, {
|
|||
}),
|
||||
|
||||
populateControls: function(items) {
|
||||
|
||||
this.addActionItem(items, 'delete', 'Delete', 'times', 'discussion.canDelete');
|
||||
},
|
||||
|
||||
populateInfo: function(items) {
|
||||
|
@ -78,10 +78,19 @@ export default Ember.Component.extend(FadeIn, HasItemLists, {
|
|||
},
|
||||
|
||||
markAsRead: function() {
|
||||
if (this.get('discussion.isUnread')) {
|
||||
var discussion = this.get('discussion');
|
||||
if (discussion.get('isUnread')) {
|
||||
discussion.set('readNumber', discussion.get('lastPostNumber'));
|
||||
discussion.save();
|
||||
}
|
||||
},
|
||||
|
||||
delete: function() {
|
||||
if (confirm('Are you sure you want to delete this discussion?')) {
|
||||
var discussion = this.get('discussion.content');
|
||||
discussion.destroyRecord();
|
||||
this.sendAction('discussionRemoved', discussion);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -54,6 +54,13 @@ export default Ember.Controller.extend(UseComposer, Paneable, {
|
|||
}
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
discussionRemoved: function(discussion) {
|
||||
if (this.get('controllers.discussion.model') === discussion) {
|
||||
this.transitionToRoute('index');
|
||||
}
|
||||
this.get('index').send('discussionRemoved', discussion);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -104,6 +104,11 @@ export default Ember.Controller.extend({
|
|||
controller.set('meta', results.get('meta'));
|
||||
controller.set('resultsLoading', false);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
discussionRemoved: function(discussion) {
|
||||
var model = this.get('model');
|
||||
model.removeObject(model.findBy('content', discussion));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -32,7 +32,8 @@
|
|||
discussion=discussion
|
||||
searchQuery=index.searchQuery
|
||||
terminalPostType=index.terminalPostType
|
||||
countType=index.countType}}
|
||||
countType=index.countType
|
||||
discussionRemoved="discussionRemoved"}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user