table: Add default option to perform_sort (#379)

This commit is contained in:
Floyd Wang 2024-10-24 18:15:12 +08:00 committed by GitHub
parent b7a1292d07
commit db041fea88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 7 deletions

View file

@ -439,12 +439,9 @@ impl TableDelegate for StockTableDelegate {
if let Some(col) = self.columns.get_mut(col_ix) { if let Some(col) = self.columns.get_mut(col_ix) {
match col.id.as_ref() { match col.id.as_ref() {
"id" => self.stocks.sort_by(|a, b| { "id" => self.stocks.sort_by(|a, b| match sort {
if sort == ColSort::Ascending { ColSort::Descending => b.id.cmp(&a.id),
a.id.cmp(&b.id) _ => a.id.cmp(&b.id),
} else {
b.id.cmp(&a.id)
}
}), }),
_ => {} _ => {}
} }

View file

@ -506,7 +506,7 @@ where
let sort = sort.unwrap(); let sort = sort.unwrap();
let sort = match sort { let sort = match sort {
ColSort::Ascending => ColSort::Descending, ColSort::Ascending => ColSort::Default,
ColSort::Descending => ColSort::Ascending, ColSort::Descending => ColSort::Ascending,
ColSort::Default => ColSort::Descending, ColSort::Default => ColSort::Descending,
}; };