2020-06-30 20:53:25 +00:00
|
|
|
<template>
|
|
|
|
<multiselect
|
2020-09-05 20:35:52 +00:00
|
|
|
:internal-search="true"
|
|
|
|
:loading="namespaceService.loading"
|
|
|
|
:multiple="false"
|
|
|
|
:options="namespaces"
|
|
|
|
:searchable="true"
|
|
|
|
:showNoOptions="false"
|
|
|
|
@search-change="findNamespaces"
|
|
|
|
@select="select"
|
|
|
|
label="title"
|
|
|
|
placeholder="Search for a namespace..."
|
|
|
|
track-by="id"
|
|
|
|
v-model="namespace">
|
2020-06-30 20:53:25 +00:00
|
|
|
<template slot="clear" slot-scope="props">
|
|
|
|
<div
|
2020-09-05 20:35:52 +00:00
|
|
|
@mousedown.prevent.stop="clearAll(props.search)" class="multiselect__clear"
|
|
|
|
v-if="namespace.id !== 0"></div>
|
2020-06-30 20:53:25 +00:00
|
|
|
</template>
|
|
|
|
<span slot="noResult">No namespace found. Consider changing the search query.</span>
|
|
|
|
</multiselect>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2020-09-05 20:35:52 +00:00
|
|
|
import NamespaceService from '../../services/namespace'
|
|
|
|
import NamespaceModel from '../../models/namespace'
|
|
|
|
import LoadingComponent from '../misc/loading'
|
|
|
|
import ErrorComponent from '../misc/error'
|
2020-06-30 20:53:25 +00:00
|
|
|
|
2020-09-05 20:35:52 +00:00
|
|
|
export default {
|
|
|
|
name: 'namespace-search',
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
namespaceService: NamespaceService,
|
|
|
|
namespace: NamespaceModel,
|
|
|
|
namespaces: [],
|
|
|
|
}
|
|
|
|
},
|
|
|
|
components: {
|
|
|
|
multiselect: () => ({
|
|
|
|
component: import(/* webpackPrefetch: true *//* webpackChunkName: "multiselect" */ 'vue-multiselect'),
|
|
|
|
loading: LoadingComponent,
|
|
|
|
error: ErrorComponent,
|
|
|
|
timeout: 60000,
|
|
|
|
}),
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.namespaceService = new NamespaceService()
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
findNamespaces(query) {
|
|
|
|
if (query === '') {
|
|
|
|
this.clearAll()
|
|
|
|
return
|
2020-06-30 20:53:25 +00:00
|
|
|
}
|
2020-09-05 20:35:52 +00:00
|
|
|
|
|
|
|
this.namespaceService.getAll({}, {s: query})
|
|
|
|
.then(response => {
|
|
|
|
this.$set(this, 'namespaces', response)
|
|
|
|
})
|
|
|
|
.catch(e => {
|
|
|
|
this.error(e, this)
|
|
|
|
})
|
2020-06-30 20:53:25 +00:00
|
|
|
},
|
2020-09-05 20:35:52 +00:00
|
|
|
clearAll() {
|
|
|
|
this.$set(this, 'namespaces', [])
|
2020-06-30 20:53:25 +00:00
|
|
|
},
|
2020-09-05 20:35:52 +00:00
|
|
|
select(namespace) {
|
|
|
|
this.$emit('selected', namespace)
|
2020-06-30 20:53:25 +00:00
|
|
|
},
|
2020-09-05 20:35:52 +00:00
|
|
|
},
|
|
|
|
}
|
2020-06-30 20:53:25 +00:00
|
|
|
</script>
|