|
|
|
@ -15,6 +15,8 @@ struct UnitView: View {
|
|
|
|
|
@State private var showingForm: Bool = false
|
|
|
|
|
var formVM = SubjectFormVM()
|
|
|
|
|
|
|
|
|
|
// TODO maybe later: when a subject is deleted this way, if the user clicks on 'Annuler', the deletion should be cancelled
|
|
|
|
|
// then update the readme accrodingly
|
|
|
|
|
private func delete(at offsets: IndexSet) {
|
|
|
|
|
guard let index = offsets.first else { return }
|
|
|
|
|
let subjectVMToDelete = unitVM.SubjectsVM[index]
|
|
|
|
@ -75,9 +77,15 @@ struct UnitView: View {
|
|
|
|
|
Button(action: { showingForm = true }) {
|
|
|
|
|
Image(systemName: "plus")
|
|
|
|
|
}
|
|
|
|
|
// FIXME this does cancel the changes made **to unit and subject** names and weights,
|
|
|
|
|
// but whereas names visibly revert instantaneously to old values, like we should expect,
|
|
|
|
|
// weights are displayed as new, cancelled values until user clicks on 'Modifier' again, when it finally takes on the true, old, value
|
|
|
|
|
// ... weights should visibly revert instantaneously to old values
|
|
|
|
|
Button(action: {
|
|
|
|
|
unitVM.isEdited = false
|
|
|
|
|
unitsManagerVM.isAllEditable.toggle()
|
|
|
|
|
unitVM.onEdited(isCancelled: true)
|
|
|
|
|
unitVM.SubjectsVM.forEach { $0.onEdited(isCancelled: true) }
|
|
|
|
|
}) {
|
|
|
|
|
Text("Annuler")
|
|
|
|
|
}
|
|
|
|
@ -137,6 +145,7 @@ struct UnitView: View {
|
|
|
|
|
// If user navigates back while editing but before clicking 'OK', the changes are cancelled
|
|
|
|
|
.onDisappear(perform: {
|
|
|
|
|
if unitsManagerVM.isAllEditable {
|
|
|
|
|
unitVM.isEdited = false
|
|
|
|
|
unitVM.onEdited(isCancelled: true)
|
|
|
|
|
unitsManagerVM.isAllEditable = false
|
|
|
|
|
}
|
|
|
|
|