Browse Source

Merge pull request #2667 from Akuket/master

 Patch admin search feature
Lauri Ojansivu 5 năm trước cách đây
mục cha
commit
ccfaf879dd
2 tập tin đã thay đổi với 8 bổ sung8 xóa
  1. 2 2
      client/components/settings/peopleBody.js
  2. 6 6
      server/publications/people.js

+ 2 - 2
client/components/settings/peopleBody.js

@@ -17,7 +17,7 @@ BlazeComponent.extendComponent({
     this.autorun(() => {
       const limit = this.page.get() * usersPerPage;
 
-      this.subscribe('people', limit, () => {
+      this.subscribe('people', this.findUsersOptions.get(), limit, () => {
         this.loadNextPageLocked = false;
         const nextPeakBefore = this.callFirstWith(null, 'getNextPeak');
         this.calculateNextPeak();
@@ -85,7 +85,7 @@ BlazeComponent.extendComponent({
     const users = Users.find(this.findUsersOptions.get(), {
       fields: { _id: true },
     });
-    this.number.set(users.count());
+    this.number.set(users.count(false));
     return users;
   },
   peopleNumber() {

+ 6 - 6
server/publications/people.js

@@ -1,4 +1,5 @@
-Meteor.publish('people', function(limit) {
+Meteor.publish('people', function(query, limit) {
+  check(query, Match.OneOf(Object, null));
   check(limit, Number);
 
   if (!Match.test(this.userId, String)) {
@@ -8,7 +9,7 @@ Meteor.publish('people', function(limit) {
   const user = Users.findOne(this.userId);
   if (user && user.isAdmin) {
     return Users.find(
-      {},
+      query,
       {
         limit,
         sort: { createdAt: -1 },
@@ -21,9 +22,8 @@ Meteor.publish('people', function(limit) {
           loginDisabled: 1,
           authenticationMethod: 1,
         },
-      },
-    );
-  } else {
-    return [];
+      });
   }
+
+  return [];
 });