add ignore_shopping && additional help
This commit is contained in:
@ -79,7 +79,7 @@ def list_from_recipe(list_recipe=None, recipe=None, mealplan=None, servings=None
|
|||||||
elif ingredients:
|
elif ingredients:
|
||||||
ingredients = Ingredient.objects.filter(pk__in=ingredients, space=space)
|
ingredients = Ingredient.objects.filter(pk__in=ingredients, space=space)
|
||||||
else:
|
else:
|
||||||
ingredients = Ingredient.objects.filter(step__recipe=r, space=space)
|
ingredients = Ingredient.objects.filter(step__recipe=r, food__ignore_shopping=False, space=space)
|
||||||
|
|
||||||
if exclude_onhand := created_by.userpreference.mealplan_autoexclude_onhand:
|
if exclude_onhand := created_by.userpreference.mealplan_autoexclude_onhand:
|
||||||
ingredients = ingredients.exclude(food__onhand_users__id__in=[x.id for x in shared_users])
|
ingredients = ingredients.exclude(food__onhand_users__id__in=[x.id for x in shared_users])
|
||||||
@ -101,9 +101,9 @@ def list_from_recipe(list_recipe=None, recipe=None, mealplan=None, servings=None
|
|||||||
if ingredients.filter(food__recipe=x).exists():
|
if ingredients.filter(food__recipe=x).exists():
|
||||||
for ing in ingredients.filter(food__recipe=x):
|
for ing in ingredients.filter(food__recipe=x):
|
||||||
if exclude_onhand:
|
if exclude_onhand:
|
||||||
x_ing = Ingredient.objects.filter(step__recipe=x, space=space).exclude(food__onhand_users__id__in=[x.id for x in shared_users])
|
x_ing = Ingredient.objects.filter(step__recipe=x, food__ignore_shopping=False, space=space).exclude(food__onhand_users__id__in=[x.id for x in shared_users])
|
||||||
else:
|
else:
|
||||||
x_ing = Ingredient.objects.filter(step__recipe=x, space=space)
|
x_ing = Ingredient.objects.filter(step__recipe=x, food__ignore_shopping=False, space=space).exclude(food__ignore_shopping=True)
|
||||||
for i in [x for x in x_ing]:
|
for i in [x for x in x_ing]:
|
||||||
ShoppingListEntry.objects.create(
|
ShoppingListEntry.objects.create(
|
||||||
list_recipe=list_recipe,
|
list_recipe=list_recipe,
|
||||||
|
@ -166,6 +166,11 @@ class UserPreferenceSerializer(WritableNestedModelSerializer):
|
|||||||
food_inherit_default = FoodInheritFieldSerializer(source='space.food_inherit', many=True, allow_null=True, required=False, read_only=True)
|
food_inherit_default = FoodInheritFieldSerializer(source='space.food_inherit', many=True, allow_null=True, required=False, read_only=True)
|
||||||
plan_share = UserNameSerializer(many=True, allow_null=True, required=False, read_only=True)
|
plan_share = UserNameSerializer(many=True, allow_null=True, required=False, read_only=True)
|
||||||
shopping_share = UserNameSerializer(many=True, allow_null=True, required=False)
|
shopping_share = UserNameSerializer(many=True, allow_null=True, required=False)
|
||||||
|
food_children_exist = serializers.SerializerMethodField('get_food_children_exist')
|
||||||
|
|
||||||
|
def get_food_children_exist(self, obj):
|
||||||
|
space = getattr(self.context.get('request', None), 'space', None)
|
||||||
|
return Food.objects.filter(depth__gt=0, space=space).exists()
|
||||||
|
|
||||||
def create(self, validated_data):
|
def create(self, validated_data):
|
||||||
if not validated_data.get('user', None):
|
if not validated_data.get('user', None):
|
||||||
@ -180,7 +185,7 @@ class UserPreferenceSerializer(WritableNestedModelSerializer):
|
|||||||
'user', 'theme', 'nav_color', 'default_unit', 'default_page', 'use_fractions', 'use_kj', 'search_style', 'show_recent', 'plan_share',
|
'user', 'theme', 'nav_color', 'default_unit', 'default_page', 'use_fractions', 'use_kj', 'search_style', 'show_recent', 'plan_share',
|
||||||
'ingredient_decimals', 'comments', 'shopping_auto_sync', 'mealplan_autoadd_shopping', 'food_inherit_default', 'default_delay',
|
'ingredient_decimals', 'comments', 'shopping_auto_sync', 'mealplan_autoadd_shopping', 'food_inherit_default', 'default_delay',
|
||||||
'mealplan_autoinclude_related', 'mealplan_autoexclude_onhand', 'shopping_share', 'shopping_recent_days', 'csv_delim', 'csv_prefix',
|
'mealplan_autoinclude_related', 'mealplan_autoexclude_onhand', 'shopping_share', 'shopping_recent_days', 'csv_delim', 'csv_prefix',
|
||||||
'filter_to_supermarket', 'shopping_add_onhand', 'left_handed'
|
'filter_to_supermarket', 'shopping_add_onhand', 'left_handed', 'food_children_exist'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@ -426,7 +431,7 @@ class FoodSerializer(UniqueFieldsMixin, WritableNestedModelSerializer, ExtendedR
|
|||||||
model = Food
|
model = Food
|
||||||
fields = (
|
fields = (
|
||||||
'id', 'name', 'description', 'shopping', 'recipe', 'food_onhand', 'supermarket_category',
|
'id', 'name', 'description', 'shopping', 'recipe', 'food_onhand', 'supermarket_category',
|
||||||
'image', 'parent', 'numchild', 'numrecipe', 'inherit_fields', 'full_name'
|
'image', 'parent', 'numchild', 'numrecipe', 'inherit_fields', 'full_name', 'ignore_shopping'
|
||||||
)
|
)
|
||||||
read_only_fields = ('id', 'numchild', 'parent', 'image', 'numrecipe')
|
read_only_fields = ('id', 'numchild', 'parent', 'image', 'numrecipe')
|
||||||
|
|
||||||
|
@ -8,21 +8,15 @@
|
|||||||
<div class="row justify-content-center">
|
<div class="row justify-content-center">
|
||||||
<div class="col-12 col-lg-10 col-xl-8 mt-3 mb-3">
|
<div class="col-12 col-lg-10 col-xl-8 mt-3 mb-3">
|
||||||
<b-input-group>
|
<b-input-group>
|
||||||
<b-input
|
<b-input class="form-control form-control-lg form-control-borderless form-control-search" v-model="search.search_input" v-bind:placeholder="$t('Search')"></b-input>
|
||||||
class="form-control form-control-lg form-control-borderless form-control-search"
|
|
||||||
v-model="search.search_input" v-bind:placeholder="$t('Search')"></b-input>
|
|
||||||
<b-input-group-append>
|
<b-input-group-append>
|
||||||
<b-button v-b-tooltip.hover :title="$t('show_sql')" @click="showSQL()"
|
<b-button v-b-tooltip.hover :title="$t('show_sql')" @click="showSQL()" v-if="debug && ui.sql_debug">
|
||||||
v-if="debug && ui.sql_debug">
|
|
||||||
<i class="fas fa-bug" style="font-size: 1.5em"></i>
|
<i class="fas fa-bug" style="font-size: 1.5em"></i>
|
||||||
</b-button>
|
</b-button>
|
||||||
<b-button variant="light" v-b-tooltip.hover :title="$t('Random Recipes')"
|
<b-button variant="light" v-b-tooltip.hover :title="$t('Random Recipes')" @click="openRandom()">
|
||||||
@click="openRandom()">
|
|
||||||
<i class="fas fa-dice-five" style="font-size: 1.5em"></i>
|
<i class="fas fa-dice-five" style="font-size: 1.5em"></i>
|
||||||
</b-button>
|
</b-button>
|
||||||
<b-button v-b-toggle.collapse_advanced_search v-b-tooltip.hover
|
<b-button v-b-toggle.collapse_advanced_search v-b-tooltip.hover :title="$t('Advanced Settings')" v-bind:variant="!searchFiltered(true) ? 'primary' : 'danger'">
|
||||||
:title="$t('Advanced Settings')"
|
|
||||||
v-bind:variant="!searchFiltered(true) ? 'primary' : 'danger'">
|
|
||||||
<!-- TODO consider changing this icon to a filter -->
|
<!-- TODO consider changing this icon to a filter -->
|
||||||
<i class="fas fa-caret-down" v-if="!search.advanced_search_visible"></i>
|
<i class="fas fa-caret-down" v-if="!search.advanced_search_visible"></i>
|
||||||
<i class="fas fa-caret-up" v-if="search.advanced_search_visible"></i>
|
<i class="fas fa-caret-up" v-if="search.advanced_search_visible"></i>
|
||||||
@ -32,18 +26,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<b-collapse id="collapse_advanced_search" class="mt-2 shadow-sm"
|
<b-collapse id="collapse_advanced_search" class="mt-2 shadow-sm" v-model="search.advanced_search_visible">
|
||||||
v-model="search.advanced_search_visible">
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body p-4">
|
<div class="card-body p-4">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<a class="btn btn-primary btn-block text-uppercase"
|
<a class="btn btn-primary btn-block text-uppercase" :href="resolveDjangoUrl('new_recipe')">{{ $t("New_Recipe") }}</a>
|
||||||
:href="resolveDjangoUrl('new_recipe')">{{ $t("New_Recipe") }}</a>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<a class="btn btn-primary btn-block text-uppercase"
|
<a class="btn btn-primary btn-block text-uppercase" :href="resolveDjangoUrl('data_import_url')">{{ $t("Import") }}</a>
|
||||||
:href="resolveDjangoUrl('data_import_url')">{{ $t("Import") }}</a>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<button
|
<button
|
||||||
@ -62,92 +53,57 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<button id="id_settings_button"
|
<button id="id_settings_button" class="btn btn-primary btn-block text-uppercase"><i class="fas fa-cog fa-lg m-1"></i></button>
|
||||||
class="btn btn-primary btn-block text-uppercase"><i
|
|
||||||
class="fas fa-cog fa-lg m-1"></i></button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<b-popover target="id_settings_button" triggers="click" placement="bottom">
|
<b-popover target="id_settings_button" triggers="click" placement="bottom">
|
||||||
<b-tabs content-class="mt-1" small>
|
<b-tabs content-class="mt-1" small>
|
||||||
<b-tab :title="$t('Settings')" active>
|
<b-tab :title="$t('Settings')" active>
|
||||||
<b-form-group v-bind:label="$t('Recently_Viewed')"
|
<b-form-group v-bind:label="$t('Recently_Viewed')" label-for="popover-input-1" label-cols="6" class="mb-3">
|
||||||
label-for="popover-input-1" label-cols="6" class="mb-3">
|
<b-form-input type="number" v-model="ui.recently_viewed" id="popover-input-1" size="sm"></b-form-input>
|
||||||
<b-form-input type="number" v-model="ui.recently_viewed"
|
|
||||||
id="popover-input-1" size="sm"></b-form-input>
|
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
|
|
||||||
<b-form-group v-bind:label="$t('Recipes_per_page')"
|
<b-form-group v-bind:label="$t('Recipes_per_page')" label-for="popover-input-page-count" label-cols="6" class="mb-3">
|
||||||
label-for="popover-input-page-count" label-cols="6"
|
<b-form-input type="number" v-model="ui.page_size" id="popover-input-page-count" size="sm"></b-form-input>
|
||||||
class="mb-3">
|
|
||||||
<b-form-input type="number" v-model="ui.page_size"
|
|
||||||
id="popover-input-page-count"
|
|
||||||
size="sm"></b-form-input>
|
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
|
|
||||||
<b-form-group v-bind:label="$t('Meal_Plan')" label-for="popover-input-2"
|
<b-form-group v-bind:label="$t('Meal_Plan')" label-for="popover-input-2" label-cols="6" class="mb-3">
|
||||||
label-cols="6" class="mb-3">
|
<b-form-checkbox switch v-model="ui.show_meal_plan" id="popover-input-2" size="sm"></b-form-checkbox>
|
||||||
<b-form-checkbox switch v-model="ui.show_meal_plan"
|
|
||||||
id="popover-input-2" size="sm"></b-form-checkbox>
|
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
|
|
||||||
<b-form-group v-if="ui.show_meal_plan"
|
<b-form-group v-if="ui.show_meal_plan" v-bind:label="$t('Meal_Plan_Days')" label-for="popover-input-5" label-cols="6" class="mb-3">
|
||||||
v-bind:label="$t('Meal_Plan_Days')"
|
<b-form-input type="number" v-model="ui.meal_plan_days" id="popover-input-5" size="sm"></b-form-input>
|
||||||
label-for="popover-input-5" label-cols="6" class="mb-3">
|
|
||||||
<b-form-input type="number" v-model="ui.meal_plan_days"
|
|
||||||
id="popover-input-5" size="sm"></b-form-input>
|
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
|
|
||||||
<b-form-group v-bind:label="$t('Sort_by_new')"
|
<b-form-group v-bind:label="$t('Sort_by_new')" label-for="popover-input-3" label-cols="6" class="mb-3">
|
||||||
label-for="popover-input-3" label-cols="6" class="mb-3">
|
<b-form-checkbox switch v-model="ui.sort_by_new" id="popover-input-3" size="sm"></b-form-checkbox>
|
||||||
<b-form-checkbox switch v-model="ui.sort_by_new"
|
|
||||||
id="popover-input-3" size="sm"></b-form-checkbox>
|
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
<div class="row" style="margin-top: 1vh">
|
<div class="row" style="margin-top: 1vh">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<a :href="resolveDjangoUrl('view_settings') + '#search'">{{
|
<a :href="resolveDjangoUrl('view_settings') + '#search'">{{ $t("Search Settings") }}</a>
|
||||||
$t("Search Settings")
|
|
||||||
}}</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</b-tab>
|
</b-tab>
|
||||||
<b-tab title="Expert Settings">
|
<b-tab title="Expert Settings">
|
||||||
<b-form-group v-bind:label="$t('remember_search')"
|
<b-form-group v-bind:label="$t('remember_search')" label-for="popover-rem-search" label-cols="6" class="mb-3">
|
||||||
label-for="popover-rem-search" label-cols="6"
|
<b-form-checkbox switch v-model="ui.remember_search" id="popover-rem-search" size="sm"></b-form-checkbox>
|
||||||
class="mb-3">
|
|
||||||
<b-form-checkbox switch v-model="ui.remember_search"
|
|
||||||
id="popover-rem-search"
|
|
||||||
size="sm"></b-form-checkbox>
|
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
<b-form-group v-if="ui.remember_search"
|
<b-form-group v-if="ui.remember_search" v-bind:label="$t('remember_hours')" label-for="popover-input-rem-hours" label-cols="6" class="mb-3">
|
||||||
v-bind:label="$t('remember_hours')"
|
<b-form-input type="number" v-model="ui.remember_hours" id="popover-rem-hours" size="sm"></b-form-input>
|
||||||
label-for="popover-input-rem-hours" label-cols="6"
|
|
||||||
class="mb-3">
|
|
||||||
<b-form-input type="number" v-model="ui.remember_hours"
|
|
||||||
id="popover-rem-hours" size="sm"></b-form-input>
|
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
<b-form-group v-bind:label="$t('tree_select')"
|
<b-form-group v-bind:label="$t('tree_select')" label-for="popover-input-treeselect" label-cols="6" class="mb-3">
|
||||||
label-for="popover-input-treeselect" label-cols="6"
|
<b-form-checkbox switch v-model="ui.tree_select" id="popover-input-treeselect" size="sm"></b-form-checkbox>
|
||||||
class="mb-3">
|
|
||||||
<b-form-checkbox switch v-model="ui.tree_select"
|
|
||||||
id="popover-input-treeselect"
|
|
||||||
size="sm"></b-form-checkbox>
|
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
<b-form-group v-if="debug" v-bind:label="$t('sql_debug')"
|
<b-form-group v-if="debug" v-bind:label="$t('sql_debug')" label-for="popover-input-sqldebug" label-cols="6" class="mb-3">
|
||||||
label-for="popover-input-sqldebug" label-cols="6"
|
<b-form-checkbox switch v-model="ui.sql_debug" id="popover-input-sqldebug" size="sm"></b-form-checkbox>
|
||||||
class="mb-3">
|
|
||||||
<b-form-checkbox switch v-model="ui.sql_debug"
|
|
||||||
id="popover-input-sqldebug"
|
|
||||||
size="sm"></b-form-checkbox>
|
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
</b-tab>
|
</b-tab>
|
||||||
</b-tabs>
|
</b-tabs>
|
||||||
|
|
||||||
<div class="row" style="margin-top: 1vh">
|
<div class="row" style="margin-top: 1vh">
|
||||||
<div class="col-12" style="text-align: right">
|
<div class="col-12" style="text-align: right">
|
||||||
<b-button size="sm" variant="secondary" style="margin-right: 8px"
|
<b-button size="sm" variant="secondary" style="margin-right: 8px" @click="$root.$emit('bv::hide::popover')">{{ $t("Close") }} </b-button>
|
||||||
@click="$root.$emit('bv::hide::popover')">{{ $t("Close") }}
|
|
||||||
</b-button>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</b-popover>
|
</b-popover>
|
||||||
@ -182,12 +138,8 @@
|
|||||||
></generic-multiselect>
|
></generic-multiselect>
|
||||||
<b-input-group-append>
|
<b-input-group-append>
|
||||||
<b-input-group-text>
|
<b-input-group-text>
|
||||||
<b-form-checkbox v-model="search.search_keywords_or"
|
<b-form-checkbox v-model="search.search_keywords_or" name="check-button" @change="refreshData(false)" class="shadow-none" switch>
|
||||||
name="check-button"
|
<span class="text-uppercase" v-if="search.search_keywords_or">{{ $t("or") }}</span>
|
||||||
@change="refreshData(false)"
|
|
||||||
class="shadow-none" switch>
|
|
||||||
<span class="text-uppercase"
|
|
||||||
v-if="search.search_keywords_or">{{ $t("or") }}</span>
|
|
||||||
<span class="text-uppercase" v-else>{{ $t("and") }}</span>
|
<span class="text-uppercase" v-else>{{ $t("and") }}</span>
|
||||||
</b-form-checkbox>
|
</b-form-checkbox>
|
||||||
</b-input-group-text>
|
</b-input-group-text>
|
||||||
@ -226,13 +178,8 @@
|
|||||||
></generic-multiselect>
|
></generic-multiselect>
|
||||||
<b-input-group-append>
|
<b-input-group-append>
|
||||||
<b-input-group-text>
|
<b-input-group-text>
|
||||||
<b-form-checkbox v-model="search.search_foods_or"
|
<b-form-checkbox v-model="search.search_foods_or" name="check-button" @change="refreshData(false)" class="shadow-none" switch>
|
||||||
name="check-button"
|
<span class="text-uppercase" v-if="search.search_foods_or">{{ $t("or") }}</span>
|
||||||
@change="refreshData(false)"
|
|
||||||
class="shadow-none" switch>
|
|
||||||
<span class="text-uppercase" v-if="search.search_foods_or">{{
|
|
||||||
$t("or")
|
|
||||||
}}</span>
|
|
||||||
<span class="text-uppercase" v-else>{{ $t("and") }}</span>
|
<span class="text-uppercase" v-else>{{ $t("and") }}</span>
|
||||||
</b-form-checkbox>
|
</b-form-checkbox>
|
||||||
</b-input-group-text>
|
</b-input-group-text>
|
||||||
@ -256,13 +203,8 @@
|
|||||||
></generic-multiselect>
|
></generic-multiselect>
|
||||||
<b-input-group-append>
|
<b-input-group-append>
|
||||||
<b-input-group-text>
|
<b-input-group-text>
|
||||||
<b-form-checkbox v-model="search.search_books_or"
|
<b-form-checkbox v-model="search.search_books_or" name="check-button" @change="refreshData(false)" class="shadow-none" tyle="width: 100%" switch>
|
||||||
name="check-button"
|
<span class="text-uppercase" v-if="search.search_books_or">{{ $t("or") }}</span>
|
||||||
@change="refreshData(false)"
|
|
||||||
class="shadow-none" tyle="width: 100%" switch>
|
|
||||||
<span class="text-uppercase" v-if="search.search_books_or">{{
|
|
||||||
$t("or")
|
|
||||||
}}</span>
|
|
||||||
<span class="text-uppercase" v-else>{{ $t("and") }}</span>
|
<span class="text-uppercase" v-else>{{ $t("and") }}</span>
|
||||||
</b-form-checkbox>
|
</b-form-checkbox>
|
||||||
</b-input-group-text>
|
</b-input-group-text>
|
||||||
@ -299,9 +241,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col col-md-12 text-right" style="margin-top: 2vh">
|
<div class="col col-md-12 text-right" style="margin-top: 2vh">
|
||||||
<span class="text-muted">
|
<span class="text-muted">
|
||||||
{{ $t("Page") }} {{ search.pagination_page }}/{{
|
{{ $t("Page") }} {{ search.pagination_page }}/{{ Math.ceil(pagination_count / ui.page_size) }}
|
||||||
Math.ceil(pagination_count / ui.page_size)
|
|
||||||
}}
|
|
||||||
<a href="#" @click="resetSearch"><i class="fas fa-times-circle"></i> {{ $t("Reset") }}</a>
|
<a href="#" @click="resetSearch"><i class="fas fa-times-circle"></i> {{ $t("Reset") }}</a>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@ -309,24 +249,18 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col col-md-12">
|
<div class="col col-md-12">
|
||||||
<div
|
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); grid-gap: 0.8rem">
|
||||||
style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); grid-gap: 0.8rem">
|
|
||||||
<template v-if="!searchFiltered()">
|
<template v-if="!searchFiltered()">
|
||||||
<recipe-card v-bind:key="`mp_${m.id}`" v-for="m in meal_plans" :recipe="m.recipe"
|
<recipe-card v-bind:key="`mp_${m.id}`" v-for="m in meal_plans" :recipe="m.recipe" :meal_plan="m" :footer_text="m.meal_type_name" footer_icon="far fa-calendar-alt"></recipe-card>
|
||||||
:meal_plan="m" :footer_text="m.meal_type_name"
|
|
||||||
footer_icon="far fa-calendar-alt"></recipe-card>
|
|
||||||
</template>
|
</template>
|
||||||
<recipe-card v-for="r in recipes" v-bind:key="r.id" :recipe="r"
|
<recipe-card v-for="r in recipes" v-bind:key="r.id" :recipe="r" :footer_text="isRecentOrNew(r)[0]" :footer_icon="isRecentOrNew(r)[1]"></recipe-card>
|
||||||
:footer_text="isRecentOrNew(r)[0]"
|
|
||||||
:footer_icon="isRecentOrNew(r)[1]"></recipe-card>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row" style="margin-top: 2vh" v-if="!random_search">
|
<div class="row" style="margin-top: 2vh" v-if="!random_search">
|
||||||
<div class="col col-md-12">
|
<div class="col col-md-12">
|
||||||
<b-pagination pills v-model="search.pagination_page" :total-rows="pagination_count"
|
<b-pagination pills v-model="search.pagination_page" :total-rows="pagination_count" :per-page="ui.page_size" @change="pageChange" align="center"></b-pagination>
|
||||||
:per-page="ui.page_size" @change="pageChange" align="center"></b-pagination>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -338,25 +272,21 @@
|
|||||||
<script>
|
<script>
|
||||||
import Vue from "vue"
|
import Vue from "vue"
|
||||||
import { BootstrapVue } from "bootstrap-vue"
|
import { BootstrapVue } from "bootstrap-vue"
|
||||||
|
import VueCookies from "vue-cookies"
|
||||||
|
|
||||||
import "bootstrap-vue/dist/bootstrap-vue.css"
|
import "bootstrap-vue/dist/bootstrap-vue.css"
|
||||||
import moment from "moment"
|
import moment from "moment"
|
||||||
import _debounce from "lodash/debounce"
|
import _debounce from "lodash/debounce"
|
||||||
|
|
||||||
import VueCookies from "vue-cookies"
|
|
||||||
|
|
||||||
Vue.use(VueCookies)
|
|
||||||
|
|
||||||
import { ApiMixin, ResolveUrlMixin } from "@/utils/utils"
|
import { ApiMixin, ResolveUrlMixin } from "@/utils/utils"
|
||||||
|
|
||||||
import LoadingSpinner from "@/components/LoadingSpinner" // TODO: is this deprecated?
|
import LoadingSpinner from "@/components/LoadingSpinner" // TODO: is this deprecated?
|
||||||
|
|
||||||
import RecipeCard from "@/components/RecipeCard"
|
import RecipeCard from "@/components/RecipeCard"
|
||||||
import GenericMultiselect from "@/components/GenericMultiselect"
|
import GenericMultiselect from "@/components/GenericMultiselect"
|
||||||
import { Treeselect, LOAD_CHILDREN_OPTIONS } from "@riophae/vue-treeselect" //TODO: delete
|
import { Treeselect, LOAD_CHILDREN_OPTIONS } from "@riophae/vue-treeselect" //TODO: delete
|
||||||
import "@riophae/vue-treeselect/dist/vue-treeselect.css" //TODO: delete
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css" //TODO: delete
|
||||||
import RecipeSwitcher from "@/components/Buttons/RecipeSwitcher"
|
import RecipeSwitcher from "@/components/Buttons/RecipeSwitcher"
|
||||||
|
|
||||||
|
Vue.use(VueCookies)
|
||||||
Vue.use(BootstrapVue)
|
Vue.use(BootstrapVue)
|
||||||
|
|
||||||
let SEARCH_COOKIE_NAME = "search_settings"
|
let SEARCH_COOKIE_NAME = "search_settings"
|
||||||
@ -435,7 +365,6 @@ export default {
|
|||||||
}
|
}
|
||||||
let urlParams = new URLSearchParams(window.location.search)
|
let urlParams = new URLSearchParams(window.location.search)
|
||||||
|
|
||||||
|
|
||||||
if (urlParams.has("keyword")) {
|
if (urlParams.has("keyword")) {
|
||||||
this.search.search_keywords = []
|
this.search.search_keywords = []
|
||||||
this.facets.Keywords = []
|
this.facets.Keywords = []
|
||||||
@ -443,13 +372,15 @@ export default {
|
|||||||
let initial_keyword = { id: Number.parseInt(x), name: "loading..." }
|
let initial_keyword = { id: Number.parseInt(x), name: "loading..." }
|
||||||
this.search.search_keywords.push(initial_keyword)
|
this.search.search_keywords.push(initial_keyword)
|
||||||
|
|
||||||
this.genericAPI(this.Models.KEYWORD, this.Actions.FETCH, {id: initial_keyword.id}).then((response) => {
|
this.genericAPI(this.Models.KEYWORD, this.Actions.FETCH, { id: initial_keyword.id })
|
||||||
let kw_index = this.search.search_keywords.findIndex((k => k.id === initial_keyword.id))
|
.then((response) => {
|
||||||
|
let kw_index = this.search.search_keywords.findIndex((k) => k.id === initial_keyword.id)
|
||||||
this.$set(this.search.search_keywords, kw_index, response.data)
|
this.$set(this.search.search_keywords, kw_index, response.data)
|
||||||
this.$set(this.facets.Keywords, kw_index, response.data)
|
this.$set(this.facets.Keywords, kw_index, response.data)
|
||||||
}).catch((err) => {
|
})
|
||||||
|
.catch((err) => {
|
||||||
if (err.response.status === 404) {
|
if (err.response.status === 404) {
|
||||||
let kw_index = this.search.search_keywords.findIndex((k => k.id === initial_keyword.id))
|
let kw_index = this.search.search_keywords.findIndex((k) => k.id === initial_keyword.id)
|
||||||
this.search.search_keywords.splice(kw_index, 1)
|
this.search.search_keywords.splice(kw_index, 1)
|
||||||
this.facets.Keywords.splice(kw_index, 1)
|
this.facets.Keywords.splice(kw_index, 1)
|
||||||
this.refreshData(false)
|
this.refreshData(false)
|
||||||
@ -616,8 +547,7 @@ export default {
|
|||||||
},
|
},
|
||||||
showSQL: function () {
|
showSQL: function () {
|
||||||
let params = this.buildParams()
|
let params = this.buildParams()
|
||||||
this.genericAPI(this.Models.RECIPE, this.Actions.LIST, params).then((result) => {
|
this.genericAPI(this.Models.RECIPE, this.Actions.LIST, params).then((result) => {})
|
||||||
})
|
|
||||||
},
|
},
|
||||||
// TODO refactor to combine with load KeywordChildren
|
// TODO refactor to combine with load KeywordChildren
|
||||||
loadFoodChildren({ action, parentNode, callback }) {
|
loadFoodChildren({ action, parentNode, callback }) {
|
||||||
|
58
vue/src/components/Badges/Help.vue
Normal file
58
vue/src/components/Badges/Help.vue
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
<template>
|
||||||
|
<span><i class="mx-1 far fa-question-circle text-muted" @click="this_help.show = !this_help.show" /></span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Vue from "vue"
|
||||||
|
import VueCookies from "vue-cookies"
|
||||||
|
Vue.use(VueCookies)
|
||||||
|
let HELP_COOKIE_NAME = "help_settings"
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: "HelpBadge",
|
||||||
|
props: {
|
||||||
|
component: { type: String, required: true },
|
||||||
|
},
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
help: {},
|
||||||
|
|
||||||
|
default: {
|
||||||
|
show: true,
|
||||||
|
},
|
||||||
|
this_help: undefined,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.$nextTick(function () {
|
||||||
|
if (this.$cookies.isKey(HELP_COOKIE_NAME)) {
|
||||||
|
this.help = Object.assign({}, this.help, this.$cookies.get(HELP_COOKIE_NAME))
|
||||||
|
}
|
||||||
|
this.this_help = Object.assign({}, this.default, this.help?.[this.component])
|
||||||
|
})
|
||||||
|
},
|
||||||
|
watch: {
|
||||||
|
help: {
|
||||||
|
handler() {
|
||||||
|
this.$cookies.set(HELP_COOKIE_NAME, this.help)
|
||||||
|
},
|
||||||
|
deep: true,
|
||||||
|
},
|
||||||
|
this_help: {
|
||||||
|
handler() {
|
||||||
|
this.help[this.component] = Object.assign({}, this.this_help)
|
||||||
|
this.$cookies.set(HELP_COOKIE_NAME, this.help)
|
||||||
|
},
|
||||||
|
deep: true,
|
||||||
|
},
|
||||||
|
"this_help.show": function () {
|
||||||
|
if (this.this_help.show) {
|
||||||
|
this.$emit("show")
|
||||||
|
} else {
|
||||||
|
this.$emit("hide")
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {},
|
||||||
|
}
|
||||||
|
</script>
|
@ -1,5 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
<span>
|
<span v-if="!item.ignore_shopping">
|
||||||
<b-button class="btn text-decoration-none px-1 border-0" variant="link" :id="`shopping${item.id}`" @click="addShopping()">
|
<b-button class="btn text-decoration-none px-1 border-0" variant="link" :id="`shopping${item.id}`" @click="addShopping()">
|
||||||
<i
|
<i
|
||||||
class="fas"
|
class="fas"
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td v-else-if="show_shopping" class="text-right text-nowrap">
|
<td v-else-if="show_shopping" class="text-right text-nowrap">
|
||||||
<b-button
|
<b-button
|
||||||
|
v-if="!ingredient.food.ignore_shopping"
|
||||||
class="btn text-decoration-none fas fa-shopping-cart px-2 user-select-none"
|
class="btn text-decoration-none fas fa-shopping-cart px-2 user-select-none"
|
||||||
variant="link"
|
variant="link"
|
||||||
v-b-popover.hover.click.blur.html.top="{ title: ShoppingPopover, variant: 'outline-dark' }"
|
v-b-popover.hover.click.blur.html.top="{ title: ShoppingPopover, variant: 'outline-dark' }"
|
||||||
@ -43,10 +44,10 @@
|
|||||||
'text-warning': shopping_status === null,
|
'text-warning': shopping_status === null,
|
||||||
}"
|
}"
|
||||||
/>
|
/>
|
||||||
<span class="px-2">
|
<span v-if="!ingredient.food.ignore_shopping" class="px-2">
|
||||||
<input type="checkbox" class="align-middle" v-model="shop" @change="changeShopping" />
|
<input type="checkbox" class="align-middle" v-model="shop" @change="changeShopping" />
|
||||||
</span>
|
</span>
|
||||||
<on-hand-badge :item="ingredient.food" />
|
<on-hand-badge v-if="!ingredient.food.ignore_shopping" :item="ingredient.food" />
|
||||||
</td>
|
</td>
|
||||||
</template>
|
</template>
|
||||||
</tr>
|
</tr>
|
||||||
@ -100,10 +101,10 @@ export default {
|
|||||||
filtered_list = filtered_list.filter((x) => x.list_recipe == this.recipe_list)
|
filtered_list = filtered_list.filter((x) => x.list_recipe == this.recipe_list)
|
||||||
}
|
}
|
||||||
// how many ShoppingListRecipes are there for this recipe?
|
// how many ShoppingListRecipes are there for this recipe?
|
||||||
let count_shopping_recipes = [...new Set(filtered_list.map((x) => x.list_recipe))].length
|
let count_shopping_recipes = [...new Set(filtered_list.filter((x) => x.list_recipe))].length
|
||||||
let count_shopping_ingredient = filtered_list.filter((x) => x.ingredient == this.ingredient.id).length
|
let count_shopping_ingredient = filtered_list.filter((x) => x.ingredient == this.ingredient.id).length
|
||||||
|
|
||||||
if (count_shopping_recipes >= 1) {
|
if (count_shopping_recipes >= 1 && this.recipe_list) {
|
||||||
// This recipe is in the shopping list
|
// This recipe is in the shopping list
|
||||||
this.shop = false // don't check any boxes until user selects a shopping list to edit
|
this.shop = false // don't check any boxes until user selects a shopping list to edit
|
||||||
if (count_shopping_ingredient >= 1) {
|
if (count_shopping_ingredient >= 1) {
|
||||||
@ -117,7 +118,7 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
// there are not recipes in the shopping list
|
// there are not recipes in the shopping list
|
||||||
// set default value
|
// set default value
|
||||||
this.shop = !this.ingredient?.food?.food_onhand && !this.ingredient?.food?.recipe
|
this.shop = !this.ingredient?.food?.food_onhand && !this.ingredient?.food?.recipe && !this.ingredient?.food?.ignore_shopping
|
||||||
this.$emit("add-to-shopping", { item: this.ingredient, add: this.shop })
|
this.$emit("add-to-shopping", { item: this.ingredient, add: this.shop })
|
||||||
// mark checked if the food is in the shopping list for this ingredient/recipe
|
// mark checked if the food is in the shopping list for this ingredient/recipe
|
||||||
if (count_shopping_ingredient >= 1) {
|
if (count_shopping_ingredient >= 1) {
|
||||||
@ -135,7 +136,7 @@ export default {
|
|||||||
if (this.add_shopping_mode) {
|
if (this.add_shopping_mode) {
|
||||||
// if we are in add shopping mode (e.g. recipe_shopping_modal) start with all checks marked
|
// if we are in add shopping mode (e.g. recipe_shopping_modal) start with all checks marked
|
||||||
// except if on_hand (could be if recipe too?)
|
// except if on_hand (could be if recipe too?)
|
||||||
this.shop = !this.ingredient?.food?.food_onhand && !this.ingredient?.food?.recipe
|
this.shop = !this.ingredient?.food?.food_onhand && !this.ingredient?.food?.recipe && !this.ingredient?.food?.ignore_shopping
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -1,19 +1,20 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<b-form-checkbox v-model="new_value">{{ label }}</b-form-checkbox>
|
<b-form-checkbox v-model="new_value">{{ label }}</b-form-checkbox>
|
||||||
|
<em v-if="help" class="small text-muted">{{ help }}</em>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'CheckboxInput',
|
name: "CheckboxInput",
|
||||||
props: {
|
props: {
|
||||||
field: {type: String, default: 'You Forgot To Set Field Name'},
|
field: { type: String, default: "You Forgot To Set Field Name" },
|
||||||
label: {type: String, default: 'Checkbox Field'},
|
label: { type: String, default: "Checkbox Field" },
|
||||||
value: { type: Boolean, default: false },
|
value: { type: Boolean, default: false },
|
||||||
show_move: { type: Boolean, default: false },
|
show_move: { type: Boolean, default: false },
|
||||||
show_merge: { type: Boolean, default: false },
|
show_merge: { type: Boolean, default: false },
|
||||||
|
help: { type: String, default: undefined },
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
@ -24,11 +25,10 @@ export default {
|
|||||||
this.new_value = this.value
|
this.new_value = this.value
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
'new_value': function () {
|
new_value: function () {
|
||||||
this.$root.$emit('change', this.field, this.new_value)
|
this.$root.$emit("change", this.field, this.new_value)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {},
|
||||||
}
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
@ -2,22 +2,26 @@
|
|||||||
<div>
|
<div>
|
||||||
<b-modal :id="'modal_' + id" @hidden="cancelAction">
|
<b-modal :id="'modal_' + id" @hidden="cancelAction">
|
||||||
<template v-slot:modal-title>
|
<template v-slot:modal-title>
|
||||||
<h4>{{ form.title }}</h4>
|
<h4 class="d-inline">{{ form.title }}</h4>
|
||||||
|
<help-badge v-if="form.show_help" @show="show_help = true" @hide="show_help = false" :component="`GenericModal${form.title}`" />
|
||||||
</template>
|
</template>
|
||||||
<div v-for="(f, i) in form.fields" v-bind:key="i">
|
<div v-for="(f, i) in form.fields" v-bind:key="i">
|
||||||
<p v-if="visibleCondition(f, 'instruction')">{{ f.label }}</p>
|
<p v-if="visibleCondition(f, 'instruction')">{{ f.label }}</p>
|
||||||
<lookup-input v-if="visibleCondition(f, 'lookup')" :form="f" :model="listModel(f.list)" @change="storeValue" />
|
<lookup-input v-if="visibleCondition(f, 'lookup')" :form="f" :model="listModel(f.list)" @change="storeValue" :help="showHelp && f.help" />
|
||||||
<checkbox-input class="mb-3" v-if="visibleCondition(f, 'checkbox')" :label="f.label" :value="f.value" :field="f.field" />
|
<checkbox-input class="mb-3" v-if="visibleCondition(f, 'checkbox')" :label="f.label" :value="f.value" :field="f.field" :help="showHelp && f.help" />
|
||||||
<text-input v-if="visibleCondition(f, 'text')" :label="f.label" :value="f.value" :field="f.field" :placeholder="f.placeholder" />
|
<text-input v-if="visibleCondition(f, 'text')" :label="f.label" :value="f.value" :field="f.field" :placeholder="f.placeholder" :help="showHelp && f.help" :subtitle="f.subtitle" />
|
||||||
<choice-input v-if="visibleCondition(f, 'choice')" :label="f.label" :value="f.value" :field="f.field" :options="f.options" :placeholder="f.placeholder" />
|
<choice-input v-if="visibleCondition(f, 'choice')" :label="f.label" :value="f.value" :field="f.field" :options="f.options" :placeholder="f.placeholder" />
|
||||||
<emoji-input v-if="visibleCondition(f, 'emoji')" :label="f.label" :value="f.value" :field="f.field" @change="storeValue" />
|
<emoji-input v-if="visibleCondition(f, 'emoji')" :label="f.label" :value="f.value" :field="f.field" @change="storeValue" />
|
||||||
<file-input v-if="visibleCondition(f, 'file')" :label="f.label" :value="f.value" :field="f.field" @change="storeValue" />
|
<file-input v-if="visibleCondition(f, 'file')" :label="f.label" :value="f.value" :field="f.field" @change="storeValue" />
|
||||||
<small-text v-if="visibleCondition(f, 'smalltext')" :value="f.value" />
|
<small-text v-if="visibleCondition(f, 'smalltext')" :value="f.value" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<template v-slot:modal-footer>
|
<template v-slot:modal-footer>
|
||||||
<b-button class="float-right mx-1" variant="secondary" v-on:click="cancelAction">{{ $t("Cancel") }}</b-button>
|
<div class="row w-100 justify-content-end">
|
||||||
<b-button class="float-right mx-1" variant="primary" v-on:click="doAction">{{ form.ok_label }}</b-button>
|
<div class="col-auto">
|
||||||
|
<b-button class="mx-1" variant="secondary" v-on:click="cancelAction">{{ $t("Cancel") }}</b-button>
|
||||||
|
<b-button class="mx-1" variant="primary" v-on:click="doAction">{{ form.ok_label }}</b-button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
</b-modal>
|
</b-modal>
|
||||||
</div>
|
</div>
|
||||||
@ -31,7 +35,7 @@ import { getForm, formFunctions } from "@/utils/utils"
|
|||||||
Vue.use(BootstrapVue)
|
Vue.use(BootstrapVue)
|
||||||
|
|
||||||
import { ApiApiFactory } from "@/utils/openapi/api"
|
import { ApiApiFactory } from "@/utils/openapi/api"
|
||||||
import { ApiMixin, StandardToasts, ToastMixin } from "@/utils/utils"
|
import { ApiMixin, StandardToasts, ToastMixin, getUserPreference } from "@/utils/utils"
|
||||||
import CheckboxInput from "@/components/Modals/CheckboxInput"
|
import CheckboxInput from "@/components/Modals/CheckboxInput"
|
||||||
import LookupInput from "@/components/Modals/LookupInput"
|
import LookupInput from "@/components/Modals/LookupInput"
|
||||||
import TextInput from "@/components/Modals/TextInput"
|
import TextInput from "@/components/Modals/TextInput"
|
||||||
@ -39,10 +43,11 @@ import EmojiInput from "@/components/Modals/EmojiInput"
|
|||||||
import ChoiceInput from "@/components/Modals/ChoiceInput"
|
import ChoiceInput from "@/components/Modals/ChoiceInput"
|
||||||
import FileInput from "@/components/Modals/FileInput"
|
import FileInput from "@/components/Modals/FileInput"
|
||||||
import SmallText from "@/components/Modals/SmallText"
|
import SmallText from "@/components/Modals/SmallText"
|
||||||
|
import HelpBadge from "@/components/Badges/Help"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "GenericModalForm",
|
name: "GenericModalForm",
|
||||||
components: { FileInput, CheckboxInput, LookupInput, TextInput, EmojiInput, ChoiceInput, SmallText },
|
components: { FileInput, CheckboxInput, LookupInput, TextInput, EmojiInput, ChoiceInput, SmallText, HelpBadge },
|
||||||
mixins: [ApiMixin, ToastMixin],
|
mixins: [ApiMixin, ToastMixin],
|
||||||
props: {
|
props: {
|
||||||
model: { required: true, type: Object },
|
model: { required: true, type: Object },
|
||||||
@ -73,6 +78,7 @@ export default {
|
|||||||
form: {},
|
form: {},
|
||||||
dirty: false,
|
dirty: false,
|
||||||
special_handling: false,
|
special_handling: false,
|
||||||
|
show_help: true,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
@ -83,11 +89,19 @@ export default {
|
|||||||
buttonLabel() {
|
buttonLabel() {
|
||||||
return this.buttons[this.action].label
|
return this.buttons[this.action].label
|
||||||
},
|
},
|
||||||
|
showHelp() {
|
||||||
|
if (this.show_help) {
|
||||||
|
return true
|
||||||
|
} else {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
show: function () {
|
show: function () {
|
||||||
if (this.show) {
|
if (this.show) {
|
||||||
this.form = getForm(this.model, this.action, this.item1, this.item2)
|
this.form = getForm(this.model, this.action, this.item1, this.item2)
|
||||||
|
|
||||||
if (this.form?.form_function) {
|
if (this.form?.form_function) {
|
||||||
this.form = formFunctions[this.form.form_function](this.form)
|
this.form = formFunctions[this.form.form_function](this.form)
|
||||||
}
|
}
|
||||||
@ -256,15 +270,33 @@ export default {
|
|||||||
let type_match = field?.type == field_type
|
let type_match = field?.type == field_type
|
||||||
let checks = true
|
let checks = true
|
||||||
if (type_match && field?.condition) {
|
if (type_match && field?.condition) {
|
||||||
if (field.condition?.condition === "exists") {
|
const value = this.item1[field?.condition?.field]
|
||||||
if ((this.item1[field.condition.field] != undefined) === field.condition.value) {
|
const preference = getUserPreference(field?.condition?.field)
|
||||||
|
console.log("condition", field?.condition?.condition)
|
||||||
|
switch (field?.condition?.condition) {
|
||||||
|
case "field_exists":
|
||||||
|
if ((value != undefined) === field.condition.value) {
|
||||||
checks = true
|
checks = true
|
||||||
} else {
|
} else {
|
||||||
checks = false
|
checks = false
|
||||||
}
|
}
|
||||||
|
break
|
||||||
|
case "preference__array_exists":
|
||||||
|
if (preference?.length > 0 === field.condition.value) {
|
||||||
|
checks = true
|
||||||
|
} else {
|
||||||
|
checks = false
|
||||||
|
}
|
||||||
|
break
|
||||||
|
case "preference_equals":
|
||||||
|
if (preference === field.condition.value) {
|
||||||
|
checks = true
|
||||||
|
} else {
|
||||||
|
checks = false
|
||||||
|
}
|
||||||
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return type_match && checks
|
return type_match && checks
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
@new="addNew"
|
@new="addNew"
|
||||||
>
|
>
|
||||||
</generic-multiselect>
|
</generic-multiselect>
|
||||||
|
<em v-if="help" class="small text-muted">{{ help }}</em>
|
||||||
</b-form-group>
|
</b-form-group>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -47,6 +48,7 @@ export default {
|
|||||||
class_list: { type: String, default: "mb-3" },
|
class_list: { type: String, default: "mb-3" },
|
||||||
show_label: { type: Boolean, default: true },
|
show_label: { type: Boolean, default: true },
|
||||||
clear: { type: Number },
|
clear: { type: Number },
|
||||||
|
help: { type: String, default: undefined },
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
<div>
|
<div>
|
||||||
<b-form-group v-bind:label="label" class="mb-3">
|
<b-form-group v-bind:label="label" class="mb-3">
|
||||||
<b-form-input v-model="new_value" type="text" :placeholder="placeholder"></b-form-input>
|
<b-form-input v-model="new_value" type="text" :placeholder="placeholder"></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>
|
</b-form-group>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -14,7 +16,8 @@ export default {
|
|||||||
label: { type: String, default: "Text Field" },
|
label: { type: String, default: "Text Field" },
|
||||||
value: { type: String, default: "" },
|
value: { type: String, default: "" },
|
||||||
placeholder: { type: String, default: "You Should Add Placeholder Text" },
|
placeholder: { type: String, default: "You Should Add Placeholder Text" },
|
||||||
show_merge: { type: Boolean, default: false },
|
help: { type: String, default: undefined },
|
||||||
|
subtitle: { type: String, default: undefined },
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
@ -289,5 +289,9 @@
|
|||||||
"remember_hours": "Hours to Remember",
|
"remember_hours": "Hours to Remember",
|
||||||
"tree_select": "Use Tree Selection",
|
"tree_select": "Use Tree Selection",
|
||||||
"left_handed": "Left-handed mode",
|
"left_handed": "Left-handed mode",
|
||||||
"left_handed_help": "Will optimize the UI for use with your left hand."
|
"left_handed_help": "Will optimize the UI for use with your left hand.",
|
||||||
|
"OnHand_help": "Food is in inventory and will not be automatically added to a shopping list.",
|
||||||
|
"ignore_shopping_help": "Never add food to the shopping list (e.g. water)",
|
||||||
|
"shopping_category_help": "Supermarkets can be ordered and filtered by Shopping Category according to the layout of the aisles.",
|
||||||
|
"food_recipe_help": "Linking a recipe here will include the linked recipe in any other recipe that use this food"
|
||||||
}
|
}
|
||||||
|
@ -76,15 +76,17 @@ export class Models {
|
|||||||
// REQUIRED: unordered array of fields that can be set during create
|
// REQUIRED: unordered array of fields that can be set during create
|
||||||
create: {
|
create: {
|
||||||
// if not defined partialUpdate will use the same parameters, prepending 'id'
|
// if not defined partialUpdate will use the same parameters, prepending 'id'
|
||||||
params: [["name", "description", "recipe", "food_onhand", "supermarket_category", "inherit", "inherit_fields"]],
|
params: [["name", "description", "recipe", "food_onhand", "supermarket_category", "inherit", "inherit_fields", "ignore_shopping"]],
|
||||||
|
|
||||||
form: {
|
form: {
|
||||||
|
show_help: true,
|
||||||
name: {
|
name: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "text",
|
type: "text",
|
||||||
field: "name",
|
field: "name",
|
||||||
label: i18n.t("Name"),
|
label: i18n.t("Name"),
|
||||||
placeholder: "",
|
placeholder: "",
|
||||||
|
subtitle_field: "full_name",
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
@ -99,12 +101,21 @@ export class Models {
|
|||||||
field: "recipe",
|
field: "recipe",
|
||||||
list: "RECIPE",
|
list: "RECIPE",
|
||||||
label: i18n.t("Recipe"),
|
label: i18n.t("Recipe"),
|
||||||
|
help_text: i18n.t("food_recipe_help"),
|
||||||
},
|
},
|
||||||
shopping: {
|
onhand: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
type: "checkbox",
|
type: "checkbox",
|
||||||
field: "food_onhand",
|
field: "food_onhand",
|
||||||
label: i18n.t("OnHand"),
|
label: i18n.t("OnHand"),
|
||||||
|
help_text: i18n.t("OnHand_help"),
|
||||||
|
},
|
||||||
|
ignore_shopping: {
|
||||||
|
form_field: true,
|
||||||
|
type: "checkbox",
|
||||||
|
field: "ignore_shopping",
|
||||||
|
label: i18n.t("Ignore_Shopping"),
|
||||||
|
help_text: i18n.t("ignore_shopping_help"),
|
||||||
},
|
},
|
||||||
shopping_category: {
|
shopping_category: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
@ -113,6 +124,7 @@ export class Models {
|
|||||||
list: "SHOPPING_CATEGORY",
|
list: "SHOPPING_CATEGORY",
|
||||||
label: i18n.t("Shopping_Category"),
|
label: i18n.t("Shopping_Category"),
|
||||||
allow_create: true,
|
allow_create: true,
|
||||||
|
help_text: i18n.t("shopping_category_help"),
|
||||||
},
|
},
|
||||||
inherit_fields: {
|
inherit_fields: {
|
||||||
form_field: true,
|
form_field: true,
|
||||||
@ -121,12 +133,7 @@ export class Models {
|
|||||||
field: "inherit_fields",
|
field: "inherit_fields",
|
||||||
list: "FOOD_INHERIT_FIELDS",
|
list: "FOOD_INHERIT_FIELDS",
|
||||||
label: i18n.t("InheritFields"),
|
label: i18n.t("InheritFields"),
|
||||||
condition: { field: "parent", value: true, condition: "exists" },
|
condition: { field: "food_children_exist", value: true, condition: "preference_equals" },
|
||||||
},
|
|
||||||
full_name: {
|
|
||||||
form_field: true,
|
|
||||||
type: "smalltext",
|
|
||||||
field: "full_name",
|
|
||||||
},
|
},
|
||||||
form_function: "FoodCreateDefault",
|
form_function: "FoodCreateDefault",
|
||||||
},
|
},
|
||||||
|
@ -211,10 +211,10 @@ export interface Food {
|
|||||||
recipe?: FoodRecipe | null;
|
recipe?: FoodRecipe | null;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {boolean}
|
* @type {string}
|
||||||
* @memberof Food
|
* @memberof Food
|
||||||
*/
|
*/
|
||||||
food_onhand?: boolean;
|
food_onhand?: string | null;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {FoodSupermarketCategory}
|
* @type {FoodSupermarketCategory}
|
||||||
@ -245,6 +245,12 @@ export interface Food {
|
|||||||
* @memberof Food
|
* @memberof Food
|
||||||
*/
|
*/
|
||||||
full_name?: string;
|
full_name?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {boolean}
|
||||||
|
* @memberof Food
|
||||||
|
*/
|
||||||
|
ignore_shopping?: boolean;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -607,10 +613,10 @@ export interface IngredientFood {
|
|||||||
recipe?: FoodRecipe | null;
|
recipe?: FoodRecipe | null;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {boolean}
|
* @type {string}
|
||||||
* @memberof IngredientFood
|
* @memberof IngredientFood
|
||||||
*/
|
*/
|
||||||
food_onhand?: boolean;
|
food_onhand?: string | null;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {FoodSupermarketCategory}
|
* @type {FoodSupermarketCategory}
|
||||||
@ -641,6 +647,12 @@ export interface IngredientFood {
|
|||||||
* @memberof IngredientFood
|
* @memberof IngredientFood
|
||||||
*/
|
*/
|
||||||
full_name?: string;
|
full_name?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {boolean}
|
||||||
|
* @memberof IngredientFood
|
||||||
|
*/
|
||||||
|
ignore_shopping?: boolean;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -1182,7 +1194,7 @@ export interface MealPlanRecipe {
|
|||||||
* @type {any}
|
* @type {any}
|
||||||
* @memberof MealPlanRecipe
|
* @memberof MealPlanRecipe
|
||||||
*/
|
*/
|
||||||
image?: any;
|
image?: any | null;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {Array<MealPlanRecipeKeywords>}
|
* @type {Array<MealPlanRecipeKeywords>}
|
||||||
@ -1255,6 +1267,12 @@ export interface MealPlanRecipe {
|
|||||||
* @memberof MealPlanRecipe
|
* @memberof MealPlanRecipe
|
||||||
*/
|
*/
|
||||||
_new?: string;
|
_new?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof MealPlanRecipe
|
||||||
|
*/
|
||||||
|
recent?: string;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -1372,7 +1390,7 @@ export interface Recipe {
|
|||||||
* @type {any}
|
* @type {any}
|
||||||
* @memberof Recipe
|
* @memberof Recipe
|
||||||
*/
|
*/
|
||||||
image?: any;
|
image?: any | null;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {Array<RecipeKeywords>}
|
* @type {Array<RecipeKeywords>}
|
||||||
@ -1715,25 +1733,25 @@ export interface RecipeNutrition {
|
|||||||
* @type {string}
|
* @type {string}
|
||||||
* @memberof RecipeNutrition
|
* @memberof RecipeNutrition
|
||||||
*/
|
*/
|
||||||
carbohydrates?: string;
|
carbohydrates: string;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {string}
|
* @type {string}
|
||||||
* @memberof RecipeNutrition
|
* @memberof RecipeNutrition
|
||||||
*/
|
*/
|
||||||
fats?: string;
|
fats: string;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {string}
|
* @type {string}
|
||||||
* @memberof RecipeNutrition
|
* @memberof RecipeNutrition
|
||||||
*/
|
*/
|
||||||
proteins?: string;
|
proteins: string;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {string}
|
* @type {string}
|
||||||
* @memberof RecipeNutrition
|
* @memberof RecipeNutrition
|
||||||
*/
|
*/
|
||||||
calories?: string;
|
calories: string;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {string}
|
* @type {string}
|
||||||
@ -1770,7 +1788,7 @@ export interface RecipeOverview {
|
|||||||
* @type {any}
|
* @type {any}
|
||||||
* @memberof RecipeOverview
|
* @memberof RecipeOverview
|
||||||
*/
|
*/
|
||||||
image?: any;
|
image?: any | null;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {Array<MealPlanRecipeKeywords>}
|
* @type {Array<MealPlanRecipeKeywords>}
|
||||||
@ -1843,6 +1861,12 @@ export interface RecipeOverview {
|
|||||||
* @memberof RecipeOverview
|
* @memberof RecipeOverview
|
||||||
*/
|
*/
|
||||||
_new?: string;
|
_new?: string;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {string}
|
||||||
|
* @memberof RecipeOverview
|
||||||
|
*/
|
||||||
|
recent?: string;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -1918,12 +1942,6 @@ export interface RecipeSteps {
|
|||||||
* @memberof RecipeSteps
|
* @memberof RecipeSteps
|
||||||
*/
|
*/
|
||||||
name?: string;
|
name?: string;
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof RecipeSteps
|
|
||||||
*/
|
|
||||||
type?: RecipeStepsTypeEnum;
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {string}
|
* @type {string}
|
||||||
@ -1991,18 +2009,6 @@ export interface RecipeSteps {
|
|||||||
*/
|
*/
|
||||||
numrecipe?: string;
|
numrecipe?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @export
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
export enum RecipeStepsTypeEnum {
|
|
||||||
Text = 'TEXT',
|
|
||||||
Time = 'TIME',
|
|
||||||
File = 'FILE',
|
|
||||||
Recipe = 'RECIPE'
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @export
|
* @export
|
||||||
@ -2523,12 +2529,6 @@ export interface Step {
|
|||||||
* @memberof Step
|
* @memberof Step
|
||||||
*/
|
*/
|
||||||
name?: string;
|
name?: string;
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @memberof Step
|
|
||||||
*/
|
|
||||||
type?: StepTypeEnum;
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {string}
|
* @type {string}
|
||||||
@ -2596,18 +2596,6 @@ export interface Step {
|
|||||||
*/
|
*/
|
||||||
numrecipe?: string;
|
numrecipe?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @export
|
|
||||||
* @enum {string}
|
|
||||||
*/
|
|
||||||
export enum StepTypeEnum {
|
|
||||||
Text = 'TEXT',
|
|
||||||
Time = 'TIME',
|
|
||||||
File = 'FILE',
|
|
||||||
Recipe = 'RECIPE'
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @export
|
* @export
|
||||||
@ -2952,6 +2940,12 @@ export interface UserPreference {
|
|||||||
* @memberof UserPreference
|
* @memberof UserPreference
|
||||||
*/
|
*/
|
||||||
default_page?: UserPreferenceDefaultPageEnum;
|
default_page?: UserPreferenceDefaultPageEnum;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {boolean}
|
||||||
|
* @memberof UserPreference
|
||||||
|
*/
|
||||||
|
use_fractions?: boolean;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
@ -3026,10 +3020,10 @@ export interface UserPreference {
|
|||||||
mealplan_autoexclude_onhand?: boolean;
|
mealplan_autoexclude_onhand?: boolean;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {Array<number>}
|
* @type {Array<MealPlanShared>}
|
||||||
* @memberof UserPreference
|
* @memberof UserPreference
|
||||||
*/
|
*/
|
||||||
shopping_share?: Array<number>;
|
shopping_share?: Array<MealPlanShared> | null;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @type {number}
|
* @type {number}
|
||||||
@ -3054,6 +3048,18 @@ export interface UserPreference {
|
|||||||
* @memberof UserPreference
|
* @memberof UserPreference
|
||||||
*/
|
*/
|
||||||
filter_to_supermarket?: boolean;
|
filter_to_supermarket?: boolean;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {boolean}
|
||||||
|
* @memberof UserPreference
|
||||||
|
*/
|
||||||
|
shopping_add_onhand?: boolean;
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @type {boolean}
|
||||||
|
* @memberof UserPreference
|
||||||
|
*/
|
||||||
|
left_handed?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,7 +156,7 @@ export function getUserPreference(pref = undefined) {
|
|||||||
return undefined
|
return undefined
|
||||||
}
|
}
|
||||||
if (pref) {
|
if (pref) {
|
||||||
return user_preference[pref]
|
return user_preference?.[pref]
|
||||||
}
|
}
|
||||||
return user_preference
|
return user_preference
|
||||||
}
|
}
|
||||||
@ -389,6 +389,8 @@ export function getForm(model, action, item1, item2) {
|
|||||||
}
|
}
|
||||||
if (value?.form_field) {
|
if (value?.form_field) {
|
||||||
value["value"] = item1?.[value?.field] ?? undefined
|
value["value"] = item1?.[value?.field] ?? undefined
|
||||||
|
value["help"] = item1?.[value?.help_text_field] ?? value?.help_text ?? undefined
|
||||||
|
value["subtitle"] = item1?.[value?.subtitle_field] ?? value?.subtitle ?? undefined
|
||||||
form.fields.push({
|
form.fields.push({
|
||||||
...value,
|
...value,
|
||||||
...{
|
...{
|
||||||
|
Reference in New Issue
Block a user