Merge branch 'version-2' into version-2-tabletop
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
<script lang="js">
|
||||
import CreatureLogs, { logRoll } from '/imports/api/creature/log/CreatureLogs.js';
|
||||
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||
import CreatureVariables from '/imports/api/creature/creatures/CreatureVariables';
|
||||
import { assertEditPermission } from '/imports/api/creature/creatures/creaturePermissions.js';
|
||||
import LogComponent from '/imports/ui/log/LogComponent.vue';
|
||||
|
||||
@@ -22,6 +23,39 @@ export default {
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
data(){return {
|
||||
inputHint: undefined,
|
||||
inputError: undefined,
|
||||
input: undefined,
|
||||
}},
|
||||
watch: {
|
||||
input(value){
|
||||
this.input = value;
|
||||
this.inputHint = this.inputError = undefined;
|
||||
if (!this.input) return;
|
||||
let result;
|
||||
try {
|
||||
result = parse(value);
|
||||
} catch (e){
|
||||
if (e.constructor.name === 'EndOfInputError'){
|
||||
this.inputError = '...';
|
||||
} else {
|
||||
let error = prettifyParseError(e);
|
||||
this.inputError = error;
|
||||
}
|
||||
return;
|
||||
}
|
||||
try {
|
||||
let {result: compiled} = resolve('compile', result, this.variables);
|
||||
this.inputHint = toString(compiled);
|
||||
return;
|
||||
} catch (e){
|
||||
console.warn(e);
|
||||
this.inputError = 'Compilation error';
|
||||
return;
|
||||
}
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
submit(input){
|
||||
logRoll.call({
|
||||
@@ -44,6 +78,9 @@ export default {
|
||||
creature(){
|
||||
return Creatures.findOne(this.creatureId) || {};
|
||||
},
|
||||
variables(){
|
||||
return CreatureVariables.findOne({_creatureId: this.creatureId}) || {};
|
||||
},
|
||||
editPermission(){
|
||||
try {
|
||||
assertEditPermission(this.creature, Meteor.userId());
|
||||
|
||||
Reference in New Issue
Block a user