@@ -179,10 +192,16 @@ export default {
return prop && prop.name;
},
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(){
+ if (this.currentLimit >= this.countAll) return;
+ this._subs['slotFillers'].setData('limit', this.currentLimit + 16);
+ },
insert(){
if (!this.selectedNode) return;
this.$store.dispatch('popDialogStack', this.selectedNode);
@@ -200,16 +219,16 @@ export default {
creature(){
return Creatures.findOne(this.creatureId);
},
+ currentLimit(){
+ return this._subs['slotFillers'].data('limit') || 16;
+ },
+ countAll(){
+ return this._subs['slotFillers'].data('countAll');
+ },
libraryNodes(){
let filter = {
removed: {$ne: true},
};
- if (this.searchValue){
- filter.name = {
- $regex: this.searchValue.replace(/[-/\\^$*+?.()|[\]{}]/g, '\\$&'),
- $options: 'i'
- };
- }
if (this.model.slotTags && this.model.slotTags.length){
filter.tags = {$all: this.model.slotTags};
}
@@ -221,7 +240,9 @@ export default {
slotFillerType: this.model.slotType,
}];
}
- let nodes = LibraryNodes.find(filter).fetch();
+ let nodes = LibraryNodes.find(filter, {
+ sort: {name: 1, order: 1}
+ }).fetch();
// Filter out slotFillers whose condition isn't met or are too big to fit
// the quantity to fill
nodes = nodes.filter(node => {