This repository has been archived on 2024-02-08. You can view files and clone it, but cannot push or open issues or pull requests.
frontend/src/components/tasks/partials/listSearch.vue

75 lines
1.4 KiB
Vue
Raw Normal View History

2020-04-18 12:39:56 +00:00
<template>
<multiselect
class="control is-expanded"
:placeholder="$t('list.search')"
@search="findLists"
:search-results="foundLists"
@select="select"
label="title"
v-model="list"
:select-placeholder="$t('list.searchSelect')"
2020-04-18 12:39:56 +00:00
>
<template #searchResult="props">
2021-08-06 17:34:22 +00:00
<span class="list-namespace-title search-result">{{ namespace(props.option.namespaceId) }} ></span>
{{ props.option.title }}
</template>
2020-04-18 12:39:56 +00:00
</multiselect>
</template>
<script>
import ListModel from '../../../models/list'
import Multiselect from '@/components/input/multiselect.vue'
2020-04-18 12:39:56 +00:00
export default {
name: 'listSearch',
data() {
return {
list: new ListModel(),
foundLists: [],
}
},
props: {
modelValue: {
required: false,
},
},
emits: ['update:modelValue', 'selected'],
components: {
Multiselect,
},
watch: {
modelValue: {
handler(value) {
this.list = value
},
immeditate: true,
2021-10-11 17:15:34 +00:00
deep: true,
},
},
methods: {
findLists(query) {
this.foundLists = this.$store.getters['lists/searchList'](query)
2020-04-18 12:39:56 +00:00
},
select(list) {
this.list = list
this.$emit('selected', list)
this.$emit('update:modelValue', list)
2020-04-18 12:39:56 +00:00
},
namespace(namespaceId) {
const namespace = this.$store.getters['namespaces/getNamespaceById'](namespaceId)
if (namespace !== null) {
return namespace.title
}
return this.$t('list.shared')
2020-04-18 12:39:56 +00:00
},
},
}
2020-04-18 12:39:56 +00:00
</script>
<style lang="scss" scoped>
.list-namespace-title {
color: var(--grey-500);
}
</style>