فهرست منبع

Revert "Merge branch 'imprv/user-status-filtering-front-of-sort' into feat/user-management"

This reverts commit 011bd28c22dffd6815b0d460d65844a07b79a3f8, reversing
changes made to 5fc49c699d7d799a0f7e682bad7e982f147ff36e.
ryuichi-e 6 سال پیش
والد
کامیت
e598df2e23
3فایلهای تغییر یافته به همراه9 افزوده شده و 49 حذف شده
  1. 5 31
      src/client/js/components/Admin/Users/UserTable.jsx
  2. 0 2
      src/client/js/services/AdminUsersContainer.js
  3. 4 16
      src/server/routes/apiv3/users.js

+ 5 - 31
src/client/js/components/Admin/Users/UserTable.jsx

@@ -19,15 +19,9 @@ class UserTable extends React.Component {
 
 
     };
     };
 
 
-    // this.onClickColumnSort = this.onClickColumnSort.bind(this);
     this.getUserStatusLabel = this.getUserStatusLabel.bind(this);
     this.getUserStatusLabel = this.getUserStatusLabel.bind(this);
   }
   }
 
 
-
-  onClickColumnSort(sortName) {
-    console.log(sortName);
-  }
-
   /**
   /**
    * return status label element by `userStatus`
    * return status label element by `userStatus`
    * @param {string} userStatus
    * @param {string} userStatus
@@ -89,31 +83,11 @@ class UserTable extends React.Component {
           <thead>
           <thead>
             <tr>
             <tr>
               <th width="100px">#</th>
               <th width="100px">#</th>
-              <th>
-                {t('status')}
-                <a className="glyphicon glyphicon-triangle-top" aria-hidden="true" onClick={() => this.onClickColumnSort('StatusAsc')}></a>
-                <a className="glyphicon glyphicon-triangle-bottom" aria-hidden="true" onClick={() => this.onClickColumnSort('StatusDesc')}></a>
-              </th>
-              <th>
-                <code>username</code>
-                <a className="glyphicon glyphicon-triangle-top" aria-hidden="true" onClick={() => this.onClickColumnSort('UserNameAsc')}></a>
-                <a className="glyphicon glyphicon-triangle-bottom" aria-hidden="true" onClick={() => this.onClickColumnSort('UserNameDesc')}></a>
-              </th>
-              <th>
-                {t('Name')}
-                <a className="glyphicon glyphicon-triangle-top" aria-hidden="true" onClick={() => this.onClickColumnSort('NameAsc')}></a>
-                <a className="glyphicon glyphicon-triangle-bottom" aria-hidden="true" onClick={() => this.onClickColumnSort('NameDesc')}></a>
-              </th>
-              <th>
-                {t('Email')}
-                <a className="glyphicon glyphicon-triangle-top" aria-hidden="true" onClick={() => this.onClickColumnSort('EmailAsc')}></a>
-                <a className="glyphicon glyphicon-triangle-bottom" aria-hidden="true" onClick={() => this.onClickColumnSort('EmailDesc')}></a>
-              </th>
-              <th width="100px">
-                {t('Created')}
-                <a className="glyphicon glyphicon-triangle-top" aria-hidden="true" onClick={() => this.onClickColumnSort('CreatedAsc')}></a>
-                <a className="glyphicon glyphicon-triangle-bottom" aria-hidden="true" onClick={() => this.onClickColumnSort('CreatedDesc')}></a>
-              </th>
+              <th>{t('status')}</th>
+              <th><code>username</code></th>
+              <th>{t('Name')}</th>
+              <th>{t('Email')}</th>
+              <th width="100px">{t('Created')}</th>
               <th width="150px">{t('Last_Login')}</th>
               <th width="150px">{t('Last_Login')}</th>
               <th width="70px"></th>
               <th width="70px"></th>
             </tr>
             </tr>

+ 0 - 2
src/client/js/services/AdminUsersContainer.js

@@ -18,8 +18,6 @@ export default class AdminUsersContainer extends Container {
 
 
     this.state = {
     this.state = {
       users: [],
       users: [],
-      descColumns: [],
-      statusList: [],
       isPasswordResetModalShown: false,
       isPasswordResetModalShown: false,
       isUserInviteModalShown: false,
       isUserInviteModalShown: false,
       userForPasswordResetModal: null,
       userForPasswordResetModal: null,

+ 4 - 16
src/server/routes/apiv3/users.js

@@ -140,36 +140,24 @@ module.exports = (crowi) => {
 
 
   router.get('/search-user-status/', validator.statusList, ApiV3FormValidator, async(req, res) => {
   router.get('/search-user-status/', validator.statusList, ApiV3FormValidator, async(req, res) => {
 
 
-    const page = parseInt(req.query.page) || 1;
     // status
     // status
+    const page = parseInt(req.query.page) || 1;
     const { statusList } = req.body;
     const { statusList } = req.body;
     const statusNoList = statusList.map(element => statusNo[element]);
     const statusNoList = statusList.map(element => statusNo[element]);
     // Search from input
     // Search from input
-    const inputWord = req.body.inputWord || '';
+    const inputWord = req.body.inputWord || 1;
     const searchWord = new RegExp(`${inputWord}`);
     const searchWord = new RegExp(`${inputWord}`);
-    const orColumns = ['name', 'username', 'email'];
-    const orOutput = {};
-    orColumns.forEach((element) => {
-      orOutput[element] = { $in: searchWord };
-    });
-
-    // Sort
-    const { descColumns } = req.body;
-    const sortOutput = {};
-    descColumns.forEach((element) => {
-      sortOutput[element] = -1;
-    });
 
 
     try {
     try {
       const paginateResult = await User.paginate(
       const paginateResult = await User.paginate(
         {
         {
           $and: [
           $and: [
             { status: { $in: statusNoList } },
             { status: { $in: statusNoList } },
-            { $or: [orOutput] },
+            { $or: [{ name: { $in: searchWord } }, { username: { $in: searchWord } }, { email: { $in: searchWord } }] },
           ],
           ],
         },
         },
         {
         {
-          sort: sortOutput,
+          sort: { status: 1, username: 1, createdAt: 1 },
           page,
           page,
           limit: PAGE_ITEMS,
           limit: PAGE_ITEMS,
         },
         },