Skip to content

Commit

Permalink
FIX: BUG - Move a parent note under its child note breaks the treevie…
Browse files Browse the repository at this point in the history
…w - EXO-75215

Prior to this fix, when a user move a note that has children, he was
able to select the children and move it below them. It creates an
infinite loop This commit filter the move treeview to not display
children of the current node so user will not be able to select any of
them as destination.
  • Loading branch information
mkrout authored Nov 14, 2024
1 parent 9f7586a commit bcdf6ab
Showing 1 changed file with 20 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -619,15 +619,20 @@ export default {
});
},
retrieveNoteTree(noteType, noteOwner, noteName) {
this.home = [];
this.items = [];
this.allItems = [];
this.allItemsHome = [];
const withDrafts = this.filter === this.$t('notes.filter.label.drafts');
this.$notesService.getFullNoteTree(noteType, noteOwner , noteName, withDrafts, this.selectedTranslation).then(data => {
if (data && data.jsonList.length) {
this.home = [];
this.items = [];
this.allItems = [];
this.allItemsHome = [];
const items = data.treeNodeData && data.treeNodeData[0] && data.treeNodeData[0] .children || [];
if (this.movePage) {
const home = { children: items , noteId: 0};
this.filterItemsForMove(home);
}
this.home = data.treeNodeData.length ? data.treeNodeData[0] : data.jsonList[0];
this.items = data.treeNodeData && data.treeNodeData[0] && data.treeNodeData[0] .children || [];
this.items = items;
this.allItems = data.jsonList;
this.allItemsHome = data.treeNodeData;
}
Expand All @@ -640,6 +645,16 @@ export default {
this.noteBookOwnerTree = noteOwner;
});
},
filterItemsForMove(item) {
if (item.noteId===this.note.id) {
delete item.children;
return item;
}
for (let i = 0; i < item.children.length; i++) {
item.children[i] = this.filterItemsForMove(item.children[i]);
}
return item;
},
getOpenedTreeViewItems(breadCrumbArray) {
const activatedNotes = [];
if (this.filter === this.$t('notes.filter.label.drafts')) {
Expand Down

0 comments on commit bcdf6ab

Please sign in to comment.