From 92653ad87f76c5257d11fad8cf2109ce102e1f9b Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Wed, 9 Jun 2021 22:23:11 +0200 Subject: [PATCH] =?UTF-8?q?Fix:=20d=C3=A9placement=20de=20conteneurs=20ent?= =?UTF-8?q?re=20acteurs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- module/actor.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/module/actor.js b/module/actor.js index 64ac12be..f62ad86c 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1141,12 +1141,17 @@ export class RdDActor extends Actor { sourceActor.buildSubConteneurObjetList(itemId, itemsList); // Get itemId list let itemMap = {}; - for (let item of itemsList) { - let srcItem = sourceActor.data.items.find(subItem => subItem._id == item.id); - let newItem = await this.createEmbeddedDocuments('Item', [duplicate(srcItem)]); + const itemsDataToCreate = itemsList.map(it => sourceActor.getObjet(it.id)) + .map(it => duplicate(Misc.data(it))) + .map(it => { it.data.contenu = []; return it; }); + let newItems = await this.createEmbeddedDocuments('Item', itemsDataToCreate); + for (let i = 0; i < itemsList.length; i++) { + const srcItem = itemsList[i]; + const newItem = newItems[i]; console.log('New object', newItem, srcItem); - itemMap[srcItem._id] = newItem._id; // Pour garder le lien ancien / nouveau + itemMap[srcItem.id] = newItem._id; // Pour garder le lien ancien / nouveau } + for (let item of itemsList) { // Second boucle pour traiter la remise en conteneurs // gestion conteneur/contenu if (item.conteneurId) { // l'Objet était dans un conteneur