REFACTOR: Remove `_.sortBy`
This commit is contained in:
parent
2353794a30
commit
17bca14c4b
|
@ -52,15 +52,18 @@ export default Component.extend({
|
|||
if (this.componentsTabActive) {
|
||||
return themes.filter(theme => theme.get("parent_themes.length") > 0);
|
||||
} else {
|
||||
themes = themes.filter(
|
||||
theme => theme.get("user_selectable") || theme.get("default")
|
||||
);
|
||||
return _.sortBy(themes, t => {
|
||||
return [
|
||||
!t.get("default"),
|
||||
!t.get("user_selectable"),
|
||||
t.get("name").toLowerCase()
|
||||
];
|
||||
return themes
|
||||
.filter(theme => theme.get("user_selectable") || theme.get("default"))
|
||||
.sort((a, b) => {
|
||||
if (a.get("default") && !b.get("default")) {
|
||||
return -1;
|
||||
} else if (b.get("default")) {
|
||||
return 1;
|
||||
}
|
||||
return a
|
||||
.get("name")
|
||||
.toLowerCase()
|
||||
.localeCompare(b.get("name").toLowerCase());
|
||||
});
|
||||
}
|
||||
},
|
||||
|
|
|
@ -1,20 +1,20 @@
|
|||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import Controller from "@ember/controller";
|
||||
|
||||
function badgeKey(badge) {
|
||||
let pos = badge.get("badge_grouping.position");
|
||||
let type = badge.get("badge_type_id");
|
||||
let name = badge.get("name");
|
||||
return ("000" + pos).slice(-4) + (10 - type) + name;
|
||||
}
|
||||
|
||||
export default Controller.extend({
|
||||
@discourseComputed("model")
|
||||
badgeGroups(model) {
|
||||
var sorted = _.sortBy(model, function(badge) {
|
||||
var pos = badge.get("badge_grouping.position");
|
||||
var type = badge.get("badge_type_id");
|
||||
var name = badge.get("name");
|
||||
|
||||
return ("000" + pos).slice(-4) + (10 - type) + name;
|
||||
});
|
||||
|
||||
var grouped = [];
|
||||
var group = [],
|
||||
groupId;
|
||||
let sorted = model.sort((a, b) => badgeKey(a).localeCompare(badgeKey(b)));
|
||||
let grouped = [];
|
||||
let group = [];
|
||||
let groupId;
|
||||
|
||||
sorted.forEach(function(badge) {
|
||||
if (groupId !== badge.badge_grouping_id) {
|
||||
|
|
|
@ -13,9 +13,9 @@ export default Mixin.create({
|
|||
|
||||
let userFields = this.site.get("user_fields");
|
||||
if (userFields) {
|
||||
userFields = _.sortBy(userFields, "position").map(function(f) {
|
||||
return EmberObject.create({ value: null, field: f });
|
||||
});
|
||||
userFields = userFields
|
||||
.sortBy("position")
|
||||
.map(f => EmberObject.create({ value: null, field: f }));
|
||||
}
|
||||
this.set("userFields", userFields);
|
||||
},
|
||||
|
|
|
@ -544,9 +544,7 @@ Category.reopenClass({
|
|||
}
|
||||
}
|
||||
|
||||
return _.sortBy(data, category => {
|
||||
return category.get("read_restricted");
|
||||
});
|
||||
return data.sortBy("read_restricted");
|
||||
}
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue