Support work sections

This commit is contained in:
Elias Projahn 2020-05-13 20:52:25 +02:00
parent 813fa2e47a
commit 93a5a06b55
6 changed files with 134 additions and 51 deletions

View file

@ -112,11 +112,17 @@ class Database extends _$Database {
));
}
final List<WorkSection> sections = [];
for (final section in await sectionsByWork(id).get()) {
sections.add(section);
}
return WorkInfo(
work: work,
instruments: instruments,
composers: composers,
parts: parts,
sections: sections,
);
}
@ -160,8 +166,8 @@ class Database extends _$Database {
await transaction(() async {
final workId = workInfo.work.id;
// Delete old work data first. The parts and instrumentations will be
// deleted automatically due to their foreign key constraints.
// Delete old work data first. The parts, sections and instrumentations
// will be deleted automatically due to their foreign key constraints.
await deleteWork(workId);
// This will also include the composers of the work's parts.
@ -194,6 +200,10 @@ class Database extends _$Database {
));
}
}
for (final section in workInfo.sections) {
await into(workSections).insert(section);
}
});
}