- on category setParent dialog do not show children of current category
- break recursion if category parentCid is equal to child cid to prevent
infinite loop
- dont allow setting the parentCid of a category to one of it's children
This commit is contained in:
Baris Usakli
2018-11-06 13:34:29 -05:00
parent 9a9f2af9c1
commit 3c611d85ed
4 changed files with 70 additions and 2 deletions

View File

@@ -240,8 +240,13 @@ define('admin/manage/category', [
}
Category.launchParentSelector = function () {
var parents = [parseInt(ajaxify.data.category.cid, 10)];
var categories = ajaxify.data.allCategories.filter(function (category) {
return category && !category.disabled && parseInt(category.cid, 10) !== parseInt(ajaxify.data.category.cid, 10);
var isChild = parents.includes(parseInt(category.parentCid, 10));
if (isChild) {
parents.push(parseInt(category.cid, 10));
}
return category && !category.disabled && parseInt(category.cid, 10) !== parseInt(ajaxify.data.category.cid, 10) && !isChild;
});
categorySelector.modal(categories, function (parentCid) {