diff --git a/kfet/static/kfet/js/kfet.api.js b/kfet/static/kfet/js/kfet.api.js index caee4e85..19be0607 100644 --- a/kfet/static/kfet/js/kfet.api.js +++ b/kfet/static/kfet/js/kfet.api.js @@ -669,7 +669,11 @@ class ModelForest { var children = this.get_children(node); if (children) { - children.sort(struct_data.child_sort); + if (struct_data.child_sort) + children.sort(struct_data.child_sort); + else + children.sort(children[0].constructor.compare); + for (let child of children) { var $child = this.render_element(child, templates, options); $container.append($child); @@ -702,7 +706,11 @@ class ModelForest { * @param {Object} [options] Options for element render method */ display($container, templates, options) { - this.roots.sort(this.constructor.root_sort); + if (this.constructor.root_sort) + this.roots.sort(this.constructor.root_sort); + else + this.roots.sort(this.roots[0].constructor.compare); + for (let root of this.roots) { $container.append(this.render_element(root, templates, options)); } @@ -720,8 +728,9 @@ class ModelForest { var that = this; function recurse(node) { if (node.constructor.verbose_name === modelname) { - if callback(node); + if (callback(node)) { return true; + } } var children = that.get_children(node); @@ -730,6 +739,8 @@ class ModelForest { if (recurse(child)) return true; } + + return false; } for (let root of this.roots) @@ -809,20 +820,11 @@ class ArticleList extends APIModelForest { 'category': { 'model': ArticleCategory, 'children': 'articles', - 'child_sort': Article.compare, }, }; } - /** - * Comparison function to sort roots - * @default {@link Models.ArticleCategory.compare|ArticleCategory.compare} - */ - static get root_sort() { - return ArticleCategory.compare; - } - /** * Default url to get ArticlList data * @abstract