mirror of
https://github.com/johrpan/musicus_mobile.git
synced 2025-10-26 18:57:25 +01:00
database: Limit to one method parameter
This commit is contained in:
parent
ab5d07afdd
commit
92c4ec932a
4 changed files with 111 additions and 46 deletions
|
|
@ -21,7 +21,7 @@ class _RecordingEditorState extends State<RecordingEditor> {
|
|||
final commentController = TextEditingController();
|
||||
|
||||
Work work;
|
||||
List<PerformanceModel> performances = [];
|
||||
List<PerformanceModel> performanceModels = [];
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
|
|
@ -64,7 +64,20 @@ class _RecordingEditorState extends State<RecordingEditor> {
|
|||
comment: commentController.text,
|
||||
);
|
||||
|
||||
await backend.db.updateRecording(recording, performances);
|
||||
final performances = performanceModels
|
||||
.map((m) => Performance(
|
||||
recording: recording.id,
|
||||
person: m.person?.id,
|
||||
ensemble: m.ensemble?.id,
|
||||
role: m.role?.id,
|
||||
))
|
||||
.toList();
|
||||
|
||||
await backend.db.updateRecording(RecordingData(
|
||||
recording: recording,
|
||||
performances: performances,
|
||||
));
|
||||
|
||||
Navigator.pop(context, recording);
|
||||
},
|
||||
)
|
||||
|
|
@ -74,10 +87,10 @@ class _RecordingEditorState extends State<RecordingEditor> {
|
|||
children: <Widget>[
|
||||
work != null
|
||||
? ListTile(
|
||||
title: WorkText(work.id),
|
||||
subtitle: ComposersText(work.id),
|
||||
onTap: selectWork,
|
||||
)
|
||||
title: WorkText(work.id),
|
||||
subtitle: ComposersText(work.id),
|
||||
onTap: selectWork,
|
||||
)
|
||||
: ListTile(
|
||||
title: Text('Work'),
|
||||
subtitle: Text('Select work'),
|
||||
|
|
@ -111,13 +124,13 @@ class _RecordingEditorState extends State<RecordingEditor> {
|
|||
|
||||
if (model != null) {
|
||||
setState(() {
|
||||
performances.add(model);
|
||||
performanceModels.add(model);
|
||||
});
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
for (final performance in performances)
|
||||
for (final performance in performanceModels)
|
||||
ListTile(
|
||||
title: Text(performance.person != null
|
||||
? '${performance.person.firstName} ${performance.person.lastName}'
|
||||
|
|
@ -128,7 +141,7 @@ class _RecordingEditorState extends State<RecordingEditor> {
|
|||
icon: const Icon(Icons.delete),
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
performances.remove(performance);
|
||||
performanceModels.remove(performance);
|
||||
});
|
||||
},
|
||||
),
|
||||
|
|
|
|||
|
|
@ -295,7 +295,7 @@ class _WorkEditorState extends State<WorkEditor> {
|
|||
onPressed: () async {
|
||||
final workId = widget.work?.id ?? generateId();
|
||||
|
||||
final model = WorkModel(
|
||||
final data = WorkPartData(
|
||||
work: Work(
|
||||
id: workId,
|
||||
title: titleController.text,
|
||||
|
|
@ -304,10 +304,10 @@ class _WorkEditorState extends State<WorkEditor> {
|
|||
instrumentIds: instruments.map((i) => i.id).toList(),
|
||||
);
|
||||
|
||||
final List<WorkModel> partModels = [];
|
||||
final List<WorkPartData> partData = [];
|
||||
for (var i = 0; i < parts.length; i++) {
|
||||
final part = parts[i];
|
||||
partModels.add(WorkModel(
|
||||
partData.add(WorkPartData(
|
||||
work: Work(
|
||||
id: generateId(),
|
||||
title: part.titleController.text,
|
||||
|
|
@ -319,8 +319,12 @@ class _WorkEditorState extends State<WorkEditor> {
|
|||
));
|
||||
}
|
||||
|
||||
await backend.db.updateWork(model, partModels);
|
||||
Navigator.pop(context, model.work);
|
||||
await backend.db.updateWork(WorkData(
|
||||
data: data,
|
||||
partData: partData,
|
||||
));
|
||||
|
||||
Navigator.pop(context, data.work);
|
||||
},
|
||||
),
|
||||
],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue