Commit 4a5dcbc3 authored by Volker Krause's avatar Volker Krause

More complete implementation of document deletion

parent d141ca1e
......@@ -57,13 +57,37 @@ Kirigami.ScrollablePage {
Kirigami.Action {
iconName: "edit-delete"
text: i18n("Delete Document")
// TODO safety question
onTriggered: DocumentManager.removeDocument(model.id);
onTriggered: {
deleteWarningSheet.docId = model.id;
deleteWarningSheet.sheetOpen = true;
}
}
]
}
}
Kirigami.OverlaySheet {
id: deleteWarningSheet
property string docId
QQC2.Label {
text: i18n("Do you really want to delete this document?")
wrapMode: Text.WordWrap
}
footer: RowLayout {
QQC2.Button {
Layout.alignment: Qt.AlignHCenter
text: i18n("Delete")
icon.name: "edit-delete"
onClicked: {
_appController.removeDocument(controller.batchId, deleteWarningSheet.docId);
deleteWarningSheet.sheetOpen = false;
}
}
}
}
actions {
contextualActions: [
Kirigami.Action {
......
......@@ -461,3 +461,14 @@ void ApplicationController::addDocument(const QString &batchId)
}
#endif
}
void ApplicationController::removeDocument(const QString &batchId, const QString &docId)
{
auto res = m_resMgr->reservation(batchId);
auto docList = JsonLdDocument::readProperty(res, "subjectOf").toList();
docList.removeAll(docId);
JsonLdDocument::writeProperty(res, "subjectOf", docList);
m_resMgr->updateReservation(batchId, res); // TODO update all reservations in the batch
m_docMgr->removeDocument(docId);
}
......@@ -67,6 +67,7 @@ public:
// document attaching
Q_INVOKABLE void addDocument(const QString &batchId);
Q_INVOKABLE void removeDocument(const QString &batchId, const QString &docId);
// for internal use
#ifdef Q_OS_ANDROID
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment