Skip to content

Commit e4e285e

Browse files
committed
opening alert box action - bug fix
1 parent c0e5369 commit e4e285e

File tree

7 files changed

+53
-51
lines changed

7 files changed

+53
-51
lines changed

examples/crm/routes/app/routes/administration/routes/users/Index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export default {
107107
resetPassword (item) {
108108
Vue.http.put(this.prefix + '/' + this.path + '/' + item.id + '/reset-password')
109109
.then((response) => {
110-
this.openAlertBox('alertSuccess', this.$t('passwordReseted'))
110+
this.openAlertBox(['alertSuccess', this.$t('passwordReseted')])
111111
this.getItems()
112112
})
113113
}

src/store/actions.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const actions = {
2-
openAlertBox ({ commit }, alertType, data) {
2+
openAlertBox ({ commit }, [alertType, data]) {
33
if (['alertSuccess', 'alertValidationError', 'alertError'].includes(alertType)) {
44
commit(alertType, data)
55
}

src/utils/auth/store/mutations.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ const mutations = {
2525
state.logged = 0
2626
state.user = null
2727
state.token = null
28+
state.permissions = null
2829
localStorage.removeItem('token')
2930
localStorage.removeItem('user')
31+
localStorage.removeItem('permissions')
3032
},
3133
editUser (state, data) {
3234
const user = JSON.stringify(data)

src/utils/crud/components/DataTableServerSide.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export default {
227227
let filteredItems
228228
Vue.http.post(`${this.prefix}/${this.path}/search`, params)
229229
.then((response) => {
230-
const items = response.body
230+
const items = response.body.data
231231
filteredItems = items.map(obj => getItemsList(obj, this.tableFields, this.meta, this.primaryKey, this.customButtons, this.activeColumnName))
232232
const data = filteredItems.map((item) => {
233233
const row = []
@@ -248,7 +248,7 @@ export default {
248248
})
249249
}, (error) => {
250250
this.excelLoading = false
251-
this.openAlertBox('alertError', error.statusText)
251+
this.openAlertBox(['alertError', error.statusText])
252252
})
253253
}
254254
}

src/utils/crud/components/ItemDetails.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -490,9 +490,9 @@ export default {
490490
} else {
491491
this.$set(this.uploadStatuses, field.name, 'error')
492492
if (response.body.status === -1) {
493-
this.openAlertBox('alertError', response.body.msg)
493+
this.openAlertBox(['alertError', response.body.msg])
494494
} else if (response.body.status === -2) {
495-
this.openAlertBox('alertValidationError', response.body.msg)
495+
this.openAlertBox(['alertValidationError', response.body.msg])
496496
}
497497
}
498498
this.$set(this.uploadLoaders, field.name, false)

src/utils/crud/mixins/datatable-main.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export default {
178178
},
179179
checkSelected () {
180180
if (this.selected.length === 0) {
181-
this.openAlertBox('alertError', this.$t('global.datatable.noItemsSelected'))
181+
this.openAlertBox(['alertError', this.$t('global.datatable.noItemsSelected')])
182182
return false
183183
}
184184
if (confirm(this.$t('global.datatable.confirm'))) {
@@ -188,7 +188,7 @@ export default {
188188
},
189189
editSelected () {
190190
if (this.selected.length === 0) {
191-
this.openAlertBox('alertError', this.$t('global.datatable.noItemsSelected'))
191+
this.openAlertBox(['alertError', this.$t('global.datatable.noItemsSelected')])
192192
return false
193193
}
194194

src/utils/crud/store/actions.js

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const actions = {
99
commit('setItems', response.body)
1010
commit('setLoadingStatus', false)
1111
}, (error) => {
12-
dispatch('openAlertBox', 'alertError', error.statusText, { root: true })
12+
dispatch('openAlertBox', ['alertError', error.statusText], { root: true })
1313
})
1414
},
1515
getItemsServerSide ({ commit, getters, dispatch }, [params]) {
@@ -20,7 +20,7 @@ const actions = {
2020
commit('setItemsServerSide', response.body)
2121
resolve()
2222
}, (error) => {
23-
dispatch('openAlertBox', 'alertError', error.statusText, { root: true })
23+
dispatch('openAlertBox', ['alertError', error.statusText], { root: true })
2424
reject(error)
2525
})
2626
})
@@ -35,7 +35,7 @@ const actions = {
3535
commit('setDetailsLoader', false)
3636
resolve()
3737
}, (error) => {
38-
dispatch('openAlertBox', 'alertError', error.statusText, { root: true })
38+
dispatch('openAlertBox', ['alertError', error.statusText], { root: true })
3939
reject(error)
4040
})
4141
})
@@ -47,16 +47,16 @@ const actions = {
4747
Vue.http.put(`${getters.path('u')}/${id}`, params)
4848
.then((response) => {
4949
if (response.body.status === 0) {
50-
dispatch('openAlertBox', 'alertSuccess', successText, { root: true })
50+
dispatch('openAlertBox', ['alertSuccess', successText], { root: true })
5151
dispatch('runTableRefreshing')
5252
resolve()
5353
} else if (response.body.status === -1) {
54-
dispatch('openAlertBox', 'alertError', response.body.msg, { root: true })
54+
dispatch('openAlertBox', ['alertError', response.body.msg], { root: true })
5555
} else if (response.body.status === -2) {
56-
dispatch('openAlertBox', 'alertValidationError', response.body.msg, { root: true })
56+
dispatch('openAlertBox', ['alertValidationError', response.body.msg], { root: true })
5757
}
5858
}, (error) => {
59-
dispatch('openAlertBox', 'alertError', errorText, { root: true })
59+
dispatch('openAlertBox', ['alertError', errorText], { root: true })
6060
reject(error)
6161
})
6262
})
@@ -68,19 +68,19 @@ const actions = {
6868
Vue.http.post(getters.path('st'), params)
6969
.then((response) => {
7070
if (response.body.status === 0) {
71-
dispatch('openAlertBox', 'alertSuccess', successText, { root: true })
71+
dispatch('openAlertBox', ['alertSuccess', successText], { root: true })
7272
dispatch('runTableRefreshing')
7373
resolve()
7474
} else if (response.body.status === -1) {
75-
dispatch('openAlertBox', 'alertError', response.body.msg, { root: true })
75+
dispatch('openAlertBox', ['alertError', response.body.msg], { root: true })
7676
} else if (response.body.status === -2) {
77-
dispatch('openAlertBox', 'alertValidationError', response.body.msg, { root: true })
77+
dispatch('openAlertBox', ['alertValidationError', response.body.msg], { root: true })
7878
}
7979
if (state.createdElement.mode === 'inform') {
8080
commit('setCreatedItemStatus', [true, response.body.id])
8181
}
8282
}, (error) => {
83-
dispatch('openAlertBox', 'alertError', errorText, { root: true })
83+
dispatch('openAlertBox', ['alertError', errorText], { root: true })
8484
reject(error)
8585
})
8686
})
@@ -90,32 +90,32 @@ const actions = {
9090
}, [id, successText, errorText]) {
9191
Vue.http.delete(`${getters.path('d')}/${id}`)
9292
.then(() => {
93-
dispatch('openAlertBox', 'alertSuccess', successText, { root: true })
93+
dispatch('openAlertBox', ['alertSuccess', successText], { root: true })
9494
dispatch('runTableRefreshing')
9595
}, () => {
96-
dispatch('openAlertBox', 'alertError', errorText, { root: true })
96+
dispatch('openAlertBox', ['alertError', errorText], { root: true })
9797
})
9898
},
9999
mulitipleItemsUpdate ({
100100
getters, dispatch
101101
}, [params, successText, errorText]) {
102102
Vue.http.post(`${getters.path('mu')}/multiple-update`, params)
103103
.then(() => {
104-
dispatch('openAlertBox', 'alertSuccess', successText, { root: true })
104+
dispatch('openAlertBox', ['alertSuccess', successText], { root: true })
105105
dispatch('runTableRefreshing')
106106
}, () => {
107-
dispatch('openAlertBox', 'alertError', errorText, { root: true })
107+
dispatch('openAlertBox', ['alertError', errorText], { root: true })
108108
})
109109
},
110110
mulitipleItemsDelete ({
111111
getters, dispatch
112112
}, [ids, successText, errorText]) {
113113
Vue.http.post(`${getters.path('md')}/multiple-delete`, ids)
114114
.then(() => {
115-
dispatch('openAlertBox', 'alertSuccess', successText, { root: true })
115+
dispatch('openAlertBox', ['alertSuccess', successText], { root: true })
116116
dispatch('runTableRefreshing')
117117
}, () => {
118-
dispatch('openAlertBox', 'alertError', errorText, { root: true })
118+
dispatch('openAlertBox', ['alertError', errorText], { root: true })
119119
})
120120
},
121121
// item elements
@@ -129,43 +129,43 @@ const actions = {
129129
}, [params, successText, errorText]) {
130130
Vue.http.post(state.itemElements.controller, params)
131131
.then(() => {
132-
dispatch('openAlertBox', 'alertSuccess', successText, { root: true })
132+
dispatch('openAlertBox', ['alertSuccess', successText], { root: true })
133133
dispatch('getItemElements')
134134
}, () => {
135-
dispatch('openAlertBox', 'alertError', errorText, { root: true })
135+
dispatch('openAlertBox', ['alertError', errorText], { root: true })
136136
})
137137
},
138138
removeItemElement ({
139139
dispatch, state
140140
}, [id, successText, errorText]) {
141141
Vue.http.delete(`${state.itemElements.controller}/${id}`)
142142
.then(() => {
143-
dispatch('openAlertBox', 'alertSuccess', successText, { root: true })
143+
dispatch('openAlertBox', ['alertSuccess', successText], { root: true })
144144
dispatch('getItemElements')
145145
}, () => {
146-
dispatch('openAlertBox', 'alertError', errorText, { root: true })
146+
dispatch('openAlertBox', ['alertError', errorText], { root: true })
147147
})
148148
},
149149
addManyItemElements ({
150150
dispatch, state
151151
}, [params, successText, errorText]) {
152152
Vue.http.post(`${state.itemElements.controller}/multiple-add`, params)
153153
.then(() => {
154-
dispatch('openAlertBox', 'alertSuccess', successText, { root: true })
154+
dispatch('openAlertBox', ['alertSuccess', successText], { root: true })
155155
dispatch('getItemElements')
156156
}, () => {
157-
dispatch('openAlertBox', 'alertError', errorText, { root: true })
157+
dispatch('openAlertBox', ['alertError', errorText], { root: true })
158158
})
159159
},
160160
removeManyItemElements ({
161161
dispatch, state
162162
}, [ids, successText, errorText]) {
163163
Vue.http.post(`${state.itemElements.controller}/multiple-delete`, ids)
164164
.then(() => {
165-
dispatch('openAlertBox', 'alertSuccess', successText, { root: true })
165+
dispatch('openAlertBox', ['alertSuccess', successText], { root: true })
166166
dispatch('getItemElements')
167167
}, () => {
168-
dispatch('openAlertBox', 'alertError', errorText, { root: true })
168+
dispatch('openAlertBox', ['alertError', errorText], { root: true })
169169
})
170170
},
171171
// extented details
@@ -178,7 +178,7 @@ const actions = {
178178
commit('setDetailsLoader', false)
179179
resolve()
180180
}, (error) => {
181-
dispatch('openAlertBox', 'alertError', error.statusText, { root: true })
181+
dispatch('openAlertBox', ['alertError', error.statusText], { root: true })
182182
reject(error)
183183
})
184184
})
@@ -189,15 +189,15 @@ const actions = {
189189
Vue.http.put(`${getters.path('u')}/${id}`, params)
190190
.then((response) => {
191191
if (response.body.status === 0) {
192-
dispatch('openAlertBox', 'alertSuccess', successText, { root: true })
192+
dispatch('openAlertBox', ['alertSuccess', successText], { root: true })
193193
} else if (response.body.status === -1) {
194-
dispatch('openAlertBox', 'alertError', response.body.msg, { root: true })
194+
dispatch('openAlertBox', ['alertError', response.body.msg], { root: true })
195195
} else if (response.body.status === -2) {
196-
dispatch('openAlertBox', 'alertValidationError', response.body.msg, { root: true })
196+
dispatch('openAlertBox', ['alertValidationError', response.body.msg], { root: true })
197197
}
198198
dispatch('getItemDetails', [state.item[state.itemIdColumn]])
199199
}, (error) => {
200-
dispatch('openAlertBox', 'alertError', error.statusText, { root: true })
200+
dispatch('openAlertBox', ['alertError', error.statusText], { root: true })
201201
})
202202
},
203203
// child details
@@ -208,16 +208,16 @@ const actions = {
208208
Vue.http.put(`${path}/${id}`, params)
209209
.then((response) => {
210210
if (response.body.status === 0) {
211-
dispatch('openAlertBox', 'alertSuccess', successText, { root: true })
211+
dispatch('openAlertBox', ['alertSuccess', successText], { root: true })
212212
resolve()
213213
} else if (response.body.status === -1) {
214-
dispatch('openAlertBox', 'alertError', response.body.msg, { root: true })
214+
dispatch('openAlertBox', ['alertError', response.body.msg], { root: true })
215215
} else if (response.body.status === -2) {
216-
dispatch('openAlertBox', 'alertValidationError', response.body.msg, { root: true })
216+
dispatch('openAlertBox', ['alertValidationError', response.body.msg], { root: true })
217217
}
218218
dispatch('getItemDetails', [state.item[state.itemIdColumn]])
219219
}, (error) => {
220-
dispatch('openAlertBox', 'alertError', error.statusText, { root: true })
220+
dispatch('openAlertBox', ['alertError', error.statusText], { root: true })
221221
reject(error)
222222
})
223223
})
@@ -228,15 +228,15 @@ const actions = {
228228
Vue.http.delete(`${path}/${id}`)
229229
.then((response) => {
230230
if (response.body.status === 0) {
231-
dispatch('openAlertBox', 'alertSuccess', successText, { root: true })
231+
dispatch('openAlertBox', ['alertSuccess', successText], { root: true })
232232
} else if (response.body.status === -1) {
233-
dispatch('openAlertBox', 'alertError', response.body.msg, { root: true })
233+
dispatch('openAlertBox', ['alertError', response.body.msg], { root: true })
234234
} else if (response.body.status === -2) {
235-
dispatch('openAlertBox', 'alertValidationError', response.body.msg, { root: true })
235+
dispatch('openAlertBox', ['alertValidationError', response.body.msg], { root: true })
236236
}
237237
dispatch('getItemDetails', [state.item[state.itemIdColumn]])
238238
}, () => {
239-
dispatch('openAlertBox', 'alertError', errorText, { root: true })
239+
dispatch('openAlertBox', ['alertError', errorText], { root: true })
240240
})
241241
},
242242
storeChild ({
@@ -246,16 +246,16 @@ const actions = {
246246
Vue.http.post(path, params)
247247
.then((response) => {
248248
if (response.body.status === 0) {
249-
dispatch('openAlertBox', 'alertSuccess', successText, { root: true })
249+
dispatch('openAlertBox', ['alertSuccess', successText], { root: true })
250250
resolve()
251251
} else if (response.body.status === -1) {
252-
dispatch('openAlertBox', 'alertError', response.body.msg, { root: true })
252+
dispatch('openAlertBox', ['alertError', response.body.msg], { root: true })
253253
} else if (response.body.status === -2) {
254-
dispatch('openAlertBox', 'alertValidationError', response.body.msg, { root: true })
254+
dispatch('openAlertBox', ['alertValidationError', response.body.msg], { root: true })
255255
}
256256
dispatch('getItemDetails', [state.item[state.itemIdColumn]])
257257
}, (error) => {
258-
dispatch('openAlertBox', 'alertError', error.statusText, { root: true })
258+
dispatch('openAlertBox', ['alertError', error.statusText], { root: true })
259259
reject(error)
260260
})
261261
})
@@ -267,7 +267,7 @@ const actions = {
267267
commit('setChild', [response.body, childItemName])
268268
resolve()
269269
}, (error) => {
270-
dispatch('openAlertBox', 'alertError', error.statusText, { root: true })
270+
dispatch('openAlertBox', ['alertError', error.statusText], { root: true })
271271
})
272272
})
273273
},

0 commit comments

Comments
 (0)