2024-05-20 10:29:02 +00:00
|
|
|
// To parse this JSON data, do
|
|
|
|
//
|
|
|
|
// final welcome = welcomeFromJson(jsonString);
|
|
|
|
|
|
|
|
import 'dart:convert';
|
|
|
|
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:hive_flutter/hive_flutter.dart';
|
|
|
|
part 'interaction_data.g.dart';
|
|
|
|
|
|
|
|
// InteractionResultData welcomeFromJson(String str) =>
|
|
|
|
// InteractionResultData.fromJson(json.decode(str));
|
|
|
|
|
|
|
|
// String welcomeToJson(InteractionResultData data) => json.encode(data.toJson());
|
|
|
|
|
|
|
|
ResponseData ResponseDataFromJson(Map<String, dynamic> str) =>
|
|
|
|
ResponseData.fromJson(str);
|
|
|
|
|
|
|
|
String ResponseDataToJson(ResponseData data) => json.encode(data.toJson());
|
|
|
|
|
|
|
|
class ResponseData {
|
|
|
|
List<InteractionResultData> data;
|
|
|
|
|
|
|
|
ResponseData({
|
|
|
|
required this.data,
|
|
|
|
});
|
|
|
|
|
|
|
|
factory ResponseData.fromJson(Map<String, dynamic> json) => ResponseData(
|
|
|
|
data: List<InteractionResultData>.from(
|
|
|
|
json["data"].map((x) => InteractionResultData.fromJson(x))),
|
|
|
|
);
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
|
|
"data": List<dynamic>.from(data.map((x) => x.toJson())),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
@HiveType(typeId: 11)
|
|
|
|
class InteractionResultData {
|
|
|
|
@HiveField(0)
|
|
|
|
List<FormFieldData> result;
|
|
|
|
@HiveField(1)
|
|
|
|
String id;
|
|
|
|
@HiveField(2)
|
|
|
|
String name;
|
|
|
|
InteractionResultData(
|
|
|
|
{required this.result, required this.id, required this.name});
|
|
|
|
|
|
|
|
factory InteractionResultData.fromJson(Map<String, dynamic> json) =>
|
|
|
|
InteractionResultData(
|
|
|
|
result: List<FormFieldData>.from(
|
|
|
|
json["form-fields"].map((x) => FormFieldData.fromJson(x))),
|
|
|
|
id: json["id"],
|
|
|
|
name: json["name"],
|
|
|
|
);
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
|
|
"id": id,
|
|
|
|
"name": name,
|
|
|
|
"result": List<dynamic>.from(result.map((x) => x.toJson())),
|
|
|
|
};
|
|
|
|
|
|
|
|
Map<String, dynamic> saveToJson() => {
|
|
|
|
"save": List<dynamic>.from(result.map((x) => x.saveToJson())),
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
@HiveType(typeId: 4)
|
|
|
|
class FormFieldData {
|
|
|
|
@HiveField(0)
|
|
|
|
String sectionName;
|
|
|
|
@HiveField(1)
|
|
|
|
bool multiple;
|
|
|
|
@HiveField(2)
|
|
|
|
List<SectionList> sectionList;
|
|
|
|
@HiveField(3)
|
|
|
|
List<SectionList>? multipleList;
|
|
|
|
|
|
|
|
FormFieldData({
|
|
|
|
required this.sectionName,
|
|
|
|
required this.multiple,
|
|
|
|
required this.sectionList,
|
|
|
|
this.multipleList,
|
|
|
|
});
|
|
|
|
|
|
|
|
factory FormFieldData.fromJson(Map<String, dynamic> json) => FormFieldData(
|
|
|
|
sectionName: json["sectionName"],
|
|
|
|
multiple: json["multiple"],
|
|
|
|
sectionList: List<SectionList>.from(
|
|
|
|
json["sectionList"].map((x) => SectionList.fromJson(x))),
|
|
|
|
);
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
|
|
"sectionName": sectionName,
|
|
|
|
"multiple": multiple,
|
|
|
|
"sectionList": List<dynamic>.from(sectionList.map((x) => x.toJson())),
|
|
|
|
};
|
|
|
|
Map<String, dynamic> saveToJson() => {
|
|
|
|
"sectionName": sectionName,
|
|
|
|
};
|
2024-06-10 11:11:00 +00:00
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
// TODO: implement toString
|
|
|
|
return multiple.toString();
|
|
|
|
}
|
2024-05-20 10:29:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@HiveType(typeId: 5)
|
|
|
|
class SectionList {
|
|
|
|
@HiveField(0)
|
|
|
|
String name;
|
|
|
|
@HiveField(1)
|
|
|
|
String? param;
|
|
|
|
@HiveField(2)
|
|
|
|
String id;
|
|
|
|
@HiveField(3)
|
|
|
|
int? gid;
|
|
|
|
@HiveField(4)
|
|
|
|
List<dynamic>? selectedValue;
|
|
|
|
@HiveField(5)
|
|
|
|
String? depid;
|
|
|
|
@HiveField(6)
|
|
|
|
InteractionWidget? widget;
|
|
|
|
@HiveField(7)
|
|
|
|
String? input;
|
|
|
|
@HiveField(8)
|
|
|
|
List<InputClass>? inputList;
|
|
|
|
@HiveField(9)
|
|
|
|
bool? isRequired;
|
|
|
|
|
|
|
|
TextEditingController? controller;
|
|
|
|
@HiveField(10)
|
|
|
|
String? value;
|
|
|
|
@HiveField(11)
|
|
|
|
String? selectedId;
|
|
|
|
@HiveField(12)
|
|
|
|
InputClass? selectedObject;
|
|
|
|
@HiveField(13)
|
|
|
|
Validation? validation;
|
|
|
|
@HiveField(14)
|
|
|
|
String? chars;
|
|
|
|
@HiveField(15)
|
|
|
|
List<dynamic>? extension;
|
|
|
|
@HiveField(16)
|
|
|
|
List<dynamic>? fileName;
|
|
|
|
@HiveField(17)
|
|
|
|
List<dynamic>? tempselectedValue;
|
|
|
|
@HiveField(18)
|
|
|
|
String? max;
|
|
|
|
@HiveField(19)
|
|
|
|
String? min;
|
|
|
|
|
|
|
|
SectionList(
|
|
|
|
{required this.name,
|
|
|
|
this.param,
|
|
|
|
required this.id,
|
|
|
|
this.selectedValue,
|
|
|
|
this.depid,
|
|
|
|
this.widget,
|
|
|
|
this.input,
|
|
|
|
this.gid,
|
|
|
|
this.inputList,
|
|
|
|
this.isRequired,
|
|
|
|
this.controller,
|
|
|
|
this.selectedObject,
|
|
|
|
this.selectedId,
|
|
|
|
this.validation,
|
|
|
|
this.chars,
|
|
|
|
this.extension,
|
|
|
|
this.fileName,
|
|
|
|
this.tempselectedValue,
|
|
|
|
this.max,
|
|
|
|
this.min,
|
|
|
|
this.value});
|
|
|
|
|
|
|
|
factory SectionList.fromJson(Map<String, dynamic> json) => SectionList(
|
|
|
|
name: json["name"],
|
|
|
|
// param: json["param"],
|
|
|
|
id: json["id"],
|
|
|
|
// selectedValue: List<dynamic>.from(json["selectedValue"].map((x) => x)),
|
|
|
|
depid: json["depid"],
|
|
|
|
widget: widgetValues.map[json["widget"]]!,
|
|
|
|
input: json["input"],
|
|
|
|
inputList: json["inputList"] == null
|
|
|
|
? []
|
|
|
|
: List<InputClass>.from(
|
|
|
|
json["inputList"]!.map((x) => InputClass.fromJson(x))),
|
|
|
|
|
|
|
|
validation: Validation.fromJson(json["validation"]),
|
|
|
|
|
|
|
|
// chars: json["chars"],
|
|
|
|
max: json["max"],
|
|
|
|
min: json["min"],
|
|
|
|
);
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
|
|
"name": name,
|
|
|
|
"param": param,
|
|
|
|
"id": id,
|
|
|
|
"selectedValue": List<dynamic>.from(selectedValue!.map((x) => x)),
|
|
|
|
"depid": depid,
|
|
|
|
"widget": widgetValues.reverse[widget],
|
|
|
|
"input": input,
|
|
|
|
"inputList": inputList == null
|
|
|
|
? []
|
|
|
|
: List<dynamic>.from(inputList!.map((x) => x.toJson())),
|
|
|
|
"isRequired": isRequired,
|
|
|
|
"chars": chars,
|
|
|
|
"fileName": List<dynamic>.from(fileName!.map((x) => x)),
|
|
|
|
"extension": List<dynamic>.from(extension!.map((x) => x)),
|
|
|
|
"max": max,
|
|
|
|
"min": min,
|
|
|
|
};
|
|
|
|
Map<String, dynamic> saveToJson() => {
|
|
|
|
"name": name,
|
|
|
|
"param": param,
|
|
|
|
"id": id,
|
|
|
|
"selectedValue": List<dynamic>.from(selectedValue!.map((x) => x)),
|
|
|
|
};
|
|
|
|
@override
|
|
|
|
String toString() {
|
|
|
|
// TODO: implement toString
|
|
|
|
return name.toString();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@HiveType(typeId: 6)
|
|
|
|
class InputClass {
|
|
|
|
@HiveField(0)
|
|
|
|
dynamic id;
|
|
|
|
@HiveField(1)
|
|
|
|
String name;
|
|
|
|
@HiveField(2)
|
|
|
|
bool? ischecked;
|
|
|
|
@HiveField(3)
|
|
|
|
String? selectedId;
|
|
|
|
@HiveField(4)
|
|
|
|
String? selectedName;
|
|
|
|
@HiveField(5)
|
|
|
|
List<String>? selectedItems;
|
|
|
|
@HiveField(6)
|
|
|
|
String? pid;
|
|
|
|
InputClass(
|
|
|
|
{required this.id,
|
|
|
|
required this.name,
|
|
|
|
this.ischecked,
|
|
|
|
this.pid,
|
|
|
|
this.selectedId,
|
|
|
|
this.selectedItems,
|
|
|
|
this.selectedName});
|
|
|
|
|
|
|
|
factory InputClass.fromJson(Map<String, dynamic> json) => InputClass(
|
|
|
|
id: json["id"],
|
|
|
|
name: json["name"],
|
|
|
|
pid: json["pid"],
|
|
|
|
);
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() => {"id": id, "name": name, "pid": pid};
|
|
|
|
}
|
|
|
|
|
|
|
|
@HiveType(typeId: 18)
|
|
|
|
class Validation {
|
|
|
|
@HiveField(0)
|
|
|
|
bool isRequired;
|
|
|
|
@HiveField(1)
|
|
|
|
bool? multipleFiles;
|
|
|
|
@HiveField(2)
|
|
|
|
String? type;
|
|
|
|
@HiveField(3)
|
|
|
|
String? chars;
|
|
|
|
|
|
|
|
Validation({
|
|
|
|
required this.isRequired,
|
|
|
|
this.multipleFiles,
|
|
|
|
this.type,
|
|
|
|
this.chars,
|
|
|
|
});
|
|
|
|
|
|
|
|
factory Validation.fromJson(Map<String, dynamic> json) => Validation(
|
|
|
|
isRequired: json["isRequired"],
|
|
|
|
multipleFiles: json["multipleFiles"],
|
|
|
|
type: json["type"],
|
|
|
|
chars: json["chars"],
|
|
|
|
);
|
|
|
|
|
|
|
|
Map<String, dynamic> toJson() => {
|
|
|
|
"isRequired": isRequired,
|
|
|
|
"multipleFiles": multipleFiles,
|
|
|
|
"type": type,
|
|
|
|
"chars": chars,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
@HiveType(typeId: 12)
|
|
|
|
enum InteractionWidget {
|
|
|
|
@HiveField(0)
|
|
|
|
CHECKBOX,
|
|
|
|
@HiveField(1)
|
|
|
|
DROPDOWN,
|
|
|
|
@HiveField(2)
|
|
|
|
LABEL,
|
|
|
|
@HiveField(3)
|
|
|
|
RADIO,
|
|
|
|
@HiveField(4)
|
|
|
|
TEXT,
|
|
|
|
@HiveField(5)
|
|
|
|
BUTTON,
|
|
|
|
@HiveField(6)
|
|
|
|
AUTOCOMPLETE,
|
|
|
|
@HiveField(7)
|
|
|
|
MULTISELECT,
|
|
|
|
@HiveField(8)
|
|
|
|
RANGESLIDER
|
|
|
|
}
|
|
|
|
|
|
|
|
final widgetValues = EnumValues({
|
|
|
|
"checkbox": InteractionWidget.CHECKBOX,
|
|
|
|
"dropdown": InteractionWidget.DROPDOWN,
|
|
|
|
"label": InteractionWidget.LABEL,
|
|
|
|
"radio": InteractionWidget.DROPDOWN,
|
|
|
|
"text": InteractionWidget.TEXT,
|
|
|
|
"button": InteractionWidget.BUTTON,
|
|
|
|
"autocomplete": InteractionWidget.AUTOCOMPLETE,
|
|
|
|
"multiselect": InteractionWidget.MULTISELECT,
|
|
|
|
"rangeslider": InteractionWidget.RANGESLIDER
|
|
|
|
});
|
|
|
|
|
|
|
|
class EnumValues<T> {
|
|
|
|
Map<String, T> map;
|
|
|
|
|
|
|
|
late Map<T, String> reverseMap;
|
|
|
|
|
|
|
|
EnumValues(this.map);
|
|
|
|
|
|
|
|
Map<T, String> get reverse {
|
|
|
|
reverseMap = map.map((k, v) => MapEntry(v, k));
|
|
|
|
return reverseMap;
|
|
|
|
}
|
|
|
|
}
|