This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/controllers/merge-topic.js.es6
Régis Hanol 0947191060 UX: improved our footer handling
- 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
2014-11-19 20:37:43 +01:00

61 lines
2.1 KiB
JavaScript

import ModalFunctionality from 'discourse/mixins/modal-functionality';
import ObjectController from 'discourse/controllers/object';
// Modal related to merging 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'),
allPostsSelected: Em.computed.alias('topicController.allPostsSelected'),
buttonDisabled: function() {
if (this.get('saving')) return true;
return this.blank('selectedTopicId');
}.property('selectedTopicId', 'saving'),
buttonTitle: function() {
if (this.get('saving')) return I18n.t('saving');
return I18n.t('topic.merge_topic.title');
}.property('saving'),
onShow: function() {
this.set('controllers.modal.modalClass', 'split-modal');
},
actions: {
movePostsToExistingTopic: function() {
this.set('saving', true);
var promise = null;
if (this.get('allPostsSelected')) {
promise = Discourse.Topic.mergeTopic(this.get('id'), this.get('selectedTopicId'));
} else {
var postIds = this.get('selectedPosts').map(function(p) { return p.get('id'); }),
replyPostIds = this.get('selectedReplies').map(function(p) { return p.get('id'); });
promise = Discourse.Topic.movePosts(this.get('id'), {
destination_topic_id: this.get('selectedTopicId'),
post_ids: postIds,
reply_post_ids: replyPostIds
});
}
var mergeTopicController = this;
promise.then(function(result) {
// Posts moved
mergeTopicController.send('closeModal');
mergeTopicController.get('topicController').send('toggleMultiSelect');
Em.run.next(function() { Discourse.URL.routeTo(result.url); });
}, function() {
// Error moving posts
mergeTopicController.flash(I18n.t('topic.merge_topic.error'));
mergeTopicController.set('saving', false);
});
return false;
}
}
});