Skip to content

Commit

Permalink
Sort tag followings alphabetically, not in reverse, fixes diaspora#3986
Browse files Browse the repository at this point in the history
  • Loading branch information
jhass committed Feb 24, 2013
1 parent 5d46baf commit 6bb644f
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 5 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Move custom splash page logic into the controller [#3991](https://github.com/diaspora/diaspora/issues/3991)
* Fixed removing images from publisher on the profile and tags pages. [#3995](https://github.com/diaspora/diaspora/pull/3995)
* Wrap text if too long in mobile notifications. [#3990](https://github.com/diaspora/diaspora/pull/3990)
* Sort tag followings alphabetically, not in reverse [#3986](https://github.com/diaspora/diaspora/issues/3986)

# 0.0.3.0

Expand Down
4 changes: 3 additions & 1 deletion app/assets/javascripts/app/collections/tag_followings.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
app.collections.TagFollowings = Backbone.Collection.extend({

model: app.models.TagFollowing,

url : "/tag_followings",
comparator: function(first_tf, second_tf) {
return first_tf.get("name") < second_tf.get("name");
},

create : function(model) {
var name = model.name || model.get("name");
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/app/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ app.Router = Backbone.Router.extend({
$("#tags_list").replaceWith(followedTagsView.render().el);
followedTagsView.setupAutoSuggest();

app.tagFollowings.add(preloads.tagFollowings);
app.tagFollowings.reset(preloads.tagFollowings);

if(name) {
var followedTagsAction = new app.views.TagFollowingAction(
Expand Down
5 changes: 3 additions & 2 deletions app/assets/javascripts/app/views/tag_following_list_view.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ app.views.TagFollowingList = app.views.Base.extend({
},

initialize : function(){
this.collection.bind("add", this.appendTagFollowing, this);
this.collection.on("add", this.appendTagFollowing, this);
this.collection.on("reset", this.postRenderTemplate, this);
},

postRenderTemplate : function() {
Expand Down Expand Up @@ -72,4 +73,4 @@ app.views.TagFollowingList = app.views.Base.extend({
}).render().el);
}

});
});
2 changes: 1 addition & 1 deletion app/assets/templates/tag_following_list_tpl.jst.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
<form accept-charset="UTF-8" action="/tag_followings" id="new_tag_following" method="post">
<input class="tag_input" type="text" name="name" placeholder="{{t "stream.followed_tag.add_a_tag"}}" />
</form>
</li>
</li>
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ describe("app.collections.TagFollowings", function(){
this.collection = new app.collections.TagFollowings();
})

describe("comparator", function() {
it("should compare in reverse order", function() {
var a = new app.models.TagFollowing({name: "aaa"}),
b = new app.models.TagFollowing({name: "zzz"})
expect(this.collection.comparator(a, b)).toBe(true)
})
})

describe("create", function(){
it("should not allow duplicates", function(){
this.collection.create({"name":"name"})
Expand Down

0 comments on commit 6bb644f

Please sign in to comment.