Skip to content
This repository has been archived by the owner on Jul 6, 2021. It is now read-only.

Commit

Permalink
show course-categories, without parents of subcategories
Browse files Browse the repository at this point in the history
  • Loading branch information
Yomadorr committed Aug 6, 2013
1 parent 1163e03 commit 68ff7ae
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion client/views/courses/details/course.edit.js
Expand Up @@ -29,7 +29,7 @@ Template.course_edit.checked = function(id, cats) {


Template.course_edit.show_subcats = function(id, cats) {
if (cats === undefined) return;
if (cats === undefined) return 'none';
if (cats.length) {
return cats.indexOf(id) >= 0 ? 'block' : 'none'
} else {
Expand Down
15 changes: 14 additions & 1 deletion client/views/courses/details/course.show_categories.js
@@ -1,4 +1,17 @@

Template.show_categories.loadcategories = function(categories) {
return Categories.find({_id: {$in: categories}})
//return Categories.find({_id: {$in: categories}});

var allSubCats = Categories.find({_id: {$in: categories}, parent: {$gte:1}});
var subCatParents = new Array();
var count = 0;

allSubCats.forEach(function (subCat) {
subCatParents[count] = subCat.parent;
count += 1;
});

//returns all categories, without parents of subcategories.
return Categories.find({_id: {$in: categories, $nin: subCatParents}});

}

0 comments on commit 68ff7ae

Please sign in to comment.