table: Add default option to perform_sort (#379)
This commit is contained in:
parent
b7a1292d07
commit
db041fea88
2 changed files with 4 additions and 7 deletions
|
|
@ -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)
|
|
||||||
}
|
|
||||||
}),
|
}),
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue