feat(shares): filter out users or teams a list is already shared with

This commit is contained in:
kolaente 2022-06-16 22:28:54 +02:00
parent fab58a2e6d
commit 05ded65f8b
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B

View file

@ -120,7 +120,9 @@
v-if="showDeleteModal"
>
<template #header>
<span>{{ $t('list.share.userTeam.removeHeader', {type: shareTypeName, sharable: sharableName}) }}</span>
<span>{{
$t('list.share.userTeam.removeHeader', {type: shareTypeName, sharable: sharableName})
}}</span>
</template>
<template #text>
<p>{{ $t('list.share.userTeam.removeText', {type: shareTypeName, sharable: sharableName}) }}</p>
@ -132,6 +134,7 @@
<script lang="ts">
import {defineComponent} from 'vue'
export default defineComponent({name: 'userTeamShare'})
</script>
@ -290,10 +293,12 @@ async function deleteSharable() {
sharables.value.splice(i, 1)
}
}
success({message: t('list.share.userTeam.removeSuccess', {
success({
message: t('list.share.userTeam.removeSuccess', {
type: shareTypeName.value,
sharable: sharableName.value,
})})
}),
})
}
async function add(admin) {
@ -348,16 +353,22 @@ async function toggleType(sharable) {
}
const found = ref([])
const currentUserId = computed(() => store.state.auth.info.id)
async function find(query) {
if (query === '') {
clearAll()
found.value = []
return
}
found.value = await searchService.getAll({}, {s: query})
const results = await searchService.getAll({}, {s: query})
found.value = results
.filter(m => {
if(props.shareType === 'user' && m.id === currentUserId.value) {
return false
}
function clearAll() {
found.value = []
return typeof sharables.value.find(s => s.id === m.id) === 'undefined'
})
}
</script>