Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/tasks.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRaimund Schlüßler <raimund.schluessler@mailbox.org>2021-07-31 10:13:54 +0300
committerRaimund Schlüßler <raimund.schluessler@mailbox.org>2021-08-02 00:44:59 +0300
commit37167d17f5c7548e9f18aaf8d516affa0ffc4ff0 (patch)
tree4e8bf57189ff98fb03112dd217be441dcafd3503 /src
parente964621320b545d7271acd09a97f1cced01303f9 (diff)
Restore ancestors and children when restoring task
Signed-off-by: Raimund Schlüßler <raimund.schluessler@mailbox.org>
Diffstat (limited to 'src')
-rw-r--r--src/models/calendarObject.js10
-rw-r--r--src/store/calendars.js41
-rw-r--r--src/utils/logger.js2
3 files changed, 51 insertions, 2 deletions
diff --git a/src/models/calendarObject.js b/src/models/calendarObject.js
index b7bf8886..86239b38 100644
--- a/src/models/calendarObject.js
+++ b/src/models/calendarObject.js
@@ -82,12 +82,22 @@ const mapCDavObjectToCalendarObject = (dav, calendarId) => {
const vObjectIterator = calendarComponent.getVObjectIterator()
const firstVObject = vObjectIterator.next().value
+ // Find the parent id if any
+ let parent = null
+ for (const rel of firstVObject.getRelationIterator()) {
+ if (rel.relationType === 'PARENT') {
+ parent = rel.relatedId
+ break
+ }
+ }
+
return getDefaultCalendarObjectObject({
id: btoa(dav.url),
calendarId,
dav,
calendarComponent,
uid: firstVObject.uid,
+ parent,
uri: dav.url,
objectType: firstVObject.name,
isEvent: firstVObject.name === COMPONENT_NAME_EVENT,
diff --git a/src/store/calendars.js b/src/store/calendars.js
index 409f98d9..52cbe0b4 100644
--- a/src/store/calendars.js
+++ b/src/store/calendars.js
@@ -708,17 +708,56 @@ const actions = {
},
async restoreCalendarObject({ commit, state, dispatch }, { vobject }) {
+
+ // Restore the direct ancestor(s)
+ await dispatch('restoreCalendarObjectAncestor', { vobject })
+
+ // Restore the object itself
await state.trashBin.restore(vobject.uri)
// Clean up the data locally
commit('removeDeletedCalendarObject', { vobject })
- // It would be more elegant to only add the restored task
+ // Restore all children
+ await dispatch('restoreCalendarObjectChildren', { vobject })
+
if (vobject.isTodo) {
dispatch('getTasksFromCalendar', { calendar: vobject.calendar })
}
},
+ async restoreCalendarObjectAncestor({ dispatch, commit }, { vobject }) {
+ // Find the direct ancestor(s)
+ const ancestors = state.deletedCalendarObjects.filter(v => {
+ return v.uid === vobject.parent
+ })
+ // Restore the ancestor(s)
+ await Promise.all(ancestors.map(async ancestor => {
+ await dispatch('restoreCalendarObjectAncestor', { vobject: ancestor })
+
+ // Restore the ancestor
+ await state.trashBin.restore(ancestor.uri)
+ // Clean up the data locally
+ commit('removeDeletedCalendarObject', { vobject: ancestor })
+ }))
+ },
+
+ async restoreCalendarObjectChildren({ state, dispatch, commit }, { vobject }) {
+ // Find the children
+ const children = state.deletedCalendarObjects.filter(v => {
+ return v.parent === vobject.uid
+ })
+ // Restore the children
+ await Promise.all(children.map(async child => {
+ // Restore the child
+ await state.trashBin.restore(child.uri)
+ // Clean up the data locally
+ commit('removeDeletedCalendarObject', { vobject: child })
+
+ return await dispatch('restoreCalendarObjectChildren', { vobject: child })
+ }))
+ },
+
/**
* Deletes a calendar-object permanently
*
diff --git a/src/utils/logger.js b/src/utils/logger.js
index 2c3f2b17..5fb842cd 100644
--- a/src/utils/logger.js
+++ b/src/utils/logger.js
@@ -21,7 +21,7 @@
import { getLoggerBuilder } from '@nextcloud/logger'
const logger = getLoggerBuilder()
- .setApp('calendar')
+ .setApp('tasks')
.detectUser()
.build()