Allowed slots with unlimited children, improved slot ui text

This commit is contained in:
Stefan Zermatten
2020-10-15 13:50:46 +02:00
parent 7fc783dcad
commit 8e9405b5ad
5 changed files with 35 additions and 10 deletions

View File

@@ -24,6 +24,7 @@ let SlotSchema = new SimpleSchema({
quantityExpected: {
type: SimpleSchema.Integer,
defaultValue: 1,
min: 0,
},
ignored: {
type: Boolean,

View File

@@ -2,7 +2,7 @@
<dialog-base :color="model.color">
<template slot="toolbar">
<v-toolbar-title>
Creature Form Dialog
Character Details
</v-toolbar-title>
<v-spacer />
<color-picker

View File

@@ -7,7 +7,7 @@
</template>
<div class="library-nodes">
<v-fade-transition mode="out-in">
<v-list v-if="$subReady.slotFillers">
<v-list v-if="$subReady.slotFillers && libraryNodes.length">
<v-list-tile
v-for="node in libraryNodes"
:key="node._id"
@@ -20,12 +20,26 @@
/>
</v-list-tile>
</v-list>
<h4
<div
v-else-if="$subReady.slotFillers"
class="ma-4"
>
Nothing suitable was found in your libraries
</h4>
<h4>
Nothing suitable was found in your libraries
</h4>
<p>
This slot requires a {{ slotPropertyTypeName }}
<template v-if="model.slotTags.length">
with the following tags:
<span
v-for="(tag, index) in model.slotTags"
:key="index"
>
<code>{{ tag }}</code>,
</span>
</template>
</p>
</div>
<div
v-else
key="character-loading"
@@ -63,7 +77,7 @@ import CreatureProperties from '/imports/api/creature/CreatureProperties.js';
import LibraryNodes from '/imports/api/library/LibraryNodes.js';
import DialogBase from '/imports/ui/dialogStack/DialogBase.vue';
import TreeNodeView from '/imports/ui/properties/treeNodeViews/TreeNodeView.vue';
import { getPropertyName } from '/imports/constants/PROPERTIES.js';
export default {
components: {
DialogBase,
@@ -78,6 +92,14 @@ export default {
data(){return {
selectedNode: undefined,
}},
computed: {
slotPropertyTypeName(){
if (!this.model) return;
if (!this.model.slotType) return 'property';
let propName = getPropertyName(this.model.slotType);
return propName && propName.toLowerCase();
},
},
meteor: {
$subscribe: {
'slotFillers'(){
@@ -94,7 +116,9 @@ export default {
if (this.model.slotType){
filter.type = this.model.slotType;
}
return LibraryNodes.find(filter);
let nodes = LibraryNodes.find(filter).fetch();
if (nodes.length === 1) this.selectedNode = nodes[0];
return nodes;
},
}
}

View File

@@ -33,7 +33,7 @@
</v-btn>
</div>
<v-btn
v-if="slot.quantityExpected > slot.children.length"
v-if="!slot.quantityExpected || slot.quantityExpected > slot.children.length"
icon
:data-id="`slot-add-button-${slot._id}`"
style="background-color: inherit;"

View File

@@ -28,8 +28,8 @@
<text-field
label="Quantity"
type="number"
min="1"
hint="How many matching properties must be used to fill this slot"
min="0"
hint="How many matching properties must be used to fill this slot, 0 is unlimited"
:value="model.quantityExpected"
:error-messages="errors.quantityExpected"
@change="change('quantityExpected', ...arguments)"