Skip to content

Commit

Permalink
dsc ls toggle sold key binding, no refresh
Browse files Browse the repository at this point in the history
Updates in DB but does not update UI yet.
  • Loading branch information
JOJ0 committed Nov 18, 2024
1 parent 487ce43 commit b89d233
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion discodos/ctrl/tui.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from textual.app import App
from textual.containers import Horizontal, Vertical, VerticalScroll
from textual.widgets import DataTable, Digits, Footer, Label, Static, RichLog
from textual.coordinate import Coordinate

from discodos.model import DiscogsMixin

Expand All @@ -20,7 +21,7 @@ class DiscodosListApp(App, DiscogsMixin): # pylint: disable=too-many-instance-a
("q", "request_quit", "Quit"),
("l", "list_sale", "List for sale"),
("d", "draft_sale", "Set to draft"),
("s", "mark_sold", "Mark sold (in DB)"),
("s", "toggle_sold", "Toggle sold (in DB)"),
("c", "fix_coll", "Sync Coll. Flag (in DB)"),
("r", "remove_coll", "Remove from Coll."),
("e", "edit_release", "Edit release"),
Expand Down Expand Up @@ -80,6 +81,16 @@ def action_list_sale(self):
def action_draft_sale(self):
pass

def action_toggle_sold(self):
"""When shortcut is pressed, toggle field "sold" in DB."""
rlog = self.query_one(RichLog)
row_key, _ = self.table.coordinate_to_cell_key(self.table.cursor_coordinate)
current_state = self.table.get_cell(row_key, "sold")
release_id = self.table.get_cell(row_key, "release_id")
wanted_state = True if current_state is False else True
self.collection.toggle_sold_state(release_id, wanted_state)
rlog.write("Set {release_id} sold state {wanted_state} ")

def action_edit_release(self):
pass

Expand Down

0 comments on commit b89d233

Please sign in to comment.