chore: make functions of linkSharing less dependent on component state

This commit is contained in:
Dominik Pschenitschni 2021-10-02 20:31:18 +02:00
parent 6fee114610
commit 1964c1352c
No known key found for this signature in database
GPG key ID: B257AC0149F43A77

View file

@ -68,7 +68,7 @@
/> />
</div> </div>
</div> </div>
<x-button @click="add" icon="plus"> <x-button @click="add(listId)" icon="plus">
{{ $t('list.share.share') }} {{ $t('list.share.share') }}
</x-button> </x-button>
</div> </div>
@ -160,7 +160,7 @@
<transition name="modal"> <transition name="modal">
<modal <modal
@close="showDeleteModal = false" @close="showDeleteModal = false"
@submit="remove()" @submit="remove(listId)"
v-if="showDeleteModal" v-if="showDeleteModal"
> >
<template #header> <template #header>
@ -215,14 +215,14 @@ export default {
frontendUrl: (state) => state.config.frontendUrl, frontendUrl: (state) => state.config.frontendUrl,
}), }),
methods: { methods: {
load() { load(listId) {
// If listId == 0 the list on the calling component wasn't already loaded, so we just bail out here // If listId == 0 the list on the calling component wasn't already loaded, so we just bail out here
if (this.listId === 0) { if (listId === 0) {
return return
} }
this.linkShareService this.linkShareService
.getAll({listId: this.listId}) .getAll({listId})
.then((r) => { .then((r) => {
this.linkShares = r this.linkShares = r
}) })
@ -230,10 +230,10 @@ export default {
this.$message.error(e) this.$message.error(e)
}) })
}, },
add() { add(listId) {
const newLinkShare = new LinkShareModel({ const newLinkShare = new LinkShareModel({
right: this.selectedRight, right: this.selectedRight,
listId: this.listId, listId,
name: this.name, name: this.name,
password: this.password, password: this.password,
}) })
@ -245,22 +245,22 @@ export default {
this.password = '' this.password = ''
this.showNewForm = false this.showNewForm = false
this.$message.success({message: this.$t('list.share.links.createSuccess')}) this.$message.success({message: this.$t('list.share.links.createSuccess')})
this.load() this.load(listId)
}) })
.catch((e) => { .catch((e) => {
this.$message.error(e) this.$message.error(e)
}) })
}, },
remove() { remove(listId) {
const linkshare = new LinkShareModel({ const linkshare = new LinkShareModel({
id: this.linkIdToDelete, id: this.linkIdToDelete,
listId: this.listId, listId,
}) })
this.linkShareService this.linkShareService
.delete(linkshare) .delete(linkshare)
.then(() => { .then(() => {
this.$message.success({message: this.$t('list.share.links.deleteSuccess')}) this.$message.success({message: this.$t('list.share.links.deleteSuccess')})
this.load() this.load(listId)
}) })
.catch((e) => { .catch((e) => {
this.$message.error(e) this.$message.error(e)