Skip to content

Commit

Permalink
Changed resp format for actions (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexeyzvegintcev authored Nov 29, 2021
1 parent c0265fd commit 2584a8e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/ng/gridz/list/BaseListCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ export default class BaseListCtrl {

handleError(er) {
console.error(er)
toast.error(er)
const message = er?.response?.status === 500 ? 'Unexpected error' : null
toast.error(message || er)
}

swalError(error) {
Expand Down Expand Up @@ -276,10 +277,10 @@ export default class BaseListCtrl {
try {
const result = await action()
if(result.ok){
toast.success(result.success[0]?.message || 'Action is sucsess')
toast.success(result.title || 'Action is sucsess')
this.gridCtrl.reload() // todo: should we reload only selected rows?
} else {
this.swalError({title: 'Action Error',message: result.failed[0]?.message || 'Action failed'})
this.swalError({title: result.title , message: result?.failed?.join('<br>') || ''})
}
} catch (e) {
this.handleError(e)
Expand Down

0 comments on commit 2584a8e

Please sign in to comment.