Update nav tree after document update
This commit is contained in:
@@ -114,12 +114,19 @@ router.post('documents.update', auth(), async (ctx) => {
|
|||||||
|
|
||||||
if (!document) throw httpErrors.BadRequest();
|
if (!document) throw httpErrors.BadRequest();
|
||||||
|
|
||||||
|
// Update document
|
||||||
document.title = title;
|
document.title = title;
|
||||||
document.text = text;
|
document.text = text;
|
||||||
document.lastModifiedById = user.id;
|
document.lastModifiedById = user.id;
|
||||||
await document.save();
|
await document.save();
|
||||||
await document.createRevision();
|
await document.createRevision();
|
||||||
|
|
||||||
|
// Update
|
||||||
|
const atlas = await Atlas.findById(document.atlasId);
|
||||||
|
if (atlas.type === 'atlas') {
|
||||||
|
await atlas.updateNavigationTree();
|
||||||
|
}
|
||||||
|
|
||||||
ctx.body = {
|
ctx.body = {
|
||||||
data: await presentDocument(document, true),
|
data: await presentDocument(document, true),
|
||||||
};
|
};
|
||||||
@@ -155,4 +162,4 @@ router.post('documents.delete', auth(), async (ctx) => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
export default router;
|
export default router;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ const Atlas = sequelize.define('atlas', {
|
|||||||
return; // TODO should create a root doc
|
return; // TODO should create a root doc
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async updateNavigationTree(tree) {
|
async updateNavigationTree(tree = this.navigationTree) {
|
||||||
let nodeIds = [];
|
let nodeIds = [];
|
||||||
nodeIds.push(tree.id);
|
nodeIds.push(tree.id);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user