Fixed stack dragging within the same container
This commit is contained in:
@@ -74,15 +74,14 @@ var moveItem = function(itemId, enable, parentCollection, parentId) {
|
|||||||
item.parent.id !== parentId ||
|
item.parent.id !== parentId ||
|
||||||
item.enabled !== enable
|
item.enabled !== enable
|
||||||
){
|
){
|
||||||
var setter = {$set: {
|
Items.update(
|
||||||
"parent.collection": parentCollection,
|
itemId,
|
||||||
"parent.id": parentId,
|
{$set: {
|
||||||
enabled: enable,
|
"parent.collection": parentCollection,
|
||||||
}};
|
"parent.id": parentId,
|
||||||
if (parentCollection === "Characters"){
|
enabled: enable,
|
||||||
setter.$set.charId = parentId;
|
}}
|
||||||
}
|
);
|
||||||
Items.update(itemId, setter);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -137,15 +136,13 @@ Meteor.methods({
|
|||||||
//create a new item stack
|
//create a new item stack
|
||||||
var newStack = _.omit(EJSON.clone(item), "_id");
|
var newStack = _.omit(EJSON.clone(item), "_id");
|
||||||
newStack.parent = parent;
|
newStack.parent = parent;
|
||||||
if (newStack.parent.collection === "Characters"){
|
|
||||||
newStack.charId = newStack.parent.id;
|
|
||||||
}
|
|
||||||
newStack.quantity = moveQuantity;
|
newStack.quantity = moveQuantity;
|
||||||
|
|
||||||
//find out if we have an exact replica in the destination
|
//find out if we have an exact replica in the destination
|
||||||
var query = _.omit(newStack, ["parent", "quantity"]);
|
var query = _.omit(newStack, ["parent", "quantity"]);
|
||||||
query["parent.collection"] = newStack.parent.collection;
|
query["parent.collection"] = newStack.parent.collection;
|
||||||
query["parent.id"] = newStack.parent.id;
|
query["parent.id"] = newStack.parent.id;
|
||||||
|
query._id = {$ne: itemId}; //make sure we don't join it to itself
|
||||||
var existingStack = Items.findOne(query);
|
var existingStack = Items.findOne(query);
|
||||||
if (existingStack){
|
if (existingStack){
|
||||||
//increase the existing stack's size
|
//increase the existing stack's size
|
||||||
|
|||||||
Reference in New Issue
Block a user