11
11
import _ from ' lodash'
12
12
import logger from ' loglevel'
13
13
import { ref } from ' vue'
14
- import { api , Context } from ' @kalisio/kdk/core.client'
14
+ import { api , Context , i18n } from ' @kalisio/kdk/core.client'
15
+ import { Notify } from ' quasar'
15
16
16
17
// Props
17
18
const props = defineProps ({
@@ -46,6 +47,10 @@ const props = defineProps({
46
47
dense: {
47
48
type: Boolean ,
48
49
default: false
50
+ },
51
+ notify: {
52
+ type: Object ,
53
+ default: null
49
54
}
50
55
})
51
56
@@ -78,9 +83,11 @@ async function apply () {
78
83
if (mode === ' creation' ) {
79
84
logger .debug (' [KDK] Create object with data' , response .values )
80
85
await service .create (values)
86
+ if (_ .has (props, ' notify.created.success' )) Notify .create ({ type: ' positive' , message: i18n .t (_ .get (props, ' notify.created.success' )) })
81
87
} else {
82
88
logger .debug (` [KDK] Patch object ${ props .object ._id } with data` , response .values )
83
89
await service .patch (props .object ._id , response .values )
90
+ if (_ .has (props, ' notify.updated.success' )) Notify .create ({ type: ' positive' , message: i18n .t (_ .get (props, ' notify.updated.success' )) })
84
91
}
85
92
// run the afterRequest hook
86
93
if (props .afterRequest ) {
@@ -90,6 +97,8 @@ async function apply () {
90
97
if (! response .isOk ) return false
91
98
return true
92
99
} else {
100
+ if (mode === ' creation' && _ .has (props, ' notify.created.error' )) Notify .create ({ type: ' negative' , message: i18n .t (_ .get (props, ' notify.created.error' )) })
101
+ if (mode === ' edition' && _ .has (props, ' notify.updated.error' )) Notify .create ({ type: ' negative' , message: i18n .t (_ .get (props, ' notify.updated.error' )) })
93
102
logger .debug (' [KDK] Form is invalid' )
94
103
}
95
104
}
0 commit comments