mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 22:43:34 -07:00
public mealplan links
This commit is contained in:
parent
5456189a70
commit
73451e1051
6 changed files with 42 additions and 4 deletions
|
@ -9,6 +9,7 @@ const mealPlanURLs = {
|
||||||
all: `${prefix}all`,
|
all: `${prefix}all`,
|
||||||
create: `${prefix}create`,
|
create: `${prefix}create`,
|
||||||
thisWeek: `${prefix}this-week`,
|
thisWeek: `${prefix}this-week`,
|
||||||
|
byId: planID => `${prefix}${planID}`,
|
||||||
update: planID => `${prefix}${planID}`,
|
update: planID => `${prefix}${planID}`,
|
||||||
delete: planID => `${prefix}${planID}`,
|
delete: planID => `${prefix}${planID}`,
|
||||||
today: `${prefix}today`,
|
today: `${prefix}today`,
|
||||||
|
@ -40,6 +41,11 @@ export const mealplanAPI = {
|
||||||
return response;
|
return response;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
async getById(id) {
|
||||||
|
let response = await apiReq.get(mealPlanURLs.byId(id));
|
||||||
|
return response.data;
|
||||||
|
},
|
||||||
|
|
||||||
delete(id) {
|
delete(id) {
|
||||||
return apiReq.delete(
|
return apiReq.delete(
|
||||||
mealPlanURLs.delete(id),
|
mealPlanURLs.delete(id),
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<v-icon left dark>
|
<v-icon left dark>
|
||||||
mdi-clipboard-check
|
mdi-clipboard-check
|
||||||
</v-icon>
|
</v-icon>
|
||||||
{{ $t("general.coppied") }}!
|
<slot> {{ $t("general.coppied") }}! </slot>
|
||||||
</span>
|
</span>
|
||||||
</v-tooltip>
|
</v-tooltip>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -37,6 +37,8 @@
|
||||||
</v-icon>
|
</v-icon>
|
||||||
Shopping List
|
Shopping List
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
<v-spacer></v-spacer>
|
||||||
|
<TheCopyButton color="info" :copy-text="mealPlanURL(mealplan.uid)"> Link Coppied </TheCopyButton>
|
||||||
</v-card-actions>
|
</v-card-actions>
|
||||||
|
|
||||||
<v-list class="mt-0 pt-0">
|
<v-list class="mt-0 pt-0">
|
||||||
|
@ -84,11 +86,12 @@ import { api } from "@/api";
|
||||||
import { utils } from "@/utils";
|
import { utils } from "@/utils";
|
||||||
import NewMeal from "@/components/MealPlan/MealPlanNew";
|
import NewMeal from "@/components/MealPlan/MealPlanNew";
|
||||||
import EditPlan from "@/components/MealPlan/MealPlanEditor";
|
import EditPlan from "@/components/MealPlan/MealPlanEditor";
|
||||||
|
import TheCopyButton from "@/components/UI/Buttons/TheCopyButton";
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
NewMeal,
|
NewMeal,
|
||||||
EditPlan,
|
EditPlan,
|
||||||
|
TheCopyButton,
|
||||||
},
|
},
|
||||||
data: () => ({
|
data: () => ({
|
||||||
plannedMeals: [],
|
plannedMeals: [],
|
||||||
|
@ -103,6 +106,9 @@ export default {
|
||||||
this.plannedMeals = response.data;
|
this.plannedMeals = response.data;
|
||||||
console.log(this.plannedMeals);
|
console.log(this.plannedMeals);
|
||||||
},
|
},
|
||||||
|
mealPlanURL(uid) {
|
||||||
|
return window.location.origin + "/meal-plan?id=" + uid;
|
||||||
|
},
|
||||||
generateKey(name, index) {
|
generateKey(name, index) {
|
||||||
return utils.generateUniqueKey(name, index);
|
return utils.generateUniqueKey(name, index);
|
||||||
},
|
},
|
||||||
|
|
|
@ -46,11 +46,20 @@ export default {
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
async mounted() {
|
async mounted() {
|
||||||
this.mealPlan = await api.mealPlans.thisWeek();
|
if (this.mealplanId) {
|
||||||
|
this.mealPlan = await api.mealPlans.getById(this.mealplanId);
|
||||||
|
} else {
|
||||||
|
this.mealPlan = await api.mealPlans.thisWeek();
|
||||||
|
}
|
||||||
|
console.log(this.mealPlans);
|
||||||
if (!this.mealPlan) {
|
if (!this.mealPlan) {
|
||||||
utils.notify.warning(this.$t("meal-plan.no-meal-plan-defined-yet"));
|
utils.notify.warning(this.$t("meal-plan.no-meal-plan-defined-yet"));
|
||||||
}
|
}
|
||||||
console.log(this.mealPlan);
|
},
|
||||||
|
computed: {
|
||||||
|
mealplanId() {
|
||||||
|
return this.$route.query.id || false;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getOrder(index) {
|
getOrder(index) {
|
||||||
|
|
|
@ -5,6 +5,13 @@ import { utils } from "@/utils";
|
||||||
import i18n from "@/i18n.js";
|
import i18n from "@/i18n.js";
|
||||||
|
|
||||||
export const mealRoutes = [
|
export const mealRoutes = [
|
||||||
|
{
|
||||||
|
path: "/meal-plan",
|
||||||
|
component: ThisWeek,
|
||||||
|
meta: {
|
||||||
|
title: "meal-plan.dinner-this-week",
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
path: "/meal-plan/planner",
|
path: "/meal-plan/planner",
|
||||||
component: Planner,
|
component: Planner,
|
||||||
|
|
|
@ -23,6 +23,16 @@ def get_all_meals(
|
||||||
return db.groups.get_meals(session, current_user.group)
|
return db.groups.get_meals(session, current_user.group)
|
||||||
|
|
||||||
|
|
||||||
|
@router.get("/{id}", response_model=MealPlanOut)
|
||||||
|
def get_meal_plan(
|
||||||
|
id,
|
||||||
|
session: Session = Depends(generate_session),
|
||||||
|
):
|
||||||
|
""" Returns a single Meal Plan from the Database """
|
||||||
|
|
||||||
|
return db.meals.get(session, id, "uid")
|
||||||
|
|
||||||
|
|
||||||
@router.post("/create", status_code=status.HTTP_201_CREATED)
|
@router.post("/create", status_code=status.HTTP_201_CREATED)
|
||||||
def create_meal_plan(
|
def create_meal_plan(
|
||||||
background_tasks: BackgroundTasks,
|
background_tasks: BackgroundTasks,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue