mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-01 20:28:46 -05:00
fdc search in property editor
This commit is contained in:
@@ -3,14 +3,17 @@
|
||||
<v-card>
|
||||
<v-closable-card-title :title="$t('Search')" icon="$search" v-model="dialog"></v-closable-card-title>
|
||||
<v-card-text>
|
||||
<v-text-field v-model="query">
|
||||
<v-text-field v-model="query" :loading="loading" :label="$t('Search')" @keydown.enter="fdcSearch()">
|
||||
<template #append>
|
||||
<v-btn icon="$search" @click="fdcSearch()"></v-btn>
|
||||
<v-btn icon="$search" color="success" @click="fdcSearch()"></v-btn>
|
||||
</template>
|
||||
</v-text-field>
|
||||
<v-select multiple v-model="fdcDataTypeSelection" :items="fdcDataTypeOptions" chips></v-select>
|
||||
|
||||
<v-list>
|
||||
<v-list-item v-for="f in fdcQueryResults?.foods">{{ f}}</v-list-item>
|
||||
<v-list-item v-for="f in fdcQueryResults?.foods" :title="f.description" @click="dialog = false; emit('selected', f.fdcId)">
|
||||
<v-list-item-subtitle>{{f.dataType}} <v-chip size="small">{{f.fdcId}}</v-chip></v-list-item-subtitle>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
@@ -22,17 +25,31 @@
|
||||
import VClosableCardTitle from "@/components/dialogs/VClosableCardTitle.vue";
|
||||
import {ref} from "vue";
|
||||
import {ApiApi, FdcQuery} from "@/openapi";
|
||||
import {ErrorMessageType, useMessageStore} from "@/stores/MessageStore";
|
||||
|
||||
const dialog = defineModel<boolean>({required: true})
|
||||
const emit = defineEmits(['selected'])
|
||||
|
||||
const dialog = defineModel<boolean>({default: false})
|
||||
const loading = ref(false)
|
||||
|
||||
const query = ref("")
|
||||
const fdcQueryResults = ref<undefined|FdcQuery>(undefined)
|
||||
const fdcQueryResults = ref<undefined | FdcQuery>(undefined)
|
||||
|
||||
function fdcSearch(){
|
||||
const fdcDataTypeOptions = ref(['Branded','Foundation','Survey (FNDDS)','SR Legacy'])
|
||||
const fdcDataTypeSelection = ref(['Foundation','Survey (FNDDS)','SR Legacy'])
|
||||
|
||||
/**
|
||||
* perform search in fdc database
|
||||
*/
|
||||
function fdcSearch() {
|
||||
let api = new ApiApi()
|
||||
|
||||
api.apiFdcSearchRetrieve({query: query.value}).then(r => {
|
||||
loading.value = true
|
||||
api.apiFdcSearchRetrieve({query: query.value, dataType: fdcDataTypeSelection.value.join(',') }).then(r => {
|
||||
fdcQueryResults.value = r
|
||||
}).catch(err => {
|
||||
useMessageStore().addError(ErrorMessageType.FETCH_ERROR, err)
|
||||
}).finally(() => {
|
||||
loading.value = false
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user