UX: Remove drag and drop reordering of categories. It was not working

perfectly and you can re-order using the modal number.
This commit is contained in:
Robin Ward 2014-08-12 17:14:02 -04:00
parent 11e43bd434
commit f1572a43e1
4 changed files with 2 additions and 63 deletions

View file

@ -5,10 +5,6 @@ export default Discourse.DiscoveryController.extend({
showPostsColumn: Em.computed.empty('withLogo'), showPostsColumn: Em.computed.empty('withLogo'),
actions: { actions: {
toggleOrdering: function(){
this.set("ordering",!this.get("ordering"));
},
refresh: function() { refresh: function() {
var self = this; var self = this;
@ -27,13 +23,6 @@ export default Discourse.DiscoveryController.extend({
return Discourse.User.currentProp('staff'); return Discourse.User.currentProp('staff');
}.property(), }.property(),
fixedCategoryPositions: Discourse.computed.setting('fixed_category_positions'),
canOrder: Em.computed.and('fixedCategoryPositions', 'canEdit'),
moveCategory: function(categoryId, position){
this.get('model.categories').moveCategory(categoryId, position);
},
latestTopicOnly: function() { latestTopicOnly: function() {
return this.get('categories').find(function(c) { return c.get('featuredTopics.length') > 1; }) === undefined; return this.get('categories').find(function(c) { return c.get('featuredTopics.length') > 1; }) === undefined;
}.property('categories.@each.featuredTopics.length') }.property('categories.@each.featuredTopics.length')

View file

@ -10,13 +10,6 @@ Discourse.CategoryList = Ember.ArrayProxy.extend({
init: function() { init: function() {
this.content = []; this.content = [];
this._super(); this._super();
},
moveCategory: function(categoryId, position){
Discourse.ajax("/category/" + categoryId + "/move", {
type: 'POST',
data: { position: position }
});
} }
}); });

View file

@ -7,9 +7,7 @@
<th class='latest'>{{i18n categories.latest}}</th> <th class='latest'>{{i18n categories.latest}}</th>
<th class='stats topics'>{{i18n categories.topics}}</th> <th class='stats topics'>{{i18n categories.topics}}</th>
{{#if showPostsColumn}} {{#if showPostsColumn}}
<th class='stats posts'>{{i18n categories.posts}} <th class='stats posts'>{{i18n categories.posts}}</th>
{{#if canOrder}}<button title='{{i18n categories.toggle_ordering}}' class='btn toggle-admin no-text' {{action toggleOrdering}}><i class='fa fa-wrench'></i></button>{{/if}}
</th>
{{/if}} {{/if}}
</tr> </tr>
</thead> </thead>
@ -19,7 +17,6 @@
<td class='category' style="border-color: #{{unbound color}}"> <td class='category' style="border-color: #{{unbound color}}">
<div> <div>
<div class="pull-left"> <div class="pull-left">
{{#if controller.ordering}}<i class="fa fa-bars"></i>{{/if}}
{{category-title-link category=this}} {{category-title-link category=this}}
{{#if unreadTopics}} {{#if unreadTopics}}
<a href={{unbound unreadUrl}} class='badge new-posts badge-notification' title='{{i18n topic.unread_topics count="unreadTopics"}}'>{{i18n filters.unread.lower_title_with_count count="unreadTopics"}}</a> <a href={{unbound unreadUrl}} class='badge new-posts badge-notification' title='{{i18n topic.unread_topics count="unreadTopics"}}'>{{i18n filters.unread.lower_title_with_count count="unreadTopics"}}</a>

View file

@ -1,43 +1,3 @@
import UrlRefresh from 'discourse/mixins/url-refresh'; import UrlRefresh from 'discourse/mixins/url-refresh';
export default Discourse.View.extend(UrlRefresh, { export default Discourse.View.extend(UrlRefresh, Discourse.ScrollTop);
orderingChanged: function(){
if (this.get("controller.ordering")) {
this.enableOrdering();
} else {
this.disableOrdering();
}
}.observes("controller.ordering"),
rows: function() {
return $('.topic-list tbody');
},
enableOrdering: function(){
var self = this;
Em.run.next(function(){
self.rows().sortable({handle: '.fa-bars'}).on('sortupdate',function(evt, data){
var tr = $(data.item);
var categoryId = tr.data('category_id');
var position = self.rows().find('tr').index(tr[0]);
self.get('controller').moveCategory(categoryId, position);
});
});
},
_scrollTop: function() {
Em.run.schedule('afterRender', function() {
$(document).scrollTop(0);
});
}.on('didInsertElement'),
disableOrdering: function(){
this.rows().sortable("destroy").off('sortupdate');
},
willDestroyElement: function(){
this.disableOrdering();
}
});