Feature: Shopping List Label Section Improvements (#2090)

* added backend for shopping list label config

* updated codegen

* refactored shopping list ops to service
removed unique contraint
removed label settings from main route/schema
added new route for label settings

* codegen

* made sure label settings output in position order

* implemented submenu for label order drag and drop

* removed redundant label and tweaked formatting

* added view by label to user preferences

* made items draggable within each label section

* moved reorder labels to its own button

* made dialog scrollable

* fixed broken model

* refactored labels to use a service
moved shopping list label logic to service
modified label seeder to use service

* added tests

* fix for first label missing the tag icon

* fixed wrong mapped type

* added statement to create existing relationships

* fix restore test, maybe
This commit is contained in:
Michael Genson
2023-02-21 21:58:41 -06:00
committed by GitHub
parent e14851531d
commit a6c46a7420
22 changed files with 715 additions and 61 deletions

View File

@@ -14,7 +14,11 @@ from .group_events import (
from .group_exports import GroupDataExport
from .group_migration import DataMigrationCreate, SupportedMigrations
from .group_permissions import SetPermissions
from .group_preferences import CreateGroupPreferences, ReadGroupPreferences, UpdateGroupPreferences
from .group_preferences import (
CreateGroupPreferences,
ReadGroupPreferences,
UpdateGroupPreferences,
)
from .group_seeder import SeederConfig
from .group_shopping_list import (
ShoppingListAddRecipeParams,
@@ -28,6 +32,9 @@ from .group_shopping_list import (
ShoppingListItemsCollectionOut,
ShoppingListItemUpdate,
ShoppingListItemUpdateBulk,
ShoppingListMultiPurposeLabelCreate,
ShoppingListMultiPurposeLabelOut,
ShoppingListMultiPurposeLabelUpdate,
ShoppingListOut,
ShoppingListPagination,
ShoppingListRecipeRefOut,
@@ -37,8 +44,20 @@ from .group_shopping_list import (
ShoppingListUpdate,
)
from .group_statistics import GroupStatistics, GroupStorage
from .invite_token import CreateInviteToken, EmailInitationResponse, EmailInvitation, ReadInviteToken, SaveInviteToken
from .webhook import CreateWebhook, ReadWebhook, SaveWebhook, WebhookPagination, WebhookType
from .invite_token import (
CreateInviteToken,
EmailInitationResponse,
EmailInvitation,
ReadInviteToken,
SaveInviteToken,
)
from .webhook import (
CreateWebhook,
ReadWebhook,
SaveWebhook,
WebhookPagination,
WebhookType,
)
__all__ = [
"CreateGroupPreferences",
@@ -73,6 +92,9 @@ __all__ = [
"ShoppingListItemUpdate",
"ShoppingListItemUpdateBulk",
"ShoppingListItemsCollectionOut",
"ShoppingListMultiPurposeLabelCreate",
"ShoppingListMultiPurposeLabelOut",
"ShoppingListMultiPurposeLabelUpdate",
"ShoppingListOut",
"ShoppingListPagination",
"ShoppingListRecipeRefOut",

View File

@@ -9,6 +9,8 @@ from pydantic.utils import GetterDict
from mealie.db.models.group.shopping_list import ShoppingList, ShoppingListItem
from mealie.schema._mealie import MealieModel
from mealie.schema._mealie.types import NoneFloat
from mealie.schema.labels.multi_purpose_label import MultiPurposeLabelSummary
from mealie.schema.recipe.recipe import RecipeSummary
from mealie.schema.recipe.recipe_ingredient import (
INGREDIENT_QTY_PRECISION,
MAX_INGREDIENT_DENOMINATOR,
@@ -186,6 +188,23 @@ class ShoppingListItemsCollectionOut(MealieModel):
deleted_items: list[ShoppingListItemOut] = []
class ShoppingListMultiPurposeLabelCreate(MealieModel):
shopping_list_id: UUID4
label_id: UUID4
position: int = 0
class ShoppingListMultiPurposeLabelUpdate(ShoppingListMultiPurposeLabelCreate):
id: UUID4
class ShoppingListMultiPurposeLabelOut(ShoppingListMultiPurposeLabelUpdate):
label: MultiPurposeLabelSummary
class Config:
orm_mode = True
class ShoppingListItemPagination(PaginationBase):
items: list[ShoppingListItemOut]
@@ -217,6 +236,8 @@ class ShoppingListSave(ShoppingListCreate):
class ShoppingListSummary(ShoppingListSave):
id: UUID4
recipe_references: list[ShoppingListRecipeRefOut]
label_settings: list[ShoppingListMultiPurposeLabelOut]
class Config:
orm_mode = True
@@ -233,16 +254,25 @@ class ShoppingListPagination(PaginationBase):
items: list[ShoppingListSummary]
class ShoppingListUpdate(ShoppingListSummary):
class ShoppingListUpdate(ShoppingListSave):
id: UUID4
list_items: list[ShoppingListItemOut] = []
class ShoppingListOut(ShoppingListUpdate):
recipe_references: list[ShoppingListRecipeRefOut]
label_settings: list[ShoppingListMultiPurposeLabelOut]
class Config:
orm_mode = True
@classmethod
def getter_dict(cls, name_orm: ShoppingList):
return {
**GetterDict(name_orm),
"extras": {x.key_name: x.value for x in name_orm.extras},
}
class ShoppingListAddRecipeParams(MealieModel):
recipe_increment_quantity: float = 1
@@ -252,10 +282,3 @@ class ShoppingListAddRecipeParams(MealieModel):
class ShoppingListRemoveRecipeParams(MealieModel):
recipe_decrement_quantity: float = 1
from mealie.schema.labels.multi_purpose_label import MultiPurposeLabelSummary # noqa: E402
from mealie.schema.recipe.recipe import RecipeSummary # noqa: E402
ShoppingListRecipeRefOut.update_forward_refs()
ShoppingListItemOut.update_forward_refs()