Reduced data load in slot fill dialog

This commit is contained in:
Stefan Zermatten
2022-06-21 11:00:50 +02:00
parent 9f59a6cf86
commit 9cc4186171
4 changed files with 65 additions and 50 deletions

View File

@@ -3,6 +3,39 @@ import Libraries from '/imports/api/library/Libraries.js';
import LibraryNodes from '/imports/api/library/LibraryNodes.js';
import { assertViewPermission, assertDocViewPermission } from '/imports/api/sharing/sharingPermissions.js';
const LIBRARY_NODE_TREE_FIELDS = {
_id: 1,
name: 1,
type: 1,
icon: 1,
color: 1,
order: 1,
parent: 1,
ancestors: 1,
// Effect
operation: 1,
targetTags: 1,
stats: 1,
// Item
quantity: 1,
plural: 1,
equipped: 1,
// Branch
branchType: 1,
// Damage:
damageType: 1,
stat: 1,
amount: 1,
// Class level
level: 1,
// Proficiency
value: 1,
// Reference
cache: 1,
}
export { LIBRARY_NODE_TREE_FIELDS };
Meteor.publish('libraries', function(){
this.autorun(function (){
let userId = this.userId;
@@ -64,36 +97,7 @@ Meteor.publish('libraryNodes', function(libraryId){
'ancestors.id': libraryId,
}, {
sort: { order: 1 },
fields: {
_id: 1,
name: 1,
type: 1,
icon: 1,
color: 1,
order: 1,
parent: 1,
ancestors: 1,
// Effect
operation: 1,
targetTags: 1,
stats: 1,
// Item
quantity: 1,
plural: 1,
equipped: 1,
// Branch
branchType: 1,
// Damage:
damageType: 1,
stat: 1,
amount: 1,
// Class level
level: 1,
// Proficiency
value: 1,
// Reference
cache: 1,
}
fields: LIBRARY_NODE_TREE_FIELDS,
}),
];
});

View File

@@ -3,6 +3,13 @@ import Libraries from '/imports/api/library/Libraries.js';
import LibraryNodes from '/imports/api/library/LibraryNodes.js';
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
import getSlotFillFilter from '/imports/api/creature/creatureProperties/methods/getSlotFillFilter.js'
import { LIBRARY_NODE_TREE_FIELDS } from '/imports/server/publications/library.js';
const FIELDS = {
...LIBRARY_NODE_TREE_FIELDS,
slotFillerCondition: 1,
tags: 1,
}
Meteor.publish('slotFillers', function(slotId, searchTerm){
if (searchTerm) check(searchTerm, String);
@@ -50,7 +57,8 @@ Meteor.publish('slotFillers', function(slotId, searchTerm){
options = {
// relevant documents have a higher score.
fields: {
_score: { $meta: 'textScore' }
_score: { $meta: 'textScore' },
...FIELDS,
},
sort: {
// `score` property specified in the projection fields above.
@@ -61,10 +69,13 @@ Meteor.publish('slotFillers', function(slotId, searchTerm){
}
} else {
delete filter.$text
options = {sort: {
name: 1,
order: 1,
}};
options = {
sort: {
name: 1,
order: 1,
},
fields: FIELDS,
};
}
options.limit = limit;
@@ -72,7 +83,6 @@ Meteor.publish('slotFillers', function(slotId, searchTerm){
self.setData('countAll', LibraryNodes.find(filter).count());
});
self.autorun(function () {
Meteor._sleepForMs(1000);
return [LibraryNodes.find(filter, options), libraries];
});
});

View File

@@ -27,20 +27,18 @@
/>
<p>
{{ slotPropertyTypeName }} with tags:
<template v-for="(tags, index) in tagsSearched.or">
<property-tags
:key="index"
:tags="tags"
:prefix="index ? 'OR' : undefined"
/>
</template>
<template v-for="(tags, index) in tagsSearched.not">
<property-tags
:key="index"
:tags="tags"
prefix="NOT"
/>
</template>
<property-tags
v-for="(tags, index) in tagsSearched.or"
:key="index"
:tags="tags"
:prefix="index ? 'OR' : undefined"
/>
<property-tags
v-for="(tags, index) in tagsSearched.not"
:key="index"
:tags="tags"
prefix="NOT"
/>
</p>
<v-expansion-panels
multiple

View File

@@ -44,6 +44,9 @@ export default {
},
meteor: {
$subscribe: {
libraryNode(){
return [this.model._id];
},
descendantLibraryNodes(){
return [this.model._id];
},