1
- import 'package:js/js.dart' ;
2
- import 'package:js/js_util.dart' ;
1
+ import 'dart:js_interop' ;
3
2
4
3
import '../../../models/screenset_event.dart' ;
5
4
import '../models/profile.dart' ;
6
5
7
- /// This typedef defines the function signature for the handler of the screenset before validation event.
8
- ///
9
- /// This function should return a [Future] that resolves with a [Map] containing the error messages per field in the form.
10
- /// If there are no errors, this future should resolve with `null` as value.
11
- typedef BeforeValidationEventHandler = Future <Map <String , dynamic >?> Function (ScreensetEvent event);
12
-
13
- /// The static interop class for the before validation event of the `Account.showScreenset` event stream.
6
+ /// The extension type for the before validation event of the `Account.showScreenset` event stream.
14
7
///
15
8
/// See: https://help.sap.com/docs/SAP_CUSTOMER_DATA_CLOUD/8b8d6fffe113457094a17701f63e3d6a/413a5b7170b21014bbc5a10ce4041860.html?locale=en-US#onbeforevalidation
16
9
@JS ()
17
10
@anonymous
18
11
@staticInterop
19
- class BeforeValidationEvent {}
20
-
21
- /// This extension defines the static interop definition
22
- /// for the [BeforeValidationEvent] class.
23
- extension BeforeValidationEventExtension on BeforeValidationEvent {
24
- /// The data object for the user. This will be empty if the user is not logged in.
25
- external Object ? get data;
12
+ extension type BeforeValidationEvent (JSObject _) {
13
+ /// The data object for the user.
14
+ /// This will be empty if the user is not logged in.
15
+ external JSAny ? get data;
26
16
27
17
/// The name of the event.
28
18
external String get eventName;
@@ -31,7 +21,7 @@ extension BeforeValidationEventExtension on BeforeValidationEvent {
31
21
external String get form;
32
22
33
23
/// An object containing the properties of the form fields.
34
- external Object ? get formData;
24
+ external JSAny ? get formData;
35
25
36
26
/// The profile object for the user. This will be empty if the user is not logged in.
37
27
external Profile ? get profile;
@@ -44,22 +34,25 @@ extension BeforeValidationEventExtension on BeforeValidationEvent {
44
34
/// e.g., 'showLoginUI', 'showCommentsUI', etc.
45
35
external String get source;
46
36
47
- /// The subscriptions data for the user. This will be empty if the user is not logged in.
48
- external Object ? get subscriptions;
37
+ // TODO: This should be the subscriptions static interop type.
38
+
39
+ /// The subscriptions data for the user.
40
+ /// This will be empty if the user is not logged in.
41
+ external JSAny ? get subscriptions;
49
42
50
43
/// Serialize this event into a [ScreensetEvent] .
51
44
ScreensetEvent serialize () {
52
45
return ScreensetEvent (
53
46
eventName,
54
47
< String , dynamic > {
55
- 'data' : dartify (data ),
48
+ 'data' : data. dartify (),
56
49
'form' : form,
57
- 'formData' : dartify (formData ),
50
+ 'formData' : formData. dartify (),
58
51
'profile' : profile? .toMap (),
59
52
'screen' : screen,
60
53
'source' : source,
61
- 'subscriptions' : dartify (subscriptions ),
54
+ 'subscriptions' : subscriptions. dartify (),
62
55
},
63
56
);
64
57
}
65
- }
58
+ }
0 commit comments