diff --git a/app/imports/ui/creature/character/CharacterSheetToolbarItems.vue b/app/imports/ui/creature/character/CharacterSheetToolbarItems.vue index 9a427040..8c95e493 100644 --- a/app/imports/ui/creature/character/CharacterSheetToolbarItems.vue +++ b/app/imports/ui/creature/character/CharacterSheetToolbarItems.vue @@ -21,7 +21,7 @@ more_vert - + delete Delete @@ -38,6 +38,13 @@ + + + + delete Unshare with me + + + @@ -49,11 +56,18 @@ import isDarkColor from '/imports/ui/utility/isDarkColor.js'; import { mapMutations } from 'vuex'; import { theme } from '/imports/ui/theme.js'; import { recomputeCreature } from '/imports/api/creature/computation/recomputeCreature.js'; +import { assertEditPermission } from '/imports/api/creature/creaturePermissions.js'; +import { updateUserSharePermissions } from '/imports/api/sharing/sharing.js'; export default { data(){return { theme, }}, + computed: { + creatureId(){ + return this.$route.params.id; + }, + }, methods: { ...mapMutations([ 'toggleDrawer', @@ -103,12 +117,23 @@ export default { } }); }, - isDarkColor, - }, - computed: { - creatureId(){ - return this.$route.params.id; + unshareWithMe(){ + updateUserSharePermissions.call({ + docRef: { + collection: 'creatures', + id: this.creatureId, + }, + userId: Meteor.userId(), + role: 'none', + }, (error) => { + if (error) { + console.error(error); + } else { + this.$router.push('/characterList'); + } + }); }, + isDarkColor, }, meteor: { $subscribe: { @@ -119,6 +144,14 @@ export default { creature(){ return Creatures.findOne(this.creatureId) || {}; }, + editPermission(){ + try { + assertEditPermission(this.creature, Meteor.userId()); + return true; + } catch (e) { + return false; + } + }, }, }