diff options
Diffstat (limited to 'client/components/settings/peopleBody.js')
-rw-r--r-- | client/components/settings/peopleBody.js | 76 |
1 files changed, 75 insertions, 1 deletions
diff --git a/client/components/settings/peopleBody.js b/client/components/settings/peopleBody.js index 7cc992f2..83cf14fa 100644 --- a/client/components/settings/peopleBody.js +++ b/client/components/settings/peopleBody.js @@ -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; @@ -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); @@ -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'); @@ -62,10 +96,43 @@ Template.peopleRow.helpers({ }, }); +Template.editUserPopup.onCreated(function() { + this.authenticationMethods = new ReactiveVar([]); + this.errorMessage = new ReactiveVar(''); + + Meteor.call('getAuthenticationsEnabled', (_, result) => { + if (result) { + // TODO : add a management of different languages + // (ex {value: ldap, text: TAPi18n.__('ldap', {}, T9n.getLanguage() || 'en')}) + this.authenticationMethods.set([ + {value: 'password'}, + // Gets only the authentication methods availables + ...Object.entries(result).filter((e) => e[1]).map((e) => ({value: e[0]})), + ]); + } + }); +}); + Template.editUserPopup.helpers({ user() { return Users.findOne(this.userId); }, + authentications() { + return Template.instance().authenticationMethods.get(); + }, + isSelected(match) { + const userId = Template.instance().data.userId; + const selected = Users.findOne(userId).authenticationMethod; + return selected === match; + }, + isLdap() { + const userId = Template.instance().data.userId; + const selected = Users.findOne(userId).authenticationMethod; + return selected === 'ldap'; + }, + errorMessage() { + return Template.instance().errorMessage.get(); + }, }); BlazeComponent.extendComponent({ @@ -91,6 +158,7 @@ Template.editUserPopup.events({ const isAdmin = tpl.find('.js-profile-isadmin').value.trim(); const isActive = tpl.find('.js-profile-isactive').value.trim(); const email = tpl.find('.js-profile-email').value.trim(); + const authentication = tpl.find('.js-authenticationMethod').value.trim(); const isChangePassword = password.length > 0; const isChangeUserName = username !== user.username; @@ -101,6 +169,7 @@ Template.editUserPopup.events({ 'profile.fullname': fullname, 'isAdmin': isAdmin === 'true', 'loginDisabled': isActive === 'true', + 'authenticationMethod': authentication, }, }); @@ -155,4 +224,9 @@ Template.editUserPopup.events({ }); } else Popup.close(); }, + + 'click #deleteButton'() { + Users.remove(this.userId); + Popup.close(); + }, }); |