mirror of
https://github.com/wekan/wekan.git
synced 2025-12-17 16:00:13 +01:00
attachment copy changes now the boardId, listId and swimlaneId in the collection data
- fixing admin attachment view, copied card attachments were wrong if copied to another board / list / swimlane
This commit is contained in:
parent
0261bb592e
commit
2eadd3eb8b
2 changed files with 19 additions and 3 deletions
|
|
@ -696,6 +696,7 @@ export const moveToStorage = function(fileObj, storageDestination, fileStoreStra
|
||||||
};
|
};
|
||||||
|
|
||||||
export const copyFile = function(fileObj, newCardId, fileStoreStrategyFactory) {
|
export const copyFile = function(fileObj, newCardId, fileStoreStrategyFactory) {
|
||||||
|
const newCard = Cards.findOne(newCardId);
|
||||||
Object.keys(fileObj.versions).forEach(versionName => {
|
Object.keys(fileObj.versions).forEach(versionName => {
|
||||||
const strategyRead = fileStoreStrategyFactory.getFileStrategy(fileObj, versionName);
|
const strategyRead = fileStoreStrategyFactory.getFileStrategy(fileObj, versionName);
|
||||||
const readStream = strategyRead.getReadStream();
|
const readStream = strategyRead.getReadStream();
|
||||||
|
|
@ -721,10 +722,10 @@ export const copyFile = function(fileObj, newCardId, fileStoreStrategyFactory) {
|
||||||
fileName: fileObj.name,
|
fileName: fileObj.name,
|
||||||
type: fileObj.type,
|
type: fileObj.type,
|
||||||
meta: {
|
meta: {
|
||||||
boardId: fileObj.meta.boardId,
|
boardId: newCard.boardId,
|
||||||
cardId: newCardId,
|
cardId: newCardId,
|
||||||
listId: fileObj.meta.listId,
|
listId: newCard.listId,
|
||||||
swimlaneId: fileObj.meta.swimlaneId,
|
swimlaneId: newCard.swimlaneId,
|
||||||
source: 'copy',
|
source: 'copy',
|
||||||
copyFrom: fileObj._id,
|
copyFrom: fileObj._id,
|
||||||
copyStorage: strategyRead.getStorageName(),
|
copyStorage: strategyRead.getStorageName(),
|
||||||
|
|
|
||||||
|
|
@ -1420,3 +1420,18 @@ Migrations.add('migrate-attachment-migration-fix-source-import', () => {
|
||||||
noValidateMulti
|
noValidateMulti
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Migrations.add('attachment-cardCopy-fix-boardId-etc', () => {
|
||||||
|
Attachments.find( {"meta.source": "copy"} ).forEach(_attachment => {
|
||||||
|
const cardId = _attachment.meta.cardId;
|
||||||
|
const card = Cards.findOne(cardId);
|
||||||
|
console.log("update attachment id: ", _attachment._id);
|
||||||
|
Attachments.update(_attachment._id, {
|
||||||
|
$set: {
|
||||||
|
"meta.boardId": card.boardId,
|
||||||
|
"meta.listId": card.listId,
|
||||||
|
"meta.swimlaneId": card.swimlaneId,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue