From 86b69c3f776d613129ddf6a3074ba98cb7e505d5 Mon Sep 17 00:00:00 2001 From: Jed Date: Thu, 22 Aug 2024 12:00:46 +0200 Subject: [PATCH] uses document mode even inside sub fields --- lib/methods/export.js | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/lib/methods/export.js b/lib/methods/export.js index c26e6dc8..4746bf3a 100644 --- a/lib/methods/export.js +++ b/lib/methods/export.js @@ -201,7 +201,13 @@ module.exports = self => { }, async getRelatedDocsFromSchema(req, { - doc, schema, relatedTypes, storedData, type = 'relationship', recursion = 0 + doc, + schema, + relatedTypes, + storedData, + type = 'relationship', + recursion = 0, + mode = doc.aposMode || req.mode }) { recursion++; for (const field of schema) { @@ -226,7 +232,8 @@ module.exports = self => { type, relatedTypes, recursion, - storedData + storedData, + mode }); } continue; @@ -239,7 +246,8 @@ module.exports = self => { type, relatedTypes, recursion, - storedData + storedData, + mode }); continue; } @@ -253,7 +261,8 @@ module.exports = self => { type, relatedTypes, recursion, - storedData + storedData, + mode }); } continue; @@ -268,14 +277,23 @@ module.exports = self => { type, storedData, shouldRecurse, - recursion + recursion, + mode }); } } }, async handleRelatedField(req, { - doc, field, fieldValue, relatedTypes, type, storedData, shouldRecurse, recursion + doc, + field, + fieldValue, + relatedTypes, + type, + storedData, + shouldRecurse, + recursion, + mode }) { if (type === 'attachment') { if (fieldValue && !storedData.includes(fieldValue._id)) { @@ -291,10 +309,10 @@ module.exports = self => { } const criteria = { aposDocId: { $in: relatedIds }, - aposLocale: doc.aposLocale || `${req.locale}:${req.mode}` + aposLocale: doc.aposLocale || `${req.locale}:${mode}` }; - const clonedReq = doc.aposMode ? req.clone({ mode: doc.aposMode }) : req; + const clonedReq = mode ? req.clone({ mode }) : req; const foundRelated = await manager .findForEditing(clonedReq, criteria) .permission('view')