Mercurial > libervia-web
comparison libervia/pages/lists/view/_browser/__init__.py @ 1412:6fdef01f6671
browser (lists/view): Q&D fix for status change
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 22 Apr 2021 21:37:50 +0200 |
parents | 4ccf42d8aab7 |
children | 0f3038f3a954 |
comparison
equal
deleted
inserted
replaced
1411:2c3bdba880bb | 1412:6fdef01f6671 |
---|---|
86 except (KeyError, IndexError) as e: | 86 except (KeyError, IndexError) as e: |
87 dialog.notification.show( | 87 dialog.notification.show( |
88 f"Can't get item status: {e}", | 88 f"Can't get item status: {e}", |
89 level="error" | 89 level="error" |
90 ) | 90 ) |
91 status = "to_buy" | 91 status = ["to_buy"] |
92 if status == "to_buy": | 92 if status == ["to_buy"]: |
93 item["status"] = "bought" | 93 item["status"] = ["bought"] |
94 class_update_method = item_elt.classList.add | 94 class_update_method = item_elt.classList.add |
95 checked = True | 95 checked = True |
96 elif status == "bought": | 96 elif status == ["bought"]: |
97 item["status"] = "to_buy" | 97 item["status"] = ["to_buy"] |
98 checked = False | 98 checked = False |
99 class_update_method = item_elt.classList.remove | 99 class_update_method = item_elt.classList.remove |
100 else: | 100 else: |
101 print(status) | |
102 dialog.notification.show( | 101 dialog.notification.show( |
103 f"unexpected item status: {status!r}", | 102 f"unexpected item status: {status!r}", |
104 level="error" | 103 level="error" |
105 ) | 104 ) |
106 return | 105 return |
107 item_elt.dataset.item = JSON.stringify(item) | 106 item_elt.dataset.item = JSON.stringify(item) |
108 try: | 107 try: |
109 await bridge.listSet( | 108 await bridge.listSet( |
110 pubsub_service, | 109 pubsub_service, |
111 pubsub_node, | 110 pubsub_node, |
112 {k: [v] for k,v in item.items()}, | 111 # FIXME: value type should be consistent, or we should serialise |
112 {k: (v if isinstance(v, list) else [v]) for k,v in item.items()}, | |
113 "", | 113 "", |
114 item["id"], | 114 item["id"], |
115 "" | 115 "" |
116 ) | 116 ) |
117 except BridgeException as e: | 117 except BridgeException as e: |