Unverified Commit a7a0c58a authored by Thomas Citharel's avatar Thomas Citharel
Browse files

Fix moving resources



Closes #838

Signed-off-by: default avatarThomas Citharel <tcit@tcit.fr>
parent 04fff848
......@@ -59,7 +59,7 @@
{{ $t("No resources in this folder") }}
</p>
<b-pagination
v-if="resource.children.total > RESOURCES_PER_PAGE"
v-if="resource.children && resource.children.total > RESOURCES_PER_PAGE"
:total="resource.children.total"
v-model="page"
size="is-small"
......
......@@ -622,8 +622,7 @@ export default class Resources extends Mixins(ResourceMixin) {
}
const updatedResource: IResource = data.updateResource;
// eslint-disable-next-line vue/max-len
oldParentCachedResource.children.elements =
const updatedElementList =
oldParentCachedResource.children.elements.filter(
(cachedResource) => 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");
},
......
Supports Markdown
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