Compare commits

..

3 Commits

Author SHA1 Message Date
Stefan Zermatten
f043c41e12 Fixed fab being confused by hiding the spells tab 2021-08-14 10:44:17 +02:00
Stefan Zermatten
0277de76c4 Removed stray console log 2021-08-12 19:56:01 +02:00
Stefan Zermatten
ffc3211ff9 Fixed some issues with slot filler searching 2021-08-12 18:28:53 +02:00
3 changed files with 34 additions and 45 deletions

View File

@@ -4,7 +4,9 @@ import LibraryNodes from '/imports/api/library/LibraryNodes.js';
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js'; import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
import getSlotFillFilter from '/imports/api/creature/creatureProperties/methods/getSlotFillFilter.js' import getSlotFillFilter from '/imports/api/creature/creatureProperties/methods/getSlotFillFilter.js'
Meteor.publish('slotFillers', function(slotId){ Meteor.publish('slotFillers', function(slotId, searchTerm){
if (searchTerm) check(searchTerm, String);
let self = this; let self = this;
this.autorun(function (){ this.autorun(function (){
let userId = this.userId; let userId = this.userId;
@@ -42,21 +44,17 @@ Meteor.publish('slotFillers', function(slotId){
var limit = self.data('limit') || 50; var limit = self.data('limit') || 50;
check(limit, Number); check(limit, Number);
// Get the search term
let searchTerm = self.data('searchTerm') || '';
check(searchTerm, String);
let options = undefined; let options = undefined;
if (searchTerm){ if (searchTerm){
filter.$text = {$search: searchTerm}; filter.$text = {$search: searchTerm};
options = { options = {
// relevant documents have a higher score. // relevant documents have a higher score.
fields: { fields: {
score: { $meta: 'textScore' } _score: { $meta: 'textScore' }
}, },
sort: { sort: {
// `score` property specified in the projection fields above. // `score` property specified in the projection fields above.
score: { $meta: 'textScore' }, _score: { $meta: 'textScore' },
name: 1, name: 1,
order: 1, order: 1,
} }
@@ -74,6 +72,7 @@ Meteor.publish('slotFillers', function(slotId){
self.setData('countAll', LibraryNodes.find(filter).count()); self.setData('countAll', LibraryNodes.find(filter).count());
}); });
self.autorun(function () { self.autorun(function () {
Meteor._sleepForMs(1000);
return [LibraryNodes.find(filter, options), libraries]; return [LibraryNodes.find(filter, options), libraries];
}); });
}); });

View File

@@ -44,6 +44,7 @@
import { getHighestOrder } from '/imports/api/parenting/order.js'; import { getHighestOrder } from '/imports/api/parenting/order.js';
import insertProperty from '/imports/api/creature/creatureProperties/methods/insertProperty.js'; import insertProperty from '/imports/api/creature/creatureProperties/methods/insertProperty.js';
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js'; import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
import Creatures from '/imports/api/creature/creatures/Creatures.js';
import PROPERTIES from '/imports/constants/PROPERTIES.js'; import PROPERTIES from '/imports/constants/PROPERTIES.js';
import insertPropertyFromLibraryNode from '/imports/api/creature/creatureProperties/methods/insertPropertyFromLibraryNode.js'; import insertPropertyFromLibraryNode from '/imports/api/creature/creatureProperties/methods/insertPropertyFromLibraryNode.js';
import fetchDocByRef from '/imports/api/parenting/fetchDocByRef.js'; import fetchDocByRef from '/imports/api/parenting/fetchDocByRef.js';
@@ -119,7 +120,11 @@
return this.$route.params.id; return this.$route.params.id;
}, },
tabNumber(){ tabNumber(){
return this.$store.getters.tabById(this.creatureId); let tabNumber = this.$store.getters.tabById(this.creatureId);
if (this.hideSpellsTab && tabNumber > 2){
tabNumber += 1;
}
return tabNumber;
}, },
speedDials(){ speedDials(){
return this.speedDialsByTab[tabs[this.tabNumber]]; return this.speedDialsByTab[tabs[this.tabNumber]];
@@ -136,6 +141,12 @@
return PROPERTIES; return PROPERTIES;
}, },
}, },
meteor: {
hideSpellsTab(){
let creature = Creatures.findOne(this.creatureId);
return creature?.settings.hideSpellsTab;
},
},
methods: { methods: {
getPropertyLabel(type){ getPropertyLabel(type){
if (type === 'buff') return 'Buff or Condition'; if (type === 'buff') return 'Buff or Condition';

View File

@@ -8,14 +8,17 @@
{{ model.name }} {{ model.name }}
</v-toolbar-title> </v-toolbar-title>
<v-spacer /> <v-spacer />
<text-field <v-text-field
v-model="searchInput"
prepend-inner-icon="mdi-magnify" prepend-inner-icon="mdi-magnify"
regular regular
clearable
hide-details hide-details
:value="searchValue" class="flex-grow-0"
:debounce="300" style="flex-basis: 300px;"
@change="searchChanged" :loading="searchLoading"
@keyup.enter="insert" @change="searchValue = searchInput || undefined"
@click:clear="searchValue = undefined"
/> />
</template> </template>
<property-description <property-description
@@ -88,7 +91,7 @@
</div> </div>
</v-layout> </v-layout>
<div <div
v-if="libraryNode.slotQuantityFilled && libraryNode.slotQuantityFilled !== 1" v-if="libraryNode.slotQuantityFilled !== undefined && libraryNode.slotQuantityFilled !== 1"
class="text-overline flex-grow-0 text-no-wrap" class="text-overline flex-grow-0 text-no-wrap"
:class="{ :class="{
'error--text': isDisabled(libraryNode) && 'error--text': isDisabled(libraryNode) &&
@@ -115,7 +118,7 @@
</template> </template>
</v-expansion-panels> </v-expansion-panels>
<v-layout <v-layout
v-if="!$subReady.slotFillers || currentLimit < countAll" v-if="(!$subReady.slotFillers && !searchValue) || currentLimit < countAll"
column column
align-center align-center
justify-center justify-center
@@ -216,6 +219,7 @@ export default {
}, },
data(){return { data(){return {
selectedNodeIds: [], selectedNodeIds: [],
searchInput: undefined,
searchValue: undefined, searchValue: undefined,
showDisabled: false, showDisabled: false,
disabledNodeCount: undefined, disabledNodeCount: undefined,
@@ -250,21 +254,10 @@ export default {
}, },
}, },
methods: { methods: {
searchChanged(val, ack){
this._subs['slotFillers'].setData('searchTerm', val);
this._subs['slotFillers'].setData('limit', undefined);
this.selectedNode = undefined;
this.searchValue = val;
setTimeout(ack, 200);
},
loadMore(){ loadMore(){
if (this.currentLimit >= this.countAll) return; if (this.currentLimit >= this.countAll) return;
this._subs['slotFillers'].setData('limit', this.currentLimit + 50); this._subs['slotFillers'].setData('limit', this.currentLimit + 50);
}, },
insert(){
if (!this.selectedNode) return;
this.$store.dispatch('popDialogStack', this.selectedNode);
},
openPropertyDetails(id){ openPropertyDetails(id){
this.$store.commit('pushDialogStack', { this.$store.commit('pushDialogStack', {
component: 'library-node-dialog', component: 'library-node-dialog',
@@ -281,14 +274,17 @@ export default {
node._disabledByQuantityFilled && node._disabledByQuantityFilled &&
!this.selectedNodeIds.includes(node._id) !this.selectedNodeIds.includes(node._id)
) )
} },
}, },
meteor: { meteor: {
$subscribe: { $subscribe: {
'slotFillers'(){ 'slotFillers'(){
return [this.slotId] return [this.slotId, this.searchValue || undefined]
}, },
}, },
searchLoading(){
return !!this.searchValue && !this.$subReady.slotFillers;
},
model(){ model(){
if (this.slotId){ if (this.slotId){
return CreatureProperties.findOne(this.slotId); return CreatureProperties.findOne(this.slotId);
@@ -359,8 +355,6 @@ export default {
sort: {name: 1, order: 1} sort: {name: 1, order: 1}
}).fetch(); }).fetch();
let disabledNodeCount = 0; let disabledNodeCount = 0;
let activeNodeCount = 0;
let lastActiveNodeId = undefined;
// Mark slotFillers whose condition isn't met or are too big to fit // Mark slotFillers whose condition isn't met or are too big to fit
// the quantity to fill // the quantity to fill
nodes.forEach(node => { nodes.forEach(node => {
@@ -384,23 +378,8 @@ export default {
if (this.alreadyAdded.has(node._id)){ if (this.alreadyAdded.has(node._id)){
node._disabledByAlreadyAdded = true; node._disabledByAlreadyAdded = true;
} }
if (
!node._disabledBySlotFillerCondition &&
!node._disabledByQuantityFilled &&
!node._disabledByAlreadyAdded
){
activeNodeCount += 1;
lastActiveNodeId = node._id;
}
}); });
this.disabledNodeCount = disabledNodeCount; this.disabledNodeCount = disabledNodeCount;
if (
activeNodeCount === 1 &&
this.$subReady.slotFillers &&
this.currentLimit >= this.countAll
) {
this.selectedNodeIds = [lastActiveNodeId]
}
return nodes; return nodes;
}, },
} }