Description fields should now show calculation errors

This commit is contained in:
Stefan Zermatten
2021-02-12 11:43:13 +02:00
parent b9e0475d07
commit a078ce3d5d
13 changed files with 84 additions and 2 deletions

View File

@@ -24,6 +24,7 @@
:hint="actionTypeHints[model.actionType]" :hint="actionTypeHints[model.actionType]"
@change="change('actionType', ...arguments)" @change="change('actionType', ...arguments)"
/> />
<text-field <text-field
v-if="attackForm" v-if="attackForm"
label="Roll bonus" label="Roll bonus"
@@ -31,6 +32,8 @@
:error-messages="errors.rollBonus" :error-messages="errors.rollBonus"
@change="change('rollBonus', ...arguments)" @change="change('rollBonus', ...arguments)"
/> />
<calculation-error-list :errors="model.rollBonusErrors" />
<text-area <text-area
label="Summary" label="Summary"
hint="This will appear in the action card in the character sheet" hint="This will appear in the action card in the character sheet"
@@ -38,6 +41,8 @@
:error-messages="errors.summary" :error-messages="errors.summary"
@change="change('summary', ...arguments)" @change="change('summary', ...arguments)"
/> />
<calculation-error-list :calculations="model.summaryCalculations" />
<text-area <text-area
label="Description" label="Description"
hint="The rest of the description that doesn't fit in the summary goes here" hint="The rest of the description that doesn't fit in the summary goes here"
@@ -45,6 +50,8 @@
:error-messages="errors.description" :error-messages="errors.description"
@change="change('description', ...arguments)" @change="change('description', ...arguments)"
/> />
<calculation-error-list :calculations="model.descriptionCalculations" />
<form-sections> <form-sections>
<form-section name="Resources"> <form-section name="Resources">
<resources-form <resources-form
@@ -81,6 +88,7 @@
:error-messages="errors.uses" :error-messages="errors.uses"
@change="change('uses', ...arguments)" @change="change('uses', ...arguments)"
/> />
<calculation-error-list :errors="model.usesErrors" />
<text-field <text-field
label="Uses used" label="Uses used"
type="number" type="number"
@@ -110,12 +118,14 @@
import FormSection, {FormSections} from '/imports/ui/properties/forms/shared/FormSection.vue'; import FormSection, {FormSections} from '/imports/ui/properties/forms/shared/FormSection.vue';
import ResourcesForm from '/imports/ui/properties/forms/ResourcesForm.vue'; import ResourcesForm from '/imports/ui/properties/forms/ResourcesForm.vue';
import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js'; import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js';
import CalculationErrorList from '/imports/ui/properties/forms/shared/CalculationErrorList.vue';
export default { export default {
components: { components: {
FormSection, FormSection,
FormSections, FormSections,
ResourcesForm, ResourcesForm,
CalculationErrorList,
}, },
mixins: [propertyFormMixin], mixins: [propertyFormMixin],
props: { props: {

View File

@@ -61,6 +61,8 @@
:error-messages="errors.description" :error-messages="errors.description"
@change="change('description', ...arguments)" @change="change('description', ...arguments)"
/> />
<calculation-error-list :calculations="model.descriptionCalculations" />
<form-section <form-section
name="Advanced" name="Advanced"
standalone standalone

View File

@@ -13,6 +13,8 @@
:error-messages="errors.description" :error-messages="errors.description"
@change="change('description', ...arguments)" @change="change('description', ...arguments)"
/> />
<calculation-error-list :calculations="model.descriptionCalculations" />
<!-- Duration not implemented yet <!-- Duration not implemented yet
<text-field <text-field
label="Duration" label="Duration"
@@ -44,8 +46,12 @@
<script> <script>
import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js'; import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js';
import CalculationErrorList from '/imports/ui/properties/forms/shared/CalculationErrorList.vue';
export default { export default {
components: {
CalculationErrorList,
},
mixins: [propertyFormMixin], mixins: [propertyFormMixin],
props: { props: {
parentTarget: { parentTarget: {

View File

@@ -27,6 +27,7 @@
@change="change('variableName', ...arguments)" @change="change('variableName', ...arguments)"
/> />
</div> </div>
<text-area <text-area
label="Description" label="Description"
hint="A brief description of what this class level gives a character" hint="A brief description of what this class level gives a character"
@@ -34,6 +35,8 @@
:error-messages="errors.description" :error-messages="errors.description"
@change="change('description', ...arguments)" @change="change('description', ...arguments)"
/> />
<calculation-error-list :calculations="model.descriptionCalculations" />
<text-field <text-field
label="Condition" label="Condition"
hint="A caclulation to determine if this can be added to the character" hint="A caclulation to determine if this can be added to the character"
@@ -56,8 +59,12 @@
<script> <script>
import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js'; import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js';
import CalculationErrorList from '/imports/ui/properties/forms/shared/CalculationErrorList.vue';
export default { export default {
components: {
CalculationErrorList,
},
mixins: [propertyFormMixin], mixins: [propertyFormMixin],
}; };
</script> </script>

View File

@@ -51,6 +51,8 @@
:error-messages="errors.description" :error-messages="errors.description"
@change="change('description', ...arguments)" @change="change('description', ...arguments)"
/> />
<calculation-error-list :calculations="model.descriptionCalculations" />
<form-section <form-section
name="Advanced" name="Advanced"
standalone standalone
@@ -80,10 +82,12 @@
<script> <script>
import FormSection from '/imports/ui/properties/forms/shared/FormSection.vue'; import FormSection from '/imports/ui/properties/forms/shared/FormSection.vue';
import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js'; import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js';
import CalculationErrorList from '/imports/ui/properties/forms/shared/CalculationErrorList.vue';
export default { export default {
components: { components: {
FormSection, FormSection,
CalculationErrorList,
}, },
mixins: [propertyFormMixin], mixins: [propertyFormMixin],
} }

View File

@@ -14,6 +14,8 @@
:error-messages="errors.summary" :error-messages="errors.summary"
@change="change('summary', ...arguments)" @change="change('summary', ...arguments)"
/> />
<calculation-error-list :calculations="model.summaryCalculations" />
<text-area <text-area
label="Description" label="Description"
hint="The rest of the description that doesn't fit in the summary goes here" hint="The rest of the description that doesn't fit in the summary goes here"
@@ -21,6 +23,8 @@
:error-messages="errors.description" :error-messages="errors.description"
@change="change('description', ...arguments)" @change="change('description', ...arguments)"
/> />
<calculation-error-list :calculations="model.descriptionCalculations" />
<smart-combobox <smart-combobox
label="Tags" label="Tags"
multiple multiple
@@ -35,8 +39,12 @@
<script> <script>
import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js'; import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js';
import CalculationErrorList from '/imports/ui/properties/forms/shared/CalculationErrorList.vue';
export default { export default {
components: {
CalculationErrorList,
},
mixins: [propertyFormMixin], mixins: [propertyFormMixin],
data(){ return{ data(){ return{
enabledOptions: [ enabledOptions: [

View File

@@ -75,6 +75,8 @@
:error-messages="errors.description" :error-messages="errors.description"
@change="change('description', ...arguments)" @change="change('description', ...arguments)"
/> />
<calculation-error-list :calculations="model.descriptionCalculations" />
<form-section <form-section
name="Advanced" name="Advanced"
standalone standalone
@@ -121,10 +123,12 @@
<script> <script>
import FormSection from '/imports/ui/properties/forms/shared/FormSection.vue'; import FormSection from '/imports/ui/properties/forms/shared/FormSection.vue';
import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js'; import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js';
import CalculationErrorList from '/imports/ui/properties/forms/shared/CalculationErrorList.vue';
export default { export default {
components: { components: {
FormSection, FormSection,
CalculationErrorList,
}, },
mixins: [propertyFormMixin], mixins: [propertyFormMixin],
} }

View File

@@ -34,12 +34,15 @@
:menu-props="{auto: true, lazy: true}" :menu-props="{auto: true, lazy: true}"
@change="change('skillType', ...arguments)" @change="change('skillType', ...arguments)"
/> />
<text-area <text-area
label="Description" label="Description"
:value="model.description" :value="model.description"
:error-messages="errors.description" :error-messages="errors.description"
@change="change('description', ...arguments)" @change="change('description', ...arguments)"
/> />
<calculation-error-list :calculations="model.descriptionCalculations" />
<form-section <form-section
name="Advanced" name="Advanced"
standalone standalone

View File

@@ -15,12 +15,15 @@
:error-messages="errors.name" :error-messages="errors.name"
@change="change('name', ...arguments)" @change="change('name', ...arguments)"
/> />
<text-area <text-area
label="Description" label="Description"
:value="model.description" :value="model.description"
:error-messages="errors.description" :error-messages="errors.description"
@change="change('description', ...arguments)" @change="change('description', ...arguments)"
/> />
<calculation-error-list :calculations="model.descriptionCalculations" />
<text-field <text-field
label="Picture URL" label="Picture URL"
hint="A link to an image representing this property" hint="A link to an image representing this property"
@@ -69,8 +72,12 @@
<script> <script>
import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js'; import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js';
import PROPERTIES from '/imports/constants/PROPERTIES.js'; import PROPERTIES from '/imports/constants/PROPERTIES.js';
import CalculationErrorList from '/imports/ui/properties/forms/shared/CalculationErrorList.vue';
export default { export default {
components: {
CalculationErrorList,
},
mixins: [propertyFormMixin], mixins: [propertyFormMixin],
data(){ data(){
let slotTypes = []; let slotTypes = [];

View File

@@ -44,12 +44,15 @@
@change="change('slotCondition', ...arguments)" @change="change('slotCondition', ...arguments)"
/> />
<calculation-error-list :errors="model.slotConditionErrors" /> <calculation-error-list :errors="model.slotConditionErrors" />
<text-area <text-area
label="Description" label="Description"
:value="model.description" :value="model.description"
:error-messages="errors.description" :error-messages="errors.description"
@change="change('description', ...arguments)" @change="change('description', ...arguments)"
/> />
<calculation-error-list :calculations="model.descriptionCalculations" />
<form-section <form-section
name="Advanced" name="Advanced"
standalone standalone

View File

@@ -96,12 +96,15 @@
:error-messages="errors.duration" :error-messages="errors.duration"
@change="change('duration', ...arguments)" @change="change('duration', ...arguments)"
/> />
<text-area <text-area
label="Description" label="Description"
:value="model.description" :value="model.description"
:error-messages="errors.description" :error-messages="errors.description"
@change="change('description', ...arguments)" @change="change('description', ...arguments)"
/> />
<calculation-error-list :calculations="model.descriptionCalculations" />
<smart-combobox <smart-combobox
label="Tags" label="Tags"
multiple multiple
@@ -128,12 +131,14 @@
import FormSection, { FormSections } from '/imports/ui/properties/forms/shared/FormSection.vue'; import FormSection, { FormSections } from '/imports/ui/properties/forms/shared/FormSection.vue';
import ActionForm from '/imports/ui/properties/forms/ActionForm.vue' import ActionForm from '/imports/ui/properties/forms/ActionForm.vue'
import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js'; import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js';
import CalculationErrorList from '/imports/ui/properties/forms/shared/CalculationErrorList.vue';
export default { export default {
components: { components: {
FormSections, FormSections,
FormSection, FormSection,
ActionForm, ActionForm,
CalculationErrorList,
}, },
mixins: [propertyFormMixin], mixins: [propertyFormMixin],
data(){return { data(){return {

View File

@@ -17,12 +17,15 @@
@change="change('variableName', ...arguments)" @change="change('variableName', ...arguments)"
/> />
</div> </div>
<text-area <text-area
label="Description" label="Description"
:value="model.description" :value="model.description"
:error-messages="errors.description" :error-messages="errors.description"
@change="change('description', ...arguments)" @change="change('description', ...arguments)"
/> />
<calculation-error-list :calculations="model.descriptionCalculations" />
<text-field <text-field
label="Maximum prepared spells" label="Maximum prepared spells"
:value="model.maxPrepared" :value="model.maxPrepared"
@@ -31,6 +34,7 @@
@change="change('maxPrepared', ...arguments)" @change="change('maxPrepared', ...arguments)"
/> />
<calculation-error-list :errors="model.maxPreparedErrors" /> <calculation-error-list :errors="model.maxPreparedErrors" />
<smart-combobox <smart-combobox
label="Tags" label="Tags"
multiple multiple

View File

@@ -1,6 +1,6 @@
<template lang="html"> <template lang="html">
<div <div
v-if="errors && errors.length" v-if="computedErrors.length"
class="error-list" class="error-list"
> >
<v-slide-x-transition <v-slide-x-transition
@@ -8,7 +8,7 @@
hide-on-leave hide-on-leave
> >
<v-alert <v-alert
v-for="error in errors" v-for="error in computedErrors"
:key="error.message" :key="error.message"
:value="true" :value="true"
:icon="errorIcon(error.type)" :icon="errorIcon(error.type)"
@@ -28,6 +28,25 @@ export default {
type: Array, type: Array,
default: undefined, default: undefined,
}, },
calculations: {
type: Array,
default: undefined,
},
},
computed: {
computedErrors(){
if (this.errors) {
return this.errors;
} else if (this.calculations){
let errors = [];
this.calculations.forEach(calc => {
if (calc.errors) errors.push(...calc.errors)
});
return errors;
} else {
return [];
}
},
}, },
methods: { methods: {
errorIcon(type){ errorIcon(type){