update Meal Plan grid to respect localization on date format

This commit is contained in:
smilerz 2023-09-06 14:01:27 -05:00
parent c72bf57ccb
commit c8fc6b5237
No known key found for this signature in database
GPG Key ID: 39444C7606D47126

View File

@ -723,9 +723,9 @@
<div class="row"> <div class="row">
<div class="col col-md-12"> <div class="col col-md-12">
<div <div
style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); column-gap: 0.5rem; row-gap: 0.5rem; grid-auto-rows: max-content"
style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); column-gap: 0.5rem;row-gap: 0.5rem; grid-auto-rows: max-content; "> >
<div v-for="day in meal_plan_grid" v-bind:key="day.day" :class="{'d-none d-sm-block': day.plan_entries.length === 0}"> <div v-for="day in meal_plan_grid" v-bind:key="day.day" :class="{ 'd-none d-sm-block': day.plan_entries.length === 0 }">
<b-list-group> <b-list-group>
<b-list-group-item class="hover-div pb-0"> <b-list-group-item class="hover-div pb-0">
<div class="d-flex flex-row align-items-center"> <div class="d-flex flex-row align-items-center">
@ -742,10 +742,8 @@
<b-list-group-item v-for="plan in day.plan_entries" v-bind:key="plan.id" class="hover-div p-0 pr-2"> <b-list-group-item v-for="plan in day.plan_entries" v-bind:key="plan.id" class="hover-div p-0 pr-2">
<div class="d-flex flex-row align-items-center"> <div class="d-flex flex-row align-items-center">
<div> <div>
<img style="height: 50px; width: 50px; object-fit: cover" :src="plan.recipe.image" v-if="plan.recipe?.image" />
<img style="height: 50px; width: 50px; object-fit: cover" :src="plan.recipe.image" v-if="plan.recipe?.image"/> <img style="height: 50px; width: 50px; object-fit: cover" :src="image_placeholder" v-else />
<img style="height: 50px; width: 50px; object-fit: cover" :src="image_placeholder" v-else/>
</div> </div>
<div class="flex-grow-1 ml-2" style="text-overflow: ellipsis; overflow-wrap: anywhere"> <div class="flex-grow-1 ml-2" style="text-overflow: ellipsis; overflow-wrap: anywhere">
<span class="two-row-text"> <span class="two-row-text">
@ -977,14 +975,16 @@ export default {
computed: { computed: {
meal_plan_grid: function () { meal_plan_grid: function () {
let grid = [] let grid = []
if (this.meal_plan_store !== null && this.meal_plan_store.plan_list.length > 0) { if (this.meal_plan_store !== null && this.meal_plan_store.plan_list.length > 0) {
for (const x of Array(this.ui.meal_plan_days).keys()) { for (const x of Array(this.ui.meal_plan_days).keys()) {
let moment_date = moment().add(x, "d") let moment_date = moment().add(x, "d")
let date_label = moment_date.format("L").split("/")
grid.push({ grid.push({
date: moment_date, date: moment_date,
create_default_date: moment_date.format("YYYY-MM-DD"), // improve meal plan edit modal to do formatting itself and accept dates create_default_date: moment_date.format("YYYY-MM-DD"), // improve meal plan edit modal to do formatting itself and accept dates
date_label: moment_date.format('ddd DD.MM'), date_label: moment_date.format("ddd") + " " + date_label[0] + "." + date_label[1],
plan_entries: this.meal_plan_store.plan_list.filter((m) => moment_date.isBetween(moment(m.from_date), moment(m.to_date), 'day', '[]')) plan_entries: this.meal_plan_store.plan_list.filter((m) => moment(m.date).isSame(moment_date, "day")),
}) })
} }
} }