mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -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`,
|
||||
create: `${prefix}create`,
|
||||
thisWeek: `${prefix}this-week`,
|
||||
byId: planID => `${prefix}${planID}`,
|
||||
update: planID => `${prefix}${planID}`,
|
||||
delete: planID => `${prefix}${planID}`,
|
||||
today: `${prefix}today`,
|
||||
|
@ -40,6 +41,11 @@ export const mealplanAPI = {
|
|||
return response;
|
||||
},
|
||||
|
||||
async getById(id) {
|
||||
let response = await apiReq.get(mealPlanURLs.byId(id));
|
||||
return response.data;
|
||||
},
|
||||
|
||||
delete(id) {
|
||||
return apiReq.delete(
|
||||
mealPlanURLs.delete(id),
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<v-icon left dark>
|
||||
mdi-clipboard-check
|
||||
</v-icon>
|
||||
{{ $t("general.coppied") }}!
|
||||
<slot> {{ $t("general.coppied") }}! </slot>
|
||||
</span>
|
||||
</v-tooltip>
|
||||
</template>
|
||||
|
|
|
@ -37,6 +37,8 @@
|
|||
</v-icon>
|
||||
Shopping List
|
||||
</v-btn>
|
||||
<v-spacer></v-spacer>
|
||||
<TheCopyButton color="info" :copy-text="mealPlanURL(mealplan.uid)"> Link Coppied </TheCopyButton>
|
||||
</v-card-actions>
|
||||
|
||||
<v-list class="mt-0 pt-0">
|
||||
|
@ -84,11 +86,12 @@ import { api } from "@/api";
|
|||
import { utils } from "@/utils";
|
||||
import NewMeal from "@/components/MealPlan/MealPlanNew";
|
||||
import EditPlan from "@/components/MealPlan/MealPlanEditor";
|
||||
|
||||
import TheCopyButton from "@/components/UI/Buttons/TheCopyButton";
|
||||
export default {
|
||||
components: {
|
||||
NewMeal,
|
||||
EditPlan,
|
||||
TheCopyButton,
|
||||
},
|
||||
data: () => ({
|
||||
plannedMeals: [],
|
||||
|
@ -103,6 +106,9 @@ export default {
|
|||
this.plannedMeals = response.data;
|
||||
console.log(this.plannedMeals);
|
||||
},
|
||||
mealPlanURL(uid) {
|
||||
return window.location.origin + "/meal-plan?id=" + uid;
|
||||
},
|
||||
generateKey(name, index) {
|
||||
return utils.generateUniqueKey(name, index);
|
||||
},
|
||||
|
|
|
@ -46,11 +46,20 @@ export default {
|
|||
};
|
||||
},
|
||||
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) {
|
||||
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: {
|
||||
getOrder(index) {
|
||||
|
|
|
@ -5,6 +5,13 @@ import { utils } from "@/utils";
|
|||
import i18n from "@/i18n.js";
|
||||
|
||||
export const mealRoutes = [
|
||||
{
|
||||
path: "/meal-plan",
|
||||
component: ThisWeek,
|
||||
meta: {
|
||||
title: "meal-plan.dinner-this-week",
|
||||
},
|
||||
},
|
||||
{
|
||||
path: "/meal-plan/planner",
|
||||
component: Planner,
|
||||
|
|
|
@ -23,6 +23,16 @@ def get_all_meals(
|
|||
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)
|
||||
def create_meal_plan(
|
||||
background_tasks: BackgroundTasks,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue