Skip to content

Commit

Permalink
Update related documents after change a category #1
Browse files Browse the repository at this point in the history
  • Loading branch information
conruacodon committed Jun 5, 2021
1 parent 4b28f1e commit aac8342
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions api/category/models/category.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const _lifecycle = new ModelLifeCycle({
function _addMenu(result) {
result.menu = {
document: {
parent: result.category?.title ?? '',
parent: result.parent?.title ?? '',
},
};
}
Expand Down Expand Up @@ -52,14 +52,12 @@ module.exports = {
fsutil.renameCategory('document', before, result);

// Update
if (before && before.path != result.path) {
const ctx = { params: { category: result.id } };
let docs = await strapi.controllers.document.find(ctx);
const ctx = { params: { category: result.id } };
let docs = await strapi.controllers.document.find(ctx);

for (const doc of docs) {
_addDocumentMenu(doc);
writer.writeContent('document', doc);
}
for (const doc of docs) {
_addDocumentMenu(doc);
writer.writeContent('document', doc);
}
}

Expand Down

0 comments on commit aac8342

Please sign in to comment.