Skip to content

Commit

Permalink
uses document mode even inside sub fields
Browse files Browse the repository at this point in the history
  • Loading branch information
ValJed committed Aug 22, 2024
1 parent ef81718 commit 86b69c3
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions lib/methods/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -226,7 +232,8 @@ module.exports = self => {
type,
relatedTypes,
recursion,
storedData
storedData,
mode
});
}
continue;
Expand All @@ -239,7 +246,8 @@ module.exports = self => {
type,
relatedTypes,
recursion,
storedData
storedData,
mode
});
continue;
}
Expand All @@ -253,7 +261,8 @@ module.exports = self => {
type,
relatedTypes,
recursion,
storedData
storedData,
mode
});
}
continue;
Expand All @@ -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)) {
Expand All @@ -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')
Expand Down

0 comments on commit 86b69c3

Please sign in to comment.