UX: Enabled sorting for more columns in admin user list (#7208)
This commit is contained in:
parent
4e594f2b2b
commit
d16a0db4e1
|
@ -87,8 +87,8 @@ export default Ember.Controller.extend(CanCheckEmails, {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
showEmails: function() {
|
toggleEmailVisibility: function() {
|
||||||
this.set("showEmails", true);
|
this.toggleProperty("showEmails");
|
||||||
this._refreshUsers();
|
this._refreshUsers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,6 @@ export default Discourse.Route.extend({
|
||||||
order: transition.to.queryParams.order,
|
order: transition.to.queryParams.order,
|
||||||
ascending: transition.to.queryParams.ascending,
|
ascending: transition.to.queryParams.ascending,
|
||||||
query: params.filter,
|
query: params.filter,
|
||||||
showEmails: false,
|
|
||||||
refreshing: false
|
refreshing: false
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -8,12 +8,16 @@
|
||||||
<div class="admin-title">
|
<div class="admin-title">
|
||||||
<h2>{{title}}</h2>
|
<h2>{{title}}</h2>
|
||||||
{{#if canCheckEmails}}
|
{{#if canCheckEmails}}
|
||||||
<button {{action "showEmails"}} class="show-emails btn btn-default">{{i18n 'admin.users.show_emails'}}</button>
|
{{#if showEmails}}
|
||||||
|
<button {{action "toggleEmailVisibility"}} class="hide-emails btn btn-default">{{i18n 'admin.users.hide_emails'}}</button>
|
||||||
|
{{else}}
|
||||||
|
<button {{action "toggleEmailVisibility"}} class="show-emails btn btn-default">{{i18n 'admin.users.show_emails'}}</button>
|
||||||
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<div class='username controls'>
|
<div class='username controls'>
|
||||||
{{text-field value=listFilter placeholder=searchHint}}
|
{{text-field value=listFilter placeholder=searchHint}}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{#conditional-loading-spinner condition=refreshing}}
|
{{#conditional-loading-spinner condition=refreshing}}
|
||||||
|
@ -23,9 +27,9 @@
|
||||||
{{#if showApproval}}
|
{{#if showApproval}}
|
||||||
<th>{{input type="checkbox" checked=selectAll}}</th>
|
<th>{{input type="checkbox" checked=selectAll}}</th>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<th>{{i18n 'username'}}</th>
|
{{admin-directory-toggle field="username" i18nKey='username' order=order ascending=ascending}}
|
||||||
<th class='email-heading'>{{i18n 'email'}}</th>
|
{{admin-directory-toggle field="email" i18nKey='email' order=order ascending=ascending}}
|
||||||
<th>{{i18n 'admin.users.last_emailed'}}</th>
|
{{admin-directory-toggle field="last_emailed" i18nKey='admin.users.last_emailed' order=order ascending=ascending}}
|
||||||
{{admin-directory-toggle field="seen" i18nKey='last_seen' order=order ascending=ascending}}
|
{{admin-directory-toggle field="seen" i18nKey='last_seen' order=order ascending=ascending}}
|
||||||
{{admin-directory-toggle field="topics_viewed" i18nKey="admin.user.topics_entered" order=order ascending=ascending}}
|
{{admin-directory-toggle field="topics_viewed" i18nKey="admin.user.topics_entered" order=order ascending=ascending}}
|
||||||
{{admin-directory-toggle field="posts_read" i18nKey="admin.user.posts_read_count" order=order ascending=ascending}}
|
{{admin-directory-toggle field="posts_read" i18nKey="admin.user.posts_read_count" order=order ascending=ascending}}
|
||||||
|
|
|
@ -435,7 +435,7 @@ $mobile-breakpoint: 700px;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
align-items: flex-start;
|
align-items: flex-start;
|
||||||
.show-emails {
|
.show-emails, .hide-emails {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3788,6 +3788,7 @@ en:
|
||||||
id_not_found: "Sorry, that user id doesn't exist in our system."
|
id_not_found: "Sorry, that user id doesn't exist in our system."
|
||||||
active: "Activated"
|
active: "Activated"
|
||||||
show_emails: "Show Emails"
|
show_emails: "Show Emails"
|
||||||
|
hide_emails: "Hide Emails"
|
||||||
nav:
|
nav:
|
||||||
new: "New"
|
new: "New"
|
||||||
active: "Active"
|
active: "Active"
|
||||||
|
|
|
@ -9,6 +9,52 @@ QUnit.test("lists users", async assert => {
|
||||||
assert.ok(!exists(".user:eq(0) .email small"), "escapes email");
|
assert.ok(!exists(".user:eq(0) .email small"), "escapes email");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
QUnit.test("sorts users", async assert => {
|
||||||
|
await visit("/admin/users/list/active");
|
||||||
|
|
||||||
|
assert.ok(exists(".users-list .user"));
|
||||||
|
|
||||||
|
await click(".users-list .sortable:nth-child(1)");
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
find(".users-list .user:nth-child(1) .username")
|
||||||
|
.text()
|
||||||
|
.includes("eviltrout"),
|
||||||
|
"list should be sorted by username"
|
||||||
|
);
|
||||||
|
|
||||||
|
await click(".users-list .sortable:nth-child(1)");
|
||||||
|
|
||||||
|
assert.ok(
|
||||||
|
find(".users-list .user:nth-child(1) .username")
|
||||||
|
.text()
|
||||||
|
.includes("discobot"),
|
||||||
|
"list should be sorted ascending by username"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
QUnit.test("toggles email visibility", async assert => {
|
||||||
|
await visit("/admin/users/list/active");
|
||||||
|
|
||||||
|
assert.ok(exists(".users-list .user"));
|
||||||
|
|
||||||
|
await click(".show-emails");
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
find(".users-list .user:nth-child(1) .email").text(),
|
||||||
|
"<small>eviltrout@example.com</small>",
|
||||||
|
"shows the emails"
|
||||||
|
);
|
||||||
|
|
||||||
|
await click(".hide-emails");
|
||||||
|
|
||||||
|
assert.equal(
|
||||||
|
find(".users-list .user:nth-child(1) .email").text(),
|
||||||
|
"",
|
||||||
|
"hides the emails"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
QUnit.test("switching tabs", async assert => {
|
QUnit.test("switching tabs", async assert => {
|
||||||
const activeUser = "eviltrout@example.com";
|
const activeUser = "eviltrout@example.com";
|
||||||
const suspectUser = "sam@example.com";
|
const suspectUser = "sam@example.com";
|
||||||
|
|
|
@ -448,14 +448,32 @@ export default function() {
|
||||||
overridden: true
|
overridden: true
|
||||||
};
|
};
|
||||||
|
|
||||||
this.get("/admin/users/list/active.json", () => {
|
this.get("/admin/users/list/active.json", request => {
|
||||||
return response(200, [
|
let store = [
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
username: "eviltrout",
|
username: "eviltrout",
|
||||||
email: "<small>eviltrout@example.com</small>"
|
email: "<small>eviltrout@example.com</small>"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
username: "discobot",
|
||||||
|
email: "<small>discobot_email</small>"
|
||||||
}
|
}
|
||||||
]);
|
];
|
||||||
|
const ascending = request.queryParams.ascending;
|
||||||
|
const order = request.queryParams.order;
|
||||||
|
|
||||||
|
if (order) {
|
||||||
|
store = store.sort(function(a, b) {
|
||||||
|
return a[order] - b[order];
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (ascending) {
|
||||||
|
store = store.reverse();
|
||||||
|
}
|
||||||
|
|
||||||
|
return response(200, store);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.get("/admin/users/list/suspect.json", () => {
|
this.get("/admin/users/list/suspect.json", () => {
|
||||||
|
|
Loading…
Reference in New Issue