Neues Aufgaben-JSON verarbeiten: Modell um choices/fields und Listen-Antworten erweitern
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
83c646c597
commit
45c21657ce
3 files changed
+119
-2
No files matched your search
@@ -14,6 +14,12 @@ class TourTask {
|
||||
int? taskFinWork;
|
||||
List<TourEntry>? entries;
|
||||
|
||||
/// Auswahloptionen eines Status-Tasks (Typ 11).
|
||||
List<TourChoice>? choices;
|
||||
|
||||
/// Eingabefelder einer Text-/Zahlen-Liste (Typ 12/13).
|
||||
List<TourField>? fields;
|
||||
|
||||
TourTask();
|
||||
|
||||
factory TourTask.fromJson(Map<String, dynamic> json) {
|
||||
@@ -36,6 +42,16 @@ class TourTask {
|
||||
.map((e) => TourEntry.fromJson(e as Map<String, dynamic>))
|
||||
.toList()
|
||||
: null;
|
||||
task.choices = json['choices'] != null
|
||||
? (json['choices'] as List<dynamic>)
|
||||
.map((e) => TourChoice.fromJson(e as Map<String, dynamic>))
|
||||
.toList()
|
||||
: null;
|
||||
task.fields = json['fields'] != null
|
||||
? (json['fields'] as List<dynamic>)
|
||||
.map((e) => TourField.fromJson(e as Map<String, dynamic>))
|
||||
.toList()
|
||||
: null;
|
||||
return task;
|
||||
}
|
||||
|
||||
@@ -55,6 +71,8 @@ class TourTask {
|
||||
'task_arrival': taskArrival,
|
||||
'task_fin_work': taskFinWork,
|
||||
'entries': entries?.map((e) => e.toJson()).toList(),
|
||||
'choices': choices?.map((e) => e.toJson()).toList(),
|
||||
'fields': fields?.map((e) => e.toJson()).toList(),
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -70,7 +88,7 @@ class TourEntry {
|
||||
final entry = TourEntry();
|
||||
entry.code = json['code'] as int;
|
||||
entry.text = json['text'] as String;
|
||||
entry.queryRemark = json['query_remark'] as bool;
|
||||
entry.queryRemark = json['query_remark'] as bool? ?? false;
|
||||
return entry;
|
||||
}
|
||||
|
||||
@@ -81,4 +99,64 @@ class TourEntry {
|
||||
'query_remark': queryRemark,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Eine Auswahloption eines Status-Tasks (Typ 11). Entspricht {@code Choice}
|
||||
/// im App-JSON (txt, ret, term, quest, action, price).
|
||||
class TourChoice {
|
||||
late String txt;
|
||||
late int ret;
|
||||
bool? term;
|
||||
String? quest;
|
||||
String? action;
|
||||
String? price;
|
||||
|
||||
TourChoice();
|
||||
|
||||
factory TourChoice.fromJson(Map<String, dynamic> json) {
|
||||
final choice = TourChoice();
|
||||
choice.txt = json['txt'] as String? ?? '';
|
||||
choice.ret = json['ret'] as int? ?? 0;
|
||||
choice.term = json['term'] as bool?;
|
||||
choice.quest = json['quest'] as String?;
|
||||
choice.action = json['action'] as String?;
|
||||
choice.price = json['price'] as String?;
|
||||
return choice;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'txt': txt,
|
||||
'ret': ret,
|
||||
'term': term,
|
||||
'quest': quest,
|
||||
'action': action,
|
||||
'price': price,
|
||||
};
|
||||
}
|
||||
|
||||
/// Ob nach Auswahl dieser Option eine zusätzliche Bemerkung erfragt wird.
|
||||
bool get requiresRemark => (quest != null && quest!.trim().isNotEmpty);
|
||||
}
|
||||
|
||||
/// Ein Eingabefeld einer Text-/Zahlen-Liste (Typ 12/13).
|
||||
class TourField {
|
||||
String? title;
|
||||
String? placeholder;
|
||||
|
||||
TourField();
|
||||
|
||||
factory TourField.fromJson(Map<String, dynamic> json) {
|
||||
final field = TourField();
|
||||
field.title = json['title'] as String?;
|
||||
field.placeholder = json['placeholder'] as String?;
|
||||
return field;
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
return {
|
||||
'title': title,
|
||||
'placeholder': placeholder,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user