fix: Collection structure update on document move
This commit is contained in:
@@ -71,6 +71,7 @@ async function documentMover({
|
||||
// Remove the document from the current collection
|
||||
const response = await collection?.removeDocumentInStructure(document, {
|
||||
transaction,
|
||||
save: collectionChanged,
|
||||
});
|
||||
|
||||
const documentJson = response?.[0];
|
||||
@@ -92,19 +93,25 @@ async function documentMover({
|
||||
? index - 1
|
||||
: index;
|
||||
|
||||
// Update the properties on the document record, this must be done after
|
||||
// the toIndex is calculated above
|
||||
document.collectionId = collectionId;
|
||||
document.parentDocumentId = parentDocumentId;
|
||||
document.lastModifiedById = user.id;
|
||||
document.updatedBy = user;
|
||||
|
||||
// Add the document and it's tree to the new collection
|
||||
await newCollection.addDocumentToStructure(document, toIndex, {
|
||||
documentJson,
|
||||
transaction,
|
||||
});
|
||||
} else {
|
||||
document.collectionId = collectionId;
|
||||
document.parentDocumentId = parentDocumentId;
|
||||
document.lastModifiedById = user.id;
|
||||
document.updatedBy = user;
|
||||
}
|
||||
|
||||
// Update the properties on the document record
|
||||
document.collectionId = collectionId;
|
||||
document.parentDocumentId = parentDocumentId;
|
||||
document.lastModifiedById = user.id;
|
||||
document.updatedBy = user;
|
||||
|
||||
if (collection && document.publishedAt) {
|
||||
result.collections.push(collection);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user