diff --git a/changelog/75_UNRELEASED_xxxx-xx-xx.md b/changelog/75_UNRELEASED_xxxx-xx-xx.md index 7396b76d..12c1770d 100644 --- a/changelog/75_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/75_UNRELEASED_xxxx-xx-xx.md @@ -17,7 +17,7 @@ ### Shopping list -- xxx +- The shopping lists dropdown on the shopping list page now also shows the number of items on the corresponding shopping list ### Recipes diff --git a/controllers/StockController.php b/controllers/StockController.php index 6fb49820..fecd6e80 100644 --- a/controllers/StockController.php +++ b/controllers/StockController.php @@ -397,7 +397,7 @@ class StockController extends BaseController 'products' => $this->getDatabase()->products()->where('active = 1')->orderBy('name', 'COLLATE NOCASE'), 'quantityunits' => $this->getDatabase()->quantity_units()->orderBy('name', 'COLLATE NOCASE'), 'missingProducts' => $this->getStockService()->GetMissingProducts(), - 'shoppingLists' => $this->getDatabase()->shopping_lists()->orderBy('name', 'COLLATE NOCASE'), + 'shoppingLists' => $this->getDatabase()->shopping_lists_view()->orderBy('name', 'COLLATE NOCASE'), 'selectedShoppingListId' => $listId, 'quantityUnitConversionsResolved' => $this->getDatabase()->cache__quantity_unit_conversions_resolved(), 'productUserfields' => $this->getUserfieldsService()->GetFields('products'), diff --git a/migrations/0235.sql b/migrations/0235.sql new file mode 100644 index 00000000..9d58eb1c --- /dev/null +++ b/migrations/0235.sql @@ -0,0 +1,6 @@ +CREATE VIEW shopping_lists_view +AS +SELECT + *, + (SELECT IFNULL(COUNT(*), 0) FROM shopping_list WHERE shopping_list_id = sl.id) AS item_count +FROM shopping_lists sl; diff --git a/views/shoppinglist.blade.php b/views/shoppinglist.blade.php index 33b785fd..cadc1b9c 100644 --- a/views/shoppinglist.blade.php +++ b/views/shoppinglist.blade.php @@ -45,7 +45,7 @@