diff --git a/vue3/src/components/dialogs/FdcSearchDialog.vue b/vue3/src/components/dialogs/FdcSearchDialog.vue
index 741d051d9..ffe6d3fb7 100644
--- a/vue3/src/components/dialogs/FdcSearchDialog.vue
+++ b/vue3/src/components/dialogs/FdcSearchDialog.vue
@@ -3,14 +3,17 @@
-
+
-
+
+
- {{ f}}
+
+ {{f.dataType}} {{f.fdcId}}
+
@@ -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({required: true})
+const emit = defineEmits(['selected'])
+
+const dialog = defineModel({default: false})
+const loading = ref(false)
const query = ref("")
-const fdcQueryResults = ref(undefined)
+const fdcQueryResults = ref(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
})
}
diff --git a/vue3/src/pages/PropertyEditorPage.vue b/vue3/src/pages/PropertyEditorPage.vue
index 94d9caff7..241c5cfec 100644
--- a/vue3/src/pages/PropertyEditorPage.vue
+++ b/vue3/src/pages/PropertyEditorPage.vue
@@ -47,6 +47,7 @@
+
- OpenSearch
-
+ {fdcSelectedFood.fdcId = fdcId; updateFoodFdcData(fdcSelectedFood)}">
@@ -158,6 +158,8 @@ import {useUrlSearchParams} from "@vueuse/core";
import BtnCopy from "@/components/buttons/BtnCopy.vue";
import FdcSearchDialog from "@/components/dialogs/FdcSearchDialog.vue";
+type FoodLoading = Food & { loading?: boolean }
+
const params = useUrlSearchParams('history', {})
const calculatorToNumerator = computed(() => {
@@ -173,10 +175,11 @@ const calculatorFromDenominator = ref(500)
const calculatorToDenominator = ref(100)
const fdcDialog = ref(false)
+const fdcSelectedFood = ref(undefined)
const recipe = ref()
const propertyTypes = ref([] as PropertyType[])
-const foods = ref(new Map())
+const foods = ref(new Map())
const recipeLoading = ref(false)
const propertyTypesLoading = ref(false)
@@ -230,13 +233,13 @@ function loadPropertyTypes() {
* set null to indicate missing property, 0 for properties with the actual value 0
*/
function buildFoodMap() {
- foods.value = new Map()
+ foods.value = new Map()
if (recipe.value != undefined) {
recipe.value.steps.forEach(step => {
step.ingredients.forEach(ingredient => {
if (ingredient.food && !foods.value.has(ingredient.food.id!)) {
- let food: Food & { loading?: boolean } = buildFoodProperties(ingredient.food)
+ let food: FoodLoading = buildFoodProperties(ingredient.food)
food.loading = false
foods.value.set(food.id!, food)
}
@@ -274,10 +277,10 @@ function buildFoodProperties(food: Food) {
* @param p
* @param food
*/
-function deleteFoodProperty(p: Property, food: Food & { loading?: boolean } ){
+function deleteFoodProperty(p: Property, food: FoodLoading) {
let api = new ApiApi()
- if(p.id){
+ if (p.id) {
food.loading = true
api.apiPropertyDestroy({id: p.id}).then(r => {
p.propertyAmount = null
@@ -295,7 +298,7 @@ function deleteFoodProperty(p: Property, food: Food & { loading?: boolean } ){
* update food
* @param food
*/
-function updateFood(food: Food & { loading?: boolean }) {
+function updateFood(food: FoodLoading) {
let api = new ApiApi()
food.loading = true
api.apiFoodPartialUpdate({id: food.id!, patchedFood: food}).then(r => {
@@ -311,7 +314,7 @@ function updateFood(food: Food & { loading?: boolean }) {
* Update the food FDC data on the server and put the updated food into the food map
* @param food
*/
-function updateFoodFdcData(food: Food & { loading?: boolean }) {
+function updateFoodFdcData(food: FoodLoading) {
let api = new ApiApi()
food.loading = true
if (food.fdcId) {