Added the ability to hide slots when full
This commit is contained in:
@@ -8,6 +8,8 @@ export default function recomputeSlotFullness(ancestorId){
|
||||
let children = CreatureProperties.find({
|
||||
'parent.id': slot._id,
|
||||
removed: {$ne: true},
|
||||
}, {
|
||||
fields: {slotQuantityFilled: 1}
|
||||
}).fetch();
|
||||
let totalFilled = 0;
|
||||
children.forEach(child => {
|
||||
@@ -17,9 +19,15 @@ export default function recomputeSlotFullness(ancestorId){
|
||||
totalFilled++;
|
||||
}
|
||||
});
|
||||
if (slot.totalFilled !== totalFilled){
|
||||
let spaceLeft;
|
||||
if (slot.quantityExpected === 0){
|
||||
spaceLeft = null;
|
||||
} else {
|
||||
spaceLeft = slot.quantityExpected - totalFilled;
|
||||
}
|
||||
if (slot.totalFilled !== totalFilled || slot.spaceLeft !== spaceLeft){
|
||||
CreatureProperties.update(slot._id, {
|
||||
$set: {totalFilled},
|
||||
$set: {totalFilled, spaceLeft},
|
||||
}, {
|
||||
selector: {type: 'propertySlot'}
|
||||
});
|
||||
|
||||
@@ -34,6 +34,10 @@ let SlotSchema = new SimpleSchema({
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
hideWhenFull: {
|
||||
type: Boolean,
|
||||
optional: true,
|
||||
}
|
||||
});
|
||||
|
||||
const ComputedOnlySlotSchema = new SimpleSchema({
|
||||
@@ -53,7 +57,11 @@ const ComputedOnlySlotSchema = new SimpleSchema({
|
||||
totalFilled: {
|
||||
type: SimpleSchema.Integer,
|
||||
defaultValue: 0,
|
||||
}
|
||||
},
|
||||
spaceLeft: {
|
||||
type: SimpleSchema.Integer,
|
||||
optional: true,
|
||||
},
|
||||
});
|
||||
|
||||
const ComputedSlotSchema = new SimpleSchema()
|
||||
|
||||
Reference in New Issue
Block a user