Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inconsistency between column ordering in the GUI and the database reference. #446

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gyohng
Copy link
Contributor

@gyohng gyohng commented Apr 21, 2024

This patch addresses an issue where the column ordering in the GUI did not match the order used in database queries. This led to improper sorting functionality within the application in the part selection dialogue. The inconsistency was observed when a header was clicked to sort by a specific field, where the list would be sorted using a wrong field.

The position of the "Stock" field in the ordering array was adjusted to precede the Manufacturer, Description, and Price fields in the way it is in the GUI.

@@ -89,10 +89,10 @@ def set_order_by(self, n):
"Package",
"Solder Joint",
"Library Type",
"Stock",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commit log mentions this has to match the database order, where is the defined? can we use the same list in both places to avoid having the two lists get out of sync?

Copy link
Contributor Author

@gyohng gyohng Apr 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This, what you're looking at is the database column reference order.

The GUI list is in partselector.py line 368 and on. In theory, one could use a single source for it, but it's going to be a much more involved refactoring:

image

Plugging it right now is more sensible than leaving it unfixed until someone finds enough time to revamp partselector.py, for which there could be a TODO task to fix it in the future.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we pull the list out of 116 as well so there is a single list of columns? Because 116 notes the list in parselector.py (typo), but 86 doesn't.

Copy link
Contributor Author

@gyohng gyohng Apr 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to get back to my projects now, cannot spend any more time on this. Please feel free to get inspired by this:

# Defining the structure of each column - put this inside `library.py` and assign to a member of `library`
sel_columns = [
    {"name": "LCSC",         "db_name": "LCSC Part",     "width": 60,  "align": wx.ALIGN_LEFT,   "ellipsize": wx.ELLIPSIZE_NONE},
    {"name": "MFR Number",   "db_name": "MFR.Part",      "width": 140, "align": wx.ALIGN_LEFT,   "ellipsize": wx.ELLIPSIZE_NONE},
    {"name": "Package",      "db_name": "Package",       "width": 100, "align": wx.ALIGN_LEFT,   "ellipsize": wx.ELLIPSIZE_NONE},
    {"name": "Pins",         "db_name": "Pins",          "width": 40,  "align": wx.ALIGN_CENTER, "ellipsize": None},
    {"name": "Type",         "db_name": "Library Type",  "width": 50,  "align": wx.ALIGN_LEFT,   "ellipsize": wx.ELLIPSIZE_NONE},
    {"name": "Stock",        "db_name": "Stock",         "width": 50,  "align": wx.ALIGN_CENTER, "ellipsize": wx.ELLIPSIZE_NONE},
    {"name": "Manufacturer", "db_name": "Manufacturer",  "width": 100, "align": wx.ALIGN_LEFT,   "ellipsize": wx.ELLIPSIZE_NONE},
    {"name": "Description",  "db_name": "Description",   "width": 300, "align": wx.ALIGN_LEFT,   "ellipsize": wx.ELLIPSIZE_NONE},
    {"name": "Price",        "db_name": "Price",         "width": 100, "align": wx.ALIGN_LEFT,   "ellipsize": wx.ELLIPSIZE_NONE}
]
......

    for col in parent.library.sel_columns:
        col_width = int(parent.scale_factor * col["width"])
        renderer = self.part_list.AppendTextColumn(
            col["name"],
            mode=wx.dataview.DATAVIEW_CELL_INERT,
            width=col_width,
            align=col["align"],
            flags=wx.dataview.DATAVIEW_COL_RESIZABLE
        ).GetRenderer()

        if "ellipsize" in col and col["ellipsize"] is not None:
            renderer.EnableEllipsize(col["ellipsize"])

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gyohng yep, I'll pick it up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants