diff --git a/app/imports/api/creature/CreatureProperties.js b/app/imports/api/creature/CreatureProperties.js index ad0debf3..95d78db3 100644 --- a/app/imports/api/creature/CreatureProperties.js +++ b/app/imports/api/creature/CreatureProperties.js @@ -74,6 +74,7 @@ const insertProperty = new ValidatedMethod({ name: 'CreatureProperties.methods.insert', validate: null, run({creatureProperty}) { + delete creatureProperty._id; assertPropertyEditPermission(creatureProperty, this.userId); let _id = CreatureProperties.insert(creatureProperty); let property = CreatureProperties.findOne(_id); @@ -81,6 +82,23 @@ const insertProperty = new ValidatedMethod({ }, }); +const duplicateProperty = new ValidatedMethod({ + name: 'CreatureProperties.methods.duplicate', + validate: new SimpleSchema({ + _id: { + type: String, + regEx: SimpleSchema.RegEx.Id, + } + }).validator(), + run({_id}) { + let creatureProperty = CreatureProperties.findOne(_id); + assertPropertyEditPermission(creatureProperty, this.userId); + delete creatureProperty._id; + CreatureProperties.insert(creatureProperty); + recomputeCreatures(creatureProperty); + }, +}); + const insertPropertyFromLibraryNode = new ValidatedMethod({ name: 'CreatureProperties.methods.insertPropertyFromLibraryNode', validate: new SimpleSchema({ @@ -290,6 +308,7 @@ export default CreatureProperties; export { CreaturePropertySchema, insertProperty, + duplicateProperty, insertPropertyFromLibraryNode, updateProperty, damageProperty, diff --git a/app/imports/ui/components/propertyToolbar.vue b/app/imports/ui/components/propertyToolbar.vue index 6ef944e4..96898829 100644 --- a/app/imports/ui/components/propertyToolbar.vue +++ b/app/imports/ui/components/propertyToolbar.vue @@ -26,6 +26,11 @@ @input="colorChanged" /> - - - - - - {{ getPropertyName(selectedProperty && selectedProperty.type) }} - - - - - create - - - - - - - - + @@ -132,8 +92,7 @@