refresh shopping list when item is delayed
This commit is contained in:
@ -155,7 +155,7 @@ class FoodInheritFieldSerializer(UniqueFieldsMixin):
|
|||||||
class UserPreferenceSerializer(serializers.ModelSerializer):
|
class UserPreferenceSerializer(serializers.ModelSerializer):
|
||||||
# food_inherit_default = FoodInheritFieldSerializer(source='space.food_inherit', read_only=True)
|
# food_inherit_default = FoodInheritFieldSerializer(source='space.food_inherit', read_only=True)
|
||||||
food_ignore_default = serializers.SerializerMethodField('get_ignore_default')
|
food_ignore_default = serializers.SerializerMethodField('get_ignore_default')
|
||||||
plan_share = UserNameSerializer(many=True)
|
plan_share = UserNameSerializer(many=True, allow_null=True, required=False)
|
||||||
|
|
||||||
def get_ignore_default(self, obj):
|
def get_ignore_default(self, obj):
|
||||||
return FoodInheritFieldSerializer(Food.inherit_fields.difference(obj.space.food_inherit.all()), many=True).data
|
return FoodInheritFieldSerializer(Food.inherit_fields.difference(obj.space.food_inherit.all()), many=True).data
|
||||||
@ -604,7 +604,7 @@ class MealPlanSerializer(SpacedModelSerializer, WritableNestedModelSerializer):
|
|||||||
meal_type_name = serializers.ReadOnlyField(source='meal_type.name') # TODO deprecate once old meal plan was removed
|
meal_type_name = serializers.ReadOnlyField(source='meal_type.name') # TODO deprecate once old meal plan was removed
|
||||||
note_markdown = serializers.SerializerMethodField('get_note_markdown')
|
note_markdown = serializers.SerializerMethodField('get_note_markdown')
|
||||||
servings = CustomDecimalField()
|
servings = CustomDecimalField()
|
||||||
shared = UserNameSerializer(many=True)
|
shared = UserNameSerializer(many=True, required=False, allow_null=True)
|
||||||
|
|
||||||
def get_note_markdown(self, obj):
|
def get_note_markdown(self, obj):
|
||||||
return markdown(obj.note)
|
return markdown(obj.note)
|
||||||
|
@ -7,14 +7,18 @@ from django.urls import reverse
|
|||||||
from django_scopes import scopes_disabled
|
from django_scopes import scopes_disabled
|
||||||
from pytest_factoryboy import LazyFixture, register
|
from pytest_factoryboy import LazyFixture, register
|
||||||
|
|
||||||
from cookbook.models import Food, ShoppingListEntry
|
from cookbook.models import ShoppingListEntry
|
||||||
from cookbook.tests.factories import ShoppingListEntryFactory
|
from cookbook.tests.factories import FoodFactory, ShoppingListEntryFactory
|
||||||
|
|
||||||
LIST_URL = 'api:shoppinglistentry-list'
|
LIST_URL = 'api:shoppinglistentry-list'
|
||||||
DETAIL_URL = 'api:shoppinglistentry-detail'
|
DETAIL_URL = 'api:shoppinglistentry-detail'
|
||||||
|
|
||||||
|
# register(FoodFactory, 'food_1', space=LazyFixture('space_1'))
|
||||||
|
# register(FoodFactory, 'food_2', space=LazyFixture('space_1'))
|
||||||
|
# register(ShoppingListEntryFactory, 'sle_1', space=LazyFixture('space_1'), food=LazyFixture('food_1'))
|
||||||
|
# register(ShoppingListEntryFactory, 'sle_2', space=LazyFixture('space_1'), food=LazyFixture('food_2'))
|
||||||
register(ShoppingListEntryFactory, 'sle_1', space=LazyFixture('space_1'))
|
register(ShoppingListEntryFactory, 'sle_1', space=LazyFixture('space_1'))
|
||||||
register(ShoppingListEntryFactory, 'sle_2', space=LazyFixture('space_2'))
|
register(ShoppingListEntryFactory, 'sle_2', space=LazyFixture('space_1'))
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("arg", [
|
@pytest.mark.parametrize("arg", [
|
||||||
@ -28,25 +32,25 @@ def test_list_permission(arg, request):
|
|||||||
assert c.get(reverse(LIST_URL)).status_code == arg[1]
|
assert c.get(reverse(LIST_URL)).status_code == arg[1]
|
||||||
|
|
||||||
|
|
||||||
def test_list_space(sle_1, sle_2, u1_s1, u1_s2, space_2):
|
def test_list_space(sle_1, u1_s1, u1_s2, space_2):
|
||||||
assert len(json.loads(u1_s1.get(reverse(LIST_URL)).content)) == 2
|
assert json.loads(u1_s1.get(reverse(LIST_URL)).content)['count'] == 2
|
||||||
assert len(json.loads(u1_s2.get(reverse(LIST_URL)).content)) == 0
|
assert json.loads(u1_s2.get(reverse(LIST_URL)).content)['count'] == 0
|
||||||
|
|
||||||
with scopes_disabled():
|
with scopes_disabled():
|
||||||
e = ShoppingListEntry.objects.first()
|
e = ShoppingListEntry.objects.first()
|
||||||
e.space = space_2
|
e.space = space_2
|
||||||
e.save()
|
e.save()
|
||||||
|
|
||||||
assert len(json.loads(u1_s1.get(reverse(LIST_URL)).content)) == 1
|
assert json.loads(u1_s1.get(reverse(LIST_URL)).content)['count'] == 1
|
||||||
assert len(json.loads(u1_s2.get(reverse(LIST_URL)).content)) == 0
|
assert json.loads(u1_s2.get(reverse(LIST_URL)).content)['count'] == 0
|
||||||
|
|
||||||
|
|
||||||
def test_get_detail(sle_1):
|
def test_get_detail(u1_s1, sle_1):
|
||||||
# r = u1_s1.get(reverse(
|
# r = u1_s1.get(reverse(
|
||||||
# DETAIL_URL,
|
# DETAIL_URL,
|
||||||
# args={sle_1.id}
|
# args={sle_1.id}
|
||||||
# ))
|
# ))
|
||||||
# assert sle_1.id == 1
|
# assert json.loads(r.content)['id'] == sle_1.id
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@ -15,6 +15,7 @@ from cookbook.tests.factories import SpaceFactory
|
|||||||
register(SpaceFactory, 'space_1')
|
register(SpaceFactory, 'space_1')
|
||||||
register(SpaceFactory, 'space_2')
|
register(SpaceFactory, 'space_2')
|
||||||
|
|
||||||
|
# TODO refactor user fixtures https://stackoverflow.com/questions/40966571/how-to-create-a-field-with-a-list-of-instances-in-factory-boy
|
||||||
|
|
||||||
# hack from https://github.com/raphaelm/django-scopes to disable scopes for all fixtures
|
# hack from https://github.com/raphaelm/django-scopes to disable scopes for all fixtures
|
||||||
# does not work on yield fixtures as only one yield can be used per fixture (i think)
|
# does not work on yield fixtures as only one yield can be used per fixture (i think)
|
||||||
|
@ -71,16 +71,16 @@ class FoodFactory(factory.django.DjangoModelFactory):
|
|||||||
"""Food factory."""
|
"""Food factory."""
|
||||||
name = factory.LazyAttribute(lambda x: faker.sentence(nb_words=3))
|
name = factory.LazyAttribute(lambda x: faker.sentence(nb_words=3))
|
||||||
description = factory.LazyAttribute(lambda x: faker.sentence(nb_words=10))
|
description = factory.LazyAttribute(lambda x: faker.sentence(nb_words=10))
|
||||||
supermarket_category = factory.Maybe(
|
# supermarket_category = factory.Maybe(
|
||||||
factory.LazyAttribute(lambda x: x.has_category),
|
# factory.LazyAttribute(lambda x: x.has_category),
|
||||||
yes_declaration=factory.SubFactory(SupermarketCategoryFactory),
|
# yes_declaration=factory.SubFactory(SupermarketCategoryFactory, space=factory.SelfAttribute('..space')),
|
||||||
no_declaration=None
|
# no_declaration=None
|
||||||
)
|
# )
|
||||||
recipe = factory.Maybe(
|
# recipe = factory.Maybe(
|
||||||
factory.LazyAttribute(lambda x: x.has_recipe),
|
# factory.LazyAttribute(lambda x: x.has_recipe),
|
||||||
yes_declaration=factory.SubFactory('cookbook.tests.factories.RecipeFactory'),
|
# yes_declaration=factory.SubFactory('cookbook.tests.factories.RecipeFactory', space=factory.SelfAttribute('..space')),
|
||||||
no_declaration=None
|
# no_declaration=None
|
||||||
)
|
# )
|
||||||
space = factory.SubFactory(SpaceFactory)
|
space = factory.SubFactory(SpaceFactory)
|
||||||
|
|
||||||
class Params:
|
class Params:
|
||||||
@ -114,8 +114,8 @@ class KeywordFactory(factory.django.DjangoModelFactory):
|
|||||||
|
|
||||||
class IngredientFactory(factory.django.DjangoModelFactory):
|
class IngredientFactory(factory.django.DjangoModelFactory):
|
||||||
"""Ingredient factory."""
|
"""Ingredient factory."""
|
||||||
food = factory.SubFactory(FoodFactory)
|
food = factory.SubFactory(FoodFactory, space=factory.SelfAttribute('..space'))
|
||||||
unit = factory.SubFactory(UnitFactory)
|
unit = factory.SubFactory(UnitFactory, space=factory.SelfAttribute('..space'))
|
||||||
amount = factory.LazyAttribute(lambda x: faker.random_int(min=1, max=10))
|
amount = factory.LazyAttribute(lambda x: faker.random_int(min=1, max=10))
|
||||||
note = factory.LazyAttribute(lambda x: faker.sentence(nb_words=5))
|
note = factory.LazyAttribute(lambda x: faker.sentence(nb_words=5))
|
||||||
space = factory.SubFactory(SpaceFactory)
|
space = factory.SubFactory(SpaceFactory)
|
||||||
@ -130,7 +130,7 @@ class MealTypeFactory(factory.django.DjangoModelFactory):
|
|||||||
# icon =
|
# icon =
|
||||||
color = factory.LazyAttribute(lambda x: faker.safe_hex_color())
|
color = factory.LazyAttribute(lambda x: faker.safe_hex_color())
|
||||||
default = False
|
default = False
|
||||||
created_by = factory.SubFactory(UserFactory)
|
created_by = factory.SubFactory(UserFactory, space=factory.SelfAttribute('..space'))
|
||||||
space = factory.SubFactory(SpaceFactory)
|
space = factory.SubFactory(SpaceFactory)
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
@ -140,13 +140,13 @@ class MealTypeFactory(factory.django.DjangoModelFactory):
|
|||||||
class MealPlanFactory(factory.django.DjangoModelFactory):
|
class MealPlanFactory(factory.django.DjangoModelFactory):
|
||||||
recipe = factory.Maybe(
|
recipe = factory.Maybe(
|
||||||
factory.LazyAttribute(lambda x: x.has_recipe),
|
factory.LazyAttribute(lambda x: x.has_recipe),
|
||||||
yes_declaration=factory.SubFactory('cookbook.tests.factories.RecipeFactory'),
|
yes_declaration=factory.SubFactory('cookbook.tests.factories.RecipeFactory', space=factory.SelfAttribute('..space')),
|
||||||
no_declaration=None
|
no_declaration=None
|
||||||
)
|
)
|
||||||
servings = factory.LazyAttribute(lambda x: Decimal(faker.random_int(min=1, max=1000)/100))
|
servings = factory.LazyAttribute(lambda x: Decimal(faker.random_int(min=1, max=1000)/100))
|
||||||
title = factory.LazyAttribute(lambda x: faker.sentence(nb_words=5))
|
title = factory.LazyAttribute(lambda x: faker.sentence(nb_words=5))
|
||||||
created_by = factory.SubFactory(UserFactory)
|
created_by = factory.SubFactory(UserFactory, space=factory.SelfAttribute('..space'))
|
||||||
meal_type = factory.SubFactory(MealTypeFactory)
|
meal_type = factory.SubFactory(MealTypeFactory, space=factory.SelfAttribute('..space'))
|
||||||
note = factory.LazyAttribute(lambda x: faker.paragraph())
|
note = factory.LazyAttribute(lambda x: faker.paragraph())
|
||||||
date = factory.LazyAttribute(lambda x: faker.future_date())
|
date = factory.LazyAttribute(lambda x: faker.future_date())
|
||||||
space = factory.SubFactory(SpaceFactory)
|
space = factory.SubFactory(SpaceFactory)
|
||||||
@ -162,11 +162,11 @@ class ShoppingListRecipeFactory(factory.django.DjangoModelFactory):
|
|||||||
name = factory.LazyAttribute(lambda x: faker.sentence(nb_words=5))
|
name = factory.LazyAttribute(lambda x: faker.sentence(nb_words=5))
|
||||||
recipe = factory.Maybe(
|
recipe = factory.Maybe(
|
||||||
factory.LazyAttribute(lambda x: x.has_recipe),
|
factory.LazyAttribute(lambda x: x.has_recipe),
|
||||||
yes_declaration=factory.SubFactory('cookbook.tests.factories.RecipeFactory'),
|
yes_declaration=factory.SubFactory('cookbook.tests.factories.RecipeFactory', space=factory.SelfAttribute('..space')),
|
||||||
no_declaration=None
|
no_declaration=None
|
||||||
)
|
)
|
||||||
servings = factory.LazyAttribute(lambda x: faker.random_int(min=1, max=10))
|
servings = factory.LazyAttribute(lambda x: faker.random_int(min=1, max=10))
|
||||||
mealplan = factory.SubFactory(MealPlanFactory)
|
mealplan = factory.SubFactory(MealPlanFactory, space=factory.SelfAttribute('..space'))
|
||||||
|
|
||||||
class Params:
|
class Params:
|
||||||
has_recipe = False
|
has_recipe = False
|
||||||
@ -177,22 +177,23 @@ class ShoppingListRecipeFactory(factory.django.DjangoModelFactory):
|
|||||||
|
|
||||||
class ShoppingListEntryFactory(factory.django.DjangoModelFactory):
|
class ShoppingListEntryFactory(factory.django.DjangoModelFactory):
|
||||||
"""ShoppingListEntry factory."""
|
"""ShoppingListEntry factory."""
|
||||||
list_recipe = factory.Maybe(
|
|
||||||
factory.LazyAttribute(lambda x: x.has_mealplan),
|
# list_recipe = factory.Maybe(
|
||||||
yes_declaration=factory.SubFactory(ShoppingListRecipeFactory),
|
# factory.LazyAttribute(lambda x: x.has_mealplan),
|
||||||
no_declaration=None
|
# yes_declaration=factory.SubFactory(ShoppingListRecipeFactory, space=factory.SelfAttribute('..space')),
|
||||||
)
|
# no_declaration=None
|
||||||
food = factory.SubFactory(FoodFactory)
|
# )
|
||||||
unit = factory.SubFactory(UnitFactory)
|
food = factory.SubFactory(FoodFactory, space=factory.SelfAttribute('..space'))
|
||||||
# ingredient = factory.SubFactory(IngredientFactory)
|
# unit = factory.SubFactory(UnitFactory, space=factory.SelfAttribute('..space'))
|
||||||
amount = factory.LazyAttribute(lambda x: Decimal(faker.random_int(min=1, max=10))/100)
|
# # ingredient = factory.SubFactory(IngredientFactory)
|
||||||
order = 0
|
# amount = factory.LazyAttribute(lambda x: Decimal(faker.random_int(min=1, max=10))/100)
|
||||||
checked = False
|
# order = 0
|
||||||
created_by = factory.SubFactory(UserFactory)
|
# checked = False
|
||||||
created_at = factory.LazyAttribute(lambda x: faker.past_date())
|
# created_by = factory.SubFactory(UserFactory, space=factory.SelfAttribute('..space'))
|
||||||
completed_at = None
|
# created_at = factory.LazyAttribute(lambda x: faker.past_date())
|
||||||
delay_until = None
|
# completed_at = None
|
||||||
space = factory.SubFactory(SpaceFactory)
|
# delay_until = None
|
||||||
|
space = factory.SubFactory('cookbook.tests.factories.SpaceFactory')
|
||||||
|
|
||||||
class Params:
|
class Params:
|
||||||
has_mealplan = False
|
has_mealplan = False
|
||||||
@ -209,14 +210,14 @@ class StepFactory(factory.django.DjangoModelFactory):
|
|||||||
# max_length=16
|
# max_length=16
|
||||||
# )
|
# )
|
||||||
instruction = factory.LazyAttribute(lambda x: ''.join(faker.paragraphs(nb=5)))
|
instruction = factory.LazyAttribute(lambda x: ''.join(faker.paragraphs(nb=5)))
|
||||||
ingredients = factory.SubFactory(IngredientFactory)
|
ingredients = factory.SubFactory(IngredientFactory, space=factory.SelfAttribute('..space'))
|
||||||
time = factory.LazyAttribute(lambda x: faker.random_int(min=1, max=1000))
|
time = factory.LazyAttribute(lambda x: faker.random_int(min=1, max=1000))
|
||||||
order = 0
|
order = 0
|
||||||
# file = models.ForeignKey('UserFile', on_delete=models.PROTECT, null=True, blank=True)
|
# file = models.ForeignKey('UserFile', on_delete=models.PROTECT, null=True, blank=True)
|
||||||
show_as_header = True
|
show_as_header = True
|
||||||
step_recipe = factory.Maybe(
|
step_recipe = factory.Maybe(
|
||||||
factory.LazyAttribute(lambda x: x.has_recipe),
|
factory.LazyAttribute(lambda x: x.has_recipe),
|
||||||
yes_declaration=factory.SubFactory('cookbook.tests.factories.RecipeFactory'),
|
yes_declaration=factory.SubFactory('cookbook.tests.factories.RecipeFactory', space=factory.SelfAttribute('..space')),
|
||||||
no_declaration=None
|
no_declaration=None
|
||||||
)
|
)
|
||||||
space = factory.SubFactory(SpaceFactory)
|
space = factory.SubFactory(SpaceFactory)
|
||||||
@ -241,15 +242,15 @@ class RecipeFactory(factory.django.DjangoModelFactory):
|
|||||||
# file_path = models.CharField(max_length=512, default="", blank=True)
|
# file_path = models.CharField(max_length=512, default="", blank=True)
|
||||||
# link = models.CharField(max_length=512, null=True, blank=True)
|
# link = models.CharField(max_length=512, null=True, blank=True)
|
||||||
# cors_link = models.CharField(max_length=1024, null=True, blank=True)
|
# cors_link = models.CharField(max_length=1024, null=True, blank=True)
|
||||||
keywords = factory.SubFactory(KeywordFactory)
|
keywords = factory.SubFactory(KeywordFactory, space=factory.SelfAttribute('..space'))
|
||||||
steps = factory.SubFactory(StepFactory)
|
steps = factory.SubFactory(StepFactory, space=factory.SelfAttribute('..space'))
|
||||||
working_time = factory.LazyAttribute(lambda x: faker.random_int(min=0, max=360))
|
working_time = factory.LazyAttribute(lambda x: faker.random_int(min=0, max=360))
|
||||||
waiting_time = factory.LazyAttribute(lambda x: faker.random_int(min=0, max=360))
|
waiting_time = factory.LazyAttribute(lambda x: faker.random_int(min=0, max=360))
|
||||||
internal = False
|
internal = False
|
||||||
# nutrition = models.ForeignKey(
|
# nutrition = models.ForeignKey(
|
||||||
# NutritionInformation, blank=True, null=True, on_delete=models.CASCADE
|
# NutritionInformation, blank=True, null=True, on_delete=models.CASCADE
|
||||||
# )
|
# )
|
||||||
created_by = factory.SubFactory(UserFactory)
|
created_by = factory.SubFactory(UserFactory, space=factory.SelfAttribute('..space'))
|
||||||
created_at = factory.LazyAttribute(lambda x: faker.date_this_decade())
|
created_at = factory.LazyAttribute(lambda x: faker.date_this_decade())
|
||||||
# updated_at = models.DateTimeField(auto_now=True)
|
# updated_at = models.DateTimeField(auto_now=True)
|
||||||
space = factory.SubFactory(SpaceFactory)
|
space = factory.SubFactory(SpaceFactory)
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
<b-button variant="link" class="px-0">
|
<b-button variant="link" class="px-0">
|
||||||
<i class="btn fas fa-plus-circle fa-lg px-0" @click="entrymode = !entrymode" :class="entrymode ? 'text-success' : 'text-muted'" />
|
<i class="btn fas fa-plus-circle fa-lg px-0" @click="entrymode = !entrymode" :class="entrymode ? 'text-success' : 'text-muted'" />
|
||||||
</b-button>
|
</b-button>
|
||||||
|
<b-button variant="link" class="px-0 text-muted">
|
||||||
|
<i class="btn fas fa-download fa-lg px-0" @click="entrymode = !entrymode" />
|
||||||
|
</b-button>
|
||||||
<b-button variant="link" id="id_filters_button" class="px-0">
|
<b-button variant="link" id="id_filters_button" class="px-0">
|
||||||
<i class="btn fas fa-filter text-decoration-none fa-lg px-0" :class="filterApplied ? 'text-danger' : 'text-muted'" />
|
<i class="btn fas fa-filter text-decoration-none fa-lg px-0" :class="filterApplied ? 'text-danger' : 'text-muted'" />
|
||||||
</b-button>
|
</b-button>
|
||||||
@ -170,12 +173,7 @@
|
|||||||
</b-card>
|
</b-card>
|
||||||
|
|
||||||
<b-card-sub-title v-if="new_supermarket.editmode" class="pt-0 pb-3">{{ $t("CategoryInstruction") }}</b-card-sub-title>
|
<b-card-sub-title v-if="new_supermarket.editmode" class="pt-0 pb-3">{{ $t("CategoryInstruction") }}</b-card-sub-title>
|
||||||
<b-card
|
<b-card v-if="new_supermarket.editmode && supermarketCategory.length === 0" class="m-0 p-0 font-weight-bold no-body" border-variant="success" v-bind:key="-1" />
|
||||||
v-if="new_supermarket.editmode && supermarketCategory.length === 0"
|
|
||||||
class="m-0 p-0 font-weight-bold no-body"
|
|
||||||
border-variant="success"
|
|
||||||
v-bind:key="-1"
|
|
||||||
/>
|
|
||||||
<draggable
|
<draggable
|
||||||
class="list-group"
|
class="list-group"
|
||||||
:list="supermarketCategory"
|
:list="supermarketCategory"
|
||||||
@ -198,13 +196,8 @@
|
|||||||
</b-card>
|
</b-card>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
</draggable>
|
</draggable>
|
||||||
<hr style="height:2px;;background-color:black" v-if="new_supermarket.editmode" />
|
<hr style="height: 2px; background-color: black" v-if="new_supermarket.editmode" />
|
||||||
<b-card
|
<b-card v-if="new_supermarket.editmode && notSupermarketCategory.length === 0" v-bind:key="-2" class="m-0 p-0 font-weight-bold no-body" border-variant="danger" />
|
||||||
v-if="new_supermarket.editmode && notSupermarketCategory.length === 0"
|
|
||||||
v-bind:key="-2"
|
|
||||||
class="m-0 p-0 font-weight-bold no-body"
|
|
||||||
border-variant="danger"
|
|
||||||
/>
|
|
||||||
<draggable
|
<draggable
|
||||||
class="list-group"
|
class="list-group"
|
||||||
:list="notSupermarketCategory"
|
:list="notSupermarketCategory"
|
||||||
@ -216,13 +209,7 @@
|
|||||||
v-bind="{ animation: 200 }"
|
v-bind="{ animation: 200 }"
|
||||||
>
|
>
|
||||||
<transition-group type="transition" :name="!drag ? 'flip-list' : null">
|
<transition-group type="transition" :name="!drag ? 'flip-list' : null">
|
||||||
<b-card
|
<b-card class="m-0 p-0 font-weight-bold no-body list-group-item" style="cursor: move" v-for="c in notSupermarketCategory" v-bind:key="c.id" :border-variant="'danger'">
|
||||||
class="m-0 p-0 font-weight-bold no-body list-group-item"
|
|
||||||
style="cursor:move"
|
|
||||||
v-for="c in notSupermarketCategory"
|
|
||||||
v-bind:key="c.id"
|
|
||||||
:border-variant="'danger'"
|
|
||||||
>
|
|
||||||
{{ categoryName(c) }}
|
{{ categoryName(c) }}
|
||||||
</b-card>
|
</b-card>
|
||||||
</transition-group>
|
</transition-group>
|
||||||
@ -376,7 +363,7 @@
|
|||||||
</b-form-group>
|
</b-form-group>
|
||||||
</div>
|
</div>
|
||||||
<div class="row" style="margin-top: 1vh; min-width: 300px">
|
<div class="row" style="margin-top: 1vh; min-width: 300px">
|
||||||
<div class="col-12 " style="text-align: right;">
|
<div class="col-12" style="text-align: right">
|
||||||
<b-button size="sm" variant="primary" class="mx-1" @click="resetFilters">{{ $t("Reset") }} </b-button>
|
<b-button size="sm" variant="primary" class="mx-1" @click="resetFilters">{{ $t("Reset") }} </b-button>
|
||||||
<b-button size="sm" variant="secondary" class="mr-3" @click="$root.$emit('bv::hide::popover')">{{ $t("Close") }} </b-button>
|
<b-button size="sm" variant="secondary" class="mr-3" @click="$root.$emit('bv::hide::popover')">{{ $t("Close") }} </b-button>
|
||||||
</div>
|
</div>
|
||||||
@ -575,7 +562,7 @@ export default {
|
|||||||
return groups
|
return groups
|
||||||
},
|
},
|
||||||
defaultDelay() {
|
defaultDelay() {
|
||||||
return getUserPreference("default_delay") || 2
|
return Number(getUserPreference("default_delay")) || 2
|
||||||
},
|
},
|
||||||
formUnit() {
|
formUnit() {
|
||||||
let unit = this.Models.SHOPPING_LIST.create.form.unit
|
let unit = this.Models.SHOPPING_LIST.create.form.unit
|
||||||
@ -688,18 +675,24 @@ export default {
|
|||||||
delayThis: function (item) {
|
delayThis: function (item) {
|
||||||
let entries = []
|
let entries = []
|
||||||
let promises = []
|
let promises = []
|
||||||
|
let delay_date = new Date(Date.now() + this.delay * (60 * 60 * 1000))
|
||||||
|
|
||||||
if (Array.isArray(item)) {
|
if (Array.isArray(item)) {
|
||||||
|
item = item.map((x) => {
|
||||||
|
return { ...x, delay_until: delay_date }
|
||||||
|
})
|
||||||
entries = item.map((x) => x.id)
|
entries = item.map((x) => x.id)
|
||||||
} else {
|
} else {
|
||||||
|
item.delay_until = delay_date
|
||||||
entries = [item.id]
|
entries = [item.id]
|
||||||
}
|
}
|
||||||
let delay_date = new Date(Date.now() + this.delay * (60 * 60 * 1000))
|
|
||||||
|
|
||||||
entries.forEach((entry) => {
|
entries.forEach((entry) => {
|
||||||
promises.push(this.saveThis({ id: entry, delay_until: delay_date }, false))
|
promises.push(this.saveThis({ id: entry, delay_until: delay_date }, false))
|
||||||
})
|
})
|
||||||
Promise.all(promises).then(() => {
|
Promise.all(promises).then(() => {
|
||||||
StandardToasts.makeStandardToast(StandardToasts.SUCCESS_UPDATE)
|
StandardToasts.makeStandardToast(StandardToasts.SUCCESS_UPDATE)
|
||||||
|
this.items = this.items.filter((x) => !entries.includes(x.id))
|
||||||
this.delay = this.defaultDelay
|
this.delay = this.defaultDelay
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
@ -1,76 +1,40 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
|
||||||
<div class="dropdown d-print-none">
|
<div class="dropdown d-print-none">
|
||||||
<a class="btn shadow-none" href="javascript:void(0);" role="button" id="dropdownMenuLink"
|
<a class="btn shadow-none" href="javascript:void(0);" role="button" id="dropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
||||||
<i class="fas fa-ellipsis-v fa-lg"></i>
|
<i class="fas fa-ellipsis-v fa-lg"></i>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuLink">
|
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenuLink">
|
||||||
|
<a class="dropdown-item" :href="resolveDjangoUrl('edit_recipe', recipe.id)"><i class="fas fa-pencil-alt fa-fw"></i> {{ $t("Edit") }}</a>
|
||||||
|
|
||||||
<a class="dropdown-item" :href="resolveDjangoUrl('edit_recipe', recipe.id)"><i
|
<a class="dropdown-item" :href="resolveDjangoUrl('edit_convert_recipe', recipe.id)" v-if="!recipe.internal"><i class="fas fa-exchange-alt fa-fw"></i> {{ $t("convert_internal") }}</a>
|
||||||
class="fas fa-pencil-alt fa-fw"></i> {{ $t('Edit') }}</a>
|
|
||||||
|
|
||||||
<a class="dropdown-item" :href="resolveDjangoUrl('edit_convert_recipe', recipe.id)" v-if="!recipe.internal"><i
|
|
||||||
class="fas fa-exchange-alt fa-fw"></i> {{ $t('convert_internal') }}</a>
|
|
||||||
|
|
||||||
<a href="javascript:void(0);">
|
<a href="javascript:void(0);">
|
||||||
<button class="dropdown-item" @click="$bvModal.show(`id_modal_add_book_${modal_id}`)">
|
<button class="dropdown-item" @click="$bvModal.show(`id_modal_add_book_${modal_id}`)"><i class="fas fa-bookmark fa-fw"></i> {{ $t("Manage_Books") }}</button>
|
||||||
<i class="fas fa-bookmark fa-fw"></i> {{ $t('Manage_Books') }}
|
|
||||||
</button>
|
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a class="dropdown-item" :href="`${resolveDjangoUrl('view_shopping') }?r=[${recipe.id},${servings_value}]`"
|
<a class="dropdown-item" :href="`${resolveDjangoUrl('view_shopping')}?r=[${recipe.id},${servings_value}]`" v-if="recipe.internal" target="_blank" rel="noopener noreferrer">
|
||||||
v-if="recipe.internal" target="_blank" rel="noopener noreferrer">
|
<i class="fas fa-shopping-cart fa-fw"></i> {{ $t("Add_to_Shopping") }}
|
||||||
<i class="fas fa-shopping-cart fa-fw"></i> {{ $t('Add_to_Shopping') }}
|
|
||||||
</a>
|
</a>
|
||||||
<a class="dropdown-item" v-if="recipe.internal" @click="addToShopping" href="#"> <i class="fas fa-shopping-cart fa-fw"></i> New {{ $t("create_shopping_new") }} </a>
|
<a class="dropdown-item" v-if="recipe.internal" @click="addToShopping" href="#"> <i class="fas fa-shopping-cart fa-fw"></i> New {{ $t("create_shopping_new") }} </a>
|
||||||
|
|
||||||
|
<a class="dropdown-item" @click="createMealPlan" href="javascript:void(0);"><i class="fas fa-calendar fa-fw"></i> {{ $t("Add_to_Plan") }} </a>
|
||||||
|
|
||||||
<a class="dropdown-item" @click="createMealPlan" href="javascript:void(0);"><i
|
<a href="javascript:void(0);">
|
||||||
class="fas fa-calendar fa-fw"></i> {{ $t('Add_to_Plan') }}
|
<button class="dropdown-item" @click="$bvModal.show(`id_modal_cook_log_${modal_id}`)"><i class="fas fa-clipboard-list fa-fw"></i> {{ $t("Log_Cooking") }}</button>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="javascript:void(0);">
|
<a href="javascript:void(0);">
|
||||||
<button class="dropdown-item" @click="$bvModal.show(`id_modal_cook_log_${modal_id}`)"><i
|
<button class="dropdown-item" onclick="window.print()"><i class="fas fa-print fa-fw"></i> {{ $t("Print") }}</button>
|
||||||
class="fas fa-clipboard-list fa-fw"></i> {{ $t('Log_Cooking') }}
|
|
||||||
</button>
|
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<a href="javascript:void(0);">
|
<a class="dropdown-item" :href="resolveDjangoUrl('view_export') + '?r=' + recipe.id" target="_blank" rel="noopener noreferrer"><i class="fas fa-file-export fa-fw"></i> {{ $t("Export") }}</a>
|
||||||
<button class="dropdown-item" onclick="window.print()"><i
|
|
||||||
class="fas fa-print fa-fw"></i> {{ $t('Print') }}
|
|
||||||
</button>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<a class="dropdown-item" :href="resolveDjangoUrl('view_export') + '?r=' + recipe.id" target="_blank"
|
|
||||||
rel="noopener noreferrer"><i class="fas fa-file-export fa-fw"></i> {{ $t('Export') }}</a>
|
|
||||||
|
|
||||||
<a href="javascript:void(0);">
|
<a href="javascript:void(0);">
|
||||||
<button class="dropdown-item" @click="createShareLink()" v-if="recipe.internal"><i
|
<button class="dropdown-item" @click="createShareLink()" v-if="recipe.internal"><i class="fas fa-share-alt fa-fw"></i> {{ $t("Share") }}</button>
|
||||||
class="fas fa-share-alt fa-fw"></i> {{ $t('Share') }}
|
|
||||||
</button>
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<cook-log :recipe="recipe" :modal_id="modal_id"></cook-log>
|
|
||||||
<add-recipe-to-book :recipe="recipe" :modal_id="modal_id"></add-recipe-to-book>
|
|
||||||
|
|
||||||
<b-modal :id="`modal-share-link_${modal_id}`" v-bind:title="$t('Share')" hide-footer>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col col-md-12">
|
|
||||||
<label v-if="recipe_share_link !== undefined">{{ $t('Public share link') }}</label>
|
|
||||||
<input ref="share_link_ref" class="form-control" v-model="recipe_share_link"/>
|
|
||||||
<b-button class="mt-2 mb-3 d-none d-md-inline" variant="secondary"
|
|
||||||
@click="$bvModal.hide(`modal-share-link_${modal_id}`)">{{ $t('Close') }}
|
|
||||||
</b-button>
|
|
||||||
<b-button class="mt-2 mb-3 ml-md-2" variant="primary" @click="copyShareLink()">{{ $t('Copy') }}</b-button>
|
|
||||||
<b-button class="mt-2 mb-3 ml-2 float-right" variant="success" @click="shareIntend()">{{ $t('Share') }} <i
|
|
||||||
class="fa fa-share-alt"></i></b-button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<cook-log :recipe="recipe" :modal_id="modal_id"></cook-log>
|
<cook-log :recipe="recipe" :modal_id="modal_id"></cook-log>
|
||||||
|
Reference in New Issue
Block a user