Added skill form, abstracted proficiency selection
This commit is contained in:
@@ -45,6 +45,7 @@ let SkillSchema = schema({
|
|||||||
"language",
|
"language",
|
||||||
"utility", //not displayed anywhere
|
"utility", //not displayed anywhere
|
||||||
],
|
],
|
||||||
|
defaultValue: 'skill',
|
||||||
},
|
},
|
||||||
// If the baseValue is higher than the computed value, it will be used as `value`
|
// If the baseValue is higher than the computed value, it will be used as `value`
|
||||||
baseValue: {
|
baseValue: {
|
||||||
|
|||||||
@@ -35,10 +35,6 @@
|
|||||||
<text-field
|
<text-field
|
||||||
label="Stat"
|
label="Stat"
|
||||||
class="mr-2"
|
class="mr-2"
|
||||||
append-icon="arrow_drop_down"
|
|
||||||
item-text="name"
|
|
||||||
item-value="variableName"
|
|
||||||
:menu-props="{transition: 'slide-y-transition', lazy: true}"
|
|
||||||
:value="model.stat"
|
:value="model.stat"
|
||||||
:items="stats"
|
:items="stats"
|
||||||
@change="(value, ack) => $emit('change', {path: ['stat'], value, ack})"
|
@change="(value, ack) => $emit('change', {path: ['stat'], value, ack})"
|
||||||
|
|||||||
@@ -6,32 +6,28 @@
|
|||||||
append-icon="arrow_drop_down"
|
append-icon="arrow_drop_down"
|
||||||
item-text="name"
|
item-text="name"
|
||||||
item-value="skill"
|
item-value="skill"
|
||||||
|
style="flex-basis: 300px;"
|
||||||
:menu-props="{transition: 'slide-y-transition', lazy: true}"
|
:menu-props="{transition: 'slide-y-transition', lazy: true}"
|
||||||
:value="model.skill"
|
:value="model.skill"
|
||||||
:items="undefined"
|
:items="undefined"
|
||||||
@change="(value, ack) => $emit('change', {path: ['skill'], value, ack})"
|
@change="(value, ack) => $emit('change', {path: ['skill'], value, ack})"
|
||||||
/>
|
/>
|
||||||
<smart-select
|
<proficiency-select
|
||||||
label="Proficiency"
|
label="Proficiency"
|
||||||
append-icon="arrow_drop_down"
|
style="flex-basis: 300px;"
|
||||||
class="mr-2 ml-3"
|
|
||||||
:menu-props="{transition: 'slide-y-transition', lazy: true}"
|
|
||||||
:items="values"
|
|
||||||
:value="model.value"
|
:value="model.value"
|
||||||
@change="(value, ack) => $emit('change', {path: ['value'], value, ack})"
|
@change="(value, ack) => $emit('change', {path: ['value'], value, ack})"
|
||||||
>
|
/>
|
||||||
<v-icon
|
|
||||||
class="icon"
|
|
||||||
slot="prepend"
|
|
||||||
:class="iconClass"
|
|
||||||
>{{displayedIcon}}</v-icon>
|
|
||||||
</smart-select>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
const ICON_SPIN_DURATION = 300;
|
import ProficiencySelect from '/imports/ui/forms/components/ProficiencySelect.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
components: {
|
||||||
|
ProficiencySelect,
|
||||||
|
},
|
||||||
props: {
|
props: {
|
||||||
model: {
|
model: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@@ -41,75 +37,8 @@
|
|||||||
type: Array,
|
type: Array,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
data(){ return {
|
|
||||||
displayedIcon: 'radio_button_unchecked',
|
|
||||||
iconClass: '',
|
|
||||||
values: [
|
|
||||||
{value: 1, text: 'Proficient'},
|
|
||||||
{value: 0.5, text: 'Half proficiency bonus'},
|
|
||||||
{value: 2, text: 'Double proficiency bonuys'},
|
|
||||||
],
|
|
||||||
}},
|
|
||||||
methods: {
|
|
||||||
proficiencyIcon(value){
|
|
||||||
if (value == 0.5){
|
|
||||||
return 'brightness_2';
|
|
||||||
} else if (value == 1) {
|
|
||||||
return 'brightness_1'
|
|
||||||
} else if (value == 2){
|
|
||||||
return 'album'
|
|
||||||
} else {
|
|
||||||
return 'radio_button_unchecked';
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
'model.value': {
|
|
||||||
immediate: true,
|
|
||||||
handler(newValue, oldValue, e){
|
|
||||||
let newIcon = this.proficiencyIcon(newValue);
|
|
||||||
if (!oldValue){
|
|
||||||
// Skip animation
|
|
||||||
this.displayedIcon = newIcon;
|
|
||||||
} else {
|
|
||||||
this.iconClass="leaving";
|
|
||||||
setTimeout(() => {
|
|
||||||
this.displayedIcon = newIcon;
|
|
||||||
this.iconClass="arriving";
|
|
||||||
requestAnimationFrame(() => {
|
|
||||||
this.iconClass="";
|
|
||||||
});
|
|
||||||
}, ICON_SPIN_DURATION / 2);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="css" scoped>
|
<style lang="css" scoped>
|
||||||
.theme--light .icon {
|
|
||||||
color: black;
|
|
||||||
}
|
|
||||||
.icon {
|
|
||||||
min-width: 30px;
|
|
||||||
transition: transform 0.15s linear, opacity 0.15s ease;
|
|
||||||
transform-origin: 18px center;
|
|
||||||
margin-left: -12px;
|
|
||||||
}
|
|
||||||
.icon.leaving {
|
|
||||||
transform: translateY(-24px);
|
|
||||||
opacity: 0;
|
|
||||||
}
|
|
||||||
.icon.arriving {
|
|
||||||
transform: translateY(24px);
|
|
||||||
opacity: 0;
|
|
||||||
transition: none;
|
|
||||||
}
|
|
||||||
.hidden {
|
|
||||||
visibility: hidden;
|
|
||||||
}
|
|
||||||
.proficiency-form > div {
|
|
||||||
flex-basis: 220px;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
114
app/imports/ui/forms/SkillForm.vue
Normal file
114
app/imports/ui/forms/SkillForm.vue
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<div class="skill-form">
|
||||||
|
<div class="layout row wrap">
|
||||||
|
<text-field
|
||||||
|
label="Name"
|
||||||
|
:value="model.name"
|
||||||
|
@change="(value, ack) => $emit('change', {path: ['name'], value, ack})"
|
||||||
|
:error-messages="errors.name"
|
||||||
|
:debounce-time="debounceTime"
|
||||||
|
/>
|
||||||
|
<text-field
|
||||||
|
label="Variable name"
|
||||||
|
:value="model.variableName"
|
||||||
|
style="flex-basis: 300px;"
|
||||||
|
@change="(value, ack) => $emit('change', {path: ['variableName'], value, ack})"
|
||||||
|
hint="Use this name in formulae to reference this skill"
|
||||||
|
:error-messages="errors.variableName"
|
||||||
|
:debounce-time="debounceTime"
|
||||||
|
/>
|
||||||
|
<text-field
|
||||||
|
label="Ability"
|
||||||
|
:value="model.ability"
|
||||||
|
style="flex-basis: 300px;"
|
||||||
|
@change="(value, ack) => $emit('change', {path: ['ability'], value, ack})"
|
||||||
|
hint="Which ability is this skill based off of"
|
||||||
|
:error-messages="errors.ability"
|
||||||
|
:debounce-time="debounceTime"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<smart-select
|
||||||
|
label="Type"
|
||||||
|
:items="skillTypes"
|
||||||
|
:value="model.type"
|
||||||
|
:error-messages="errors.type"
|
||||||
|
:menu-props="{auto: true, lazy: true}"
|
||||||
|
@change="(value, ack) => $emit('change', {path: ['type'], value, ack})"
|
||||||
|
:debounce-time="debounceTime"
|
||||||
|
/>
|
||||||
|
<form-section name="Advanced" standalone>
|
||||||
|
<div class="layout row justify-center">
|
||||||
|
<text-field
|
||||||
|
label="Base Value"
|
||||||
|
type="number"
|
||||||
|
class="base-value-field text-xs-center large-format no-flex"
|
||||||
|
:value="model.baseValue"
|
||||||
|
@change="(value, ack) => $emit('change', {path: ['baseValue'], value, ack})"
|
||||||
|
hint="This is the value of the skill before effects are applied"
|
||||||
|
:error-messages="errors.baseValue"
|
||||||
|
:debounce-time="debounceTime"
|
||||||
|
/>
|
||||||
|
<proficiency-select
|
||||||
|
style="flex-basis: 300px;"
|
||||||
|
label="Base Proficiency"
|
||||||
|
clearable
|
||||||
|
:value="model.baseProficiency"
|
||||||
|
:error-messages="errors.baseProficiency"
|
||||||
|
@change="(value, ack) => $emit('change', {path: ['baseProficiency'], value, ack})"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</form-section>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import ProficiencySelect from '/imports/ui/forms/components/ProficiencySelect.vue';
|
||||||
|
import FormSection from '/imports/ui/forms/components/FormSection.vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
ProficiencySelect,
|
||||||
|
FormSection,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
model: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({}),
|
||||||
|
},
|
||||||
|
errors: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({}),
|
||||||
|
},
|
||||||
|
debounceTime: Number,
|
||||||
|
},
|
||||||
|
data(){return{
|
||||||
|
skillTypes: [
|
||||||
|
{
|
||||||
|
text: 'Skill',
|
||||||
|
value: 'skill',
|
||||||
|
}, {
|
||||||
|
text: 'Save',
|
||||||
|
value: 'save',
|
||||||
|
}, {
|
||||||
|
text: 'Check',
|
||||||
|
value: 'check',
|
||||||
|
}, {
|
||||||
|
text: 'Tool',
|
||||||
|
value: 'tool',
|
||||||
|
}, {
|
||||||
|
text: 'Weapon',
|
||||||
|
value: 'weapon',
|
||||||
|
}, {
|
||||||
|
text: 'Language',
|
||||||
|
value: 'language',
|
||||||
|
}, {
|
||||||
|
text: 'Utility',
|
||||||
|
value: 'utility',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
};},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="css" scoped>
|
||||||
|
</style>
|
||||||
92
app/imports/ui/forms/components/ProficiencySelect.vue
Normal file
92
app/imports/ui/forms/components/ProficiencySelect.vue
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<smart-select
|
||||||
|
append-icon="arrow_drop_down"
|
||||||
|
class="ml-3"
|
||||||
|
v-bind="$attrs"
|
||||||
|
:menu-props="{transition: 'slide-y-transition', lazy: true}"
|
||||||
|
:items="values"
|
||||||
|
:value="value"
|
||||||
|
@change="(value, ack) => $emit('change', value, ack)"
|
||||||
|
>
|
||||||
|
<v-icon
|
||||||
|
class="icon"
|
||||||
|
slot="prepend"
|
||||||
|
:class="iconClass"
|
||||||
|
>{{displayedIcon}}</v-icon>
|
||||||
|
</smart-select>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const ICON_SPIN_DURATION = 300;
|
||||||
|
let proficiencyIcon = function(value){
|
||||||
|
if (value == 0.5){
|
||||||
|
return 'brightness_2';
|
||||||
|
} else if (value == 1) {
|
||||||
|
return 'brightness_1'
|
||||||
|
} else if (value == 2){
|
||||||
|
return 'album'
|
||||||
|
} else {
|
||||||
|
return 'radio_button_unchecked';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
value: Number,
|
||||||
|
},
|
||||||
|
data(){ return {
|
||||||
|
displayedIcon: 'radio_button_unchecked',
|
||||||
|
iconClass: '',
|
||||||
|
values: [
|
||||||
|
{value: 1, text: 'Proficient'},
|
||||||
|
{value: 0.5, text: 'Half proficiency bonus'},
|
||||||
|
{value: 2, text: 'Double proficiency bonus'},
|
||||||
|
],
|
||||||
|
}},
|
||||||
|
watch: {
|
||||||
|
'value': {
|
||||||
|
immediate: true,
|
||||||
|
handler(newValue, oldValue, e){
|
||||||
|
let newIcon = proficiencyIcon(newValue);
|
||||||
|
if (!oldValue){
|
||||||
|
// Skip animation
|
||||||
|
this.displayedIcon = newIcon;
|
||||||
|
} else {
|
||||||
|
this.iconClass="leaving";
|
||||||
|
setTimeout(() => {
|
||||||
|
this.displayedIcon = newIcon;
|
||||||
|
this.iconClass="arriving";
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
this.iconClass="";
|
||||||
|
});
|
||||||
|
}, ICON_SPIN_DURATION / 2);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="css" scoped>
|
||||||
|
.theme--light .icon {
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
|
.icon {
|
||||||
|
min-width: 30px;
|
||||||
|
transition: transform 0.15s linear, opacity 0.15s ease;
|
||||||
|
transform-origin: 18px center;
|
||||||
|
margin-left: -12px;
|
||||||
|
}
|
||||||
|
.icon.leaving {
|
||||||
|
transform: translateY(-24px);
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
.icon.arriving {
|
||||||
|
transform: translateY(24px);
|
||||||
|
opacity: 0;
|
||||||
|
transition: none;
|
||||||
|
}
|
||||||
|
.hidden {
|
||||||
|
visibility: hidden;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -10,6 +10,7 @@ import FolderForm from '/imports/ui/forms/FolderForm.vue';
|
|||||||
import NoteForm from '/imports/ui/forms/NoteForm.vue';
|
import NoteForm from '/imports/ui/forms/NoteForm.vue';
|
||||||
import ProficiencyForm from '/imports/ui/forms/ProficiencyForm.vue';
|
import ProficiencyForm from '/imports/ui/forms/ProficiencyForm.vue';
|
||||||
import RollForm from '/imports/ui/forms/RollForm.vue';
|
import RollForm from '/imports/ui/forms/RollForm.vue';
|
||||||
|
import SkillForm from '/imports/ui/forms/SkillForm.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
action: ActionForm,
|
action: ActionForm,
|
||||||
@@ -24,4 +25,5 @@ export default {
|
|||||||
note: NoteForm,
|
note: NoteForm,
|
||||||
proficiency: ProficiencyForm,
|
proficiency: ProficiencyForm,
|
||||||
roll: RollForm,
|
roll: RollForm,
|
||||||
|
skill: SkillForm,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user