From 43c4122fe3d7d42ead76e4c0e659797722fa536b Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Mon, 11 May 2015 17:10:58 +0200 Subject: [PATCH] Fixed stack dragging within the same container --- rpg-docs/Model/Inventory/Items.js | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/rpg-docs/Model/Inventory/Items.js b/rpg-docs/Model/Inventory/Items.js index 419677e49..9e6448e18 100644 --- a/rpg-docs/Model/Inventory/Items.js +++ b/rpg-docs/Model/Inventory/Items.js @@ -74,15 +74,14 @@ var moveItem = function(itemId, enable, parentCollection, parentId) { item.parent.id !== parentId || item.enabled !== enable ){ - var setter = {$set: { - "parent.collection": parentCollection, - "parent.id": parentId, - enabled: enable, - }}; - if (parentCollection === "Characters"){ - setter.$set.charId = parentId; - } - Items.update(itemId, setter); + Items.update( + itemId, + {$set: { + "parent.collection": parentCollection, + "parent.id": parentId, + enabled: enable, + }} + ); } }; @@ -137,15 +136,13 @@ Meteor.methods({ //create a new item stack var newStack = _.omit(EJSON.clone(item), "_id"); newStack.parent = parent; - if (newStack.parent.collection === "Characters"){ - newStack.charId = newStack.parent.id; - } newStack.quantity = moveQuantity; //find out if we have an exact replica in the destination var query = _.omit(newStack, ["parent", "quantity"]); query["parent.collection"] = newStack.parent.collection; query["parent.id"] = newStack.parent.id; + query._id = {$ne: itemId}; //make sure we don't join it to itself var existingStack = Items.findOne(query); if (existingStack){ //increase the existing stack's size