Added multi level up to the level up dialog
This commit is contained in:
@@ -32,7 +32,7 @@ export default function getSlotFillFilter({ slot, libraryIds }) {
|
||||
if (slot.missingLevels && slot.missingLevels.length) {
|
||||
filter.level = { $in: slot.missingLevels };
|
||||
} else {
|
||||
filter.level = (slot.level || 0) + 1;
|
||||
filter.level = { $gt: slot.level || 0 };
|
||||
}
|
||||
}
|
||||
let tagsOr = [];
|
||||
|
||||
@@ -192,7 +192,7 @@ import getSlotFillFilter from '/imports/api/creature/creatureProperties/methods/
|
||||
import Libraries from '/imports/api/library/Libraries.js';
|
||||
import LibraryNodeExpansionContent from '/imports/client/ui/library/LibraryNodeExpansionContent.vue';
|
||||
import PropertyTags from '/imports/client/ui/properties/viewers/shared/PropertyTags.vue';
|
||||
import { clone } from 'lodash';
|
||||
import { clone, difference } from 'lodash';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -248,6 +248,29 @@ export default {
|
||||
return { or, not };
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
selectedNodeIds(selectedIds, oldSelectedIds) {
|
||||
// Skip if we didn't increase the length by adding a new Id
|
||||
if (oldSelectedIds.length >= selectedIds.length) return;
|
||||
// Find out which library node was added
|
||||
const addedId = difference(selectedIds, oldSelectedIds)[0];
|
||||
if (!addedId) return;
|
||||
const addedNode = LibraryNodes.findOne(addedId);
|
||||
if (!addedNode) return;
|
||||
// Tick any unchecked nodes of a lower level, but only one per level
|
||||
const backFilledLevels = new Set();
|
||||
this.libraryNodes.forEach(node => {
|
||||
if (
|
||||
!selectedIds.includes(node._id)
|
||||
&& node.level < addedNode.level
|
||||
&& !backFilledLevels.has(node.level)
|
||||
) {
|
||||
selectedIds.push(node._id);
|
||||
}
|
||||
});
|
||||
this.selectedNodeIds = selectedIds;
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
loadMore() {
|
||||
if (this.currentLimit >= this.countAll) return;
|
||||
@@ -345,9 +368,15 @@ export default {
|
||||
Libraries.find().forEach(lib => names[lib._id] = lib.name)
|
||||
return names;
|
||||
},
|
||||
libraryNodeFilter() {
|
||||
const filterString = this._subs['classFillers'].data('libraryNodeFilter');
|
||||
if (!filterString) return;
|
||||
return EJSON.parse(filterString);
|
||||
},
|
||||
libraryNodes() {
|
||||
let filter = getSlotFillFilter({ slot: this.model });
|
||||
let nodes = LibraryNodes.find(filter, {
|
||||
if (!this.libraryNodeFilter) return [];
|
||||
if (!this.$subReady.classFillers) return [];
|
||||
let nodes = LibraryNodes.find(this.libraryNodeFilter, {
|
||||
sort: { name: 1, order: 1 }
|
||||
}).fetch();
|
||||
let disabledNodeCount = 0;
|
||||
|
||||
@@ -126,6 +126,7 @@ Meteor.publish('classFillers', function (classId) {
|
||||
|
||||
let options = {
|
||||
sort: {
|
||||
level: 1,
|
||||
name: 1,
|
||||
order: 1,
|
||||
},
|
||||
@@ -135,6 +136,7 @@ Meteor.publish('classFillers', function (classId) {
|
||||
|
||||
self.autorun(function () {
|
||||
self.setData('countAll', LibraryNodes.find(filter).count());
|
||||
self.setData('libraryNodeFilter', EJSON.stringify(filter));
|
||||
});
|
||||
self.autorun(function () {
|
||||
return [LibraryNodes.find(filter, options), libraries];
|
||||
|
||||
Reference in New Issue
Block a user