Skip to content

Commit 12d3e2e

Browse files
kushthedudeiamareebjamal
authored andcommitted
fix: Enable sorting in admin users table (#3488)
* Enable sorting in admin users table * Update list.js * Sorting through name * Fix: extraRecords used wrongly
1 parent 178a7dd commit 12d3e2e

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

app/controllers/admin/users/list.js

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
1212
return [
1313
{
1414
name : 'Name',
15-
valuePath : 'id',
16-
extraValuePaths : ['firstName', 'deletedAt'],
15+
valuePath : 'firstName',
16+
extraValuePaths : ['deletedAt', 'id', 'isSuperAdmin'],
1717
cellComponent : 'ui-table/cell/admin/users/cell-first-name',
1818
width : 155,
19+
isSortable : true,
20+
headerComponent : 'tables/headers/sort',
1921
options : {
2022
hasRestorePrivileges: this.hasRestorePrivileges
2123
},
@@ -27,9 +29,11 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
2729
}
2830
},
2931
{
30-
name : 'Email',
31-
valuePath : 'email',
32-
width : 160
32+
name : 'Email',
33+
valuePath : 'email',
34+
width : 175,
35+
isSortable : true,
36+
headerComponent : 'tables/headers/sort'
3337
},
3438
{
3539
name : 'Status',
@@ -59,15 +63,19 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
5963
cellComponent : 'ui-table/cell/admin/users/cell-user-links'
6064
},
6165
{
62-
name : 'Member Since',
63-
valuePath : 'createdAt',
64-
cellComponent : 'ui-table/cell/admin/users/cell-created-at'
66+
name : 'Member Since',
67+
valuePath : 'createdAt',
68+
cellComponent : 'ui-table/cell/admin/users/cell-created-at',
69+
isSortable : true,
70+
headerComponent : 'tables/headers/sort'
6571
},
6672
{
67-
name : 'Last Accessed',
68-
valuePath : 'lastAccessedAt',
69-
cellComponent : 'ui-table/cell/cell-simple-date',
70-
options : {
73+
name : 'Last Accessed',
74+
valuePath : 'lastAccessedAt',
75+
isSortable : true,
76+
headerComponent : 'tables/headers/sort',
77+
cellComponent : 'ui-table/cell/cell-simple-date',
78+
options : {
7179
dateFormat: 'MMMM DD, YYYY - hh:mm A'
7280
}
7381
}
@@ -78,6 +86,7 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
7886
moveToUserDetails(id) {
7987
this.transitionToRoute('admin.users.view', id);
8088
}
89+
8190
@action
8291
async deleteUser(user_id) {
8392
this.set('isLoading', true);
@@ -89,6 +98,7 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
8998
} catch (e) {
9099
this.notify.error(this.l10n.t('An unexpected error has occurred.'));
91100
}
101+
92102
this.set('isLoading', false);
93103
}
94104

@@ -113,6 +123,7 @@ export default class extends Controller.extend(EmberTableControllerMixin) {
113123
this.notify.error(this.l10n.t('An unexpected error has occurred.'));
114124
console.warn(e);
115125
}
126+
116127
this.set('isLoading', false);
117128
}
118129
}

app/templates/components/ui-table/cell/admin/users/cell-first-name.hbs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
<span>{{extraRecords.firstName}}</span>
1+
<span>{{record}}</span>
22
<div class="ui hidden divider"></div>
33
<div class="ui horizontal compact basic buttons">
4-
{{#ui-popup tagName='a' click=(action props.actions.moveToUserDetails record) content=(t 'View') class='ui icon button'}}
4+
{{#ui-popup tagName='a' click=(action props.actions.moveToUserDetails extraRecords.id) content=(t 'View') class='ui icon button'}}
55
<i class="unhide icon"></i>
66
{{/ui-popup}}
7-
{{#unless record.isSuperAdmin}}
8-
{{#if (not record.deletedAt)}}
9-
{{#ui-popup content=(t 'Edit') click=(action props.actions.openEditModal record) class='ui icon button'}}
7+
{{#unless extraRecords.isSuperAdmin}}
8+
{{#if (not extraRecords.deletedAt)}}
9+
{{#ui-popup content=(t 'Edit') click=(action props.actions.openEditModal extraRecords.id) class='ui icon button'}}
1010
<i class="edit icon"></i>
1111
{{/ui-popup}}
1212
{{/if}}
1313
{{#if (and props.options.hasRestorePrivileges extraRecords.deletedAt)}}
14-
{{#ui-popup content=(t 'Restore') click=(action props.actions.restoreUser record) class='ui icon button' position='left center'}}
14+
{{#ui-popup content=(t 'Restore') click=(action props.actions.restoreUser extraRecords.id) class='ui icon button' position='left center'}}
1515
<i class="undo icon"></i>
1616
{{/ui-popup}}
1717
{{else}}
18-
{{#ui-popup content=(t 'Delete') click=(action (confirm (t 'Are you sure you would like to delete this user?') (action props.actions.deleteUser record))) class='ui icon button'}}
18+
{{#ui-popup content=(t 'Delete') click=(action (confirm (t 'Are you sure you would like to delete this user?') (action props.actions.deleteUser extraRecords.id))) class='ui icon button'}}
1919
<i class="trash outline icon"></i>
2020
{{/ui-popup}}
2121
{{/if}}

0 commit comments

Comments
 (0)