Improved slot tag handling

This commit is contained in:
Stefan Zermatten
2022-07-24 21:50:31 +02:00
parent a0c2822dac
commit 4c5c537f29
9 changed files with 29 additions and 23 deletions

View File

@@ -49,10 +49,10 @@ export default function getSlotFillFilter({slot, libraryIds}){
});
}
if (tagsOr.length){
filter.$and.push({$or: tagsOr});
filter.$or = tagsOr;
}
if (tagsNin.length){
filter.$and.push({$nin: tagsNin});
filter.$and.push({tags: {$nin: tagsNin}});
}
if (!filter.$and.length){
delete filter.$and;

View File

@@ -14,6 +14,8 @@ const LIBRARY_NODE_TREE_FIELDS = {
order: 1,
parent: 1,
ancestors: 1,
tags: 1,
slotFillerCondition: 1,
// SlotFillers
slotQuantityFilled: 1,
// Effect

View File

@@ -6,12 +6,6 @@ import getSlotFillFilter from '/imports/api/creature/creatureProperties/methods/
import getCreatureLibraryIds from '/imports/api/library/getCreatureLibraryIds.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);
@@ -56,7 +50,7 @@ Meteor.publish('slotFillers', function(slotId, searchTerm){
// relevant documents have a higher score.
fields: {
_score: { $meta: 'textScore' },
...FIELDS,
...LIBRARY_NODE_TREE_FIELDS,
},
sort: {
// `score` property specified in the projection fields above.
@@ -72,7 +66,7 @@ Meteor.publish('slotFillers', function(slotId, searchTerm){
name: 1,
order: 1,
},
fields: FIELDS,
fields: LIBRARY_NODE_TREE_FIELDS,
};
}
options.limit = limit;
@@ -135,7 +129,7 @@ Meteor.publish('classFillers', function(classId){
name: 1,
order: 1,
},
fields: FIELDS,
fields: LIBRARY_NODE_TREE_FIELDS,
limit,
};

View File

@@ -91,6 +91,7 @@
<form-section name="Libraries">
<smart-switch
label="All user libraries"
:value="allUserLibraries"
@change="allUserLibrariesChange"
/>
<library-list
@@ -156,6 +157,11 @@ export default {
dirty: false, // If there are pending changes
}
},
computed: {
allUserLibraries() {
return !this.model.allowedLibraries && !this.model.allowedLibraryCollections
},
},
watch: {
'model.allowedLibraryCollections': function (newVal) {
if (!this.dirty) this.libraryCollections = newVal;
@@ -165,7 +171,6 @@ export default {
},
},
mounted() {
this.updateAllowedLibraryCollections = debounce(() => {
this.libraryWriteLoading = true;
this.dirty = false;
@@ -189,7 +194,6 @@ export default {
this.libraryWriteError = error;
});
}, 500);
},
meteor: {
$subscribe: {
@@ -232,10 +236,10 @@ export default {
);
}
},
allUserLibrariesChange(val, ack) {
allUserLibrariesChange(value, ack) {
toggleAllUserLibraries.call({
_id: this.model._id,
val
value,
}, error => ack(error));
},
selectLibrary(id, val) {

View File

@@ -150,7 +150,8 @@
},
canFillWithMany(){
return this.isSlot && (
this. node.quantityExpected?.value === 0 ||
!this.node.quantityExpected ||
this.node.quantityExpected.value === 0 ||
(this.node.quantityExpected.value > 1 && this.node.spaceLeft > 0)
);
},

View File

@@ -207,6 +207,7 @@ export default {
$or: [
{'slotCondition.value': {$nin: [false, 0, '']}},
{'slotCondition.value': {$exists: false}},
{'slotCondition': {$exists: false}},
],
removed: {$ne: true},
inactive: {$ne: true},
@@ -228,7 +229,8 @@ export default {
const model = child.node;
const isSlotWithSpace = model.type === 'propertySlot' &&
model.spaceLeft > 0 ||
(model.quantityExpected && model.quantityExpected.value == 0);
!model.quantityExpected ||
model.quantityExpected.value === 0;
if(isSlotWithSpace) {
model._canFill = true;
parents.forEach(node => {

View File

@@ -85,8 +85,8 @@ export default {
]
},{
$or: [
{ quantityExpected: {exists: false} },
{ 'quantityExpected.value': 0 },
{ 'quantityExpected.value': {$in: [false, 0, '', undefined]} },
{ 'quantityExpected.value': {exists: false} },
{spaceLeft: {$gt: 0}},
]
},

View File

@@ -29,13 +29,13 @@
{{ slotPropertyTypeName }} with tags:
<property-tags
v-for="(tags, index) in tagsSearched.or"
:key="index"
:key="index + 'tags'"
:tags="tags"
:prefix="index ? 'OR' : undefined"
/>
<property-tags
v-for="(tags, index) in tagsSearched.not"
:key="index"
:key="index + 'not'"
:tags="tags"
prefix="NOT"
/>

View File

@@ -72,11 +72,14 @@
@change="change('slotTags', ...arguments)"
/>
</v-layout>
<v-slide-x-transition group>
<v-slide-x-transition
group
>
<div
v-for="(extras, i) in model.extraTags"
:key="extras._id"
class="extra-tags layout align-center justify-space-between"
class="extra-tags layout align-center justify-space-between"
style="transition: all 0.3s !important;"
>
<smart-select
label="Operation"