Moved ancestry setting responsibility to trusted code
This commit is contained in:
@@ -7,6 +7,7 @@ import { reorderDocs } from '/imports/api/parenting/order.js';
|
||||
import recomputeInactiveProperties from '/imports/api/creature/denormalise/recomputeInactiveProperties.js';
|
||||
import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
||||
import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory.js';
|
||||
import { getAncestry } from '/imports/api/parenting/parenting.js';
|
||||
|
||||
const insertProperty = new ValidatedMethod({
|
||||
name: 'creatureProperties.insert',
|
||||
@@ -16,9 +17,24 @@ const insertProperty = new ValidatedMethod({
|
||||
numRequests: 5,
|
||||
timeInterval: 5000,
|
||||
},
|
||||
run({creatureProperty}) {
|
||||
let rootCreature = getRootCreatureAncestor(creatureProperty);
|
||||
run({creatureProperty, parentRef}) {
|
||||
// get the new ancestry for the properties
|
||||
let {parentDoc, ancestors} = getAncestry({parentRef});
|
||||
|
||||
// Check permission to edit
|
||||
let rootCreature;
|
||||
if (parentRef.collection === 'creatures'){
|
||||
rootCreature = parentDoc;
|
||||
} else if (parentRef.collection === 'creatureProperties'){
|
||||
rootCreature = getRootCreatureAncestor(parentDoc);
|
||||
} else {
|
||||
throw `${parentRef.collection} is not a valid parent collection`
|
||||
}
|
||||
assertEditPermission(rootCreature, this.userId);
|
||||
|
||||
creatureProperty.parent = parentRef;
|
||||
creatureProperty.ancestors = ancestors;
|
||||
|
||||
return insertPropertyWork({
|
||||
property: creatureProperty,
|
||||
creature: rootCreature,
|
||||
|
||||
@@ -10,9 +10,14 @@ export default {
|
||||
},
|
||||
},
|
||||
mounted(){
|
||||
if (this.$refs.focusFirst && this.$refs.focusFirst.focus){
|
||||
setTimeout(() => this.$refs.focusFirst.focus(), 300);
|
||||
}
|
||||
// Don't autofocus on mobile, it brings up the on-screen keyboard
|
||||
if (this.$vuetify.breakpoint.smAndDown) return;
|
||||
|
||||
setTimeout(() => {
|
||||
if (this.$refs.focusFirst && this.$refs.focusFirst.focus){
|
||||
this.$refs.focusFirst.focus()
|
||||
}
|
||||
}, 300);
|
||||
},
|
||||
methods: {
|
||||
change(path, value, ack){
|
||||
|
||||
Reference in New Issue
Block a user