Fix moving resources
Closes #838 Signed-off-by: Thomas Citharel <tcit@tcit.fr>
This commit is contained in:
parent
04fff8485e
commit
a7a0c58ae3
@ -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");
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user