mirror of
https://github.com/discourse/discourse.git
synced 2025-02-16 16:02:45 +08:00
![Régis Hanol](/assets/img/avatar_default.png)
- new "show-footer" mixins - converted most of the routes to ES6 - FIX: handling of "indexStream" in user pages There will now be a footer on all the following pages - /exception - /about - /latest - /new - /unread - /starred - /top - /categories - /c/:category - /c/:category/l/latest - /c/:category/l/new - /c/:category/l/unread - /c/:category/l/top - /t/:topic/:id - /groups/:name/members - /user/activity - /user/activity/topics - /user/activity/posts - /user/activity/replies - /user/activity/likes-given - /user/activity/likes-received - /user/activity/bookmarks - /user/activity/starred - /user/badges - /user/notifications - /user/flagged-posts - /user/deleted-posts - /user/private-messages - /user/private-messages/mine - /user/private-messages/unread - /user/invited - /user/:username/preferences - /faq (static pages) - /badges - /badges/:id/:badge
73 lines
2.1 KiB
JavaScript
73 lines
2.1 KiB
JavaScript
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
|
import ObjectController from 'discourse/controllers/object';
|
|
|
|
// Modal related to auto closing of topics
|
|
export default ObjectController.extend(Discourse.SelectedPostsCount, ModalFunctionality, {
|
|
needs: ['topic'],
|
|
|
|
topicController: Em.computed.alias('controllers.topic'),
|
|
selectedPosts: Em.computed.alias('topicController.selectedPosts'),
|
|
selectedReplies: Em.computed.alias('topicController.selectedReplies'),
|
|
|
|
buttonDisabled: function() {
|
|
if (this.get('saving')) return true;
|
|
return this.blank('topicName');
|
|
}.property('saving', 'topicName'),
|
|
|
|
buttonTitle: function() {
|
|
if (this.get('saving')) return I18n.t('saving');
|
|
return I18n.t('topic.split_topic.action');
|
|
}.property('saving'),
|
|
|
|
onShow: function() {
|
|
this.setProperties({
|
|
'controllers.modal.modalClass': 'split-modal',
|
|
saving: false,
|
|
categoryId: null,
|
|
topicName: ''
|
|
});
|
|
},
|
|
|
|
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,
|
|
categoryId = this.get('categoryId'),
|
|
saveOpts = {
|
|
title: this.get('topicName'),
|
|
post_ids: postIds,
|
|
reply_post_ids: replyPostIds
|
|
};
|
|
|
|
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); });
|
|
}).catch(function(xhr) {
|
|
|
|
var error = I18n.t('topic.split_topic.error');
|
|
|
|
if (xhr) {
|
|
var json = xhr.responseJSON;
|
|
if (json && json.errors) {
|
|
error = json.errors[0];
|
|
}
|
|
}
|
|
|
|
// Error moving posts
|
|
self.flash(error);
|
|
self.set('saving', false);
|
|
});
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
});
|