Support for choosing a destination category when splitting topics.
This commit is contained in:
@@ -25,31 +25,43 @@ Discourse.SplitTopicController = Discourse.ObjectController.extend(Discourse.Sel
|
||||
}.property('saving'),
|
||||
|
||||
onShow: function() {
|
||||
this.set('saving', false);
|
||||
this.setProperties({
|
||||
'controllers.modal.modalClass': 'split-modal',
|
||||
saving: false,
|
||||
categoryId: null,
|
||||
topicName: ''
|
||||
});
|
||||
},
|
||||
|
||||
movePostsToNewTopic: function() {
|
||||
this.set('saving', true);
|
||||
actions: {
|
||||
movePostsToNewTopic: function() {
|
||||
this.set('saving', true);
|
||||
|
||||
var postIds = this.get('selectedPosts').map(function(p) { return p.get('id'); }),
|
||||
replyPostIds = this.get('selectedReplies').map(function(p) { return p.get('id'); }),
|
||||
self = this;
|
||||
var postIds = this.get('selectedPosts').map(function(p) { return p.get('id'); }),
|
||||
replyPostIds = this.get('selectedReplies').map(function(p) { return p.get('id'); }),
|
||||
self = this,
|
||||
categoryId = this.get('categoryId'),
|
||||
saveOpts = {
|
||||
title: this.get('topicName'),
|
||||
post_ids: postIds,
|
||||
reply_post_ids: replyPostIds
|
||||
};
|
||||
|
||||
Discourse.Topic.movePosts(this.get('id'), {
|
||||
title: this.get('topicName'),
|
||||
post_ids: postIds,
|
||||
reply_post_ids: replyPostIds
|
||||
}).then(function(result) {
|
||||
// Posts moved
|
||||
self.send('closeModal');
|
||||
self.get('topicController').send('toggleMultiSelect');
|
||||
Em.run.next(function() { Discourse.URL.routeTo(result.url); });
|
||||
}, function() {
|
||||
// Error moving posts
|
||||
self.flash(I18n.t('topic.split_topic.error'));
|
||||
self.set('saving', false);
|
||||
});
|
||||
return false;
|
||||
if (!Ember.isNone(categoryId)) { saveOpts.category_id = categoryId; }
|
||||
|
||||
Discourse.Topic.movePosts(this.get('id'), saveOpts).then(function(result) {
|
||||
// Posts moved
|
||||
self.send('closeModal');
|
||||
self.get('topicController').send('toggleMultiSelect');
|
||||
Em.run.next(function() { Discourse.URL.routeTo(result.url); });
|
||||
}, function() {
|
||||
// Error moving posts
|
||||
self.flash(I18n.t('topic.split_topic.error'));
|
||||
self.set('saving', false);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user