Line data Source code
1 : part of apptive_grid_model; 2 : 3 : /// Model for a Action inside a Form 4 : class FormAction { 5 : /// Creates a Form Action 6 3 : FormAction(this.uri, this.method); 7 : 8 : /// Deserialize [json] into a [FormAction] 9 3 : FormAction.fromJson(Map<String, dynamic> json) 10 3 : : uri = json['uri'], 11 3 : method = json['method']; 12 : 13 : /// Path the Action points to 14 : final String uri; 15 : 16 : /// [http.BaseRequest.method] method this Action uses 17 : final String method; 18 : 19 : /// Serializes [FormAction] to json 20 6 : Map<String, dynamic> toJson() => { 21 3 : 'uri': uri, 22 3 : 'method': method, 23 : }; 24 : 25 2 : @override 26 : String toString() { 27 6 : return 'FormAction(uri: $uri, method: $method)'; 28 : } 29 : 30 3 : @override 31 : bool operator ==(Object other) { 32 21 : return other is FormAction && uri == other.uri && method == other.method; 33 : } 34 : 35 1 : @override 36 2 : int get hashCode => toString().hashCode; 37 : } 38 : 39 : /// Wrapper class to use in [ApptiveGridCache] 40 : class ActionItem { 41 : /// Creates a new Action Item 42 2 : ActionItem({ 43 : required this.action, 44 : required this.data, 45 : }); 46 : 47 : /// Creates a ActionItem base on a [json] map 48 1 : ActionItem.fromJson(Map<String, dynamic> json) 49 2 : : action = FormAction.fromJson(json['action']), 50 2 : data = FormData.fromJson(json['data']); 51 : 52 : /// Action to be performed 53 : final FormAction action; 54 : 55 : /// Data to be send in the Action 56 : final FormData data; 57 : 58 : /// Serializes the ActionItem to a json map 59 2 : Map<String, dynamic> toJson() => { 60 2 : 'action': action.toJson(), 61 2 : 'data': data.toJson(), 62 : }; 63 : 64 2 : @override 65 : String toString() { 66 6 : return 'ActionItem(action: $action, data: $data)'; 67 : } 68 : 69 2 : @override 70 : bool operator ==(Object other) { 71 14 : return other is ActionItem && action == other.action && data == other.data; 72 : } 73 : 74 1 : @override 75 2 : int get hashCode => toString().hashCode; 76 : }