mirror of
https://github.com/TandoorRecipes/recipes.git
synced 2026-01-08 23:58:15 -05:00
improved meal plan cards on home page
This commit is contained in:
@@ -1,31 +1,30 @@
|
|||||||
<template>
|
<template>
|
||||||
<!-- <v-row justify="space-between">-->
|
<!-- <v-row justify="space-between">-->
|
||||||
<!-- <v-col>-->
|
<!-- <v-col>-->
|
||||||
<!-- <h2><i class="fas fa-calendar-week fa-fw"></i> Meal Plans</h2>-->
|
<!-- <h2><i class="fas fa-calendar-week fa-fw"></i> Meal Plans</h2>-->
|
||||||
<!-- </v-col>-->
|
<!-- </v-col>-->
|
||||||
<!-- </v-row>-->
|
<!-- </v-row>-->
|
||||||
|
|
||||||
<v-row class="mt-0" v-if="mealPlanWindows.length > 0">
|
<v-row class="mt-0" v-if="mealPlanWindows.length > 0">
|
||||||
<v-col>
|
<v-col>
|
||||||
<v-window show-arrows>
|
<v-window v-model="currentWindowIndex">
|
||||||
<v-window-item v-for="w in mealPlanWindows" class="pt-1 pb-1">
|
<v-window-item v-for="(w, i) in mealPlanWindows" :value="i" class="pt-1 pb-1">
|
||||||
<v-row>
|
<v-row>
|
||||||
<v-col v-for="mealPlanGridItem in w">
|
<v-col v-for="mealPlanGridItem in w">
|
||||||
<v-list density="compact" class="pt-0 pb-0">
|
<v-list density="compact" class="pt-0 pb-0">
|
||||||
<v-list-item>
|
<v-list-item class="text-center">
|
||||||
|
<div class="d-flex ">
|
||||||
<div class="d-flex justify-space-between">
|
<div class="flex-col align-self-start">
|
||||||
<div class="align-self-center">
|
<v-btn @click="currentWindowIndex--" v-if="currentWindowIndex != 0" icon="fa-solid fa-chevron-left" size="small"></v-btn>
|
||||||
|
</div>
|
||||||
|
<div class="flex-col flex-grow-1 mt-auto mb-auto">
|
||||||
{{ mealPlanGridItem.date_label }}
|
{{ mealPlanGridItem.date_label }}
|
||||||
</div>
|
</div>
|
||||||
<div class="align-self-center">
|
<div class="flex-col align-self-end">
|
||||||
<v-btn variant="flat" icon="">
|
<v-btn @click="currentWindowIndex++" v-if="currentWindowIndex + 1 < mealPlanWindows.length" icon="fa-solid fa-chevron-right"
|
||||||
<i class="fas fa-plus"></i>
|
size="small"></v-btn>
|
||||||
<model-edit-dialog model="MealPlan" :item-defaults="{fromDate: mealPlanGridItem.date.toJSDate()}" :close-after-create="false" :close-after-save="false"></model-edit-dialog>
|
|
||||||
</v-btn>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
<v-divider v-if="mealPlanGridItem.plan_entries.length > 0"></v-divider>
|
<v-divider v-if="mealPlanGridItem.plan_entries.length > 0"></v-divider>
|
||||||
<v-list-item v-for="p in mealPlanGridItem.plan_entries" :key="p.id" @click="clickMealPlan(p)" link>
|
<v-list-item v-for="p in mealPlanGridItem.plan_entries" :key="p.id" @click="clickMealPlan(p)" link>
|
||||||
@@ -47,7 +46,7 @@
|
|||||||
<v-menu activator="parent">
|
<v-menu activator="parent">
|
||||||
<v-list>
|
<v-list>
|
||||||
<v-list-item prepend-icon="$edit" link>
|
<v-list-item prepend-icon="$edit" link>
|
||||||
{{$t('Edit')}}
|
{{ $t('Edit') }}
|
||||||
<model-edit-dialog model="MealPlan" :item="p"></model-edit-dialog>
|
<model-edit-dialog model="MealPlan" :item="p"></model-edit-dialog>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</v-list>
|
</v-list>
|
||||||
@@ -55,7 +54,11 @@
|
|||||||
</v-btn>
|
</v-btn>
|
||||||
</template>
|
</template>
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
|
<v-list-item class="text-center cursor-pointer" variant="tonal">
|
||||||
|
<model-edit-dialog model="MealPlan" :item-defaults="{fromDate: mealPlanGridItem.date.toJSDate()}" :close-after-create="false"
|
||||||
|
:close-after-save="false"></model-edit-dialog>
|
||||||
|
<v-icon icon="$create" size="small"></v-icon>
|
||||||
|
</v-list-item>
|
||||||
</v-list>
|
</v-list>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
</v-row>
|
||||||
@@ -79,7 +82,9 @@ import {useRouter} from "vue-router";
|
|||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const {name} = useDisplay()
|
const {name} = useDisplay()
|
||||||
|
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
|
const currentWindowIndex = ref(0)
|
||||||
|
|
||||||
let numberOfCols = computed(() => {
|
let numberOfCols = computed(() => {
|
||||||
return homePageCols(name.value)
|
return homePageCols(name.value)
|
||||||
@@ -100,7 +105,12 @@ const meal_plan_grid = computed(() => {
|
|||||||
grid.push({
|
grid.push({
|
||||||
date: grid_day_date,
|
date: grid_day_date,
|
||||||
create_default_date: grid_day_date.toISODate(), // improve meal plan edit modal to do formatting itself and accept dates
|
create_default_date: grid_day_date.toISODate(), // improve meal plan edit modal to do formatting itself and accept dates
|
||||||
date_label: grid_day_date.toLocaleString(DateTime.DATE_MED),
|
date_label: grid_day_date.toLocaleString({
|
||||||
|
weekday: 'short',
|
||||||
|
month: '2-digit',
|
||||||
|
day: '2-digit',
|
||||||
|
year: '2-digit',
|
||||||
|
}),
|
||||||
plan_entries: useMealPlanStore().planList.filter((m: MealPlan) => ((DateTime.fromJSDate(m.fromDate).startOf('day') <= grid_day_date.startOf('day')) && (DateTime.fromJSDate((m.toDate != undefined) ? m.toDate : m.fromDate).startOf('day') >= grid_day_date.startOf('day')))),
|
plan_entries: useMealPlanStore().planList.filter((m: MealPlan) => ((DateTime.fromJSDate(m.fromDate).startOf('day') <= grid_day_date.startOf('day')) && (DateTime.fromJSDate((m.toDate != undefined) ? m.toDate : m.fromDate).startOf('day') >= grid_day_date.startOf('day')))),
|
||||||
} as MealPlanGridItem)
|
} as MealPlanGridItem)
|
||||||
}
|
}
|
||||||
@@ -134,9 +144,9 @@ onMounted(() => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
function clickMealPlan(plan: MealPlan){
|
function clickMealPlan(plan: MealPlan) {
|
||||||
if(plan.recipe){
|
if (plan.recipe) {
|
||||||
router.push( {name: 'RecipeViewPage', params: {id: plan.recipe.id}})
|
router.push({name: 'RecipeViewPage', params: {id: plan.recipe.id}})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user