meal plan in search

This commit is contained in:
vabene1111
2021-04-18 17:19:11 +02:00
parent 4ad5d6ef2f
commit 058d705170
6 changed files with 67 additions and 16 deletions

View File

@ -2,26 +2,36 @@
<b-card no-body>
<a :href="resolveDjangoUrl('view_recipe', recipe.id)">
<a :href="clickUrl()">
<b-card-img-lazy style="height: 15vh; object-fit: cover" :src=recipe_image v-bind:alt="$t('Recipe_Image')"
top></b-card-img-lazy>
<div class="card-img-overlay h-100 d-flex flex-column justify-content-right"
style="float:right; text-align: right; padding-top: 10px; padding-right: 5px">
<recipe-context-menu :recipe="recipe" style="float:right"></recipe-context-menu>
<recipe-context-menu :recipe="recipe" style="float:right" v-if="recipe !== null"></recipe-context-menu>
</div>
</a>
<b-card-body>
<h5><a :href="resolveDjangoUrl('view_recipe', recipe.id)">{{ recipe.name }}</a></h5>
<h5><a :href="clickUrl()">
<template v-if="recipe !== null">{{ recipe.name }}</template>
<template v-else>{{ meal_plan.title }}</template>
</a></h5>
<b-card-text style="text-overflow: ellipsis">
{{ recipe.description }}
<keywords :recipe="recipe" style="margin-top: 4px"></keywords>
<template v-if="recipe !== null">
{{ recipe.description }}
<keywords :recipe="recipe" style="margin-top: 4px"></keywords>
</template>
<template v-else>{{ meal_plan.note }}</template>
</b-card-text>
</b-card-body>
<b-card-footer v-if="meal_plan !== undefined">
<i class="far fa-calendar-alt"></i> {{ meal_plan.meal_type_name }}
</b-card-footer>
</b-card>
</template>
@ -29,7 +39,7 @@
<script>
import RecipeContextMenu from "@/components/RecipeContextMenu";
import Keywords from "@/components/Keywords";
import {ResolveUrlMixin} from "@/utils/utils";
import {resolveDjangoUrl, ResolveUrlMixin} from "@/utils/utils";
export default {
name: "RecipeCard",
@ -39,6 +49,7 @@ export default {
components: {Keywords, RecipeContextMenu},
props: {
recipe: Object,
meal_plan: Object,
},
data() {
return {
@ -46,11 +57,21 @@ export default {
}
},
mounted() {
if (this.recipe.image === null) {
if (this.recipe == null || this.recipe.image === null) {
this.recipe_image = window.IMAGE_PLACEHOLDER
} else {
this.recipe_image = this.recipe.image
}
},
methods: {
clickUrl: function () {
if (this.recipe !== null) {
return resolveDjangoUrl('view_recipe', this.recipe.id)
} else {
return resolveDjangoUrl('view_plan_entry', this.meal_plan.id)
}
}
}
}
</script>