Mercurial > libervia-web
diff libervia/pages/lists/view/page_meta.py @ 1395:4ccf42d8aab7
browser (lists/view): `grocery` list specialised behaviour:
if the list is a `grocery` list, user can change status directly in list view, delete an
item, and do a quick item creation without having to use the `create` button.
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 27 Feb 2021 21:08:42 +0100 |
parents | ac4173fff71d |
children | d62df81440c6 915c7c2f1729 |
line wrap: on
line diff
--- a/libervia/pages/lists/view/page_meta.py Sat Feb 27 21:06:45 2021 +0100 +++ b/libervia/pages/lists/view/page_meta.py Sat Feb 27 21:08:42 2021 +0100 @@ -119,3 +119,28 @@ pubsub_node=node, list_type=list_type, ) + + +async def on_data_post(self, request): + data = self.getRData(request) + profile = self.getProfile(request) + service = data["service"] + node = data["node"] + list_type = self.getPostedData(request, ("type",)) + if list_type == "grocery": + name, quantity = self.getPostedData(request, ("name", "quantity")) + if not name: + self.pageError(request, C.HTTP_BAD_REQUEST) + item_data = { + "name": [name], + } + if quantity: + item_data["quantity"] = [quantity] + await self.host.bridgeCall( + "listSet", service.full(), node, item_data, "", "", "", profile + ) + return C.POST_NO_CONFIRM + else: + raise NotImplementedError( + f"Can't use quick list item set for list of type {list_type!r}" + )