Use type instead of isAccount flag
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-02-25 22:28:22 +00:00
parent 32439e3e87
commit ae9e9d34c9
10 changed files with 54 additions and 26 deletions

View File

@@ -6,23 +6,26 @@ import { useBudgetsStore } from "../stores/budget";
export interface Suggestion {
ID: string
Name: string
Type: string
}
const props = defineProps<{
text: String,
id: String | undefined,
model: String
model: String,
type?: string | undefined,
}>();
const SearchQuery = ref(props.text || "");
const Suggestions = ref<Array<Suggestion>>([]);
const emit = defineEmits(["update:id", "update:text"]);
const emit = defineEmits(["update:id", "update:text", "update:type"]);
watch(SearchQuery, () => {
load(SearchQuery.value);
});
function load(text: String) {
emit('update:id', null);
emit('update:text', text);
emit('update:type', undefined);
if (text == "") {
Suggestions.value = [];
return;
@@ -53,6 +56,7 @@ function keypress(e: KeyboardEvent) {
function selectElement(element: Suggestion) {
emit('update:id', element.ID);
emit('update:text', element.Name);
emit('update:type', element.Type);
Suggestions.value = [];
};
function select(e: MouseEvent) {
@@ -67,6 +71,7 @@ function select(e: MouseEvent) {
function clear() {
emit('update:id', null);
emit('update:text', SearchQuery.value);
emit('update:type', undefined);
};
</script>