Skip to content

Commit

Permalink
meal plan stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
vabene1111 committed Aug 30, 2023
1 parent 4a1ec5a commit dcfb269
Show file tree
Hide file tree
Showing 9 changed files with 300 additions and 221 deletions.
249 changes: 133 additions & 116 deletions vue/src/apps/MealPlanView/MealPlanView.vue

Large diffs are not rendered by default.

10 changes: 4 additions & 6 deletions vue/src/components/MealPlanCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<div class="card-header p-1 text-center text-primary border-bottom-0" v-if="detailed" :style="`background-color: ${background_color}`">
<span class="font-light text-center" v-if="entry.entry.meal_type.icon != null">{{ entry.entry.meal_type.icon }}</span>
<span class="font-light d-none d-md-inline">{{ entry.entry.meal_type.name }}</span>
<span v-if="entry.entry.shopping" class="font-light"><i class="fas fa-shopping-cart fa-xs float-left" v-b-tooltip.hover.top :title="$t('in_shopping')" /></span>
<span v-if="entry.entry.shopping" class="font-light"><i class="fas fa-shopping-cart fa-xs float-left" v-b-tooltip.hover.top :title="$t('in_shopping')"/></span>
</div>
<div class="card-img-overlay h-100 d-flex flex-column justify-content-right float-right text-right p-0" v-if="detailed">
<a>
Expand All @@ -41,11 +41,8 @@
<div class="card-body p-1" v-if="detailed && entry.entry.recipe == null" :style="`background-color: ${background_color}`">
<p>{{ entry.entry.note }}</p>
</div>

<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}`">
<span class="font-light">{{ title }}</span>
</div>
Expand All @@ -71,7 +68,8 @@ export default {
image_placeholder: window.IMAGE_PLACEHOLDER,
}
},
mounted() {},
mounted() {
},
computed: {
entry: function () {
return this.value.originalItem
Expand Down
7 changes: 4 additions & 3 deletions vue/src/components/MealPlanEditModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,9 @@ import Vue from "vue"
import VueCookies from "vue-cookies"
import {BootstrapVue} from "bootstrap-vue"
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 {StandardToasts} = require("@/utils/utils")
import {useUserPreferenceStore} from "@/stores/UserPreferenceStore";
import {useMealPlanStore} from "@/stores/MealPlanStore";
Expand All @@ -163,7 +162,7 @@ export default {
default: true,
},
},
mixins: [ApiMixin],
mixins: [ApiMixin, ToastMixin],
components: {
GenericMultiselect,
RecipeCard: () => import("@/components/RecipeCard.vue"),
Expand Down Expand Up @@ -234,9 +233,11 @@ export default {
editEntry() {
if (this.entryEditing.meal_type == null) {
this.makeToast('Warning', this.$t('Meal_Type_Required'), 'warning')
return;
}
if (this.entryEditing.recipe == null && this.entryEditing.title === "") {
this.makeToast('Warning', this.$t('Title_or_Recipe_Required'), 'warning')
return
}
//TODO properly validate
Expand Down
46 changes: 46 additions & 0 deletions vue/src/components/Modals/ColorInput.vue
Original file line number Diff line number Diff line change
@@ -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>
1 change: 1 addition & 0 deletions vue/src/components/Modals/GenericModalForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
<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"/>
<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"/>
</div>
<template v-slot:modal-footer>
Expand Down
108 changes: 61 additions & 47 deletions vue/src/utils/models.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class Models {
false: undefined,
},
},
tree: { default: undefined },
tree: {default: undefined},
},
},
delete: {
Expand All @@ -50,7 +50,7 @@ export class Models {
type: "lookup",
field: "target",
list: "self",
sticky_options: [{ id: 0, name: "tree_root" }],
sticky_options: [{id: 0, name: "tree_root"}],
},
},
},
Expand All @@ -71,7 +71,7 @@ export class Models {
food_onhand: true,
shopping: true,
},
tags: [{ field: "supermarket_category", label: "name", color: "info" }],
tags: [{field: "supermarket_category", label: "name", color: "info"}],
// REQUIRED: unordered array of fields that can be set during create
create: {
// if not defined partialUpdate will use the same parameters, prepending 'id'
Expand Down Expand Up @@ -177,7 +177,7 @@ export class Models {
field: "substitute_siblings",
label: "substitute_siblings", // form.label always translated in utils.getForm()
help_text: "substitute_siblings_help", // form.help_text always translated
condition: { field: "parent", value: true, condition: "field_exists" },
condition: {field: "parent", value: true, condition: "field_exists"},
},
substitute_children: {
form_field: true,
Expand All @@ -186,7 +186,7 @@ export class Models {
field: "substitute_children",
label: "substitute_children",
help_text: "substitute_children_help",
condition: { field: "numchild", value: 0, condition: "gt" },
condition: {field: "numchild", value: 0, condition: "gt"},
},
inherit_fields: {
form_field: true,
Expand All @@ -196,7 +196,7 @@ export class Models {
field: "inherit_fields",
list: "FOOD_INHERIT_FIELDS",
label: "InheritFields",
condition: { field: "food_children_exist", value: true, condition: "preference_equals" },
condition: {field: "food_children_exist", value: true, condition: "preference_equals"},
help_text: "InheritFields_help",
},
child_inherit_fields: {
Expand All @@ -207,7 +207,7 @@ export class Models {
field: "child_inherit_fields",
list: "FOOD_INHERIT_FIELDS",
label: "ChildInheritFields", // form.label always translated in utils.getForm()
condition: { field: "numchild", value: 0, condition: "gt" },
condition: {field: "numchild", value: 0, condition: "gt"},
help_text: "ChildInheritFields_help", // form.help_text always translated
},
reset_inherit: {
Expand All @@ -217,7 +217,7 @@ export class Models {
field: "reset_inherit",
label: "reset_children",
help_text: "reset_children_help",
condition: { field: "numchild", value: 0, condition: "gt" },
condition: {field: "numchild", value: 0, condition: "gt"},
},
form_function: "FoodCreateDefault",
},
Expand Down Expand Up @@ -304,24 +304,24 @@ export class Models {
form_field: true,
type: "choice",
options: [
{ value: "g", text: "g" },
{ value: "kg", text: "kg" },
{ value: "ounce", text: "ounce" },
{ value: "pound", text: "pound" },
{ value: "ml", text: "ml" },
{ value: "l", text: "l" },
{ value: "fluid_ounce", text: "fluid_ounce" },
{ value: "pint", text: "pint" },
{ value: "quart", text: "quart" },
{ value: "gallon", text: "gallon" },
{ value: "tbsp", text: "tbsp" },
{ value: "tsp", text: "tsp" },
{ value: "imperial_fluid_ounce", text: "imperial_fluid_ounce" },
{ value: "imperial_pint", text: "imperial_pint" },
{ value: "imperial_quart", text: "imperial_quart" },
{ value: "imperial_gallon", text: "imperial_gallon" },
{ value: "imperial_tbsp", text: "imperial_tbsp" },
{ value: "imperial_tsp", text: "imperial_tsp" },
{value: "g", text: "g"},
{value: "kg", text: "kg"},
{value: "ounce", text: "ounce"},
{value: "pound", text: "pound"},
{value: "ml", text: "ml"},
{value: "l", text: "l"},
{value: "fluid_ounce", text: "fluid_ounce"},
{value: "pint", text: "pint"},
{value: "quart", text: "quart"},
{value: "gallon", text: "gallon"},
{value: "tbsp", text: "tbsp"},
{value: "tsp", text: "tsp"},
{value: "imperial_fluid_ounce", text: "imperial_fluid_ounce"},
{value: "imperial_pint", text: "imperial_pint"},
{value: "imperial_quart", text: "imperial_quart"},
{value: "imperial_gallon", text: "imperial_gallon"},
{value: "imperial_tbsp", text: "imperial_tbsp"},
{value: "imperial_tsp", text: "imperial_tsp"},
],
field: "base_unit",
label: "Base Unit",
Expand Down Expand Up @@ -375,7 +375,7 @@ export class Models {
name: "Recipe_Book",
apiName: "RecipeBook",
create: {
params: [["name", "description", "filter"]],
params: [["name", "description", "filter"]],
form: {
name: {
form_field: true,
Expand Down Expand Up @@ -457,7 +457,7 @@ export class Models {
static SUPERMARKET = {
name: "Supermarket",
apiName: "Supermarket",
ordered_tags: [{ field: "category_to_supermarket", label: "category::name", color: "info" }],
ordered_tags: [{field: "category_to_supermarket", label: "category::name", color: "info"}],
create: {
params: [["name", "description", "category_to_supermarket"]],
form: {
Expand Down Expand Up @@ -540,13 +540,13 @@ export class Models {
form_field: true,
type: "choice",
options: [
{ value: "FOOD_ALIAS", text: "Food_Alias" },
{ value: "UNIT_ALIAS", text: "Unit_Alias" },
{ value: "KEYWORD_ALIAS", text: "Keyword_Alias" },
{ value: "DESCRIPTION_REPLACE", text: "Description_Replace" },
{ value: "INSTRUCTION_REPLACE", text: "Instruction_Replace" },
{ value: "NEVER_UNIT", text: "Never_Unit" },
{ value: "TRANSPOSE_WORDS", text: "Transpose_Words" },
{value: "FOOD_ALIAS", text: "Food_Alias"},
{value: "UNIT_ALIAS", text: "Unit_Alias"},
{value: "KEYWORD_ALIAS", text: "Keyword_Alias"},
{value: "DESCRIPTION_REPLACE", text: "Description_Replace"},
{value: "INSTRUCTION_REPLACE", text: "Instruction_Replace"},
{value: "NEVER_UNIT", text: "Never_Unit"},
{value: "TRANSPOSE_WORDS", text: "Transpose_Words"},
],
field: "type",
label: "Type",
Expand Down Expand Up @@ -830,7 +830,7 @@ export class Models {
params: ["filter_list"],
},
create: {
params: [["name"]],
params: [["name", "color", "default"]],
form: {
name: {
form_field: true,
Expand All @@ -839,6 +839,20 @@ export class Models {
label: "Name",
placeholder: "",
},
color: {
form_field: true,
type: "color",
field: "color",
label: "Color",
placeholder: "",
},
default: {
form_field: true,
type: "checkbox",
field: "default",
label: "Default",
placeholder: "",
},
},
},
}
Expand Down Expand Up @@ -995,7 +1009,7 @@ export class Actions {
},
],
},
ok_label: { function: "translate", phrase: "Save" },
ok_label: {function: "translate", phrase: "Save"},
},
}
static UPDATE = {
Expand Down Expand Up @@ -1030,7 +1044,7 @@ export class Actions {
},
],
},
ok_label: { function: "translate", phrase: "Delete" },
ok_label: {function: "translate", phrase: "Delete"},
instruction: {
form_field: true,
type: "instruction",
Expand All @@ -1057,17 +1071,17 @@ export class Actions {
suffix: "s",
params: ["query", "page", "pageSize", "options"],
config: {
query: { default: undefined },
page: { default: 1 },
pageSize: { default: 25 },
query: {default: undefined},
page: {default: 1},
pageSize: {default: 25},
},
}
static MERGE = {
function: "merge",
params: ["source", "target"],
config: {
source: { type: "string" },
target: { type: "string" },
source: {type: "string"},
target: {type: "string"},
},
form: {
title: {
Expand All @@ -1082,7 +1096,7 @@ export class Actions {
},
],
},
ok_label: { function: "translate", phrase: "Merge" },
ok_label: {function: "translate", phrase: "Merge"},
instruction: {
form_field: true,
type: "instruction",
Expand Down Expand Up @@ -1116,8 +1130,8 @@ export class Actions {
function: "move",
params: ["source", "target"],
config: {
source: { type: "string" },
target: { type: "string" },
source: {type: "string"},
target: {type: "string"},
},
form: {
title: {
Expand All @@ -1132,7 +1146,7 @@ export class Actions {
},
],
},
ok_label: { function: "translate", phrase: "Move" },
ok_label: {function: "translate", phrase: "Move"},
instruction: {
form_field: true,
type: "instruction",
Expand Down
Loading

0 comments on commit dcfb269

Please sign in to comment.