fix: planner date picker local and starting day (#1864)
* fix type definitions * use day of week setting + fix multiple type errors * add locale for yyyy-mm-dd format
This commit is contained in:
parent
3ad3d92e5f
commit
32c4ce4536
3 changed files with 29 additions and 9 deletions
|
@ -4,7 +4,12 @@ import { useAsyncKey } from "./use-utils";
|
||||||
import { useUserApi } from "~/composables/api";
|
import { useUserApi } from "~/composables/api";
|
||||||
import { CreatePlanEntry, PlanEntryType, UpdatePlanEntry } from "~/lib/api/types/meal-plan";
|
import { CreatePlanEntry, PlanEntryType, UpdatePlanEntry } from "~/lib/api/types/meal-plan";
|
||||||
|
|
||||||
export const planTypeOptions = [
|
type PlanOption = {
|
||||||
|
text: string;
|
||||||
|
value: PlanEntryType;
|
||||||
|
};
|
||||||
|
|
||||||
|
export const planTypeOptions: PlanOption[] = [
|
||||||
{ text: "Breakfast", value: "breakfast" },
|
{ text: "Breakfast", value: "breakfast" },
|
||||||
{ text: "Lunch", value: "lunch" },
|
{ text: "Lunch", value: "lunch" },
|
||||||
{ text: "Dinner", value: "dinner" },
|
{ text: "Dinner", value: "dinner" },
|
||||||
|
|
|
@ -331,6 +331,7 @@
|
||||||
"add-recipe-to-mealplan": "Add Recipe to Mealplan",
|
"add-recipe-to-mealplan": "Add Recipe to Mealplan",
|
||||||
"entry-type": "Entry Type",
|
"entry-type": "Entry Type",
|
||||||
"date-format-hint": "MM/DD/YYYY format",
|
"date-format-hint": "MM/DD/YYYY format",
|
||||||
|
"date-format-hint-yyyy-mm-dd": "YYYY-MM-DD format",
|
||||||
"add-to-list": "Add to List",
|
"add-to-list": "Add to List",
|
||||||
"add-to-plan": "Add to Plan",
|
"add-to-plan": "Add to Plan",
|
||||||
"recipe-added-to-list": "Recipe added to list",
|
"recipe-added-to-list": "Recipe added to list",
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<!-- Create Meal Dialog -->
|
<!-- Create Meal Dialog -->
|
||||||
<BaseDialog
|
<BaseDialog
|
||||||
v-model="createMealDialog"
|
v-model="createMealDialog"
|
||||||
:title="$t('meal-plan.create-a-new-meal-plan')"
|
:title="$tc('meal-plan.create-a-new-meal-plan')"
|
||||||
color="primary"
|
color="primary"
|
||||||
:icon="$globals.icons.foods"
|
:icon="$globals.icons.foods"
|
||||||
@submit="
|
@submit="
|
||||||
|
@ -23,8 +23,8 @@
|
||||||
<template #activator="{ on, attrs }">
|
<template #activator="{ on, attrs }">
|
||||||
<v-text-field
|
<v-text-field
|
||||||
v-model="newMeal.date"
|
v-model="newMeal.date"
|
||||||
label="Date"
|
:label="$t('general.date')"
|
||||||
hint="MM/DD/YYYY format"
|
:hint="$t('recipe.date-format-hint-yyyy-mm-dd')"
|
||||||
persistent-hint
|
persistent-hint
|
||||||
:prepend-icon="$globals.icons.calendar"
|
:prepend-icon="$globals.icons.calendar"
|
||||||
v-bind="attrs"
|
v-bind="attrs"
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
v-on="on"
|
v-on="on"
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
</template>
|
</template>
|
||||||
<v-date-picker v-model="newMeal.date" no-title @input="pickerMenu = false"></v-date-picker>
|
<v-date-picker v-model="newMeal.date" :first-day-of-week="firstDayOfWeek" no-title @input="pickerMenu = false"></v-date-picker>
|
||||||
</v-menu>
|
</v-menu>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-select v-model="newMeal.entryType" :return-object="false" :items="planTypeOptions" label="Entry Type">
|
<v-select v-model="newMeal.entryType" :return-object="false" :items="planTypeOptions" label="Entry Type">
|
||||||
|
@ -178,13 +178,13 @@
|
||||||
event: 'random',
|
event: 'random',
|
||||||
children: [
|
children: [
|
||||||
{
|
{
|
||||||
icon: $globals.icons.dice,
|
icon: $globals.icons.diceMultiple,
|
||||||
text: 'Breakfast',
|
text: 'Breakfast',
|
||||||
event: 'randomBreakfast',
|
event: 'randomBreakfast',
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
icon: $globals.icons.dice,
|
icon: $globals.icons.diceMultiple,
|
||||||
text: 'Lunch',
|
text: 'Lunch',
|
||||||
event: 'randomLunch',
|
event: 'randomLunch',
|
||||||
},
|
},
|
||||||
|
@ -202,7 +202,7 @@
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
icon: $globals.icons.createAlt,
|
icon: $globals.icons.createAlt,
|
||||||
text: $t('general.new'),
|
text: $tc('general.new'),
|
||||||
event: 'create',
|
event: 'create',
|
||||||
},
|
},
|
||||||
]"
|
]"
|
||||||
|
@ -273,6 +273,7 @@ import RecipeCard from "~/components/Domain/Recipe/RecipeCard.vue";
|
||||||
import RecipeContextMenu from "~/components/Domain/Recipe/RecipeContextMenu.vue";
|
import RecipeContextMenu from "~/components/Domain/Recipe/RecipeContextMenu.vue";
|
||||||
import { PlanEntryType } from "~/lib/api/types/meal-plan";
|
import { PlanEntryType } from "~/lib/api/types/meal-plan";
|
||||||
import { useUserApi } from "~/composables/api";
|
import { useUserApi } from "~/composables/api";
|
||||||
|
import { useGroupSelf } from "~/composables/use-groups";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
|
@ -285,7 +286,7 @@ export default defineComponent({
|
||||||
const state = reactive({
|
const state = reactive({
|
||||||
createMealDialog: false,
|
createMealDialog: false,
|
||||||
edit: false,
|
edit: false,
|
||||||
hover: {},
|
hover: {} as Record<string, boolean>,
|
||||||
pickerMenu: null,
|
pickerMenu: null,
|
||||||
today: new Date(),
|
today: new Date(),
|
||||||
});
|
});
|
||||||
|
@ -303,6 +304,18 @@ export default defineComponent({
|
||||||
|
|
||||||
useRecipes(true, true);
|
useRecipes(true, true);
|
||||||
|
|
||||||
|
const { group } = useGroupSelf();
|
||||||
|
|
||||||
|
const firstDayOfWeek = computed(() => {
|
||||||
|
const pref = group.value?.preferences?.firstDayOfWeek;
|
||||||
|
|
||||||
|
if (pref) {
|
||||||
|
return pref;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0
|
||||||
|
});
|
||||||
|
|
||||||
function filterMealByDate(date: Date) {
|
function filterMealByDate(date: Date) {
|
||||||
if (!mealplans.value) return [];
|
if (!mealplans.value) return [];
|
||||||
return mealplans.value.filter((meal) => {
|
return mealplans.value.filter((meal) => {
|
||||||
|
@ -425,6 +438,7 @@ export default defineComponent({
|
||||||
randomMeal,
|
randomMeal,
|
||||||
resetDialog,
|
resetDialog,
|
||||||
weekRange,
|
weekRange,
|
||||||
|
firstDayOfWeek,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
head() {
|
head() {
|
||||||
|
|
Loading…
Reference in a new issue