From 9667c2fc5a4126e9098a86833efe75c89e21fd52 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 1 Jul 2021 13:11:17 +0300 Subject: [PATCH] fix category tree --- client/res/templates/list-with-categories.tpl | 2 +- client/src/views/list-with-categories.js | 31 +++++++------------ 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/client/res/templates/list-with-categories.tpl b/client/res/templates/list-with-categories.tpl index 4299c0ab6c..20c4d0875b 100644 --- a/client/res/templates/list-with-categories.tpl +++ b/client/res/templates/list-with-categories.tpl @@ -8,7 +8,7 @@ {{/if}}
-
{{{nestedCategories}}}
+
{{{nestedCategories}}}
{{{list}}}
diff --git a/client/src/views/list-with-categories.js b/client/src/views/list-with-categories.js index ddf2a85438..3375700687 100644 --- a/client/src/views/list-with-categories.js +++ b/client/src/views/list-with-categories.js @@ -63,6 +63,8 @@ define('views/list-with-categories', 'views/list', function (Dep) { data.hasTree = (this.isExpanded || this.hasNavigationPanel) && !this.categoriesDisabled; + data.hasNestedCategories = !this.isExpanded; + return data; }, @@ -214,7 +216,7 @@ define('views/list-with-categories', 'views/list', function (Dep) { } if (!this.isExpanded && !this.hasView('nestedCategories')) { - this.loadNestedCategories(); + this.loadNestedCategories(); } }, @@ -226,11 +228,6 @@ define('views/list-with-categories', 'views/list', function (Dep) { this.applyCategoryToCollection(); this.clearView('nestedCategories'); - - /*if (this.hasView('categories')) { - this.getView('categories').isExpanded = true; - }*/ - this.clearView('categories'); this.getRouter().navigate('#' + this.scope); @@ -250,9 +247,6 @@ define('views/list-with-categories', 'views/list', function (Dep) { this.applyCategoryToCollection(); this.applyCategoryToNestedCategoriesCollection(); - /*if (this.hasView('categories')) { - this.getView('categories').isExpanded = false; - }*/ this.clearView('categories'); this.navigateToCurrentCategory(); @@ -325,25 +319,22 @@ define('views/list-with-categories', 'views/list', function (Dep) { Promise.all([ this.nestedCategoriesCollection .fetch() - .then( - function () { - this.controlNestedCategoriesVisibility(); - this.updateHeader(); - - }.bind(this) - ), + .then(() => { + this.controlNestedCategoriesVisibility(); + this.updateHeader(); + }), this.collection.fetch({openCategory: true}) - ]).then(function () { + ]).then(() => { Espo.Ui.notify(false); this.controlListVisibility(); - }.bind(this)); + }); } else { - this.collection.fetch().then(function () { + this.collection.fetch().then(() => { Espo.Ui.notify(false); - }.bind(this)); + }); } },