Merge pull request #5361 from aignatov-bio/ai-sci-8390-fix-navigator-update

Fix navigator update [SCI-8390]
This commit is contained in:
aignatov-bio 2023-05-04 14:23:48 +02:00 committed by GitHub
commit ef0cacfded
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View file

@ -148,6 +148,7 @@ function init() {
initializeGraph(".diagram .module-large"); initializeGraph(".diagram .module-large");
initializeFullZoom(); initializeFullZoom();
} }
window.navigatorContainer.reloadChildrenLevel = true;
} }
jsPlumb.ready(function () { jsPlumb.ready(function () {

View file

@ -119,6 +119,7 @@
function refreshCurrentView() { function refreshCurrentView() {
loadCardsView(); loadCardsView();
window.navigatorContainer.reloadChildrenLevel = true;
} }
function selectDate($field) { function selectDate($field) {

View file

@ -44,12 +44,13 @@ export default {
data: function() { data: function() {
return { return {
childrenExpanded: false, childrenExpanded: false,
childrenLoaded: false,
children: [] children: []
}; };
}, },
computed: { computed: {
hasChildren: function() { hasChildren: function() {
return this.item.has_children; return this.item.has_children || this.children.length > 0;
}, },
sortedMenuItems: function() { sortedMenuItems: function() {
return this.children.sort((a, b) => { return this.children.sort((a, b) => {
@ -93,6 +94,13 @@ export default {
if (this.reloadCurrentLevel && this.children.find((item) => item.id == this.currentItemId)) { if (this.reloadCurrentLevel && this.children.find((item) => item.id == this.currentItemId)) {
this.loadChildren(); this.loadChildren();
} }
},
children: function() {
if (this.children.length > 0) {
this.childrenExpanded = true;
} else if (this.childrenLoaded) {
this.item.has_children = false;
}
} }
}, },
methods: { methods: {
@ -103,6 +111,7 @@ export default {
loadChildren: function() { loadChildren: function() {
$.get(this.item.children_url, {archived: this.archived}, (data) => { $.get(this.item.children_url, {archived: this.archived}, (data) => {
this.children = data.items; this.children = data.items;
this.childrenLoaded = true;
}); });
}, },
treeExpand: function() { treeExpand: function() {