mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 06:23:34 -07:00
add quick week option
This commit is contained in:
parent
2206034b7e
commit
72f6706dc0
1 changed files with 35 additions and 7 deletions
|
@ -2,7 +2,11 @@
|
||||||
<v-card>
|
<v-card>
|
||||||
<v-card-title class=" headline">
|
<v-card-title class=" headline">
|
||||||
{{ $t("meal-plan.create-a-new-meal-plan") }}
|
{{ $t("meal-plan.create-a-new-meal-plan") }}
|
||||||
|
<v-btn color="info" class="ml-auto" @click="setQuickWeek()">
|
||||||
|
<v-icon left>mdi-calendar-minus</v-icon> Quick Week
|
||||||
|
</v-btn>
|
||||||
</v-card-title>
|
</v-card-title>
|
||||||
|
|
||||||
<v-divider></v-divider>
|
<v-divider></v-divider>
|
||||||
<v-card-text>
|
<v-card-text>
|
||||||
<v-row dense>
|
<v-row dense>
|
||||||
|
@ -116,12 +120,10 @@ export default {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
groupSettings() {
|
|
||||||
this.buildMealStore();
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.$store.dispatch("requestCurrentGroup");
|
await this.$store.dispatch("requestCurrentGroup");
|
||||||
|
await this.buildMealStore();
|
||||||
},
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
|
@ -160,7 +162,7 @@ export default {
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
async buildMealStore() {
|
async buildMealStore() {
|
||||||
let categories = Array.from(this.groupSettings.categories, x => x.name);
|
const categories = Array.from(this.groupSettings.categories, x => x.name);
|
||||||
this.items = await api.recipes.getAllByCategory(categories);
|
this.items = await api.recipes.getAllByCategory(categories);
|
||||||
|
|
||||||
if (this.items.length === 0) {
|
if (this.items.length === 0) {
|
||||||
|
@ -189,7 +191,6 @@ export default {
|
||||||
this.meals[index]["slug"] = recipe.slug;
|
this.meals[index]["slug"] = recipe.slug;
|
||||||
this.meals[index]["name"] = recipe.name;
|
this.meals[index]["name"] = recipe.name;
|
||||||
this.usedRecipes.push(recipe);
|
this.usedRecipes.push(recipe);
|
||||||
console.log(this.usedRecipes, recipe);
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
processTime(index) {
|
processTime(index) {
|
||||||
|
@ -237,6 +238,33 @@ export default {
|
||||||
const [month, day, year] = date.split("/");
|
const [month, day, year] = date.split("/");
|
||||||
return `${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`;
|
return `${year}-${month.padStart(2, "0")}-${day.padStart(2, "0")}`;
|
||||||
},
|
},
|
||||||
|
getNextDayOfTheWeek(dayName, excludeToday = true, refDate = new Date()) {
|
||||||
|
const dayOfWeek = [
|
||||||
|
"sun",
|
||||||
|
"mon",
|
||||||
|
"tue",
|
||||||
|
"wed",
|
||||||
|
"thu",
|
||||||
|
"fri",
|
||||||
|
"sat",
|
||||||
|
].indexOf(dayName.slice(0, 3).toLowerCase());
|
||||||
|
if (dayOfWeek < 0) return;
|
||||||
|
refDate.setHours(0, 0, 0, 0);
|
||||||
|
refDate.setDate(
|
||||||
|
refDate.getDate() +
|
||||||
|
+!!excludeToday +
|
||||||
|
((dayOfWeek + 7 - refDate.getDay() - +!!excludeToday) % 7)
|
||||||
|
);
|
||||||
|
return refDate;
|
||||||
|
},
|
||||||
|
setQuickWeek() {
|
||||||
|
const nextMonday = this.getNextDayOfTheWeek("Monday", false);
|
||||||
|
const nextEndDate = new Date(nextMonday);
|
||||||
|
nextEndDate.setDate(nextEndDate.getDate() + 4);
|
||||||
|
|
||||||
|
this.startDate = nextMonday.toISOString().substr(0, 10);
|
||||||
|
this.endDate = nextEndDate.toISOString().substr(0, 10);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue