Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve admin panel (peopleBody) #2346

Merged
merged 3 commits into from
Apr 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions client/components/settings/peopleBody.jade
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,13 @@ template(name="people")
unless currentUser.isAdmin
| {{_ 'error-notAuthorized'}}
else
.content-title
span {{_ 'people'}}
.content-title.ext-box
.ext-box-left
span {{_ 'people'}}
input#searchInput(placeholder="{{_ 'search'}}")
button#searchButton {{_ 'enter'}}
.ext-box-right
span {{_ 'people-number'}} #{peopleNumber}
.content-body
.side-menu
ul
Expand Down Expand Up @@ -103,4 +108,4 @@ template(name="editUserPopup")
| {{_ 'password'}}
input.js-profile-password(type="password")

input.primary.wide(type="submit" value="{{_ 'save'}}")
input.primary.wide(type="submit" value="{{_ 'save'}}")
36 changes: 35 additions & 1 deletion client/components/settings/peopleBody.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ BlazeComponent.extendComponent({
this.error = new ReactiveVar('');
this.loading = new ReactiveVar(false);
this.people = new ReactiveVar(true);
this.findUsersOptions = new ReactiveVar({});
this.number = new ReactiveVar(0);

this.page = new ReactiveVar(1);
this.loadNextPageLocked = false;
Expand All @@ -26,6 +28,33 @@ BlazeComponent.extendComponent({
});
});
},
events() {
return [{
'click #searchButton'() {
this.filterPeople();
},
'keydown #searchInput'(event) {
if (event.keyCode === 13 && !event.shiftKey) {
this.filterPeople();
}
},
}];
},
filterPeople() {
const value = $('#searchInput').first().val();
if (value === '') {
this.findUsersOptions.set({});
} else {
const regex = new RegExp(value, 'i');
this.findUsersOptions.set({
$or: [
{ username: regex },
{ 'profile.fullname': regex },
{ 'emails.address': regex },
],
});
}
},
loadNextPage() {
if (this.loadNextPageLocked === false) {
this.page.set(this.page.get() + 1);
Expand All @@ -49,9 +78,14 @@ BlazeComponent.extendComponent({
this.loading.set(w);
},
peopleList() {
return Users.find({}, {
const users = Users.find(this.findUsersOptions.get(), {
fields: {_id: true},
});
this.number.set(users.count());
return users;
},
peopleNumber() {
return this.number.get();
},
}).register('people');

Expand Down
21 changes: 21 additions & 0 deletions client/components/settings/peopleBody.styl
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,24 @@ table

tr:nth-child(even)
background-color: #dddddd;

.ext-box
display: flex;
flex-direction: row;
height: 34px;

.ext-box-left
display: flex;
width: 40%

span
vertical-align: center;
line-height: 34px;
margin-right: 10px;

input, button
margin: 0 10px 0 0;
padding: 0;

button
min-width: 60px;
3 changes: 2 additions & 1 deletion i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -686,5 +686,6 @@
"error-ldap-login": "An error occurred while trying to login",
"display-authentication-method": "Display Authentication Method",
"default-authentication-method": "Default Authentication Method",
"duplicate-board": "Duplicate Board"
"duplicate-board": "Duplicate Board",
"people-number": "The number of people is: "
}
5 changes: 3 additions & 2 deletions i18n/fr.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -683,5 +683,6 @@
"error-ldap-login": "Une erreur s'est produite lors de la tentative de connexion",
"display-authentication-method": "Afficher la méthode d'authentification",
"default-authentication-method": "Méthode d'authentification par défaut",
"duplicate-board": "Dupliquer le tableau"
}
"duplicate-board": "Dupliquer le tableau",
"people-number": "Le nombre d'utilisateurs est de : "
}