diff --git a/app/imports/api/creature/creatureProperties/methods/getSlotFillFilter.js b/app/imports/api/creature/creatureProperties/methods/getSlotFillFilter.js
index a25e7bf4..f6a5e7f9 100644
--- a/app/imports/api/creature/creatureProperties/methods/getSlotFillFilter.js
+++ b/app/imports/api/creature/creatureProperties/methods/getSlotFillFilter.js
@@ -1,7 +1,7 @@
export default function getSlotFillFilter({ slot, libraryIds }) {
- if (!slot) throw 'Slot is required';
- if (!libraryIds) throw 'LibraryIds is required';
+ if (!slot) throw 'Slot is required for getSlotFillFilter';
+ if (!libraryIds) throw 'LibraryIds is required for getSlotFillFilter';
let filter = {
removed: { $ne: true },
@@ -13,7 +13,6 @@ export default function getSlotFillFilter({ slot, libraryIds }) {
$or: [{
type: slot.slotType
}, {
- type: 'slotFiller',
slotFillerType: slot.slotType,
}]
});
@@ -22,7 +21,6 @@ export default function getSlotFillFilter({ slot, libraryIds }) {
$or: [{
type: 'classLevel',
}, {
- type: 'slotFiller',
slotFillerType: 'classLevel',
}]
});
diff --git a/app/imports/api/creature/creatureProperties/methods/getSlotFillFilter.test.js b/app/imports/api/creature/creatureProperties/methods/getSlotFillFilter.test.js
index 2e4048d2..5ca0f4ed 100644
--- a/app/imports/api/creature/creatureProperties/methods/getSlotFillFilter.test.js
+++ b/app/imports/api/creature/creatureProperties/methods/getSlotFillFilter.test.js
@@ -50,7 +50,6 @@ describe('Slot fill filter', function () {
$or: [{
type: 'feature'
}, {
- type: 'slotFiller',
slotFillerType: 'feature',
}],
}]);
diff --git a/app/imports/api/engine/computation/buildComputation/computeSlotQuantityFilled.js b/app/imports/api/engine/computation/buildComputation/computeSlotQuantityFilled.js
index e3adabc8..e9e4a287 100644
--- a/app/imports/api/engine/computation/buildComputation/computeSlotQuantityFilled.js
+++ b/app/imports/api/engine/computation/buildComputation/computeSlotQuantityFilled.js
@@ -2,7 +2,7 @@
* Only computes `totalFilled`, need to compute `quantityExpected.value`
* before `spacesLeft` can be computed
*/
-export default function computeSlotQuantityFilled(node, dependencyGraph){
+export default function computeSlotQuantityFilled(node, dependencyGraph) {
let slot = node.node;
if (slot.type !== 'propertySlot') return;
slot.totalFilled = 0;
@@ -10,9 +10,8 @@ export default function computeSlotQuantityFilled(node, dependencyGraph){
let childProp = child.node;
dependencyGraph.addLink(slot._id, childProp._id, 'slotFill');
if (
- childProp.type === 'slotFiller' &&
Number.isFinite(childProp.slotQuantityFilled)
- ){
+ ) {
slot.totalFilled += childProp.slotQuantityFilled;
} else {
slot.totalFilled++;
diff --git a/app/imports/api/engine/computation/computeComputation/computeByType/computeSlot.js b/app/imports/api/engine/computation/computeComputation/computeByType/computeSlot.js
index 9e9dc07b..8128719a 100644
--- a/app/imports/api/engine/computation/computeComputation/computeByType/computeSlot.js
+++ b/app/imports/api/engine/computation/computeComputation/computeByType/computeSlot.js
@@ -1,6 +1,6 @@
-export default function computSlot(computation, node){
+export default function computeSlot(computation, node) {
const prop = node.data;
- if (prop.quantityExpected && prop.quantityExpected.value){
+ if (prop.quantityExpected && prop.quantityExpected.value) {
prop.spaceLeft = prop.quantityExpected.value - prop.totalFilled;
}
}
diff --git a/app/imports/api/library/getCreatureLibraryIds.js b/app/imports/api/library/getCreatureLibraryIds.js
index beb9c7d3..a951a042 100644
--- a/app/imports/api/library/getCreatureLibraryIds.js
+++ b/app/imports/api/library/getCreatureLibraryIds.js
@@ -4,6 +4,7 @@ import getUserLibraryIds from './getUserLibraryIds';
import { intersection, union } from 'lodash';
export default function getCreatureLibraryIds(creature, userId) {
+ if (!userId) console.log('no userId, returning empty array');
if (!userId) return [];
// Get the ids of libraries the user is permitted to view
@@ -17,14 +18,14 @@ export default function getCreatureLibraryIds(creature, userId) {
allowedLibraryCollections: 1,
}
});
- if (!creature) return [];
+ if (!creature) return userLibIds;
}
// If the creature does not restrict the libraries, let it use them all
if (!creature.allowedLibraryCollections && !creature.allowedLibraries) {
return userLibIds;
}
-
+
// Get the ids of the libraries that the creature allows
const allowedCollections = creature.allowedLibraryCollections || [];
let creatureLibIds = creature.allowedLibraries || [];
diff --git a/app/imports/api/utility/escapeRegex.js b/app/imports/api/utility/escapeRegex.js
new file mode 100644
index 00000000..8ec4073c
--- /dev/null
+++ b/app/imports/api/utility/escapeRegex.js
@@ -0,0 +1,3 @@
+export default function escapeRegex(string) {
+ return string.replace(/[/\-\\^$*+?.()|[\]{}]/g, '');
+}
\ No newline at end of file
diff --git a/app/imports/client/ui/creature/slots/SlotFillDialog.vue b/app/imports/client/ui/creature/slots/SlotFillDialog.vue
index 8b2d24f0..15fc925b 100644
--- a/app/imports/client/ui/creature/slots/SlotFillDialog.vue
+++ b/app/imports/client/ui/creature/slots/SlotFillDialog.vue
@@ -26,7 +26,7 @@
:string="model.description"
/>
- {{ slotPropertyTypeName }} with tags:
+ {{ slotPropertyTypeName }} with library tags:
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{ libraryNode.slotFillerCondition }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ libraryNode._conditionError }}
+
+
+
+ {{ libraryNames[libraryNode.ancestors[0].id ] }}
-
- {{ libraryNames[libraryNode.ancestors[0].id ] }}
-
-
-
- {{ libraryNode.slotQuantityFilled }} slots
-
-
-
- mdi-window-restore
-
+ {{ libraryNode.slotQuantityFilled }} slots
+
+
+
+ mdi-window-restore
+
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
this.spaceLeft
) {
+ node._disabled = true;
node._disabledByQuantityFilled = true;
}
if (this.alreadyAdded.has(node._id)) {
+ node._disabled = true;
node._disabledByAlreadyAdded = true;
}
});
+ // Only run the auto-select once
+ if (!this.autoSelectRan) {
+ this.autoSelectRan = true;
+ // If we have exactly one active node and no selected nodes, pre-select it
+ if (
+ nodes.length === 1
+ && !nodes[0]._disabled
+ && !this.selectedNodeIds?.length
+ ) {
+ this.selectedNodeIds = [nodes[0]._id];
+ }
+ }
this.disabledNodeCount = disabledNodeCount;
return nodes;
},
diff --git a/app/imports/client/ui/library/LibraryNodeExpansionContent.vue b/app/imports/client/ui/library/LibraryNodeExpansionContent.vue
index 1067d4a5..f6168488 100644
--- a/app/imports/client/ui/library/LibraryNodeExpansionContent.vue
+++ b/app/imports/client/ui/library/LibraryNodeExpansionContent.vue
@@ -1,16 +1,27 @@
@@ -31,6 +42,11 @@ export default {
required: true,
},
},
+ computed: {
+ subsReady() {
+ return this.$subReady.descendantLibraryNodes && this.$subReady.libraryNode;
+ }
+ },
methods: {
clickChild(id){
this.$store.commit('pushDialogStack', {
@@ -57,7 +73,7 @@ export default {
ancestorId: this.model._id
});
},
- },
+ }
}
diff --git a/app/imports/server/publications/library.js b/app/imports/server/publications/library.js
index 68c378b5..5fe0b019 100644
--- a/app/imports/server/publications/library.js
+++ b/app/imports/server/publications/library.js
@@ -14,15 +14,18 @@ const LIBRARY_NODE_TREE_FIELDS = {
order: 1,
parent: 1,
ancestors: 1,
- tags: 1,
- slotFillerCondition: 1,
removed: 1,
removedAt: 1,
// Actions
actionType: 1,
// SlotFillers
+ libraryTags: 1,
slotQuantityFilled: 1,
slotFillerType: 1,
+ slotFillerConditionNote: 1,
+ slotFillerCondition: 1,
+ searchable: 1,
+ slotFillImage: 1,
// Effect
operation: 1,
targetTags: 1,
diff --git a/app/imports/server/publications/searchLibraryNodes.js b/app/imports/server/publications/searchLibraryNodes.js
index bbfcea84..75750d33 100644
--- a/app/imports/server/publications/searchLibraryNodes.js
+++ b/app/imports/server/publications/searchLibraryNodes.js
@@ -4,10 +4,7 @@ import LibraryNodes from '/imports/api/library/LibraryNodes.js';
import getCreatureLibraryIds from '/imports/api/library/getCreatureLibraryIds.js';
import getUserLibraryIds from '/imports/api/library/getUserLibraryIds.js';
import { assertViewPermission } from '/imports/api/sharing/sharingPermissions.js';
-
-function escapeRegex(string) {
- return string.replace(/[/\-\\^$*+?.()|[\]{}]/g, '');
-}
+import escapeRegex from '/imports/api/utility/escapeRegex.js';
Meteor.publish('selectedLibraryNodes', function (selectedNodeIds) {
check(selectedNodeIds, Array);
diff --git a/app/imports/server/publications/slotFillers.js b/app/imports/server/publications/slotFillers.js
index 6427af79..d3cf32c0 100644
--- a/app/imports/server/publications/slotFillers.js
+++ b/app/imports/server/publications/slotFillers.js
@@ -5,19 +5,20 @@ import CreatureProperties from '/imports/api/creature/creatureProperties/Creatur
import getSlotFillFilter from '/imports/api/creature/creatureProperties/methods/getSlotFillFilter.js'
import getCreatureLibraryIds from '/imports/api/library/getCreatureLibraryIds.js';
import { LIBRARY_NODE_TREE_FIELDS } from '/imports/server/publications/library.js';
+import escapeRegex from '/imports/api/utility/escapeRegex.js';
-Meteor.publish('slotFillers', function(slotId, searchTerm){
+Meteor.publish('slotFillers', function (slotId, searchTerm) {
if (searchTerm) check(searchTerm, String);
let self = this;
- this.autorun(function (){
+ this.autorun(function () {
let userId = this.userId;
if (!userId) {
return [];
}
// Get the slot
let slot = CreatureProperties.findOne(slotId);
- if (!slot){
+ if (!slot) {
return [];
}
@@ -36,31 +37,32 @@ Meteor.publish('slotFillers', function(slotId, searchTerm){
});
// Build a filter for nodes in those libraries that match the slot
- let filter = getSlotFillFilter({slot, libraryIds});
-
- this.autorun(function(){
+ let filter = getSlotFillFilter({ slot, libraryIds });
+ this.autorun(function () {
// Get the limit of the documents the user can fetch
var limit = self.data('limit') || 50;
check(limit, Number);
let options = undefined;
- if (searchTerm){
- filter.$text = {$search: searchTerm};
+ if (searchTerm) {
+ filter.name = { $regex: escapeRegex(searchTerm), '$options': 'i' };
+ //filter.$text = { $search: searchTerm };
options = {
// relevant documents have a higher score.
fields: {
- _score: { $meta: 'textScore' },
+ //_score: { $meta: 'textScore' },
...LIBRARY_NODE_TREE_FIELDS,
},
sort: {
// `score` property specified in the projection fields above.
- _score: { $meta: 'textScore' },
+ //_score: { $meta: 'textScore' },
name: 1,
order: 1,
}
}
} else {
- delete filter.$text
+ //delete filter.$text
+ delete filter.name
options = {
sort: {
name: 1,
@@ -73,6 +75,7 @@ Meteor.publish('slotFillers', function(slotId, searchTerm){
self.autorun(function () {
self.setData('countAll', LibraryNodes.find(filter).count());
+ self.setData('libraryNodeFilter', EJSON.stringify(filter));
});
self.autorun(function () {
return [
@@ -84,18 +87,18 @@ Meteor.publish('slotFillers', function(slotId, searchTerm){
});
});
-Meteor.publish('classFillers', function(classId){
+Meteor.publish('classFillers', function (classId) {
let self = this;
if (!classId) return [];
- this.autorun(function (){
+ this.autorun(function () {
let userId = this.userId;
if (!userId) {
return [];
}
// Get the class
let classProp = CreatureProperties.findOne(classId);
- if (!classProp){
+ if (!classProp) {
return [];
}
@@ -114,9 +117,9 @@ Meteor.publish('classFillers', function(classId){
});
// Build a filter for nodes in those libraries that match the slot
- let filter = getSlotFillFilter({slot: classProp, libraryIds});
+ let filter = getSlotFillFilter({ slot: classProp, libraryIds });
- this.autorun(function(){
+ this.autorun(function () {
// Get the limit of the documents the user can fetch
var limit = self.data('limit') || 50;
check(limit, Number);