Added point buy form
This commit is contained in:
@@ -27,10 +27,18 @@ let PointBuySchema = createPropertySchema({
|
|||||||
'values': {
|
'values': {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
|
maxCount: STORAGE_LIMITS.pointBuyRowsCount,
|
||||||
},
|
},
|
||||||
'values.$': {
|
'values.$': {
|
||||||
type: Object,
|
type: Object,
|
||||||
},
|
},
|
||||||
|
'values.$._id': {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
autoValue(){
|
||||||
|
if (!this.isSet) return Random.id();
|
||||||
|
}
|
||||||
|
},
|
||||||
'values.$.name': {
|
'values.$.name': {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
@@ -47,6 +55,18 @@ let PointBuySchema = createPropertySchema({
|
|||||||
type: Number,
|
type: Number,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
'values.$.min': {
|
||||||
|
type: 'fieldToCompute',
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'values.$.max': {
|
||||||
|
type: 'fieldToCompute',
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'values.$.cost': {
|
||||||
|
type: 'fieldToCompute',
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
min: {
|
min: {
|
||||||
type: 'fieldToCompute',
|
type: 'fieldToCompute',
|
||||||
optional: true,
|
optional: true,
|
||||||
@@ -74,11 +94,31 @@ const ComputedOnlyPointBuySchema = createPropertySchema({
|
|||||||
type: 'computedOnlyField',
|
type: 'computedOnlyField',
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
total: {
|
cost: {
|
||||||
type: 'computedOnlyField',
|
type: 'computedOnlyField',
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
cost: {
|
'values': {
|
||||||
|
type: Array,
|
||||||
|
defaultValue: [],
|
||||||
|
maxCount: STORAGE_LIMITS.pointBuyRowsCount,
|
||||||
|
},
|
||||||
|
'values.$': {
|
||||||
|
type: Object,
|
||||||
|
},
|
||||||
|
'values.$.min': {
|
||||||
|
type: 'computedOnlyField',
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'values.$.max': {
|
||||||
|
type: 'computedOnlyField',
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'values.$.cost': {
|
||||||
|
type: 'computedOnlyField',
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
total: {
|
||||||
type: 'computedOnlyField',
|
type: 'computedOnlyField',
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
@@ -87,6 +127,11 @@ const ComputedOnlyPointBuySchema = createPropertySchema({
|
|||||||
optional: true,
|
optional: true,
|
||||||
removeBeforeCompute: true,
|
removeBeforeCompute: true,
|
||||||
},
|
},
|
||||||
|
error: {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
removeBeforeCompute: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const ComputedPointBuySchema = new SimpleSchema()
|
const ComputedPointBuySchema = new SimpleSchema()
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { ComputedOnlyFeatureSchema } from '/imports/api/properties/Features.js';
|
|||||||
import { ComputedOnlyFolderSchema } from '/imports/api/properties/Folders.js';
|
import { ComputedOnlyFolderSchema } from '/imports/api/properties/Folders.js';
|
||||||
import { ComputedOnlyItemSchema } from '/imports/api/properties/Items.js';
|
import { ComputedOnlyItemSchema } from '/imports/api/properties/Items.js';
|
||||||
import { ComputedOnlyNoteSchema } from '/imports/api/properties/Notes.js';
|
import { ComputedOnlyNoteSchema } from '/imports/api/properties/Notes.js';
|
||||||
|
import { ComputedOnlyPointBuySchema } from '/imports/api/properties/PointBuys.js';
|
||||||
import { ComputedOnlyProficiencySchema } from '/imports/api/properties/Proficiencies.js';
|
import { ComputedOnlyProficiencySchema } from '/imports/api/properties/Proficiencies.js';
|
||||||
import { ComputedOnlyReferenceSchema } from '/imports/api/properties/References.js';
|
import { ComputedOnlyReferenceSchema } from '/imports/api/properties/References.js';
|
||||||
import { ComputedOnlyRollSchema } from '/imports/api/properties/Rolls.js';
|
import { ComputedOnlyRollSchema } from '/imports/api/properties/Rolls.js';
|
||||||
@@ -44,6 +45,7 @@ const propertySchemasIndex = {
|
|||||||
folder: ComputedOnlyFolderSchema,
|
folder: ComputedOnlyFolderSchema,
|
||||||
item: ComputedOnlyItemSchema,
|
item: ComputedOnlyItemSchema,
|
||||||
note: ComputedOnlyNoteSchema,
|
note: ComputedOnlyNoteSchema,
|
||||||
|
pointBuy: ComputedOnlyPointBuySchema,
|
||||||
proficiency: ComputedOnlyProficiencySchema,
|
proficiency: ComputedOnlyProficiencySchema,
|
||||||
propertySlot: ComputedOnlySlotSchema,
|
propertySlot: ComputedOnlySlotSchema,
|
||||||
reference: ComputedOnlyReferenceSchema,
|
reference: ComputedOnlyReferenceSchema,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { ComputedFeatureSchema } from '/imports/api/properties/Features.js';
|
|||||||
import { FolderSchema } from '/imports/api/properties/Folders.js';
|
import { FolderSchema } from '/imports/api/properties/Folders.js';
|
||||||
import { ComputedItemSchema } from '/imports/api/properties/Items.js';
|
import { ComputedItemSchema } from '/imports/api/properties/Items.js';
|
||||||
import { ComputedNoteSchema } from '/imports/api/properties/Notes.js';
|
import { ComputedNoteSchema } from '/imports/api/properties/Notes.js';
|
||||||
|
import { ComputedPointBuySchema } from '/imports/api/properties/PointBuys.js';
|
||||||
import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js';
|
import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js';
|
||||||
import { ReferenceSchema } from '/imports/api/properties/References.js';
|
import { ReferenceSchema } from '/imports/api/properties/References.js';
|
||||||
import { ComputedRollSchema } from '/imports/api/properties/Rolls.js';
|
import { ComputedRollSchema } from '/imports/api/properties/Rolls.js';
|
||||||
@@ -42,6 +43,7 @@ const propertySchemasIndex = {
|
|||||||
feature: ComputedFeatureSchema,
|
feature: ComputedFeatureSchema,
|
||||||
folder: FolderSchema,
|
folder: FolderSchema,
|
||||||
note: ComputedNoteSchema,
|
note: ComputedNoteSchema,
|
||||||
|
pointBuy: ComputedPointBuySchema,
|
||||||
proficiency: ProficiencySchema,
|
proficiency: ProficiencySchema,
|
||||||
propertySlot: ComputedSlotSchema,
|
propertySlot: ComputedSlotSchema,
|
||||||
reference: ReferenceSchema,
|
reference: ReferenceSchema,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { EffectSchema } from '/imports/api/properties/Effects.js';
|
|||||||
import { FeatureSchema } from '/imports/api/properties/Features.js';
|
import { FeatureSchema } from '/imports/api/properties/Features.js';
|
||||||
import { FolderSchema } from '/imports/api/properties/Folders.js';
|
import { FolderSchema } from '/imports/api/properties/Folders.js';
|
||||||
import { NoteSchema } from '/imports/api/properties/Notes.js';
|
import { NoteSchema } from '/imports/api/properties/Notes.js';
|
||||||
|
import { PointBuySchema } from '/imports/api/properties/PointBuys.js';
|
||||||
import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js';
|
import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js';
|
||||||
import { ReferenceSchema } from '/imports/api/properties/References.js';
|
import { ReferenceSchema } from '/imports/api/properties/References.js';
|
||||||
import { RollSchema } from '/imports/api/properties/Rolls.js';
|
import { RollSchema } from '/imports/api/properties/Rolls.js';
|
||||||
@@ -42,6 +43,7 @@ const propertySchemasIndex = {
|
|||||||
feature: FeatureSchema,
|
feature: FeatureSchema,
|
||||||
folder: FolderSchema,
|
folder: FolderSchema,
|
||||||
note: NoteSchema,
|
note: NoteSchema,
|
||||||
|
pointBuy: PointBuySchema,
|
||||||
proficiency: ProficiencySchema,
|
proficiency: ProficiencySchema,
|
||||||
propertySlot: SlotSchema,
|
propertySlot: SlotSchema,
|
||||||
reference: ReferenceSchema,
|
reference: ReferenceSchema,
|
||||||
|
|||||||
@@ -96,7 +96,13 @@ const PROPERTIES = Object.freeze({
|
|||||||
icon: 'mdi-note-outline',
|
icon: 'mdi-note-outline',
|
||||||
name: 'Note',
|
name: 'Note',
|
||||||
helpText: 'Notes about your character and their adventures',
|
helpText: 'Notes about your character and their adventures',
|
||||||
suggestedParents: ['folder'],
|
suggestedParents: ['note', 'folder'],
|
||||||
|
},
|
||||||
|
pointBuy: {
|
||||||
|
icon: 'mdi-table',
|
||||||
|
name: 'Point Buy',
|
||||||
|
helpText: 'A point buy table that allows the user to select an array of values that match a given cost',
|
||||||
|
suggestedParents: [],
|
||||||
},
|
},
|
||||||
proficiency: {
|
proficiency: {
|
||||||
icon: 'mdi-brightness-1',
|
icon: 'mdi-brightness-1',
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ const STORAGE_LIMITS = Object.freeze({
|
|||||||
tagCount: 64,
|
tagCount: 64,
|
||||||
writersCount: 20,
|
writersCount: 20,
|
||||||
libraryCollectionCount: 32,
|
libraryCollectionCount: 32,
|
||||||
|
pointBuyRowsCount: 32,
|
||||||
});
|
});
|
||||||
|
|
||||||
export default STORAGE_LIMITS;
|
export default STORAGE_LIMITS;
|
||||||
|
|||||||
129
app/imports/ui/properties/forms/PointBuyForm.vue
Normal file
129
app/imports/ui/properties/forms/PointBuyForm.vue
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<div class="point-buy-form">
|
||||||
|
<v-row dense>
|
||||||
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
|
label="Name"
|
||||||
|
:value="model.name"
|
||||||
|
:error-messages="errors.name"
|
||||||
|
@change="change('name', ...arguments)"
|
||||||
|
/>
|
||||||
|
<text-field
|
||||||
|
label="Variable name"
|
||||||
|
:value="model.variableName"
|
||||||
|
hint="Use this name in calculations to reference this point buy table"
|
||||||
|
:error-messages="errors.variableName"
|
||||||
|
@change="change('variableName', ...arguments)"
|
||||||
|
/>
|
||||||
|
<computed-field
|
||||||
|
label="Min"
|
||||||
|
hint="The minimum value for each row"
|
||||||
|
:model="model.min"
|
||||||
|
:error-messages="errors.min"
|
||||||
|
@change="change('min', ...arguments)"
|
||||||
|
/>
|
||||||
|
<computed-field
|
||||||
|
label="Max"
|
||||||
|
hint="The maximum value for each row"
|
||||||
|
:model="model.max"
|
||||||
|
:error-messages="errors.max"
|
||||||
|
@change="change('max', ...arguments)"
|
||||||
|
/>
|
||||||
|
<computed-field
|
||||||
|
label="Cost"
|
||||||
|
hint="A function of `value` that determines the cost of each row"
|
||||||
|
:model="model.cost"
|
||||||
|
:error-messages="errors.cost"
|
||||||
|
@change="change('cost', ...arguments)"
|
||||||
|
/>
|
||||||
|
<computed-field
|
||||||
|
label="Total"
|
||||||
|
hint="The total allowed cost of all rows"
|
||||||
|
:model="model.total"
|
||||||
|
:error-messages="errors.total"
|
||||||
|
@change="change('total', ...arguments)"
|
||||||
|
/>
|
||||||
|
</v-row>
|
||||||
|
<v-row
|
||||||
|
v-for="(row, i) in model.values"
|
||||||
|
:key="row._id"
|
||||||
|
dense
|
||||||
|
>
|
||||||
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
|
label="Name"
|
||||||
|
:value="model.name"
|
||||||
|
:error-messages="errors.name"
|
||||||
|
@change="change(['values', i, 'name'], ...arguments)"
|
||||||
|
/>
|
||||||
|
<text-field
|
||||||
|
label="Variable name"
|
||||||
|
:value="model.variableName"
|
||||||
|
hint="Use this name to reference this row of the table: tableVariableName.thisVariableName"
|
||||||
|
:error-messages="errors.variableName"
|
||||||
|
@change="change(['values', i, 'variableName'], ...arguments)"
|
||||||
|
/>
|
||||||
|
<v-btn
|
||||||
|
icon
|
||||||
|
@click="$emit('pull', {path: ['values', i]})"
|
||||||
|
>
|
||||||
|
<v-icon>mdi-delete</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</v-row>
|
||||||
|
<v-btn
|
||||||
|
icon
|
||||||
|
outlined
|
||||||
|
:loading="addRowLoading"
|
||||||
|
:disabled="rowsFull"
|
||||||
|
@click="addRow"
|
||||||
|
>
|
||||||
|
<v-icon>
|
||||||
|
mdi-plus
|
||||||
|
</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
<form-section
|
||||||
|
v-if="$slots.children"
|
||||||
|
name="Children"
|
||||||
|
standalone
|
||||||
|
>
|
||||||
|
<slot name="children" />
|
||||||
|
</form-section>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="js">
|
||||||
|
import attributeListMixin from '/imports/ui/properties/forms/shared/lists/attributeListMixin.js';
|
||||||
|
import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js';
|
||||||
|
import { PointBuySchema } from '/imports/api/properties/PointBuys.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
mixins: [propertyFormMixin, attributeListMixin],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
addRowLoading: false,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
rowsFull(){
|
||||||
|
if (!this.model.values) return false;
|
||||||
|
let maxCount = PointBuySchema.get('values', 'maxCount');
|
||||||
|
return this.model.values.length >= maxCount;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
acknowledgeAddResult(){
|
||||||
|
this.addRowLoading = false;
|
||||||
|
},
|
||||||
|
addRow(){
|
||||||
|
this.addRowLoading = true;
|
||||||
|
this.$emit('push', {
|
||||||
|
path: ['values'],
|
||||||
|
value: {
|
||||||
|
_id: Random.id(),
|
||||||
|
},
|
||||||
|
ack: this.acknowledgeAddResult,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -14,6 +14,7 @@ const FeatureForm = () => import('/imports/ui/properties/forms/FeatureForm.vue')
|
|||||||
const FolderForm = () => import('/imports/ui/properties/forms/FolderForm.vue');
|
const FolderForm = () => import('/imports/ui/properties/forms/FolderForm.vue');
|
||||||
const ItemForm = () => import('/imports/ui/properties/forms/ItemForm.vue');
|
const ItemForm = () => import('/imports/ui/properties/forms/ItemForm.vue');
|
||||||
const NoteForm = () => import('/imports/ui/properties/forms/NoteForm.vue');
|
const NoteForm = () => import('/imports/ui/properties/forms/NoteForm.vue');
|
||||||
|
const PointBuyForm = () => import('/imports/ui/properties/forms/PointBuyForm.vue');
|
||||||
const ProficiencyForm = () => import('/imports/ui/properties/forms/ProficiencyForm.vue');
|
const ProficiencyForm = () => import('/imports/ui/properties/forms/ProficiencyForm.vue');
|
||||||
const ReferenceForm = () => import('/imports/ui/properties/forms/ReferenceForm.vue');
|
const ReferenceForm = () => import('/imports/ui/properties/forms/ReferenceForm.vue');
|
||||||
const RollForm = () => import('/imports/ui/properties/forms/RollForm.vue');
|
const RollForm = () => import('/imports/ui/properties/forms/RollForm.vue');
|
||||||
@@ -43,6 +44,7 @@ export default {
|
|||||||
folder: FolderForm,
|
folder: FolderForm,
|
||||||
item: ItemForm,
|
item: ItemForm,
|
||||||
note: NoteForm,
|
note: NoteForm,
|
||||||
|
pointBuy: PointBuyForm,
|
||||||
proficiency: ProficiencyForm,
|
proficiency: ProficiencyForm,
|
||||||
propertySlot: SlotForm,
|
propertySlot: SlotForm,
|
||||||
reference: ReferenceForm,
|
reference: ReferenceForm,
|
||||||
|
|||||||
Reference in New Issue
Block a user