many editor improvements (and more)

This commit is contained in:
vabene1111
2025-01-04 17:59:56 +01:00
parent c691d6028b
commit c75d265686
40 changed files with 256 additions and 61 deletions

View File

@@ -28,7 +28,7 @@
</v-list-item>
<v-divider v-if="mealPlanGridItem.plan_entries.length > 0"></v-divider>
<v-list-item v-for="p in mealPlanGridItem.plan_entries" link>
<v-list-item v-for="p in mealPlanGridItem.plan_entries" :key="p.id" @click="clickMealPlan(p)" link>
<template #prepend>
<v-avatar :image="p.recipe.image" v-if="p.recipe?.image"></v-avatar>
<v-avatar image="../../assets/recipe_no_image.svg" v-else></v-avatar>
@@ -40,7 +40,20 @@
<v-list-item-subtitle>
{{ p.mealType.name }}
</v-list-item-subtitle>
<model-edit-dialog model="MealPlan" :item="p"></model-edit-dialog>
<model-edit-dialog model="MealPlan" :item="p" v-if="!p.recipe"></model-edit-dialog>
<template #append>
<v-btn icon variant="plain">
<v-icon icon="$menu"></v-icon>
<v-menu activator="parent">
<v-list>
<v-list-item prepend-icon="$edit">
{{$t('Edit')}}
<model-edit-dialog model="MealPlan" :item="p"></model-edit-dialog>
</v-list-item>
</v-list>
</v-menu>
</v-btn>
</template>
</v-list-item>
</v-list>
@@ -62,7 +75,9 @@ import {useMealPlanStore} from "@/stores/MealPlanStore";
import {DateTime} from "luxon";
import {homePageCols} from "@/utils/breakpoint_utils";
import ModelEditDialog from "@/components/dialogs/ModelEditDialog.vue";
import {useRouter} from "vue-router";
const router = useRouter()
const {name} = useDisplay()
const loading = ref(false)
@@ -119,6 +134,12 @@ onMounted(() => {
})
})
function clickMealPlan(plan: MealPlan){
if(plan.recipe){
router.push( {name: 'view_recipe', params: {id: plan.recipe.id}})
}
}
</script>

View File

@@ -1,7 +1,12 @@
<template>
<span v-if="ingredient.amount && !Number.isNaN(ingredient.amount)">{{$n(ingredient.amount)}}</span>
<span class="ms-1" v-if="ingredient.unit">{{ ingredient.unit.name}}</span>
<span class="ms-1" v-if="ingredient.food">{{ ingredient.food.name}}</span>
<template v-if="ingredient.isHeader">
<span class="font-weight-bold">{{ ingredient.note}}</span>
</template>
<template v-else>
<span v-if="ingredient.amount && !Number.isNaN(ingredient.amount)">{{$n(ingredient.amount)}}</span>
<span class="ms-1" v-if="ingredient.unit">{{ ingredient.unit.name}}</span>
<span class="ms-1" v-if="ingredient.food">{{ ingredient.food.name}}</span>
</template>
</template>

View File

@@ -8,20 +8,51 @@
<!-- </v-table>-->
<v-data-table :items="ingredients" hide-default-footer hide-default-header :headers="tableHeaders" density="compact" v-if="ingredients.length > 0" @click:row="handleRowClick" items-per-page="0">
<template v-slot:item.checked="{ item }">
<v-checkbox-btn v-model="item.checked" color="success"></v-checkbox-btn>
</template>
<template v-slot:item.amount="{ item }">
{{ item.amount * props.ingredientFactor }}
</template>
<!-- <v-data-table :items="ingredients" hide-default-footer hide-default-header :headers="tableHeaders" density="compact" v-if="ingredients.length > 0" @click:row="handleRowClick"-->
<!-- items-per-page="0">-->
<!-- <template v-slot:item.checked="{ item }">-->
<!-- <v-checkbox-btn v-model="item.checked" color="success" v-if="!item.isHeader"></v-checkbox-btn>-->
<!-- </template>-->
<!-- <template v-slot:item.amount="{ item }">-->
<!-- <template v-if="item.isHeader"><p style="width: 100px"><b>{{ item.note }}</b></p></template>-->
<!-- <template v-else>{{ item.amount * props.ingredientFactor }}</template>-->
<!-- </template>-->
<template v-slot:item.note="{ item }">
<v-icon class="far fa-comment float-right" v-if="item.note != '' && item.note != undefined">
<v-tooltip activator="parent" open-on-click location="start">{{ item.note }}</v-tooltip>
</v-icon>
</template>
</v-data-table>
<!-- <template v-slot:item.note="{ item }">-->
<!-- <v-icon class="far fa-comment float-right" v-if="item.note != '' && item.note != undefined">-->
<!-- <v-tooltip activator="parent" open-on-click location="start">{{ item.note }}</v-tooltip>-->
<!-- </v-icon>-->
<!-- </template>-->
<!-- </v-data-table>-->
<v-table density="compact">
<tbody>
<tr v-for="i in ingredients" :key="i.id" @click="i.checked = !i.checked">
<template v-if="i.isHeader">
<td colspan="5" class="font-weight-bold">{{ i.note }}</td>
</template>
<template v-else>
<td style="width: 1%; text-wrap: nowrap" class="pa-0">
<v-checkbox-btn v-model="i.checked" color="success" v-if="!i.isHeader"></v-checkbox-btn>
</td>
<td style="width: 1%; text-wrap: nowrap" class="pr-1">{{ i.amount * props.ingredientFactor }}</td>
<td style="width: 1%; text-wrap: nowrap" class="pr-1">
<template v-if="i.unit"> {{ i.unit.name }}</template>
</td>
<td>
<template v-if="i.food"> {{ i.food.name }}</template>
</td>
<td style="width: 1%; text-wrap: nowrap">
<v-icon class="far fa-comment float-right" v-if="i.note != '' && i.note != undefined">
<v-tooltip activator="parent" open-on-click location="start">{{ i.note }}</v-tooltip>
</v-icon>
</td>
</template>
</tr>
</tbody>
</v-table>
</template>