Remove modal state to choose move type. Instead use two buttons on the multi select popup, one

for split and one for merge.
This commit is contained in:
Robin Ward 2013-05-16 14:22:41 -04:00
parent 1e9497d9ef
commit 7daca77443
9 changed files with 44 additions and 81 deletions

View file

@ -72,11 +72,22 @@ Discourse.TopicController = Discourse.ObjectController.extend(Discourse.Selected
this.toggleProperty('summaryCollapsed'); this.toggleProperty('summaryCollapsed');
}, },
moveSelected: function() { splitTopic: function() {
var modalController = this.get('controllers.modal'); var modalController = this.get('controllers.modal');
if (!modalController) return; if (!modalController) return;
modalController.show(Discourse.MoveSelectedView.create({ modalController.show(Discourse.SplitTopicView.create({
topicController: this,
topic: this.get('content'),
selectedPosts: this.get('selectedPosts')
}));
},
mergeTopic: function() {
var modalController = this.get('controllers.modal');
if (!modalController) return;
modalController.show(Discourse.MergeTopicView.create({
topicController: this, topicController: this,
topic: this.get('content'), topic: this.get('content'),
selectedPosts: this.get('selectedPosts') selectedPosts: this.get('selectedPosts')

View file

@ -5,7 +5,7 @@
</div> </div>
{{/if}} {{/if}}
<p>{{{i18n topic.move_selected.existing_topic.instructions count="view.selectedPostsCount"}}}</p> <p>{{{i18n topic.merge_topic.instructions count="view.selectedPostsCount"}}}</p>
{{view Discourse.ChooseTopicView selectedTopicIdBinding="view.selectedTopicId"}} {{view Discourse.ChooseTopicView selectedTopicIdBinding="view.selectedTopicId"}}
</div> </div>

View file

@ -1,8 +0,0 @@
<div id='move-selected' class="modal-body">
<p>{{{i18n topic.move_selected.instructions count="view.selectedPostsCount"}}}</p>
<button {{action showMoveNewTopic target="view"}} class="btn">{{i18n topic.move_selected.new_topic.title}}</button>
<button {{action showMoveExistingTopic target="view"}} class="btn">{{i18n topic.move_selected.existing_topic.title}}</button>
</div>

View file

@ -5,10 +5,10 @@
</div> </div>
{{/if}} {{/if}}
{{{i18n topic.move_selected.new_topic.instructions count="view.selectedPostsCount"}}} {{{i18n topic.split_topic.instructions count="view.selectedPostsCount"}}}
<form> <form>
<label>{{i18n topic.move_selected.new_topic.topic_name}}</label> <label>{{i18n topic.split_topic.topic_name}}</label>
{{view Discourse.TextField valueBinding="view.topicName" placeholderKey="composer.title_placeholder"}} {{view Discourse.TextField valueBinding="view.topicName" placeholderKey="composer.title_placeholder"}}
</form> </form>

View file

@ -5,7 +5,8 @@
{{/if}} {{/if}}
{{#if canMoveSelected}} {{#if canMoveSelected}}
<button class='btn' {{action moveSelected}}><i class='icon icon-move'></i> {{i18n topic.multi_select.move}}</button> <button class='btn' {{action splitTopic}}><i class='icon icon-move'></i> {{i18n topic.split_topic.action}}</button>
<button class='btn' {{action mergeTopic}}><i class='icon icon-move'></i> {{i18n topic.merge_topic.action}}}</button>
{{/if}} {{/if}}
<p class='cancel'><a href='#' {{action toggleMultiSelect}}>{{i18n topic.multi_select.cancel}}</a></p> <p class='cancel'><a href='#' {{action toggleMultiSelect}}>{{i18n topic.multi_select.cancel}}</a></p>

View file

@ -1,14 +1,14 @@
/** /**
A modal view for handling moving of posts to an existing topic A modal view for handling moving of posts to an existing topic
@class MoveSelectedExistingTopicView @class MergeTopicView
@extends Discourse.ModalBodyView @extends Discourse.ModalBodyView
@namespace Discourse @namespace Discourse
@module Discourse @module Discourse
**/ **/
Discourse.MoveSelectedExistingTopicView = Discourse.ModalBodyView.extend(Discourse.SelectedPostsCount, { Discourse.MergeTopicView = Discourse.ModalBodyView.extend(Discourse.SelectedPostsCount, {
templateName: 'modal/move_selected_existing_topic', templateName: 'modal/merge_topic',
title: Em.String.i18n('topic.move_selected.existing_topic.title'), title: Em.String.i18n('topic.merge_topic.title'),
buttonDisabled: function() { buttonDisabled: function() {
if (this.get('saving')) return true; if (this.get('saving')) return true;
@ -17,7 +17,7 @@ Discourse.MoveSelectedExistingTopicView = Discourse.ModalBodyView.extend(Discour
buttonTitle: function() { buttonTitle: function() {
if (this.get('saving')) return Em.String.i18n('saving'); if (this.get('saving')) return Em.String.i18n('saving');
return Em.String.i18n('topic.move_selected.title'); return Em.String.i18n('topic.merge_topic.title');
}.property('saving'), }.property('saving'),
movePostsToExistingTopic: function() { movePostsToExistingTopic: function() {
@ -36,7 +36,7 @@ Discourse.MoveSelectedExistingTopicView = Discourse.ModalBodyView.extend(Discour
Em.run.next(function() { Discourse.URL.routeTo(result.url); }); Em.run.next(function() { Discourse.URL.routeTo(result.url); });
}, function() { }, function() {
// Error moving posts // Error moving posts
moveSelectedView.flash(Em.String.i18n('topic.move_selected.error')); moveSelectedView.flash(Em.String.i18n('topic.merge_topic.error'));
moveSelectedView.set('saving', false); moveSelectedView.set('saving', false);
}); });
return false; return false;

View file

@ -1,37 +0,0 @@
/**
A modal view for handling moving of posts.
@class MoveSelectedView
@extends Discourse.ModalBodyView
@namespace Discourse
@module Discourse
**/
Discourse.MoveSelectedView = Discourse.ModalBodyView.extend(Discourse.SelectedPostsCount, {
templateName: 'modal/move_selected',
title: Em.String.i18n('topic.move_selected.title'),
showMoveNewTopic: function() {
var modalController = this.get('controller');
if (!modalController) return;
modalController.show(Discourse.MoveSelectedNewTopicView.create({
topicController: this.get('topicController'),
topic: this.get('topic'),
selectedPosts: this.get('selectedPosts')
}));
},
showMoveExistingTopic: function() {
var modalController = this.get('controller');
if (!modalController) return;
modalController.show(Discourse.MoveSelectedExistingTopicView.create({
topicController: this.get('topicController'),
topic: this.get('topic'),
selectedPosts: this.get('selectedPosts')
}));
}
});

View file

@ -1,14 +1,14 @@
/** /**
A modal view for handling moving of posts to a new topic A modal view for handling moving of posts to a new topic
@class MoveSelectedNewTopicView @class SplitTopicView
@extends Discourse.ModalBodyView @extends Discourse.ModalBodyView
@namespace Discourse @namespace Discourse
@module Discourse @module Discourse
**/ **/
Discourse.MoveSelectedNewTopicView = Discourse.ModalBodyView.extend(Discourse.SelectedPostsCount, { Discourse.SplitTopicView = Discourse.ModalBodyView.extend(Discourse.SelectedPostsCount, {
templateName: 'modal/move_selected_new_topic', templateName: 'modal/split_topic',
title: Em.String.i18n('topic.move_selected.new_topic.title'), title: Em.String.i18n('topic.split_topic.title'),
saving: false, saving: false,
buttonDisabled: function() { buttonDisabled: function() {
@ -18,7 +18,7 @@ Discourse.MoveSelectedNewTopicView = Discourse.ModalBodyView.extend(Discourse.Se
buttonTitle: function() { buttonTitle: function() {
if (this.get('saving')) return Em.String.i18n('saving'); if (this.get('saving')) return Em.String.i18n('saving');
return Em.String.i18n('topic.move_selected.title'); return Em.String.i18n('topic.split_topic.action');
}.property('saving'), }.property('saving'),
movePostsToNewTopic: function() { movePostsToNewTopic: function() {
@ -37,7 +37,7 @@ Discourse.MoveSelectedNewTopicView = Discourse.ModalBodyView.extend(Discourse.Se
Em.run.next(function() { Discourse.URL.routeTo(result.url); }); Em.run.next(function() { Discourse.URL.routeTo(result.url); });
}, function() { }, function() {
// Error moving posts // Error moving posts
moveSelectedView.flash(Em.String.i18n('topic.move_selected.error')); moveSelectedView.flash(Em.String.i18n('topic.split_topic.error'));
moveSelectedView.set('saving', false); moveSelectedView.set('saving', false);
}); });
return false; return false;

View file

@ -601,32 +601,28 @@ en:
other: "of {{count}} in the topic" other: "of {{count}} in the topic"
cancel: "Show all posts in this topic again." cancel: "Show all posts in this topic again."
move_selected: split_topic:
title: "Move Selected Posts" title: "Split Topic"
error: "Sorry, there was an error moving those posts." action: "split topic"
topic_name: "New Topic Name:"
error: "There was an error splitting that topic."
instructions: instructions:
one: "How would you like to move this post?" one: "You are about to create a new topic and populate it with the post you've selected."
other: "How would you like to move the <b>{{count}}</b> posts you've selected?" other: "You are about to create a new topic and populate it with the <b>{{count}}</b> posts you've selected."
new_topic: merge_topic:
title: "Move Selected Posts to a New Topic" title: "Merge Topic"
topic_name: "New Topic Name:" action: "merge topic"
instructions: error: "There was an error merging that topic."
one: "You are about to create a new topic and populate it with the post you've selected." instructions:
other: "You are about to create a new topic and populate it with the <b>{{count}}</b> posts you've selected." one: "Please choose the topic you'd like to move that post to."
other: "Please choose the topic you'd like to move those <b>{{count}}</b> posts to."
existing_topic:
title: "Move Selected Posts to an Existing Topic"
instructions:
one: "Please choose the topic you'd like to move that post to."
other: "Please choose the topic you'd like to move those <b>{{count}}</b> posts to."
multi_select: multi_select:
select: 'select' select: 'select'
selected: 'selected ({{count}})' selected: 'selected ({{count}})'
delete: delete selected delete: delete selected
cancel: cancel selecting cancel: cancel selecting
move: move selected
description: description:
one: You have selected <b>1</b> post. one: You have selected <b>1</b> post.
other: "You have selected <b>{{count}}</b> posts." other: "You have selected <b>{{count}}</b> posts."