Skip to content

Commit 5a34c12

Browse files
committed
better user list
1 parent dcd482d commit 5a34c12

File tree

3 files changed

+38
-14
lines changed

3 files changed

+38
-14
lines changed

src/Modules/SimplCommerce.Module.Core/Controllers/UserApiController.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,16 +51,16 @@ public IActionResult List([FromBody] SmartTableParam param)
5151
query = query.Where(x => x.FullName.Contains(fullName));
5252
}
5353

54-
if (search.Role != null)
54+
if (search.RoleId != null)
5555
{
56-
string roleName = search.Role;
57-
query = query.Where(x => x.Roles.Any(r => r.Role.Name.Contains(roleName)));
56+
long roleId = search.RoleId;
57+
query = query.Where(x => x.Roles.Any(r => r.RoleId == roleId));
5858
}
5959

60-
if (search.CustomerGroup != null)
60+
if (search.CustomerGroupId != null)
6161
{
62-
string customerGroupName = search.CustomerGroup;
63-
query = query.Where(x => x.CustomerGroups.Any(g => g.CustomerGroup.Name.Contains(customerGroupName)));
62+
long customerGroupId = search.CustomerGroupId;
63+
query = query.Where(x => x.CustomerGroups.Any(g => g.CustomerGroupId == customerGroupId));
6464
}
6565

6666
if (search.CreatedOn != null)

src/Modules/SimplCommerce.Module.Core/wwwroot/admin/user/user-list.html

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,26 @@ <h2>{{::vm.translate.get('Users')}}</h2>
3232
</th>
3333
<th>
3434
<div class="form-group">
35-
<input class="form-control" st-search="Role" />
35+
<select class="form-control" st-search="RoleId">
36+
<option value="">{{::vm.translate.get('All')}}</option>
37+
<option ng-repeat="role in vm.roles" value="{{role.id}}">{{role.name}}</option>
38+
</select>
3639
</div>
3740
</th>
3841
<th>
3942
<div class="form-group">
40-
<input class="form-control" st-search="CustomerGroup" />
43+
<select class="form-control" st-search="CustomerGroupId">
44+
<option value="">{{::vm.translate.get('All')}}</option>
45+
<option ng-repeat="group in vm.customerGroups" value="{{group.id}}">{{group.name}}</option>
46+
</select>
4147
</div>
4248
</th>
4349
<th><st-date-range predicate="CreatedOn" before="query.before" after="query.after"></st-date-range></th>
4450
<th></th>
4551
</tr>
52+
<tr>
53+
<th ng-show="!vm.isLoading" colspan="6">{{vm.tableStateRef.pagination.totalItemCount | number:0}} records found</th>
54+
</tr>
4655
</thead>
4756
<tbody ng-show="!vm.isLoading">
4857
<tr ng-repeat="user in vm.users">
@@ -59,12 +68,12 @@ <h2>{{::vm.translate.get('Users')}}</h2>
5968
</tbody>
6069
<tbody ng-show="vm.isLoading">
6170
<tr>
62-
<td colspan="5" class="text-center">Loading ... </td>
71+
<td colspan="6" class="text-center">Loading ... </td>
6372
</tr>
6473
</tbody>
6574
<tfoot>
6675
<tr>
67-
<td class="text-center" st-pagination="" st-items-by-page="50" st-displayed-pages="10" colspan="5"></td>
76+
<td class="text-center" st-pagination="" st-items-by-page="50" st-displayed-pages="10" colspan="6"></td>
6877
</tr>
6978
</tfoot>
7079
</table>

src/Modules/SimplCommerce.Module.Core/wwwroot/admin/user/user-list.js

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,19 @@
66

77
/* @ngInject */
88
function UserListCtrl(userService, translateService) {
9-
var vm = this,
10-
tableStateRef;
9+
var vm = this;
10+
vm.tableStateRef;
1111
vm.users = [];
12+
vm.roles = [];
13+
vm.customerGroups = [];
1214
vm.translate = translateService;
1315

1416
vm.getUsers = function getUsers(tableState) {
15-
tableStateRef = tableState;
17+
vm.tableStateRef = tableState;
1618
vm.isLoading = true;
1719
userService.getUsers(tableState).then(function (result) {
1820
vm.users = result.data.items;
21+
tableState.pagination.totalItemCount = result.data.totalRecord;
1922
tableState.pagination.numberOfPages = result.data.numberOfPages;
2023
vm.isLoading = false;
2124
});
@@ -26,7 +29,7 @@
2629
if (result) {
2730
userService.deleteUser(user)
2831
.then(function (result) {
29-
vm.getUsers(tableStateRef);
32+
vm.getUsers(vm.tableStateRef);
3033
toastr.success(user.fullName + ' has been deleted');
3134
})
3235
.catch(function (response) {
@@ -35,5 +38,17 @@
3538
}
3639
});
3740
};
41+
42+
function init() {
43+
userService.getRoles().then(function (result) {
44+
vm.roles = result.data;
45+
});
46+
47+
userService.getCustomerGroups().then(function (result) {
48+
vm.getCustomerGroups = result.data;
49+
});
50+
}
51+
52+
init();
3853
}
3954
})();

0 commit comments

Comments
 (0)