From a7a0c58ae3abf64ef6004264c81977df2589830b Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Fri, 20 Aug 2021 17:13:04 +0200 Subject: [PATCH] Fix moving resources Closes #838 Signed-off-by: Thomas Citharel --- .../components/Resource/ResourceSelector.vue | 2 +- js/src/views/Resources/ResourceFolder.vue | 28 +++++++++++++++---- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/js/src/components/Resource/ResourceSelector.vue b/js/src/components/Resource/ResourceSelector.vue index e1aa4acde..90ccb6024 100644 --- a/js/src/components/Resource/ResourceSelector.vue +++ b/js/src/components/Resource/ResourceSelector.vue @@ -59,7 +59,7 @@ {{ $t("No resources in this folder") }}

cachedResource.id !== updatedResource.id ); @@ -634,7 +633,15 @@ export default class Resources extends Mixins(ResourceMixin) { path: parentPath, username: this.resource.actor.preferredUsername, }, - data: { oldParentCachedResource }, + data: { + resource: { + ...oldParentCachedResource, + children: { + ...oldParentCachedResource.children, + elements: [...updatedElementList], + }, + }, + }, }); console.log("Finished removing ressource from old parent"); @@ -659,15 +666,24 @@ export default class Resources extends Mixins(ResourceMixin) { return; } - newParentCachedResource.children.elements.push(resource); - store.writeQuery({ query: GET_RESOURCE, variables: { path: updatedResource.parent.path, username: this.resource.actor.preferredUsername, }, - data: { newParentCachedResource }, + data: { + resource: { + ...newParentCachedResource, + children: { + ...newParentCachedResource.children, + elements: [ + ...newParentCachedResource.children.elements, + resource, + ], + }, + }, + }, }); console.log("Finished adding resource to new parent"); },