FIX: Update order when column is clicked (#40)
In #29209, we introduced a callback to the TableHeaderToggle's parent to update the column order. This commit is to update this component to use that callback.
This commit is contained in:
parent
8f569de21b
commit
010ada35b7
|
@ -108,6 +108,14 @@ export default {
|
||||||
userCardShowUser(user) {
|
userCardShowUser(user) {
|
||||||
DiscourseURL.routeTo(userPath(user.username_lower));
|
DiscourseURL.routeTo(userPath(user.username_lower));
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@action
|
||||||
|
updateOrder(field, asc) {
|
||||||
|
this.setProperties({
|
||||||
|
order: field,
|
||||||
|
asc,
|
||||||
|
});
|
||||||
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -100,6 +100,7 @@
|
||||||
</span>
|
</span>
|
||||||
<span class="label">
|
<span class="label">
|
||||||
<TableHeaderToggle
|
<TableHeaderToggle
|
||||||
|
@onToggle={{this.updateOrder}}
|
||||||
@field={{column.name}}
|
@field={{column.name}}
|
||||||
@icon={{column.icon}}
|
@icon={{column.icon}}
|
||||||
@order={{this.order}}
|
@order={{this.order}}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { click, visit } from "@ember/test-helpers";
|
import { click, currentURL, visit } from "@ember/test-helpers";
|
||||||
import { test } from "qunit";
|
import { test } from "qunit";
|
||||||
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
|
||||||
|
|
||||||
|
@ -145,6 +145,16 @@ acceptance("User Card Directory", function (needs) {
|
||||||
.exists({ count: 2 }, "has two cards showing");
|
.exists({ count: 2 }, "has two cards showing");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("Updates the order when column is clicked", async function (assert) {
|
||||||
|
await visit("/u?order=post_count&period=yearly");
|
||||||
|
await click("#table-header-toggle-post_count");
|
||||||
|
assert.equal(
|
||||||
|
currentURL(),
|
||||||
|
"/u?asc=true&order=post_count&period=yearly",
|
||||||
|
"sorts by topic count"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
test("Can toggle between views", async function (assert) {
|
test("Can toggle between views", async function (assert) {
|
||||||
await visit("/u?cards=no");
|
await visit("/u?cards=no");
|
||||||
assert
|
assert
|
||||||
|
|
Loading…
Reference in New Issue