From 225b895833421e78c15fed628ecdf4cc19b87b07 Mon Sep 17 00:00:00 2001
From: Thaum Rystra <9525416+ThaumRystra@users.noreply.github.com>
Date: Sat, 23 Mar 2024 21:06:58 +0200
Subject: [PATCH] Fixed some character sheet Query errors
---
.../ui/creature/buildTree/BuildTreeNode.vue | 72 +++++++++----------
.../creature/buildTree/BuildTreeNodeList.vue | 4 +-
.../character/characterSheetTabs/BuildTab.vue | 8 +--
.../characterSheetTabs/InventoryTab.vue | 4 +-
.../characterSheetTabs/JournalTab.vue | 4 +-
.../characterSheetTabs/SpellsTab.vue | 5 +-
.../creatureProperties/Breadcrumbs.vue | 2 +-
.../components/spells/SpellListCard.vue | 3 +-
.../viewers/shared/PropertyField.vue | 1 -
.../server/publications/slotFillers.js | 6 +-
10 files changed, 54 insertions(+), 55 deletions(-)
diff --git a/app/imports/client/ui/creature/buildTree/BuildTreeNode.vue b/app/imports/client/ui/creature/buildTree/BuildTreeNode.vue
index e72b1a59..17cc8174 100644
--- a/app/imports/client/ui/creature/buildTree/BuildTreeNode.vue
+++ b/app/imports/client/ui/creature/buildTree/BuildTreeNode.vue
@@ -4,12 +4,12 @@
:class="{
'empty': !hasChildren,
}"
- :data-id="`tree-node-${node._id}`"
+ :data-id="`tree-node-${doc._id}`"
>
-
+
- {{ node.name }}
+ {{ doc.name }}
mdi-delete
@@ -68,13 +68,13 @@
:
mdi-delete
@@ -109,7 +109,7 @@
>
@@ -147,7 +147,7 @@ export default {
type: Number,
default: 0,
},
- node: {
+ doc: {
type: Object,
required: true,
},
@@ -163,42 +163,42 @@ export default {
data(){return {
expanded: this.depth <= 2,
/* expand if there's a slot needing attention:
- this.node._descendantCanFill || (
- this.node.type === 'propertySlot' &&
+ this.doc._descendantCanFill || (
+ this.doc.type === 'propertySlot' &&
this. node.quantityExpected?.value === 0 ||
- (this.node.quantityExpected?.value > 1 && this.node.spaceLeft > 0)
+ (this.doc.quantityExpected?.value > 1 && this.doc.spaceLeft > 0)
)
*/
}},
computed: {
condenseChild(){
- return this.node.type === 'propertySlot' &&
+ return this.doc.type === 'propertySlot' &&
this.children.length === 1 &&
- this.children[0].node.type !== 'propertySlot' &&
- this.node.quantityExpected &&
- this.node.quantityExpected.value === 1 &&
+ this.children[0].doc.type !== 'propertySlot' &&
+ this.doc.quantityExpected &&
+ this.doc.quantityExpected.value === 1 &&
!this.canFill;
},
isSlot(){
- return this.node.type === 'propertySlot';
+ return this.doc.type === 'propertySlot';
},
canFill(){
- return !!this.node._canFill;
+ return !!this.doc._canFill;
},
canFillWithOne(){
return this.isSlot &&
this.canFill &&
- this.node.quantityExpected &&
- this.node.quantityExpected.value === 1 &&
- this.node.spaceLeft === 1 &&
+ this.doc.quantityExpected &&
+ this.doc.quantityExpected.value === 1 &&
+ this.doc.spaceLeft === 1 &&
!this.children?.length;
},
canFillWithMany(){
return this.isSlot && this.canFill && (
- !this.node.quantityExpected ||
- this.node.quantityExpected.value === 0 ||
- (this.node.quantityExpected.value > 1 && this.node.spaceLeft > 0) ||
- (this.node.quantityExpected.value === 1 && this.children?.length)
+ !this.doc.quantityExpected ||
+ this.doc.quantityExpected.value === 0 ||
+ (this.doc.quantityExpected.value > 1 && this.doc.spaceLeft > 0) ||
+ (this.doc.quantityExpected.value === 1 && this.children?.length)
);
},
hasChildren(){
@@ -215,14 +215,14 @@ export default {
},
computedSlotId() {
if (this.condenseChild) {
- if (this.children[0].node.type === 'propertySlot') {
- return this.children[0].node._id;
+ if (this.children[0].doc.type === 'propertySlot') {
+ return this.children[0].doc._id;
} else {
return undefined;
}
} else {
- if (this.node.type === 'propertySlot') {
- return this.node._id;
+ if (this.doc.type === 'propertySlot') {
+ return this.doc._id;
} else {
return undefined;
}
@@ -233,11 +233,11 @@ export default {
},
},
watch: {
- 'node._ancestorOfMatchedDocument'(value){
- this.expanded = !!value || isAncestor(this.node, this.selectedNode);
+ 'doc._ancestorOfMatchedDocument'(value){
+ this.expanded = !!value || isAncestor(this.doc, this.selectedNode);
},
'selectedNode.parentId'(){
- this.expanded = isAncestor(this.node, this.selectedNode) || this.expanded;
+ this.expanded = isAncestor(this.doc, this.selectedNode) || this.expanded;
},
},
beforeCreate() {
diff --git a/app/imports/client/ui/creature/buildTree/BuildTreeNodeList.vue b/app/imports/client/ui/creature/buildTree/BuildTreeNodeList.vue
index 497ced9e..98569378 100644
--- a/app/imports/client/ui/creature/buildTree/BuildTreeNodeList.vue
+++ b/app/imports/client/ui/creature/buildTree/BuildTreeNodeList.vue
@@ -2,8 +2,8 @@
import Creatures from '/imports/api/creature/creatures/Creatures';
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties';
-import { docsToForest as nodeArrayToTree } from '/imports/api/parenting/parentingFunctions';
+import { docsToForest } from '/imports/api/parenting/parentingFunctions';
import BuildTreeNodeList from '/imports/client/ui/creature/buildTree/BuildTreeNodeList.vue';
import SlotCardsToFill from '/imports/client/ui/creature/slots/SlotCardsToFill.vue';
import CreatureVariables from '/imports/api/creature/creatures/CreatureVariables';
@@ -356,12 +356,12 @@ export default {
}, {
sort: { order: 1 },
});
- const tree = nodeArrayToTree([
+ const tree = docsToForest([
...slots.fetch(),
...slotChildren.fetch()
]);
traverse(tree, (child, parents) => {
- const model = child.node;
+ const model = child.doc;
const isSlotWithSpace = model.type === 'propertySlot' && (
model.spaceLeft > 0 ||
!model.quantityExpected ||
@@ -370,7 +370,7 @@ export default {
if(isSlotWithSpace) {
model._canFill = true;
parents.forEach(node => {
- node.node._descendantCanFill = true;
+ node.doc._descendantCanFill = true;
});
}
});
diff --git a/app/imports/client/ui/creature/character/characterSheetTabs/InventoryTab.vue b/app/imports/client/ui/creature/character/characterSheetTabs/InventoryTab.vue
index 296df786..d934e54f 100644
--- a/app/imports/client/ui/creature/character/characterSheetTabs/InventoryTab.vue
+++ b/app/imports/client/ui/creature/character/characterSheetTabs/InventoryTab.vue
@@ -180,7 +180,7 @@ export default {
containersWithoutAncestorContainers() {
return CreatureProperties.find({
...getFilter.descendantsOfRoot(this.creatureId),
- $not: getFilter.descendantsOfAll(this.containers),
+ $nor: [getFilter.descendantsOfAll(this.containers)],
parentId: {
$nin: this.folderIds,
},
@@ -194,7 +194,7 @@ export default {
carriedItems() {
return CreatureProperties.find({
...getFilter.descendantsOfRoot(this.creatureId),
- $not: getFilter.descendantsOfAll(this.containers),
+ $nor: [getFilter.descendantsOfAll(this.containers)],
parentId: {
$nin: this.folderIds,
},
diff --git a/app/imports/client/ui/creature/character/characterSheetTabs/JournalTab.vue b/app/imports/client/ui/creature/character/characterSheetTabs/JournalTab.vue
index d8b32e63..bd53a20e 100644
--- a/app/imports/client/ui/creature/character/characterSheetTabs/JournalTab.vue
+++ b/app/imports/client/ui/creature/character/characterSheetTabs/JournalTab.vue
@@ -83,12 +83,12 @@ export default {
};
const allNotes = CreatureProperties.find(noteFilter, {
sort: { left: 1 },
- });
+ }).fetch();
return CreatureProperties.find({
...noteFilter,
...getFilter.descendantsOfRoot(this.creatureId),
- $not: getFilter.descendantsOfAll(allNotes),
+ $nor: [getFilter.descendantsOfAll(allNotes)],
}, {
sort: {order: 1},
});
diff --git a/app/imports/client/ui/creature/character/characterSheetTabs/SpellsTab.vue b/app/imports/client/ui/creature/character/characterSheetTabs/SpellsTab.vue
index ff68b24b..cfba26e8 100644
--- a/app/imports/client/ui/creature/character/characterSheetTabs/SpellsTab.vue
+++ b/app/imports/client/ui/creature/character/characterSheetTabs/SpellsTab.vue
@@ -77,7 +77,6 @@ export default {
tabName: 'spells',
}
},
- // @ts-ignore Meteor isn't defined on vue
meteor: {
folderIds() {
return CreatureProperties.find({
@@ -143,7 +142,7 @@ export default {
spellsWithoutList() {
return CreatureProperties.find({
...getFilter.descendantsOfRoot(this.creatureId),
- $not: getFilter.descendantsOfAll(this.spellLists),
+ $nor: [getFilter.descendantsOfAll(this.spellLists)],
parentId: {
$nin: this.folderIds,
},
@@ -161,7 +160,7 @@ export default {
spellListsWithoutAncestorSpellLists() {
return CreatureProperties.find({
...getFilter.descendantsOfRoot(this.creatureId),
- $not: getFilter.descendantsOfAll(this.spellLists),
+ $nor: [getFilter.descendantsOfAll(this.spellLists)],
parentId: {
$nin: this.folderIds,
},
diff --git a/app/imports/client/ui/creature/creatureProperties/Breadcrumbs.vue b/app/imports/client/ui/creature/creatureProperties/Breadcrumbs.vue
index 95420086..f880c17e 100644
--- a/app/imports/client/ui/creature/creatureProperties/Breadcrumbs.vue
+++ b/app/imports/client/ui/creature/creatureProperties/Breadcrumbs.vue
@@ -141,7 +141,7 @@ import { Mongo } from 'meteor/mongo';
component: 'creature-root-dialog',
elementId: 'breadcrumb-root',
data: {
- _id: this.model.ancestors[0].id,
+ _id: this.model.root.id,
startInEditTab: this.editing,
},
});
diff --git a/app/imports/client/ui/properties/components/spells/SpellListCard.vue b/app/imports/client/ui/properties/components/spells/SpellListCard.vue
index 02c91e8c..4a4194c1 100644
--- a/app/imports/client/ui/properties/components/spells/SpellListCard.vue
+++ b/app/imports/client/ui/properties/components/spells/SpellListCard.vue
@@ -78,6 +78,7 @@
import ToolbarCard from '/imports/client/ui/components/ToolbarCard.vue';
import SpellList from '/imports/client/ui/properties/components/spells/SpellList.vue';
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties';
+import { getFilter } from '/imports/api/parenting/parentingFunctions';
export default {
components: {
@@ -99,7 +100,7 @@ export default {
meteor: {
spells() {
let filter = {
- 'ancestors.id': this.model._id,
+ ...getFilter.descendants(this.model),
type: 'spell',
removed: { $ne: true },
};
diff --git a/app/imports/client/ui/properties/viewers/shared/PropertyField.vue b/app/imports/client/ui/properties/viewers/shared/PropertyField.vue
index e7f43a4e..c26bb740 100644
--- a/app/imports/client/ui/properties/viewers/shared/PropertyField.vue
+++ b/app/imports/client/ui/properties/viewers/shared/PropertyField.vue
@@ -40,7 +40,6 @@
v-bind="$attrs"
>
- default slot content
{{ valueText }}
diff --git a/app/imports/server/publications/slotFillers.js b/app/imports/server/publications/slotFillers.js
index f8f233cd..5b0f7cd1 100644
--- a/app/imports/server/publications/slotFillers.js
+++ b/app/imports/server/publications/slotFillers.js
@@ -27,7 +27,7 @@ Meteor.publish('selectedFillers', function (slotId, nodeIds, isDummySlot) {
if (!slot) return [];
// Get all the ids of libraries the user can access
- const creatureId = slot.ancestors[0].id;
+ const creatureId = slot.root.id;
const libraryIds = getCreatureLibraryIds(creatureId, userId);
const libraries = Libraries.find({
$or: [
@@ -80,7 +80,7 @@ Meteor.publish('slotFillers', function (slotId, searchTerm, isDummySlot) {
if (!slot) return [];
// Get all the ids of libraries the user can access
- const creatureId = slot.ancestors[0].id;
+ const creatureId = slot.root.id;
const libraryIds = getCreatureLibraryIds(creatureId, userId);
const libraries = Libraries.find({
$or: [
@@ -166,7 +166,7 @@ Meteor.publish('classFillers', function (classId) {
}
// Get all the ids of libraries the user can access
- const creatureId = classProp.ancestors[0].id;
+ const creatureId = classProp.root.id;
const libraryIds = getCreatureLibraryIds(creatureId, userId);
const libraries = Libraries.find({
$or: [