Fixed some character sheet Query errors

This commit is contained in:
Thaum Rystra
2024-03-23 21:06:58 +02:00
parent 359d645f6b
commit 225b895833
10 changed files with 54 additions and 55 deletions

View File

@@ -4,12 +4,12 @@
:class="{
'empty': !hasChildren,
}"
:data-id="`tree-node-${node._id}`"
:data-id="`tree-node-${doc._id}`"
>
<div
class="layout align-center justify-start tree-node-title"
style="cursor: pointer;"
@click.stop="$emit('selected', node._id)"
@click.stop="$emit('selected', doc._id)"
>
<v-btn
small
@@ -17,7 +17,7 @@
class="expand-button"
:class="{
'rotate-90': showExpanded,
'accent--text': node._descendantCanFill || canFillWithMany
'accent--text': doc._descendantCanFill || canFillWithMany
}"
:disabled="!canExpand"
@click.stop="expanded = !expanded"
@@ -29,7 +29,7 @@
<div
class="layout align-center justify-start pr-1"
>
<!--{{node && node.order}}-->
<!--{{doc && doc.order}}-->
<div
v-if="isSlot"
class="text-truncate"
@@ -40,25 +40,25 @@
'accent--text': canFill,
}"
>
{{ node.name }}
{{ doc.name }}
</span>
<fill-slot-button
v-if="canFillWithOne"
:model="node"
:model="doc"
/>
</div>
<template
v-else
>
<tree-node-view
:model="node"
:model="doc"
/>
<v-spacer />
<v-btn
v-if="node.parent.id === parentSlotId"
v-if="doc.parent.id === parentSlotId"
icon
:disabled="context.editPermission === false"
@click.stop="remove(node)"
@click.stop="remove(doc)"
>
<v-icon>
mdi-delete
@@ -68,13 +68,13 @@
<template v-if="condenseChild">
<span class="mr-4">:</span>
<tree-node-view
:model="children[0].node"
:model="children[0].doc"
/>
<v-spacer />
<v-btn
icon
:disabled="context.editPermission === false"
@click.stop="remove(children[0].node)"
@click.stop="remove(children[0].doc)"
>
<v-icon>
mdi-delete
@@ -109,7 +109,7 @@
>
<fill-slot-button
class="ml-5"
:model="node"
:model="doc"
/>
</div>
</div>
@@ -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() {

View File

@@ -2,8 +2,8 @@
<div class="build-tree-node-list">
<build-tree-node
v-for="child in children"
:key="child.node._id"
:node="child.node"
:key="child.doc._id"
:doc="child.doc"
:children="child.children"
:parent-slot-id="parentSlotId"
:depth="depth + 1"

View File

@@ -201,7 +201,7 @@
<script lang="js">
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;
});
}
});

View File

@@ -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,
},

View File

@@ -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},
});

View File

@@ -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,
},

View File

@@ -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,
},
});

View File

@@ -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 },
};

View File

@@ -40,7 +40,6 @@
v-bind="$attrs"
>
<slot>
default slot content
<template v-if="value !== undefined">
{{ valueText }}
</template>

View File

@@ -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: [