Fixed slot fill test in library prop edit

This commit is contained in:
Stefan Zermatten
2023-06-07 11:16:07 +02:00
parent 54e54ef5a8
commit 35ebed81dd
3 changed files with 24 additions and 11 deletions

View File

@@ -153,6 +153,7 @@
class="ma-4"
>
<v-btn
v-if="!dummySlot"
text
color="accent"
:disabled="!model"
@@ -358,7 +359,7 @@ export default {
meteor: {
$subscribe: {
'slotFillers'() {
return [this.slotId, this.searchValue || undefined]
return [this.slotId || this.dummySlot?._id, this.searchValue || undefined, !!this.dummySlot]
},
},
searchLoading() {

View File

@@ -79,17 +79,22 @@
cols="12"
md="6"
>
<v-layout justify-center>
<outlined-input
name="Test"
data-id="test-slot-button"
>
<v-btn
v-if="context.isLibraryForm"
color="accent"
class="ma-2 mb-4"
data-id="test-slot-button"
text
class="ma-0"
height="54"
width="100%"
style="justify-content: start;"
@click="testSlot"
>
Test Slot
</v-btn>
</v-layout>
</outlined-input>
</v-col>
</v-row>
<inline-computation-field
@@ -148,11 +153,13 @@ import propertyFormMixin from '/imports/client/ui/properties/forms/shared/proper
import FormSection from '/imports/client/ui/properties/forms/shared/FormSection.vue';
import PROPERTIES from '/imports/constants/PROPERTIES.js';
import TagTargeting from '/imports/client/ui/properties/forms/shared/TagTargeting.vue';
import OutlinedInput from '/imports/client/ui/properties/viewers/shared/OutlinedInput.vue';
export default {
components: {
FormSection,
TagTargeting,
OutlinedInput,
},
mixins: [propertyFormMixin],
inject: {

View File

@@ -7,7 +7,7 @@ import getCreatureLibraryIds from '/imports/api/library/getCreatureLibraryIds.js
import { LIBRARY_NODE_TREE_FIELDS } from '/imports/server/publications/library.js';
import escapeRegex from '/imports/api/utility/escapeRegex.js';
Meteor.publish('slotFillers', function (slotId, searchTerm) {
Meteor.publish('slotFillers', function (slotId, searchTerm, isDummySlot) {
if (searchTerm) check(searchTerm, String);
let self = this;
@@ -16,12 +16,17 @@ Meteor.publish('slotFillers', function (slotId, searchTerm) {
if (!userId) {
return [];
}
// Get the slot
let slot = CreatureProperties.findOne(slotId);
if (!slot) {
return [];
// Get the slot from the right collection
let slot;
if (isDummySlot) {
slot = LibraryNodes.findOne(slotId);
} else {
slot = CreatureProperties.findOne(slotId);
}
if (!slot) return [];
// Get all the ids of libraries the user can access
const creatureId = slot.ancestors[0].id;
const libraryIds = getCreatureLibraryIds(creatureId, userId);