Skip to content

Commit 6944d57

Browse files
committed
bulk delete users
1 parent 0829ca6 commit 6944d57

File tree

9 files changed

+791
-656
lines changed

9 files changed

+791
-656
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ The mission is to bring software dev inspired features (refactoring, testing, li
88

99
## Latest version
1010

11-
v1.45.2
11+
v1.45.3
1212

1313
## OS Support
1414

app/app/components/customize/user-list.js renamed to app/app/components/customize/user-admin.js

Lines changed: 55 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,18 @@ export default Ember.Component.extend(AuthProvider, {
1717
deleteUser: null,
1818
drop: null,
1919
password: {},
20+
filter: '',
21+
filteredUsers: [],
22+
selectedUsers: [],
23+
hasSelectedUsers: false,
2024

2125
didReceiveAttrs() {
2226
this.users.forEach(user => {
2327
user.set('me', user.get('id') === this.get('session.session.authenticated.user.id'));
28+
user.set('selected', false);
2429
});
30+
31+
this.set('filteredUsers', this.users);
2532
},
2633

2734
willDestroyElement() {
@@ -32,7 +39,39 @@ export default Ember.Component.extend(AuthProvider, {
3239
}
3340
},
3441

42+
onKeywordChange: function () {
43+
Ember.run.debounce(this, this.filterUsers, 350);
44+
}.observes('filter'),
45+
46+
filterUsers() {
47+
let users = this.get('users');
48+
let filteredUsers = [];
49+
let filter = this.get('filter').toLowerCase();
50+
51+
users.forEach(user => {
52+
if (user.get('fullname').toLowerCase().includes(filter) || user.get('email').toLowerCase().includes(filter)) {
53+
filteredUsers.pushObject(user);
54+
}
55+
});
56+
57+
this.set('filteredUsers', filteredUsers);
58+
},
59+
3560
actions: {
61+
toggleSelect(user) {
62+
user.set('selected', !user.get('selected'));
63+
64+
let su = this.get('selectedUsers');
65+
if (user.get('selected')) {
66+
su.push(user.get('id'));
67+
} else {
68+
su = _.reject(su, function(id){ return id === user.get('id') });
69+
}
70+
71+
this.set('selectedUsers', su);
72+
this.set('hasSelectedUsers', su.length > 0);
73+
},
74+
3675
toggleActive(id) {
3776
let user = this.users.findBy("id", id);
3877
user.set('active', !user.get('active'));
@@ -142,8 +181,22 @@ export default Ember.Component.extend(AuthProvider, {
142181
let drop = this.get('drop');
143182
drop.close();
144183

145-
let user = this.get('deleteUser');
146-
this.attrs.onDelete(user);
184+
this.set('selectedUsers', []);
185+
this.set('hasSelectedUsers', false);
186+
this.attrs.onDelete(this.get('deleteUser.id'));
187+
},
188+
189+
onBulkDelete() {
190+
let su = this.get('selectedUsers');
191+
192+
su.forEach(userId => {
193+
this.attrs.onDelete(userId);
194+
});
195+
196+
this.set('selectedUsers', []);
197+
this.set('hasSelectedUsers', false);
198+
199+
return true;
147200
}
148201
}
149202
});

app/app/pods/customize/users/controller.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ export default Ember.Controller.extend(NotifierMixin, {
3232
});
3333
},
3434

35-
onDelete(user) {
35+
onDelete(userId) {
3636
let self = this;
37-
this.get('userService').remove(user.get('id')).then(function () {
37+
this.get('userService').remove(userId).then(function () {
3838
self.showNotification('Deleted');
3939

4040
self.get('userService').getComplete().then(function (users) {

app/app/pods/customize/users/template.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
<div class="clearfix" />
44

5-
{{customize/user-list users=model onDelete=(action "onDelete") onSave=(action "onSave") onPassword=(action "onPassword")}}
5+
{{customize/user-admin users=model onDelete=(action "onDelete") onSave=(action "onSave") onPassword=(action "onPassword")}}

app/app/styles/view/page-customize.scss

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
.page-customize {
22
@include content-container();
33

4-
.user-list {
4+
.user-admin {
55
margin: 30px 0;
66

77
> .heading {
@@ -13,16 +13,73 @@
1313

1414
> .basic-table {
1515
background-color: $color-white;
16-
font-size: 0.9rem;
16+
border: none !important;
17+
font-size: 1rem;
18+
color: $color-off-black;
19+
20+
> thead {
21+
> tr {
22+
> th {
23+
height: 40px;
24+
font-weight: bold;
25+
color: $color-gray;
26+
}
27+
28+
> th:first-child {
29+
font-weight: normal;
30+
}
31+
32+
> th:last-child {
33+
text-align: center;
34+
}
35+
}
36+
}
37+
38+
> tbody {
39+
> tr {
40+
> td {
41+
vertical-align: middle;
42+
text-align: center;
43+
44+
> .selector {
45+
> i {
46+
color: $color-off-black;
47+
}
48+
}
49+
50+
> .name {
51+
font-size: 1rem;
52+
color: $color-off-black;
53+
margin: 0 0 0 30px;
54+
}
55+
56+
> .email {
57+
font-size: 0.9rem;
58+
color: $color-gray;
59+
margin: 0 0 0 30px;
60+
}
61+
}
62+
63+
> td:first-child, td:last-child {
64+
text-align: left;
65+
}
66+
}
67+
}
1768
}
1869

19-
.inactive
70+
.inactive-user
2071
{
2172
@extend .color-red;
2273
font-weight: normal;
2374
text-decoration: line-through;
2475
}
2576

77+
.admin-user
78+
{
79+
@extend .color-primary;
80+
font-weight: normal;
81+
}
82+
2683
.checkbox {
2784
color: $color-checkbox;
2885
cursor: pointer;

app/app/templates/components/customize/user-list.hbs renamed to app/app/templates/components/customize/user-admin.hbs

Lines changed: 49 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,76 @@
1-
<div class="user-list">
1+
<div class="user-admin">
22
<div class="form-header">
33
<div class="title">User Management</div>
44
<div class="tip">Set basic information, passwords and permissions for {{users.length}} users</div>
55
</div>
6+
67
<table class="basic-table">
78
<thead>
89
<tr>
9-
<th class="border-bottom border-top">Firstname</th>
10-
<th class="border-bottom border-top">Lastname</th>
11-
<th class="border-bottom border-top">Email</th>
12-
<th class="border-bottom border-top no-width">Active</th>
13-
<th class="border-bottom border-top no-width">Add Spaces</th>
14-
<th class="border-bottom border-top no-width">Admin</th>
15-
<th class="border-bottom border-top no-width">&nbsp;</th>
10+
<th class="">
11+
<div class="input-inline input-transparent">
12+
{{focus-input type="text" placeholder="< type here to filter users >" value=filter}}
13+
</div>
14+
</th>
15+
<th class="no-width">Create spaces</th>
16+
<th class="no-width">Is administrator</th>
17+
<th class="no-width">Is active</th>
18+
<th class="no-width">
19+
{{#if hasSelectedUsers}}
20+
<div class="round-button round-button-small button-red" id="bulk-delete-users">
21+
<i class="material-icons">delete</i>
22+
</div>
23+
{{#dropdown-dialog target="bulk-delete-users" position="bottom right" button="Delete" color="flat-red" onAction=(action 'onBulkDelete')}}
24+
<p>Are you sure you want to delete selected users?</p>
25+
{{/dropdown-dialog}}
26+
{{/if}}
27+
</th>
1628
</tr>
1729
</thead>
1830
<tbody>
19-
{{#each users as |user|}}
31+
{{#each filteredUsers as |user|}}
2032
<tr>
21-
<td class="border-bottom {{if user.active '' 'inactive'}}">{{ user.firstname }}</td>
22-
<td class="border-bottom {{if user.active '' 'inactive'}}">{{ user.lastname }}</td>
23-
<td class="border-bottom {{if user.active '' 'inactive'}}">{{ user.email }}</td>
24-
<td class="border-bottom no-width">
25-
{{#if user.me}}
26-
<i class="material-icons">check_box</i> {{else if user.active}}
27-
<i class="material-icons checkbox" {{action 'toggleActive' user.id}}>check_box</i>
28-
{{else}}
29-
<i class="material-icons checkbox" {{action 'toggleActive' user.id}}>check_box_outline_blank</i>
30-
{{/if}}
33+
<td class="{{unless user.active 'inactive-user'}} {{if user.admin 'admin-user'}}">
34+
<div class="selector pull-left">
35+
{{#unless user.me}}
36+
{{#if user.selected}}
37+
<i class="material-icons checkbox" {{action 'toggleSelect' user}}>check_box</i>
38+
{{else}}
39+
<i class="material-icons checkbox" {{action 'toggleSelect' user}}>check_box_outline_blank</i>
40+
{{/if}}
41+
{{/unless}}
42+
</div>
43+
<div class="name">{{ user.fullname }}</div>
44+
<div class="email">{{ user.email }}</div>
3145
</td>
32-
<td class="border-bottom no-width">
46+
<td class="no-width text-center">
3347
{{#if user.me}}
34-
<i class="material-icons">check_box</i> {{else if user.editor}}
48+
<i class="material-icons color-gray">check_box</i>
49+
{{else if user.editor}}
3550
<i class="material-icons checkbox" {{action 'toggleEditor' user.id}}>check_box</i>
3651
{{else}}
3752
<i class="material-icons checkbox" {{action 'toggleEditor' user.id}}>check_box_outline_blank</i>
3853
{{/if}}
3954
</td>
40-
<td class="border-bottom no-width">
55+
<td class="no-width text-center">
4156
{{#if user.me}}
42-
<i class="material-icons">check_box</i> {{else if user.admin}}
57+
<i class="material-icons color-gray">check_box</i>
58+
{{else if user.admin}}
4359
<i class="material-icons checkbox" {{action 'toggleAdmin' user.id}}>check_box</i>
4460
{{else}}
4561
<i class="material-icons checkbox" {{action 'toggleAdmin' user.id}}>check_box_outline_blank</i>
4662
{{/if}}
4763
</td>
48-
<td class="border-bottom no-width">
64+
<td class="no-width text-center">
65+
{{#if user.me}}
66+
<i class="material-icons color-gray">check_box</i>
67+
{{else if user.active}}
68+
<i class="material-icons checkbox" {{action 'toggleActive' user.id}}>check_box</i>
69+
{{else}}
70+
<i class="material-icons checkbox" {{action 'toggleActive' user.id}}>check_box_outline_blank</i>
71+
{{/if}}
72+
</td>
73+
<td class="no-width text-center">
4974
{{#if user.me}}
5075
<div class="edit-button-{{user.id}} round-button-mono" title="Edit" {{action "edit" user.id}}>
5176
<i class="material-icons">edit</i>

app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "documize",
3-
"version": "1.45.2",
3+
"version": "1.45.3",
44
"description": "The Document IDE",
55
"private": true,
66
"repository": "",

core/api/endpoint/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ var Product core.ProdInfo
3535
func init() {
3636
Product.Major = "1"
3737
Product.Minor = "45"
38-
Product.Patch = "2"
38+
Product.Patch = "3"
3939
Product.Version = fmt.Sprintf("%s.%s.%s", Product.Major, Product.Minor, Product.Patch)
4040
Product.Edition = "Community"
4141
Product.Title = fmt.Sprintf("%s Edition", Product.Edition)

0 commit comments

Comments
 (0)