Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allowing for case type select with typeahead #3257

Merged
merged 1 commit into from
Apr 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions src/dispatch/static/dispatch/src/case/type/CaseTypeSelect.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,18 @@
<template>
<v-select
<v-combobox
v-model="case_type"
:items="items"
:search-input.sync="search"
:menu-props="{ maxHeight: '400' }"
item-text="name"
label="Type"
item-value="id"
:label="label"
placeholder="Start typing to search"
:hint="hint"
return-object
:loading="loading"
no-filter
>
<template v-slot:item="data">
<v-list-item-content>
Expand All @@ -25,7 +31,7 @@
</v-list-item-content>
</v-list-item>
</template>
</v-select>
</v-combobox>
</template>

<script>
Expand All @@ -48,10 +54,16 @@ export default {
type: [Object],
default: null,
},
hint: {
type: String,
default: function () {
return "Case Type to associate"
},
},
label: {
type: String,
default: function () {
return "Type"
return "Case Type"
},
},
},
Expand All @@ -60,6 +72,7 @@ export default {
return {
loading: false,
items: [],
search: null,
more: false,
numItems: 5,
}
Expand All @@ -86,6 +99,7 @@ export default {
this.loading = "error"

let filterOptions = {
q: this.search,
sortBy: ["name"],
descending: [false],
itemsPerPage: this.numItems,
Expand Down Expand Up @@ -125,6 +139,16 @@ export default {
},
},

watch: {
search(val) {
val && val !== this.select && this.fetchData()
},
value(val) {
if (!val) return
this.items.push(val)
},
},

created() {
this.fetchData()
this.$watch(
Expand Down