Skip to content
Snippets Groups Projects

Refactor Cart into checkerboard table

Merged Mateusz Kudela requested to merge mkudela/issue-173 into develop
Compare and Show latest version
1 file
+ 5
4
Compare changes
  • Side-by-side
  • Inline
@@ -214,7 +214,7 @@ class CartTable(CliveCheckerboardTable):
@staticmethod
def _create_widget_id_to_focus(event: CartItem.Focus | CartItem.Move) -> str:
assert event.button_to_focus is not None, "Button to focus has to be passed to get it's id."
return event.button_to_focus
return f"#{event.button_to_focus}"
def _disable_appropriate_button(self, widget: CartItem) -> None:
if len(self.app.world.profile.cart) > 0 and widget.reactive_idx == 0:
@@ -247,7 +247,8 @@ class CartTable(CliveCheckerboardTable):
for cells, data in [(to_cells, from_data), (from_cells, to_data)]:
for cell, value in zip(cells, data):
cell.update_content(value) # type: ignore[arg-type]
assert isinstance(value, str), "New value for cell has to be a string."
cell.update_content(value)
async def _remove_operation_from_everywhere(self, widget: CartItem) -> None:
self._rows.remove(widget)
@@ -275,7 +276,7 @@ class CartTable(CliveCheckerboardTable):
self.app.set_focus(cart_item)
if event.button_to_focus:
button_id = self._create_widget_id_to_focus(event)
cart_item.query_one(f"#{button_id}").focus()
cart_item.query_one(button_id).focus()
@on(CartItem.Focus)
def focus_item(self, event: CartItem.Focus) -> None:
@@ -284,7 +285,7 @@ class CartTable(CliveCheckerboardTable):
self.app.set_focus(cart_item)
if event.button_to_focus:
button_id = self._create_widget_id_to_focus(event)
cart_item.query_one(f"#{button_id}").focus()
cart_item.query_one(button_id).focus()
class Cart(BaseScreen):
Loading