Skip to content

Commit

Permalink
Big fat sales price display
Browse files Browse the repository at this point in the history
  • Loading branch information
JOJ0 committed Nov 6, 2024
1 parent c81e541 commit 3a405e8
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 41 deletions.
20 changes: 10 additions & 10 deletions discodos/model_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,16 +162,16 @@ def stats_releases_d_collection_online(self):

def get_sales_listing_details(self, listing_id):
listing = self.d.listing(listing_id)
l = [
listing.condition,
listing.external_id,
str(listing.format_quantity),
str(listing.allow_offers),
listing.location,
str(listing.price.value),
datetime.strftime(listing.posted, "%Y-%m-%d"),
]
return ", ".join(l)
l = {
"condition": listing.condition,
"external_id": listing.external_id,
"format_quantity": str(listing.format_quantity),
"allow_offers": "yes" if listing.allow_offers else "no",
"location": listing.location,
"price": str(listing.price.value),
"posted": datetime.strftime(listing.posted, "%Y-%m-%d"),
}
return l

def rate_limit_slow_downer(self, remaining=10, sleep=2):
'''Discogs util: stay in 60/min rate limit'''
Expand Down
64 changes: 34 additions & 30 deletions discodos/view/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import asyncio
from tabulate import tabulate as tab
from textual.app import App
from textual.widgets import DataTable, Label, Footer
from textual.widgets import DataTable, Label, Footer, Digits
from textual.containers import Container, Grid, Horizontal, Vertical, HorizontalScroll, VerticalScroll, ScrollableContainer
# from textual.css import StyleSheet

Expand Down Expand Up @@ -58,27 +58,7 @@ def __init__(self, rows, headers, discogs=None):
self.left_column_label = None
self.middle_column_label = None
self.right_column_label = None

def compose(self):
table = DataTable(classes="ls_results-list")
table.focus()
table.add_columns(*self.headers)
table.cursor_type = "cell"
table.zebra_stripes = True
# Layout
self.left_column_label = Label("Left column data")
self.middle_column_label = Label("Middle column")
self.right_column_label = Label("Right column")
self.details_panel = HorizontalScroll(
VerticalScroll(self.left_column_label),
VerticalScroll(self.middle_column_label),
VerticalScroll(self.right_column_label),
classes="details-panel",
)

yield table
yield self.details_panel
yield Footer()
self.sales_price = None

def action_toggle_dark(self):
self.dark = not self.dark
Expand All @@ -98,6 +78,12 @@ def action_edit_release(self):
def action_edit_sale(self):
pass

def _load_ls_results(self):
table_widget = self.query_one(DataTable)
for row in self.rows:
row_id, *_ = row
table_widget.add_row(*row, key=row_id)

def on_mount(self):
self.title = "DiscoDOS ls results"
self.sub_title = "Use keystrokes to edit/sell/view details, ..."
Expand All @@ -109,15 +95,33 @@ def on_data_table_cell_selected(self, event):
return
result = self.get_sales_listing_details(event.value)
# Load data into the left column
self.left_column_label.update(result)
self.middle_column_label.update("Middle column updated!") # Example update
self.right_column_label.update("Right column updated!") # Example update
# self.left_column_label.update(result)
self.sales_price.update(result['price'])
# self.right_column_label.update("Right column updated!") # Example update

def _load_ls_results(self):
table_widget = self.query_one(DataTable)
for row in self.rows:
row_id, *_ = row
table_widget.add_row(*row, key=row_id)
def compose(self):
table = DataTable(classes="ls_results-list")
table.focus()
table.add_columns(*self.headers)
table.cursor_type = "cell"
table.zebra_stripes = True
# Layout
self.left_column_label = Label("")
self.middle_column_label = Label("[b]Price[/b]")
self.right_column_label = Label("")
self.sales_price = Digits("0", id="pi")
self.details_panel = HorizontalScroll(
VerticalScroll(self.left_column_label),
VerticalScroll(
self.middle_column_label, self.sales_price, classes="centered"
),
VerticalScroll(self.right_column_label),
classes="details-panel",
)

yield table
yield self.details_panel
yield Footer()


class CollectionViewCommandline(
Expand Down
14 changes: 13 additions & 1 deletion discodos/view/tui_ls.tcss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@
}

.details-panel > VerticalScroll {
height: 1fr;
width: 1fr;
border: solid grey;
padding: 0;
}
}

#pi {
border: double orange;
width: auto;
}

.centered {
width: auto;
align: center top;
}

0 comments on commit 3a405e8

Please sign in to comment.