feat(shares): filter out users or teams a list is already shared with
This commit is contained in:
parent
fab58a2e6d
commit
05ded65f8b
1 changed files with 26 additions and 15 deletions
|
@ -120,7 +120,9 @@
|
||||||
v-if="showDeleteModal"
|
v-if="showDeleteModal"
|
||||||
>
|
>
|
||||||
<template #header>
|
<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>
|
||||||
<template #text>
|
<template #text>
|
||||||
<p>{{ $t('list.share.userTeam.removeText', {type: shareTypeName, sharable: sharableName}) }}</p>
|
<p>{{ $t('list.share.userTeam.removeText', {type: shareTypeName, sharable: sharableName}) }}</p>
|
||||||
|
@ -132,7 +134,8 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import {defineComponent} from 'vue'
|
import {defineComponent} from 'vue'
|
||||||
export default defineComponent({ name: 'userTeamShare' })
|
|
||||||
|
export default defineComponent({name: 'userTeamShare'})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
@ -158,7 +161,7 @@ import TeamModel from '@/models/team'
|
||||||
import RIGHTS from '@/models/constants/rights.json'
|
import RIGHTS from '@/models/constants/rights.json'
|
||||||
import Multiselect from '@/components/input/multiselect.vue'
|
import Multiselect from '@/components/input/multiselect.vue'
|
||||||
import Nothing from '@/components/misc/nothing.vue'
|
import Nothing from '@/components/misc/nothing.vue'
|
||||||
import { success } from '@/message'
|
import {success} from '@/message'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
type: {
|
type: {
|
||||||
|
@ -186,7 +189,7 @@ let stuffService: ShallowReactive<UserNamespaceService | UserListService | TeamL
|
||||||
let stuffModel: UserNamespaceModel | UserListModel | TeamListModel | TeamNamespaceModel
|
let stuffModel: UserNamespaceModel | UserListModel | TeamListModel | TeamNamespaceModel
|
||||||
let searchService: ShallowReactive<UserService | TeamService>
|
let searchService: ShallowReactive<UserService | TeamService>
|
||||||
let sharable: Ref<UserModel | TeamModel>
|
let sharable: Ref<UserModel | TeamModel>
|
||||||
|
|
||||||
const searchLabel = ref('')
|
const searchLabel = ref('')
|
||||||
const selectedRight = ref({})
|
const selectedRight = ref({})
|
||||||
|
|
||||||
|
@ -290,10 +293,12 @@ async function deleteSharable() {
|
||||||
sharables.value.splice(i, 1)
|
sharables.value.splice(i, 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
success({message: t('list.share.userTeam.removeSuccess', {
|
success({
|
||||||
type: shareTypeName.value,
|
message: t('list.share.userTeam.removeSuccess', {
|
||||||
sharable: sharableName.value,
|
type: shareTypeName.value,
|
||||||
})})
|
sharable: sharableName.value,
|
||||||
|
}),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
async function add(admin) {
|
async function add(admin) {
|
||||||
|
@ -310,7 +315,7 @@ async function add(admin) {
|
||||||
} else if (props.shareType === 'team') {
|
} else if (props.shareType === 'team') {
|
||||||
stuffModel.teamId = sharable.value.id
|
stuffModel.teamId = sharable.value.id
|
||||||
}
|
}
|
||||||
|
|
||||||
await stuffService.create(stuffModel)
|
await stuffService.create(stuffModel)
|
||||||
success({message: t('list.share.userTeam.addedSuccess', {type: shareTypeName.value})})
|
success({message: t('list.share.userTeam.addedSuccess', {type: shareTypeName.value})})
|
||||||
await load()
|
await load()
|
||||||
|
@ -348,16 +353,22 @@ async function toggleType(sharable) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const found = ref([])
|
const found = ref([])
|
||||||
|
|
||||||
|
const currentUserId = computed(() => store.state.auth.info.id)
|
||||||
async function find(query) {
|
async function find(query) {
|
||||||
if (query === '') {
|
if (query === '') {
|
||||||
clearAll()
|
found.value = []
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
found.value = await searchService.getAll({}, {s: query})
|
const results = await searchService.getAll({}, {s: query})
|
||||||
}
|
found.value = results
|
||||||
|
.filter(m => {
|
||||||
function clearAll() {
|
if(props.shareType === 'user' && m.id === currentUserId.value) {
|
||||||
found.value = []
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
return typeof sharables.value.find(s => s.id === m.id) === 'undefined'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue