-
Notifications
You must be signed in to change notification settings - Fork 0
/
UsersList.vue
239 lines (226 loc) · 7.02 KB
/
UsersList.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
<template>
<div id="user-list">
<confirm-dialog
id="users-list-confirm-modal"
:show="dialogHasToBeShown"
:acting="performingAction"
:title="confirmDialogTitle"
:body="confirmDialogBody"
@hide="onHide"
@confirm="onConfirm"
:confirm-text="confirmDialogText"
></confirm-dialog>
<adminlte-vue-box color="success" :collapsed="isCollapsed" id="users-list-box" :loading="loading">
<span slot="title">Users Lists</span>
<users-list-filter-bar></users-list-filter-bar>
<users-list-global-actions :selected="selectedItems()"></users-list-global-actions>
<adminlte-vue-alert color="success" title="Done!" v-if="showResult" id="users-list-result"
style="clear: left;">
{{ result }}
</adminlte-vue-alert>
<div class="table-responsive" style="clear: left;">
<vuetable ref="vuetable"
:api-url="apiUri"
:fields="columns"
pagination-path=""
:css="css.table"
:api-mode="true"
row-class="um-user-row"
:append-params="moreParams"
:multi-sort="true"
detail-row-component="user-detail-row"
@vuetable:pagination-data="onPaginationData"
@vuetable:cell-clicked="onCellClicked"
@vuetable:loading="showLoader"
@vuetable:loaded="hideLoader"
></vuetable>
</div>
<div class="vuetable-pagination" id="users-list-vuetable-pagination">
<vuetable-pagination-info ref="paginationInfo"
info-class="pagination-info"
infoTemplate="Displaying {from} to {to} of {total} users"
></vuetable-pagination-info>
<vuetable-pagination ref="pagination"
:css="css.pagination"
:icons="css.icons"
@vuetable-pagination:change-page="onChangePage"
></vuetable-pagination>
</div>
</adminlte-vue-box>
</div>
</template>
<script>
import UsersListFilterBar from './UsersListFilterBar'
import UsersListGlobalActions from './UsersListGlobalActions'
import UserDetailRow from './UserDetailRow'
import UserListCustomActions from './UsersListCustomActions'
Vue.component('users-list-filter-bar', UsersListFilterBar)
Vue.component('users-list-global-actions', UsersListGlobalActions)
Vue.component('user-detail-row', UserDetailRow)
Vue.component('users-list-custom-actions', UserListCustomActions)
import List from './mixins/List.js'
import HideDialog from './mixins/HideDialog.js'
import PerformAction from './mixins/PerformAction.js'
export default {
mixins: [
List, PerformAction, HideDialog
],
components: {
UsersListFilterBar
},
data() {
return {
columns: [
{
name: '__sequence',
title: '#',
titleClass: 'text-right',
dataClass: 'text-right'
},
{
name: '__checkbox',
titleClass: 'text-center',
dataClass: 'text-center',
},
{
name: 'extra',
visible: false,
},
{
name: 'id',
sortField: 'id',
},
{
name: 'name',
sortField: 'name',
},
{
name: 'email',
},
{
name: 'created_at',
},
{
name: 'updated_at',
},
{
name: '__component:users-list-custom-actions',
title: 'Actions',
titleClass: 'text-center',
dataClass: 'text-center'
}
],
}
},
methods: {
selectedItems () {
if (this.$refs.vuetable) return this.$refs.vuetable.selectedTo
return []
},
checkDialogType (type){
return this.validDialogs().includes(type)
},
validDialogs() {
return ['delete-user','reset-user-password','delete-users','reset-users-passwords']
},
executePostConfirmAction () {
switch(this.confirmDialogType) {
case 'delete-user':
this.deleteUser(this.currentData)
break;
case 'reset-user-password':
this.resetPassword(this.currentData)
break;
case 'delete-users':
this.deleteUsers(this.currentData)
break;
case 'reset-users-passwords':
this.resetPasswords(this.currentData)
break;
}
},
deleteUser (data) {
this.performAction(
data,
'/' + data.id,
[],
'User ' + data.name + ' has been deleted!',
'delete',
'show-result-users-list'
)
this.reload()
},
resetPassword(data) {
this.performAction(
data,
'/send/reset-password-email',
{
email: data.email
},
'Password reset email sent to user ' + data.name + '.',
'post',
'show-result-users-list'
)
},
deleteUsers(data) {
this.performAction(
data,
'-massive',
{
ids: data
},
'Selected users removed.',
'post',
'show-result-users-list'
)
this.reload()
},
resetPasswords(data) {
this.performAction(
data,
'/send/reset-password-email/massive',
{
ids: data
},
'Password reset email sent to user all the selected users.',
'post',
'show-result-users-list')
}
},
events: {
'filter-set-users-list' (filterText) {
this.moreParams = {
filter: filterText
}
Vue.nextTick(() => this.refresh())
},
'filter-reset-users-list' () {
this.moreParams = {}
Vue.nextTick(() => this.refresh())
},
'reload-users-list' () {
Vue.nextTick(() => this.reload())
},
'toogle-show-user' (id) {
this.detailRowEditing(id,false)
},
'toogle-edit-user' (id) {
this.detailRowEditing(id,true)
},
'reload-user-list' () {
Vue.nextTick(() => this.refresh())
},
'show-result-users-list' (result) {
this.showResult = true
this.result = result
},
'hideDialog' () {
this.onHide()
},
'show-confirm-dialog' (type, dialog, data) {
this.showDialog(type, dialog, data)
}
}
}
</script>
<style src="./css/pagination.css"></style>