mirror of
https://github.com/discourse/discourse.git
synced 2026-08-08 20:18:23 -05:00
DEV: Standardize table sorting verbiage (#9757)
* DEV: Standardize table sorting verbiage This commit creates a common component that tables can use to make their headers sortable. This commit also standardizes on using `desc` as the default and passing in the `asc=true` flag to adjust the sorting direction. * Add deprecation warnings Adds deprecation warnings if using previous params and maintains backwards compatibility. Set the default sort value for group members to be asc. * switch group requests to use common table-header-toggle * update fixture
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
import Component from "@ember/component";
|
||||
import { iconHTML } from "discourse-common/lib/icon-library";
|
||||
|
||||
export default Component.extend({
|
||||
tagName: "th",
|
||||
classNames: ["sortable"],
|
||||
chevronIcon: null,
|
||||
toggleProperties() {
|
||||
if (this.order === this.field) {
|
||||
this.set("ascending", this.ascending ? null : true);
|
||||
} else {
|
||||
this.setProperties({ order: this.field, ascending: null });
|
||||
}
|
||||
},
|
||||
toggleChevron() {
|
||||
if (this.order === this.field) {
|
||||
let chevron = iconHTML(this.ascending ? "chevron-up" : "chevron-down");
|
||||
this.set("chevronIcon", `${chevron}`.htmlSafe());
|
||||
} else {
|
||||
this.set("chevronIcon", null);
|
||||
}
|
||||
},
|
||||
click() {
|
||||
this.toggleProperties();
|
||||
},
|
||||
didReceiveAttrs() {
|
||||
this._super(...arguments);
|
||||
this.toggleChevron();
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user