Explorar el Código

merging

master
Kobus hace 5 años
padre
commit
042bb002c9

+ 92
- 2
src/components/admin/status/agentsUserManagementPage.vue Ver fichero

28
     <br />
28
     <br />
29
     <br />
29
     <br />
30
     <div class="container">
30
     <div class="container">
31
+      <div class="d-flex justify-content-between">
32
+        <div class="p-2">
33
+          <input v-model="searchItem" class="form-control" placeholder="Search ..." />
34
+        </div>
35
+      </div>
31
       <table class="table table-bordered">
36
       <table class="table table-bordered">
32
         <thead>
37
         <thead>
33
           <tr>
38
           <tr>
62
         <tbody>
67
         <tbody>
63
           <tr>
68
           <tr>
64
             <td colspan="10">
69
             <td colspan="10">
65
-              <h5>Agents</h5>
70
+              <div class="myWell">
71
+                <h4>Agents</h4>
72
+              </div>
66
             </td>
73
             </td>
67
           </tr>
74
           </tr>
68
           <tr v-for="(item, i) in agents" :key="i">
75
           <tr v-for="(item, i) in agents" :key="i">
93
           </tr>
100
           </tr>
94
         </tbody>
101
         </tbody>
95
       </table>
102
       </table>
103
+      <div class="d-flex justify-content-between">
104
+        <div class="p-1">{{ currentPage + ' / ' + PageCount }}</div>
105
+        <div class="p-1">
106
+          <BasePagination
107
+            :currentPage="currentPage"
108
+            :pageCount="PageCount"
109
+            @nextPage="pageChangeHandle('next')"
110
+            @previousPage="pageChangeHandle('previous')"
111
+            @loadPage="pageChangeHandle"
112
+          />
113
+        </div>
114
+      </div>
96
     </div>
115
     </div>
97
     <br />
116
     <br />
98
   </div>
117
   </div>
99
 </template>
118
 </template>
119
+
100
 <script>
120
 <script>
101
 import { mapState, mapActions } from 'vuex';
121
 import { mapState, mapActions } from 'vuex';
102
 import axios from 'axios';
122
 import axios from 'axios';
123
+import _ from 'lodash';
124
+import ItemsPerPageList from '../../../assets/staticData/itemsPerPage';
125
+import BasePagination from '../../shared/basePagination.vue';
103
 
126
 
104
 export default {
127
 export default {
105
   name: 'agentManagementPage',
128
   name: 'agentManagementPage',
129
+  components: {
130
+    BasePagination,
131
+  },
106
   data() {
132
   data() {
107
-    return {};
133
+    return {
134
+      sortKey: '',
135
+      reverse: false,
136
+      searchItem: '',
137
+      itemsPerPageList: ItemsPerPageList,
138
+      visibleItemsPerPageCount: 0,
139
+      currentPage: 1,
140
+    };
108
   },
141
   },
109
   methods: {
142
   methods: {
110
     ...mapActions('register', ['getAgents']),
143
     ...mapActions('register', ['getAgents']),
117
     routerGoTo(goTo) {
150
     routerGoTo(goTo) {
118
       this.$router.push(goTo);
151
       this.$router.push(goTo);
119
     },
152
     },
153
+    sortBy(sortKey) {
154
+      this.reverse = this.sortKey === sortKey ? !this.reverse : false;
155
+      this.sortKey = sortKey;
156
+    },
157
+    async pageChangeHandle(value) {
158
+      console.log(value);
159
+      switch (value) {
160
+        case 'next':
161
+          this.currentPage += 1;
162
+          break;
163
+        case 'previous':
164
+          this.currentPage -= 1;
165
+          break;
166
+        default:
167
+          this.currentPage = value;
168
+      }
169
+    },
170
+    onChangeItemsPerPage() {
171
+      if (this.currentPage !== 1) {
172
+        this.currentPage = 1;
173
+      }
174
+    },
120
   },
175
   },
121
   mounted() {
176
   mounted() {
122
     this.getAgents();
177
     this.getAgents();
178
+    try {
179
+      // to assign initial value to itemsPerPage
180
+      if (this.itemsPerPageList && this.itemsPerPageList.length > 0) {
181
+        const [startItem] = this.itemsPerPageList;
182
+        this.visibleItemsPerPageCount = startItem;
183
+      }
184
+    } catch (error) {
185
+      throw error;
186
+    }
123
   },
187
   },
124
   computed: {
188
   computed: {
125
     ...mapState('register', ['agents']),
189
     ...mapState('register', ['agents']),
190
+
191
+    SortDirection() {
192
+      return this.reverse ? 'desc' : 'asc';
193
+    },
194
+    PageCount() {
195
+      return this.visibleItemsPerPageCount !== 0
196
+        ? Math.ceil(this.FilteredItems.length / this.visibleItemsPerPageCount)
197
+        : 1;
198
+    },
199
+    FilteredItems() {
200
+      const list = _.filter(this.individuals, item => Object.values(item).some(
201
+          i => JSON.stringify(i)
202
+              .toLowerCase()
203
+              .indexOf(this.searchItem) > -1,
204
+        ),);
205
+      return _.orderBy(list, this.sortKey, this.SortDirection);
206
+    },
207
+    DisplayItems() {
208
+      const list = this.FilteredItems;
209
+      const startSlice = (this.currentPage - 1) * this.visibleItemsPerPageCount;
210
+      let endSlice = this.currentPage * this.visibleItemsPerPageCount;
211
+      if (endSlice > list.length) {
212
+        endSlice = list.length;
213
+      }
214
+      return list.slice(startSlice, endSlice);
215
+    },
126
   },
216
   },
127
 };
217
 };
128
 </script>
218
 </script>

+ 94
- 6
src/components/admin/status/userManagementPage.vue Ver fichero

22
         >Agents</button>
22
         >Agents</button>
23
       </div>
23
       </div>
24
     </div>
24
     </div>
25
-    <br />
26
-    <br />
27
     <div class="container">
25
     <div class="container">
26
+      <div class="d-flex justify-content-between">
27
+        <div class="p-2">
28
+          <input v-model="searchItem" class="form-control" placeholder="Search ..." />
29
+        </div>
30
+      </div>
28
       <table class="table table-bordered">
31
       <table class="table table-bordered">
29
         <thead>
32
         <thead>
30
           <tr>
33
           <tr>
59
         <tbody>
62
         <tbody>
60
           <tr>
63
           <tr>
61
             <td colspan="10">
64
             <td colspan="10">
62
-              <h5>Private Users</h5>
65
+              <div class="myWell">
66
+                <h4>Private Users</h4>
67
+              </div>
63
             </td>
68
             </td>
64
           </tr>
69
           </tr>
65
-          <tr v-for="(item, i) in individuals" :key="i">
70
+          <tr v-for="(item, i) in DisplayItems" :key="i">
66
             <td>{{ item.id }}</td>
71
             <td>{{ item.id }}</td>
67
             <td>{{ item.name }}</td>
72
             <td>{{ item.name }}</td>
68
             <td>{{ item.surname }}</td>
73
             <td>{{ item.surname }}</td>
86
           </tr>
91
           </tr>
87
         </tbody>
92
         </tbody>
88
       </table>
93
       </table>
94
+      <div class="d-flex justify-content-between">
95
+        <div class="p-1">{{ currentPage + ' / ' + PageCount }}</div>
96
+        <div class="p-1">
97
+          <BasePagination
98
+            :currentPage="currentPage"
99
+            :pageCount="PageCount"
100
+            @nextPage="pageChangeHandle('next')"
101
+            @previousPage="pageChangeHandle('previous')"
102
+            @loadPage="pageChangeHandle"
103
+          />
104
+        </div>
105
+      </div>
106
+      <br />
89
     </div>
107
     </div>
90
-    <br />
91
   </div>
108
   </div>
92
 </template>
109
 </template>
110
+
93
 <script>
111
 <script>
94
 import { mapState, mapActions } from 'vuex';
112
 import { mapState, mapActions } from 'vuex';
113
+import _ from 'lodash';
114
+import ItemsPerPageList from '../../../assets/staticData/itemsPerPage';
115
+import BasePagination from '../../shared/basePagination.vue';
95
 
116
 
96
 export default {
117
 export default {
97
   name: 'userManagementPage',
118
   name: 'userManagementPage',
119
+  components: {
120
+    BasePagination,
121
+  },
98
   data() {
122
   data() {
99
-    return {};
123
+    return {
124
+      sortKey: '',
125
+      reverse: false,
126
+      searchItem: '',
127
+      itemsPerPageList: ItemsPerPageList,
128
+      visibleItemsPerPageCount: 0,
129
+      currentPage: 1,
130
+    };
100
   },
131
   },
101
   methods: {
132
   methods: {
102
     ...mapActions('register', ['getIndividuals']),
133
     ...mapActions('register', ['getIndividuals']),
103
     routerGoTo(goTo) {
134
     routerGoTo(goTo) {
104
       this.$router.push(goTo);
135
       this.$router.push(goTo);
105
     },
136
     },
137
+    sortBy(sortKey) {
138
+      this.reverse = this.sortKey === sortKey ? !this.reverse : false;
139
+      this.sortKey = sortKey;
140
+    },
141
+    async pageChangeHandle(value) {
142
+      console.log(value);
143
+      switch (value) {
144
+        case 'next':
145
+          this.currentPage += 1;
146
+          break;
147
+        case 'previous':
148
+          this.currentPage -= 1;
149
+          break;
150
+        default:
151
+          this.currentPage = value;
152
+      }
153
+    },
154
+    onChangeItemsPerPage() {
155
+      if (this.currentPage !== 1) {
156
+        this.currentPage = 1;
157
+      }
158
+    },
106
   },
159
   },
107
   mounted() {
160
   mounted() {
108
     this.getIndividuals();
161
     this.getIndividuals();
162
+    try {
163
+      // to assign initial value to itemsPerPage
164
+      if (this.itemsPerPageList && this.itemsPerPageList.length > 0) {
165
+        const [startItem] = this.itemsPerPageList;
166
+        this.visibleItemsPerPageCount = startItem;
167
+      }
168
+    } catch (error) {
169
+      throw error;
170
+    }
109
   },
171
   },
110
   computed: {
172
   computed: {
111
     ...mapState('register', ['individuals']),
173
     ...mapState('register', ['individuals']),
174
+
175
+    SortDirection() {
176
+      return this.reverse ? 'desc' : 'asc';
177
+    },
178
+    PageCount() {
179
+      return this.visibleItemsPerPageCount !== 0
180
+        ? Math.ceil(this.FilteredItems.length / this.visibleItemsPerPageCount)
181
+        : 1;
182
+    },
183
+    FilteredItems() {
184
+      const list = _.filter(this.individuals, item => Object.values(item).some(
185
+          i => JSON.stringify(i)
186
+              .toLowerCase()
187
+              .indexOf(this.searchItem) > -1,
188
+        ),);
189
+      return _.orderBy(list, this.sortKey, this.SortDirection);
190
+    },
191
+    DisplayItems() {
192
+      const list = this.FilteredItems;
193
+      const startSlice = (this.currentPage - 1) * this.visibleItemsPerPageCount;
194
+      let endSlice = this.currentPage * this.visibleItemsPerPageCount;
195
+      if (endSlice > list.length) {
196
+        endSlice = list.length;
197
+      }
198
+      return list.slice(startSlice, endSlice);
199
+    },
112
   },
200
   },
113
 };
201
 };
114
 </script>
202
 </script>

+ 0
- 11
src/components/shared/navBar.vue Ver fichero

192
               </span>
192
               </span>
193
               <span v-else></span>
193
               <span v-else></span>
194
             </li>
194
             </li>
195
-            <li class="nav-item dropdown" v-if="!isLoggedIn">
196
-              <a
197
-                class="nav-link"
198
-                @click="routerGoTo('/status/agentUserManagementPage')"
199
-                id="navbarDropdown"
200
-                role="button"
201
-                data-toggle="dropdown"
202
-                aria-haspopup="true"
203
-                aria-expanded="false"
204
-              >Test</a>
205
-            </li>
206
           </ul>
195
           </ul>
207
         </div>
196
         </div>
208
       </div>
197
       </div>

Loading…
Cancelar
Guardar