meal plan stuff

This commit is contained in:
vabene1111
2023-08-30 10:30:12 +02:00
parent 4a1ec5adf7
commit dcfb269909
9 changed files with 304 additions and 225 deletions

View File

@@ -2,7 +2,31 @@
<div> <div>
<b-tabs content-class="mt-3" v-model="current_tab"> <b-tabs content-class="mt-3" v-model="current_tab">
<b-tab :title="$t('Planner')" active> <b-tab :title="$t('Planner')" active>
<div class="row calender-row d-none d-lg-block"> <div class=" d-none d-lg-block">
<div class="row">
<div class="col col-2">
<h4>{{ $t('Meal_Types') }}</h4>
<b-form-checkbox :button-variant="danger" v-model="mt.checked" size="lg" v-for="mt in meal_types" v-bind:key="mt.id">
<b-badge variant="primary" :style="{'background-color':mt.color}">{{ mt.name }}</b-badge>
</b-form-checkbox>
<hr/>
<button class="btn btn-success shadow-none mt-1 btn-block" @click="createEntryClick(new Date())"><i
class="fas fa-calendar-plus"></i> {{ $t("Create") }}
</button>
<button class="btn btn-primary shadow-none mt-1 btn-block" @click="createAutoPlan(new Date())"><i
class="fas fa-calendar-plus"></i> {{ $t("Auto_Planner") }}
</button>
<a class="btn btn-primary shadow-none mt-1 btn-blockmt-1 btn-block" :href="iCalUrl"><i class="fas fa-download"></i>
{{ $t("Export_To_ICal") }}
</a>
</div>
<div class="col col-10">
<div class="row calender-row ">
<div class="col-12 calender-parent"> <div class="col-12 calender-parent">
<calendar-view <calendar-view
:show-date="showDate" :show-date="showDate"
@@ -48,6 +72,10 @@
</calendar-view> </calendar-view>
</div> </div>
</div> </div>
</div>
</div>
<div class="row">
<div class="col">
<div class="row d-block d-lg-none"> <div class="row d-block d-lg-none">
<div> <div>
<div class="col-12"> <div class="col-12">
@@ -120,6 +148,9 @@
</div> </div>
</div> </div>
</div>
</div>
</div>
</b-tab> </b-tab>
<b-tab :title="$t('Settings')"> <b-tab :title="$t('Settings')">
@@ -253,20 +284,6 @@
:current_period="current_period" :current_period="current_period"
></auto-meal-plan-modal> ></auto-meal-plan-modal>
<div class="row d-none d-lg-block">
<div class="col-12 float-right">
<button class="btn btn-success shadow-none" @click="createEntryClick(new Date())"><i
class="fas fa-calendar-plus"></i> {{ $t("Create") }}
</button>
<button class="btn btn-primary shadow-none" @click="createAutoPlan(new Date())"><i
class="fas fa-calendar-plus"></i> {{ $t("Auto_Planner") }}
</button>
<a class="btn btn-primary shadow-none" :href="iCalUrl"><i class="fas fa-download"></i>
{{ $t("Export_To_ICal") }}
</a>
</div>
</div>
<bottom-navigation-bar :create_links="[{label:$t('Export_To_ICal'), url: iCalUrl, icon:'fas fa-download'}]"> <bottom-navigation-bar :create_links="[{label:$t('Export_To_ICal'), url: iCalUrl, icon:'fas fa-download'}]">
<template #custom_create_functions> <template #custom_create_functions>
<h6 class="dropdown-header">{{ $t('Meal_Plan') }}</h6> <h6 class="dropdown-header">{{ $t('Meal_Plan') }}</h6>

View File

@@ -41,11 +41,8 @@
<div class="card-body p-1" v-if="detailed && entry.entry.recipe == null" :style="`background-color: ${background_color}`"> <div class="card-body p-1" v-if="detailed && entry.entry.recipe == null" :style="`background-color: ${background_color}`">
<p>{{ entry.entry.note }}</p> <p>{{ entry.entry.note }}</p>
</div> </div>
<div class="row p-1 flex-nowrap" v-if="!detailed" :style="`background-color: ${background_color}`"> <div class="row p-1 flex-nowrap" v-if="!detailed" :style="`background-color: ${background_color}`">
<div class="col-2">
<span class="font-light text-center" v-if="entry.entry.meal_type.icon != null" v-b-tooltip.hover.left :title="entry.entry.meal_type.name">{{ entry.entry.meal_type.icon }}</span>
<span class="font-light text-center" v-if="entry.entry.meal_type.icon == null" v-b-tooltip.hover.left :title="entry.entry.meal_type.name"></span>
</div>
<div class="col-10 d-inline-block text-truncate" :style="`max-height:${item_height}`"> <div class="col-10 d-inline-block text-truncate" :style="`max-height:${item_height}`">
<span class="font-light">{{ title }}</span> <span class="font-light">{{ title }}</span>
</div> </div>
@@ -71,7 +68,8 @@ export default {
image_placeholder: window.IMAGE_PLACEHOLDER, image_placeholder: window.IMAGE_PLACEHOLDER,
} }
}, },
mounted() {}, mounted() {
},
computed: { computed: {
entry: function () { entry: function () {
return this.value.originalItem return this.value.originalItem

View File

@@ -135,10 +135,9 @@ import Vue from "vue"
import VueCookies from "vue-cookies" import VueCookies from "vue-cookies"
import {BootstrapVue} from "bootstrap-vue" import {BootstrapVue} from "bootstrap-vue"
import GenericMultiselect from "@/components/GenericMultiselect" import GenericMultiselect from "@/components/GenericMultiselect"
import {ApiMixin, getUserPreference} from "@/utils/utils" import {ApiMixin, getUserPreference, ToastMixin} from "@/utils/utils"
const {ApiApiFactory} = require("@/utils/openapi/api") const {ApiApiFactory} = require("@/utils/openapi/api")
const {StandardToasts} = require("@/utils/utils")
import {useUserPreferenceStore} from "@/stores/UserPreferenceStore"; import {useUserPreferenceStore} from "@/stores/UserPreferenceStore";
import {useMealPlanStore} from "@/stores/MealPlanStore"; import {useMealPlanStore} from "@/stores/MealPlanStore";
@@ -163,7 +162,7 @@ export default {
default: true, default: true,
}, },
}, },
mixins: [ApiMixin], mixins: [ApiMixin, ToastMixin],
components: { components: {
GenericMultiselect, GenericMultiselect,
RecipeCard: () => import("@/components/RecipeCard.vue"), RecipeCard: () => import("@/components/RecipeCard.vue"),
@@ -234,9 +233,11 @@ export default {
editEntry() { editEntry() {
if (this.entryEditing.meal_type == null) { if (this.entryEditing.meal_type == null) {
this.makeToast('Warning', this.$t('Meal_Type_Required'), 'warning')
return; return;
} }
if (this.entryEditing.recipe == null && this.entryEditing.title === "") { if (this.entryEditing.recipe == null && this.entryEditing.title === "") {
this.makeToast('Warning', this.$t('Title_or_Recipe_Required'), 'warning')
return return
} }
//TODO properly validate //TODO properly validate

View File

@@ -0,0 +1,46 @@
<template>
<div>
<b-form-group v-bind:label="field_label" class="mb-3">
<b-form-input v-model="new_value" type="color" ></b-form-input>
<em v-if="help" class="small text-muted">{{ help }}</em>
<small v-if="subtitle" class="text-muted">{{ subtitle }}</small>
</b-form-group>
</div>
</template>
<script>
export default {
name: "ColorInput",
props: {
field: { type: String, default: "You Forgot To Set Field Name" },
label: { type: String, default: "Text Field" },
value: { type: String, default: "" },
help: { type: String, default: undefined },
subtitle: { type: String, default: undefined },
optional: {type: Boolean, default: false},
},
computed: {
field_label: function () {
if (this.optional) {
return this.label
} else {
return this.label + '*'
}
}
},
data() {
return {
new_value: undefined,
}
},
mounted() {
this.new_value = this.value
},
watch: {
new_value: function () {
this.$root.$emit("change", this.field, this.new_value)
},
},
methods: {},
}
</script>

View File

@@ -19,6 +19,7 @@
<file-input v-if="visibleCondition(f, 'file')" :label="f.label" :value="f.value" :field="f.field" @change="storeValue" :optional="f.optional"/> <file-input v-if="visibleCondition(f, 'file')" :label="f.label" :value="f.value" :field="f.field" @change="storeValue" :optional="f.optional"/>
<small-text v-if="visibleCondition(f, 'smalltext')" :value="f.value" /> <small-text v-if="visibleCondition(f, 'smalltext')" :value="f.value" />
<date-input v-if="visibleCondition(f, 'date')" :label="f.label" :value="f.value" :field="f.field" :help="showHelp && f.help" :subtitle="f.subtitle" :optional="f.optional"/> <date-input v-if="visibleCondition(f, 'date')" :label="f.label" :value="f.value" :field="f.field" :help="showHelp && f.help" :subtitle="f.subtitle" :optional="f.optional"/>
<color-input v-if="visibleCondition(f, 'color')" :label="f.label" :value="f.value" :field="f.field" :help="showHelp && f.help" :subtitle="f.subtitle" :optional="f.optional"/>
<number-input v-if="visibleCondition(f, 'number')" :label="f.label" :value="f.value" :field="f.field" :placeholder="f.placeholder" :help="showHelp && f.help" :subtitle="f.subtitle" :optional="f.optional"/> <number-input v-if="visibleCondition(f, 'number')" :label="f.label" :value="f.value" :field="f.field" :placeholder="f.placeholder" :help="showHelp && f.help" :subtitle="f.subtitle" :optional="f.optional"/>
</div> </div>
<template v-slot:modal-footer> <template v-slot:modal-footer>

View File

@@ -830,7 +830,7 @@ export class Models {
params: ["filter_list"], params: ["filter_list"],
}, },
create: { create: {
params: [["name"]], params: [["name", "color", "default"]],
form: { form: {
name: { name: {
form_field: true, form_field: true,
@@ -839,6 +839,20 @@ export class Models {
label: "Name", label: "Name",
placeholder: "", placeholder: "",
}, },
color: {
form_field: true,
type: "color",
field: "color",
label: "Color",
placeholder: "",
},
default: {
form_field: true,
type: "checkbox",
field: "default",
label: "Default",
placeholder: "",
},
}, },
}, },
} }

View File

@@ -4,7 +4,7 @@
* Django Recipes * Django Recipes
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
* *
* The version of the OpenAPI document: 0.0.0 * The version of the OpenAPI document: 1.0.0
* *
* *
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
@@ -166,7 +166,9 @@ export enum AutomationTypeEnum {
UnitAlias = 'UNIT_ALIAS', UnitAlias = 'UNIT_ALIAS',
KeywordAlias = 'KEYWORD_ALIAS', KeywordAlias = 'KEYWORD_ALIAS',
DescriptionReplace = 'DESCRIPTION_REPLACE', DescriptionReplace = 'DESCRIPTION_REPLACE',
InstructionReplace = 'INSTRUCTION_REPLACE' InstructionReplace = 'INSTRUCTION_REPLACE',
NeverUnit = 'NEVER_UNIT',
TransposeWords = 'TRANSPOSE_WORDS'
} }
/** /**
@@ -463,6 +465,12 @@ export interface Food {
* @memberof Food * @memberof Food
*/ */
recipe?: FoodRecipe | null; recipe?: FoodRecipe | null;
/**
*
* @type {string}
* @memberof Food
*/
url?: string | null;
/** /**
* *
* @type {Array<FoodProperties>} * @type {Array<FoodProperties>}
@@ -665,6 +673,12 @@ export interface FoodPropertiesFoodUnit {
* @memberof FoodPropertiesFoodUnit * @memberof FoodPropertiesFoodUnit
*/ */
description?: string | null; description?: string | null;
/**
*
* @type {string}
* @memberof FoodPropertiesFoodUnit
*/
base_unit?: string | null;
/** /**
* *
* @type {string} * @type {string}
@@ -690,12 +704,6 @@ export interface FoodPropertyType {
* @memberof FoodPropertyType * @memberof FoodPropertyType
*/ */
name: string; name: string;
/**
*
* @type {string}
* @memberof FoodPropertyType
*/
icon?: string | null;
/** /**
* *
* @type {string} * @type {string}
@@ -708,6 +716,12 @@ export interface FoodPropertyType {
* @memberof FoodPropertyType * @memberof FoodPropertyType
*/ */
description?: string | null; description?: string | null;
/**
*
* @type {number}
* @memberof FoodPropertyType
*/
order?: number;
/** /**
* *
* @type {string} * @type {string}
@@ -928,12 +942,6 @@ export interface ImportLogKeyword {
* @memberof ImportLogKeyword * @memberof ImportLogKeyword
*/ */
name: string; name: string;
/**
*
* @type {string}
* @memberof ImportLogKeyword
*/
icon?: string | null;
/** /**
* *
* @type {string} * @type {string}
@@ -1104,6 +1112,12 @@ export interface IngredientFood {
* @memberof IngredientFood * @memberof IngredientFood
*/ */
recipe?: FoodRecipe | null; recipe?: FoodRecipe | null;
/**
*
* @type {string}
* @memberof IngredientFood
*/
url?: string | null;
/** /**
* *
* @type {Array<FoodProperties>} * @type {Array<FoodProperties>}
@@ -1708,12 +1722,6 @@ export interface Keyword {
* @memberof Keyword * @memberof Keyword
*/ */
name: string; name: string;
/**
*
* @type {string}
* @memberof Keyword
*/
icon?: string | null;
/** /**
* *
* @type {string} * @type {string}
@@ -1866,12 +1874,6 @@ export interface MealPlanMealType {
* @memberof MealPlanMealType * @memberof MealPlanMealType
*/ */
order?: number; order?: number;
/**
*
* @type {string}
* @memberof MealPlanMealType
*/
icon?: string | null;
/** /**
* *
* @type {string} * @type {string}
@@ -2043,12 +2045,6 @@ export interface MealType {
* @memberof MealType * @memberof MealType
*/ */
order?: number; order?: number;
/**
*
* @type {string}
* @memberof MealType
*/
icon?: string | null;
/** /**
* *
* @type {string} * @type {string}
@@ -3062,12 +3058,6 @@ export interface PropertyType {
* @memberof PropertyType * @memberof PropertyType
*/ */
name: string; name: string;
/**
*
* @type {string}
* @memberof PropertyType
*/
icon?: string | null;
/** /**
* *
* @type {string} * @type {string}
@@ -3080,6 +3070,12 @@ export interface PropertyType {
* @memberof PropertyType * @memberof PropertyType
*/ */
description?: string | null; description?: string | null;
/**
*
* @type {number}
* @memberof PropertyType
*/
order?: number;
/** /**
* *
* @type {string} * @type {string}
@@ -3262,12 +3258,6 @@ export interface RecipeBook {
* @memberof RecipeBook * @memberof RecipeBook
*/ */
description?: string; description?: string;
/**
*
* @type {string}
* @memberof RecipeBook
*/
icon?: string | null;
/** /**
* *
* @type {Array<CustomFilterShared>} * @type {Array<CustomFilterShared>}
@@ -3514,12 +3504,6 @@ export interface RecipeKeywords {
* @memberof RecipeKeywords * @memberof RecipeKeywords
*/ */
name: string; name: string;
/**
*
* @type {string}
* @memberof RecipeKeywords
*/
icon?: string | null;
/** /**
* *
* @type {string} * @type {string}
@@ -3855,6 +3839,12 @@ export interface RecipeSteps {
* @memberof RecipeSteps * @memberof RecipeSteps
*/ */
numrecipe?: string; numrecipe?: string;
/**
*
* @type {boolean}
* @memberof RecipeSteps
*/
show_ingredients_table?: boolean;
} }
/** /**
* *
@@ -4580,7 +4570,7 @@ export interface Step {
* @type {boolean} * @type {boolean}
* @memberof Step * @memberof Step
*/ */
show_ingredeints_table?: boolean; show_ingredients_table?: boolean;
} }
/** /**
* *
@@ -4851,6 +4841,12 @@ export interface Unit {
* @memberof Unit * @memberof Unit
*/ */
description?: string | null; description?: string | null;
/**
*
* @type {string}
* @memberof Unit
*/
base_unit?: string | null;
/** /**
* *
* @type {string} * @type {string}
@@ -4943,6 +4939,12 @@ export interface UnitConversionBaseUnit {
* @memberof UnitConversionBaseUnit * @memberof UnitConversionBaseUnit
*/ */
description?: string | null; description?: string | null;
/**
*
* @type {string}
* @memberof UnitConversionBaseUnit
*/
base_unit?: string | null;
/** /**
* *
* @type {string} * @type {string}

View File

@@ -4,7 +4,7 @@
* Django Recipes * Django Recipes
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
* *
* The version of the OpenAPI document: 0.0.0 * The version of the OpenAPI document: 1.0.0
* *
* *
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).

View File

@@ -4,7 +4,7 @@
* Django Recipes * Django Recipes
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
* *
* The version of the OpenAPI document: 0.0.0 * The version of the OpenAPI document: 1.0.0
* *
* *
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).