mirror of
https://github.com/flarum/framework.git
synced 2025-04-26 14:44:03 +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) {
|
populateControls: function(items) {
|
||||||
|
this.addActionItem(items, 'delete', 'Delete', 'times', 'discussion.canDelete');
|
||||||
},
|
},
|
||||||
|
|
||||||
populateInfo: function(items) {
|
populateInfo: function(items) {
|
||||||
@ -78,10 +78,19 @@ export default Ember.Component.extend(FadeIn, HasItemLists, {
|
|||||||
},
|
},
|
||||||
|
|
||||||
markAsRead: function() {
|
markAsRead: function() {
|
||||||
if (this.get('discussion.isUnread')) {
|
var discussion = this.get('discussion');
|
||||||
|
if (discussion.get('isUnread')) {
|
||||||
discussion.set('readNumber', discussion.get('lastPostNumber'));
|
discussion.set('readNumber', discussion.get('lastPostNumber'));
|
||||||
discussion.save();
|
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('meta', results.get('meta'));
|
||||||
controller.set('resultsLoading', false);
|
controller.set('resultsLoading', false);
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
|
||||||
|
discussionRemoved: function(discussion) {
|
||||||
|
var model = this.get('model');
|
||||||
|
model.removeObject(model.findBy('content', discussion));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -32,7 +32,8 @@
|
|||||||
discussion=discussion
|
discussion=discussion
|
||||||
searchQuery=index.searchQuery
|
searchQuery=index.searchQuery
|
||||||
terminalPostType=index.terminalPostType
|
terminalPostType=index.terminalPostType
|
||||||
countType=index.countType}}
|
countType=index.countType
|
||||||
|
discussionRemoved="discussionRemoved"}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user