mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-06 22:58:19 -05:00
saerch dialogh
This commit is contained in:
@@ -610,6 +610,21 @@ class RecipeSimpleSerializer(WritableNestedModelSerializer):
|
||||
fields = ('id', 'name', 'url')
|
||||
|
||||
|
||||
class RecipeFlatSerializer(WritableNestedModelSerializer):
|
||||
|
||||
def create(self, validated_data):
|
||||
# don't allow writing to Recipe via this API
|
||||
return Recipe.objects.get(**validated_data)
|
||||
|
||||
def update(self, instance, validated_data):
|
||||
# don't allow writing to Recipe via this API
|
||||
return Recipe.objects.get(**validated_data)
|
||||
|
||||
class Meta:
|
||||
model = Recipe
|
||||
fields = ('id', 'name', 'image')
|
||||
|
||||
|
||||
class FoodSimpleSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Food
|
||||
|
||||
@@ -97,7 +97,7 @@ from cookbook.serializer import (AccessTokenSerializer, AutomationSerializer,
|
||||
SyncLogSerializer, SyncSerializer, UnitConversionSerializer,
|
||||
UnitSerializer, UserFileSerializer, UserPreferenceSerializer,
|
||||
UserSerializer, UserSpaceSerializer, ViewLogSerializer,
|
||||
ShoppingListEntryBulkSerializer, ConnectorConfigConfigSerializer)
|
||||
ShoppingListEntryBulkSerializer, ConnectorConfigConfigSerializer, RecipeFlatSerializer)
|
||||
from cookbook.views.import_export import get_integration
|
||||
from recipes import settings
|
||||
from recipes.settings import DRF_THROTTLE_RECIPE_URL_IMPORT, FDC_API_KEY
|
||||
@@ -1068,11 +1068,13 @@ class RecipeViewSet(viewsets.ModelViewSet):
|
||||
@decorators.action(
|
||||
detail=False,
|
||||
methods=['GET'],
|
||||
serializer_class=RecipeFlatSerializer,
|
||||
)
|
||||
def flat(self, request):
|
||||
return JsonResponse({'data': list(Recipe.objects.filter(space=request.space).filter(
|
||||
Q(private=False) | (Q(private=True) & (Q(created_by=self.request.user) | Q(shared=self.request.user)))
|
||||
).values_list('name', flat=True))})
|
||||
qs = Recipe.objects.filter(
|
||||
space=request.space).filter(Q(private=False) | (Q(private=True) & (Q(created_by=self.request.user) | Q(shared=self.request.user)))).all() # TODO limit fields retrieved but .values() kills image
|
||||
|
||||
return Response(self.serializer_class(qs, many=True).data)
|
||||
|
||||
|
||||
class UnitConversionViewSet(viewsets.ModelViewSet):
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -6,9 +6,9 @@
|
||||
<template v-slot:prepend>
|
||||
Tandoor Brand Logo
|
||||
</template>
|
||||
|
||||
<div id="id_dialog_anchor"></div>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn density="compact" icon="fas fa-search"></v-btn>
|
||||
<global-search-dialog></global-search-dialog>
|
||||
<v-btn density="compact" icon="fas fa-ellipsis-v"></v-btn>
|
||||
</v-app-bar>
|
||||
|
||||
@@ -51,9 +51,10 @@
|
||||
<script lang="ts">
|
||||
|
||||
import {defineComponent} from 'vue'
|
||||
import GlobalSearchDialog from "@/components/inputs/GlobalSearchDialog.vue";
|
||||
|
||||
export default defineComponent({
|
||||
components: {},
|
||||
components: {GlobalSearchDialog},
|
||||
mixins: [],
|
||||
data() {
|
||||
return {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
</template>
|
||||
<td>{{ ingredient.amount }}</td>
|
||||
<td><span v-if="ingredient.unit != null">{{ ingredient.unit.name }}</span></td>
|
||||
<td>{{ ingredient.food.name }}</td>
|
||||
<td ><span v-if="ingredient.food != null">{{ ingredient.food.name }}</span></td>
|
||||
<td>
|
||||
<v-icon class="far fa-comment" v-if="ingredient.note != ''" @click="show_tooltip = !show_tooltip">
|
||||
<v-tooltip v-model="show_tooltip" activator="parent" location="start">{{ ingredient.note }}</v-tooltip>
|
||||
|
||||
115
vue3/src/components/inputs/GlobalSearchDialog.vue
Normal file
115
vue3/src/components/inputs/GlobalSearchDialog.vue
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
14
vue3/src/types/SearchTypes.ts
Normal file
14
vue3/src/types/SearchTypes.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
export interface SearchResult {
|
||||
name: string,
|
||||
recipe_id?: number,
|
||||
suffix?: string,
|
||||
description?: string,
|
||||
icon?: string,
|
||||
image?: string,
|
||||
}
|
||||
|
||||
export interface FlatRecipe{
|
||||
id: number,
|
||||
name: string,
|
||||
image:string|null,
|
||||
}
|
||||
Reference in New Issue
Block a user