mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-24 08:12:24 +02:00
This commit is contained in:
parent
f65a3be231
commit
7e200b1ec7
@ -177,4 +177,19 @@ describe('models_Folder', function() {
|
||||
expect(foldersById[f4.id].note_count).toBe(0);
|
||||
}));
|
||||
|
||||
it('should recursively find folder path', asyncTest(async () => {
|
||||
|
||||
let f1 = await Folder.save({ title: 'folder1' });
|
||||
let f2 = await Folder.save({ title: 'folder2', parent_id: f1.id });
|
||||
let f3 = await Folder.save({ title: 'folder3', parent_id: f2.id });
|
||||
|
||||
const folders = await Folder.all();
|
||||
const folderPath = await Folder.folderPath(folders, f3.id);
|
||||
|
||||
expect(folderPath.length).toBe(3);
|
||||
expect(folderPath[0].id).toBe(f1.id);
|
||||
expect(folderPath[1].id).toBe(f2.id);
|
||||
expect(folderPath[2].id).toBe(f3.id);
|
||||
}));
|
||||
|
||||
});
|
||||
|
@ -1653,6 +1653,7 @@ class NoteTextComponent extends React.Component {
|
||||
folderId: this.state.folder.id,
|
||||
noteId: note.id,
|
||||
});
|
||||
Folder.expandTree(this.props.folders, this.state.folder.parent_id);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
@ -218,6 +218,17 @@ class Folder extends BaseItem {
|
||||
return output;
|
||||
}
|
||||
|
||||
static async expandTree(folders, parentId) {
|
||||
const folderPath = await this.folderPath(folders, parentId);
|
||||
for (const folder of folderPath) {
|
||||
this.dispatch({
|
||||
type: 'FOLDER_SET_COLLAPSED',
|
||||
id: folder.id,
|
||||
collapsed: false,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
static async allAsTree(folders = null, options = null) {
|
||||
const all = folders ? folders : await this.all(options);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user